[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-11 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 481989.
schittir added a comment.

Fix typos


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

https://reviews.llvm.org/D139148

Files:
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5936,6 +5936,7 @@
   // We're at the end of the line for C: it's either a write-back conversion
   // or it's a C assignment. There's no need to check anything else.
   if (!S.getLangOpts().CPlusPlus) {
+assert(Initializer && "Initializer must be non-null");
 // If allowed, check whether this is an Objective-C writeback conversion.
 if (allowObjCWritebackConversion &&
 tryObjCWritebackConversion(S, *this, Entity, Initializer)) {
@@ -5962,7 +5963,8 @@
 if (Kind.getKind() == InitializationKind::IK_Direct ||
 (Kind.getKind() == InitializationKind::IK_Copy &&
  (Context.hasSameUnqualifiedType(SourceType, DestType) ||
-  S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType
+  (Initializer &&
+   S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, 
DestType)
   TryConstructorInitialization(S, Entity, Kind, Args,
DestType, DestType, *this);
 // - Otherwise (i.e., for the remaining copy-initialization cases),
@@ -5971,9 +5973,11 @@
 //   used) to a derived class thereof are enumerated as described in
 //   13.3.1.4, and the best one is chosen through overload resolution
 //   (13.3).
-else
+else {
+  assert(Initializer && "Initializer must be non-null");
   TryUserDefinedConversion(S, DestType, Kind, Initializer, *this,
TopLevelOfInitList);
+}
 return;
   }
 
@@ -6022,6 +6026,7 @@
   //- Otherwise, if the source type is a (possibly cv-qualified) class
   //  type, conversion functions are considered.
   if (!SourceType.isNull() && SourceType->isRecordType()) {
+assert(Initializer && "Initializer must be non-null");
 // For a conversion to _Atomic(T) from either T or a class type derived
 // from T, initialize the T object then convert to _Atomic type.
 bool NeedAtomicConversion = false;


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5936,6 +5936,7 @@
   // We're at the end of the line for C: it's either a write-back conversion
   // or it's a C assignment. There's no need to check anything else.
   if (!S.getLangOpts().CPlusPlus) {
+assert(Initializer && "Initializer must be non-null");
 // If allowed, check whether this is an Objective-C writeback conversion.
 if (allowObjCWritebackConversion &&
 tryObjCWritebackConversion(S, *this, Entity, Initializer)) {
@@ -5962,7 +5963,8 @@
 if (Kind.getKind() == InitializationKind::IK_Direct ||
 (Kind.getKind() == InitializationKind::IK_Copy &&
  (Context.hasSameUnqualifiedType(SourceType, DestType) ||
-  S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType
+  (Initializer &&
+   S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType)
   TryConstructorInitialization(S, Entity, Kind, Args,
DestType, DestType, *this);
 // - Otherwise (i.e., for the remaining copy-initialization cases),
@@ -5971,9 +5973,11 @@
 //   used) to a derived class thereof are enumerated as described in
 //   13.3.1.4, and the best one is chosen through overload resolution
 //   (13.3).
-else
+else {
+  assert(Initializer && "Initializer must be non-null");
   TryUserDefinedConversion(S, DestType, Kind, Initializer, *this,
TopLevelOfInitList);
+}
 return;
   }
 
@@ -6022,6 +6026,7 @@
   //- Otherwise, if the source type is a (possibly cv-qualified) class
   //  type, conversion functions are considered.
   if (!SourceType.isNull() && SourceType->isRecordType()) {
+assert(Initializer && "Initializer must be non-null");
 // For a conversion to _Atomic(T) from either T or a class type derived
 // from T, initialize the T object then convert to _Atomic type.
 bool NeedAtomicConversion = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-11 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 481980.
tianshilei1992 added a comment.

rebase and fix comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

Files:
  openmp/libomptarget/plugins-nextgen/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp

Index: openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
@@ -358,6 +358,10 @@
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 return true;
   }
+
+  Triple::ArchType getTripleArch() const override {
+return Triple::LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE;
+  }
 };
 
 GenericPluginTy *Plugin::createPlugin() { return new GenELF64PluginTy(); }
Index: openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -278,6 +278,14 @@
  GridValues.GV_Warp_Size))
   return Err;
 
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
+ ComputeCapability.Major))
+  return Err;
+
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
+ ComputeCapability.Minor))
+  return Err;
+
 return Plugin::success();
   }
 
@@ -776,6 +784,8 @@
 return Plugin::check(Res, "Error in cuDeviceGetAttribute: %s");
   }
 
+  std::string getArch() const override { return ComputeCapability.str(); }
+
 private:
   using CUDAStreamManagerTy = GenericDeviceResourceManagerTy;
   using CUDAEventManagerTy = GenericDeviceResourceManagerTy;
@@ -792,6 +802,15 @@
 
   /// The CUDA device handler.
   CUdevice Device = CU_DEVICE_INVALID;
+
+  ///
+  struct ComputeCapabilityTy {
+uint32_t Major;
+uint32_t Minor;
+std::string str() const {
+  return "sm_" + std::to_string(Major * 10 + Minor);
+}
+  } ComputeCapability;
 };
 
 Error CUDAKernelTy::launchImpl(GenericDeviceTy ,
@@ -890,6 +909,11 @@
   /// Get the ELF code for recognizing the compatible image binary.
   uint16_t getMagicElfBits() const override { return ELF::EM_CUDA; }
 
+  Triple::ArchType getTripleArch() const override {
+// TODO: I think we can drop the support for 32-bit NVPTX devices.
+return Triple::nvptx64;
+  }
+
   /// Check whether the image is compatible with the available CUDA devices.
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 for (int32_t DevId = 0; DevId < getNumDevices(); ++DevId) {
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
@@ -25,6 +25,7 @@
 #include "omptarget.h"
 
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/Support/Allocator.h"
@@ -372,6 +373,17 @@
   }
   uint32_t getDynamicMemorySize() const { return OMPX_SharedMemorySize; }
 
+  /// Get target architecture.
+  virtual std::string getArch() const {
+llvm_unreachable("device doesn't support JIT");
+  }
+
+  /// Post processing after jit backend. The ownership of \p MB will be taken.
+  virtual Expected>
+  doJITPostProcessing(std::unique_ptr MB) const {
+return MB;
+  }
+
 private:
   /// Register offload entry for global variable.
   Error registerGlobalOffloadEntry(DeviceImageTy ,
@@ -482,6 +494,11 @@
   /// Get the ELF code to recognize the binary image of this plugin.
   virtual uint16_t getMagicElfBits() const = 0;
 
+  /// Get the target triple of this plugin.
+  virtual Triple::ArchType getTripleArch() const {
+llvm_unreachable("target doesn't support jit");
+  }
+
   /// Allocate a structure using the internal allocator.
   template  Ty *allocate() {
 return reinterpret_cast(Allocator.Allocate(sizeof(Ty), alignof(Ty)));
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp

[PATCH] D137059: [Driver] [C++20] [Modules] Support -fmodule-output= (2/2)

2022-12-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 481978.
ChuanqiXu added a comment.

Update after D137058  updated.


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

https://reviews.llvm.org/D137059

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/module-output.cppm


Index: clang/test/Driver/module-output.cppm
===
--- clang/test/Driver/module-output.cppm
+++ clang/test/Driver/module-output.cppm
@@ -7,6 +7,15 @@
 // output and the name of the .pcm file should be the same with the output 
file.
 // RUN: %clang -std=c++20 %s -fmodule-output -c -o %t/output/Hello.o \
 // RUN:   -### 2>&1 | FileCheck %s -DOUTPUT_PATH=%t/output 
--check-prefix=CHECK-WITH-OUTPUT
+//
+// Tests that the .pcm file will be generated in the same path with the 
specified one in the comamnd line.
+// RUN: %clang -std=c++20 %s -fmodule-output=%t/pcm/Hello.pcm \
+// RUN:   -c -### 2>&1 | FileCheck %s -DPCM_PATH=%t/pcm 
--check-prefix=CHECK-SPECIFIED
+//
+// Tests that the .pcm file will be generated in the same path with the 
specified one in the comamnd line
+// even if we specified the output file.
+// RUN: %clang -std=c++20 %s -fmodule-output=%t/pcm/Hello.pcm -o %t/Hello.o \
+// RUN:   -c -### 2>&1 | FileCheck %s -DPCM_PATH=%t/pcm 
--check-prefix=CHECK-SPECIFIED-WITH-OUTPUT
 
 export module Hello;
 
@@ -14,3 +23,7 @@
 // CHECK: "-emit-obj" {{.*}}"-main-file-name" "module-output.cppm" {{.*}}"-o" 
"module-output.o" "-x" "pcm" "[[SOURCE_PATH]]/module-output.pcm"
 // CHECK-WITH-OUTPUT: "-emit-module-interface" {{.*}}"-main-file-name" 
"module-output.cppm" {{.*}}"-o" "[[OUTPUT_PATH]]/Hello.pcm" "-x" "c++" 
"{{.*}}/module-output.cppm"
 // CHECK-WITH-OUTPUT: "-emit-obj" {{.*}}"-main-file-name" "module-output.cppm" 
{{.*}}"-o" "[[OUTPUT_PATH]]/Hello.o" "-x" "pcm" "[[OUTPUT_PATH]]/Hello.pcm"
+// CHECK-SPECIFIED: "-emit-module-interface" {{.*}}"-main-file-name" 
"module-output.cppm" {{.*}}"-o" "[[PCM_PATH]]/Hello.pcm" "-x" "c++" 
"{{.*}}/module-output.cppm"
+// CHECK-SPECIFIED: "-emit-obj" {{.*}}"-main-file-name" "module-output.cppm" 
{{.*}}"-o" "module-output.o" "-x" "pcm" "[[PCM_PATH]]/Hello.pcm"
+// CHECK-SPECIFIED-WITH-OUTPUT: "-emit-module-interface" 
{{.*}}"-main-file-name" "module-output.cppm" {{.*}}"-o" 
"[[PCM_PATH]]/Hello.pcm" "-x" "c++" "{{.*}}/module-output.cppm"
+// CHECK-SPECIFIED-WITH-OUTPUT: "-emit-obj" {{.*}}"-main-file-name" 
"module-output.cppm" {{.*}}"-o" "{{.*}}/Hello.o" "-x" "pcm" 
"[[PCM_PATH]]/Hello.pcm"
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5530,15 +5530,21 @@
   }
 
   // If `-fmodule-output` is specfied, then:
-  // - If `-o` is specified, the module file is writing to the same path
+  // - If `-fmodule-output` has a value, the module file is
+  //   writing to the value.
+  // - Else if `-o` is specified, the module file is writing to the same path
   //   with the output file in module file's suffix. 
-  // - If `-o` is not specified, the module file is writing to the same path
+  // - Else, the module file is writing to the same path
   //   with the input file in module file's suffix.
   if (!AtTopLevel && isa(JA) &&
   JA.getType() == types::TY_ModuleFile &&
-  C.getArgs().hasArg(options::OPT_fmodule_output)) {
+  (C.getArgs().hasArg(options::OPT_fmodule_output) ||
+   C.getArgs().hasArg(options::OPT_fmodule_output_EQ))) {
 SmallString<128> TempPath;
-if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+
+if (Arg *ModuleFilePath = 
C.getArgs().getLastArg(options::OPT_fmodule_output_EQ))
+  TempPath = ModuleFilePath->getValue();
+else if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
   TempPath = FinalOutput->getValue();
 else
   TempPath = BaseInput;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2285,6 +2285,8 @@
   PosFlag,
   NegFlag, BothFlags<[NoXarchOption, CC1Option]>>;
 
+def fmodule_output_EQ : Joined<["-"], "fmodule-output=">, 
Flags<[NoXarchOption, CC1Option]>,
+  HelpText<"Save intermediate module file results when compiling a standard 
C++ module unit.">;
 def fmodule_output : Flag<["-"], "fmodule-output">, Flags<[NoXarchOption, 
CC1Option]>,
   HelpText<"Save intermediate module file results when compiling a standard 
C++ module unit.">;
 


Index: clang/test/Driver/module-output.cppm
===
--- clang/test/Driver/module-output.cppm
+++ clang/test/Driver/module-output.cppm
@@ -7,6 +7,15 @@
 // output and the name of the .pcm file should be the same with the output file.
 // RUN: %clang -std=c++20 %s -fmodule-output -c -o 

[PATCH] D137058: [Driver] [Modules] Support -fmodule-output (1/2)

2022-12-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked an inline comment as done.
ChuanqiXu added inline comments.



Comment at: clang/test/Driver/save-std-c++-module-file.cpp:8-9
+//
+// RUN: %clang -std=c++20 %t/Hello.cppm -fmodule-output -o %t/output/Hello.o \
+// RUN:   -### 2>&1 | FileCheck %t/Hello.cppm -DPREFIX=%t 
--check-prefix=CHECK-WITH-OUTPUT
+

dblaikie wrote:
> Not sure I understand the need for two tests here - they both specify an 
> absolute path to a .o file & CHECK that the absolute path matches the .pcm 
> output file path, so they don't seem to be testing distinct scenarios?
The above one doesn't specify the path for the .o file. So in the first test 
the .pcm file will be in the same directory with the input source file. And in 
the second command line, the .pcm file will be in the same directory with the 
.o file.



Comment at: clang/test/Driver/save-std-c++-module-file.cpp:1-4
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//

dblaikie wrote:
> dblaikie wrote:
> > Is this needed? Maybe we don't need to split the file, if it's just the one 
> > file anyway?
> Ping on this ^
Sorry for missing it. Thanks for clarification.



Comment at: clang/test/Driver/save-std-c++-module-file.cpp:6
+// RUN: %clang -std=c++20 %t/Hello.cppm -fsave-std-c++-module-file -### 2>&1 | 
\
+// RUN:   FileCheck %t/Hello.cppm -DPREFIX=%t
+//

dblaikie wrote:
> Is the prefix needed? I'd expect we'd usually regex match away the actual 
> directory with `{{.*}}` in tests like this?
Yeah, generally we would use `{{.*}}`. And `-DPREFIX` is more precise for what 
we want to test. So I feel it wouldn't be bad.


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

https://reviews.llvm.org/D137058

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


[PATCH] D137058: [Driver] [Modules] Support -fmodule-output (1/2)

2022-12-11 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 481975.
ChuanqiXu marked 3 inline comments as done.
ChuanqiXu edited the summary of this revision.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D137058

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/lit.local.cfg
  clang/test/Driver/module-output.cppm


Index: clang/test/Driver/module-output.cppm
===
--- /dev/null
+++ clang/test/Driver/module-output.cppm
@@ -0,0 +1,16 @@
+// Tests that the .pcm file will be generated in the same directory with the 
input
+// and the name of the .pcm file should be the same with the input file.
+// RUN: %clang -std=c++20 %s -fmodule-output -c -### 2>&1 | \
+// RUN:   FileCheck %s -DSOURCE_PATH=%S
+//
+// Tests that the .pcm file will be generated in the same direcotry with the 
specified 
+// output and the name of the .pcm file should be the same with the output 
file.
+// RUN: %clang -std=c++20 %s -fmodule-output -c -o %t/output/Hello.o \
+// RUN:   -### 2>&1 | FileCheck %s -DOUTPUT_PATH=%t/output 
--check-prefix=CHECK-WITH-OUTPUT
+
+export module Hello;
+
+// CHECK: "-emit-module-interface" {{.*}}"-main-file-name" 
"module-output.cppm" {{.*}}"-o" "[[SOURCE_PATH]]/module-output.pcm" "-x" "c++" 
"[[SOURCE_PATH]]/module-output.cppm"
+// CHECK: "-emit-obj" {{.*}}"-main-file-name" "module-output.cppm" {{.*}}"-o" 
"module-output.o" "-x" "pcm" "[[SOURCE_PATH]]/module-output.pcm"
+// CHECK-WITH-OUTPUT: "-emit-module-interface" {{.*}}"-main-file-name" 
"module-output.cppm" {{.*}}"-o" "[[OUTPUT_PATH]]/Hello.pcm" "-x" "c++" 
"{{.*}}/module-output.cppm"
+// CHECK-WITH-OUTPUT: "-emit-obj" {{.*}}"-main-file-name" "module-output.cppm" 
{{.*}}"-o" "[[OUTPUT_PATH]]/Hello.o" "-x" "pcm" "[[OUTPUT_PATH]]/Hello.pcm"
Index: clang/test/Driver/lit.local.cfg
===
--- clang/test/Driver/lit.local.cfg
+++ clang/test/Driver/lit.local.cfg
@@ -1,6 +1,6 @@
 from lit.llvm import llvm_config
 
-config.suffixes = ['.c', '.cpp', '.h', '.m', '.mm', '.S', '.s', '.f90', 
'.F90', '.f95',
+config.suffixes = ['.c', '.cpp', '.cppm', '.h', '.m', '.mm', '.S', '.s', 
'.f90', '.F90', '.f95',
'.cu', '.rs', '.cl', '.clcpp', '.hip', '.hlsl']
 config.substitutions = list(config.substitutions)
 config.substitutions.insert(0,
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5529,6 +5529,25 @@
 return "-";
   }
 
+  // If `-fmodule-output` is specfied, then:
+  // - If `-o` is specified, the module file is writing to the same path
+  //   with the output file in module file's suffix. 
+  // - If `-o` is not specified, the module file is writing to the same path
+  //   with the input file in module file's suffix.
+  if (!AtTopLevel && isa(JA) &&
+  JA.getType() == types::TY_ModuleFile &&
+  C.getArgs().hasArg(options::OPT_fmodule_output)) {
+SmallString<128> TempPath;
+if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+  TempPath = FinalOutput->getValue();
+else
+  TempPath = BaseInput;
+
+const char *Extension = types::getTypeTempSuffix(JA.getType());
+llvm::sys::path::replace_extension(TempPath, Extension);
+return C.addResultFile(C.getArgs().MakeArgString(TempPath.c_str()), );
+  }
+
   if (IsDXCMode() && !C.getArgs().hasArg(options::OPT_o))
 return "-";
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2285,6 +2285,9 @@
   PosFlag,
   NegFlag, BothFlags<[NoXarchOption, CC1Option]>>;
 
+def fmodule_output : Flag<["-"], "fmodule-output">, Flags<[NoXarchOption, 
CC1Option]>,
+  HelpText<"Save intermediate module file results when compiling a standard 
C++ module unit.">;
+
 def fmodules_prune_interval : Joined<["-"], "fmodules-prune-interval=">, 
Group,
   Flags<[CC1Option]>, MetaVarName<"">,
   HelpText<"Specify the interval (in seconds) between attempts to prune the 
module cache">,


Index: clang/test/Driver/module-output.cppm
===
--- /dev/null
+++ clang/test/Driver/module-output.cppm
@@ -0,0 +1,16 @@
+// Tests that the .pcm file will be generated in the same directory with the input
+// and the name of the .pcm file should be the same with the input file.
+// RUN: %clang -std=c++20 %s -fmodule-output -c -### 2>&1 | \
+// RUN:   FileCheck %s -DSOURCE_PATH=%S
+//
+// Tests that the .pcm file will be generated in the same direcotry with the specified 
+// output and the name of the .pcm file should be the same with the output file.
+// RUN: %clang -std=c++20 %s -fmodule-output -c -o %t/output/Hello.o \

[PATCH] D139148: Fix nullptr dereference found by Coverity static analysis tool

2022-12-11 Thread Sindhu Chittireddy via Phabricator via cfe-commits
schittir updated this revision to Diff 481974.
schittir marked an inline comment as done.
schittir added a comment.

Fixed typo. Sorry!


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

https://reviews.llvm.org/D139148

Files:
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5936,6 +5936,7 @@
   // We're at the end of the line for C: it's either a write-back conversion
   // or it's a C assignment. There's no need to check anything else.
   if (!S.getLangOpts().CPlusPlus) {
+assert(Initializer && "Intializer must be non-null");
 // If allowed, check whether this is an Objective-C writeback conversion.
 if (allowObjCWritebackConversion &&
 tryObjCWritebackConversion(S, *this, Entity, Initializer)) {
@@ -5962,7 +5963,8 @@
 if (Kind.getKind() == InitializationKind::IK_Direct ||
 (Kind.getKind() == InitializationKind::IK_Copy &&
  (Context.hasSameUnqualifiedType(SourceType, DestType) ||
-  S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType
+  (Initializer &&
+   S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, 
DestType)
   TryConstructorInitialization(S, Entity, Kind, Args,
DestType, DestType, *this);
 // - Otherwise (i.e., for the remaining copy-initialization cases),
@@ -5971,9 +5973,11 @@
 //   used) to a derived class thereof are enumerated as described in
 //   13.3.1.4, and the best one is chosen through overload resolution
 //   (13.3).
-else
+else {
+  assert(Initializer && "Intializer must be non-null");
   TryUserDefinedConversion(S, DestType, Kind, Initializer, *this,
TopLevelOfInitList);
+}
 return;
   }
 
@@ -6022,6 +6026,7 @@
   //- Otherwise, if the source type is a (possibly cv-qualified) class
   //  type, conversion functions are considered.
   if (!SourceType.isNull() && SourceType->isRecordType()) {
+assert(Initializer && "Intializer must be non-null");
 // For a conversion to _Atomic(T) from either T or a class type derived
 // from T, initialize the T object then convert to _Atomic type.
 bool NeedAtomicConversion = false;


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -5936,6 +5936,7 @@
   // We're at the end of the line for C: it's either a write-back conversion
   // or it's a C assignment. There's no need to check anything else.
   if (!S.getLangOpts().CPlusPlus) {
+assert(Initializer && "Intializer must be non-null");
 // If allowed, check whether this is an Objective-C writeback conversion.
 if (allowObjCWritebackConversion &&
 tryObjCWritebackConversion(S, *this, Entity, Initializer)) {
@@ -5962,7 +5963,8 @@
 if (Kind.getKind() == InitializationKind::IK_Direct ||
 (Kind.getKind() == InitializationKind::IK_Copy &&
  (Context.hasSameUnqualifiedType(SourceType, DestType) ||
-  S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType
+  (Initializer &&
+   S.IsDerivedFrom(Initializer->getBeginLoc(), SourceType, DestType)
   TryConstructorInitialization(S, Entity, Kind, Args,
DestType, DestType, *this);
 // - Otherwise (i.e., for the remaining copy-initialization cases),
@@ -5971,9 +5973,11 @@
 //   used) to a derived class thereof are enumerated as described in
 //   13.3.1.4, and the best one is chosen through overload resolution
 //   (13.3).
-else
+else {
+  assert(Initializer && "Intializer must be non-null");
   TryUserDefinedConversion(S, DestType, Kind, Initializer, *this,
TopLevelOfInitList);
+}
 return;
   }
 
@@ -6022,6 +6026,7 @@
   //- Otherwise, if the source type is a (possibly cv-qualified) class
   //  type, conversion functions are considered.
   if (!SourceType.isNull() && SourceType->isRecordType()) {
+assert(Initializer && "Intializer must be non-null");
 // For a conversion to _Atomic(T) from either T or a class type derived
 // from T, initialize the T object then convert to _Atomic type.
 bool NeedAtomicConversion = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 4ca9c6a - [NFC][Clang] Add missing test cases for segment load

2022-12-11 Thread via cfe-commits

Author: Zakk Chen
Date: 2022-12-11T19:02:47-08:00
New Revision: 4ca9c6a84f918be4314fc7066eb899f4e86f07f3

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

LOG: [NFC][Clang] Add missing test cases for segment load

This patch fixed the missing test cases from: 
010f329803c84e43ec15ffaff7b6e26b032cbcc6

Reviewed By: kito-cheng, craig.topper

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

Added: 


Modified: 
clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlseg.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg_mask.c
clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c

Removed: 




diff  --git a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlseg.c 
b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlseg.c
index 31aebd012e3dc..815012baf7b86 100644
--- a/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlseg.c
+++ b/clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlseg.c
@@ -6486,3 +6486,135 @@ void test_vlseg4e64_v_f64m2_m (vfloat64m2_t *v0, 
vfloat64m2_t *v1, vfloat64m2_t
 void test_vlseg2e64_v_f64m4_m (vfloat64m4_t *v0, vfloat64m4_t *v1, vbool16_t 
mask, vfloat64m4_t maskedoff0, vfloat64m4_t maskedoff1, const double *base, 
size_t vl) {
   return vlseg2e64(v0, v1, mask, maskedoff0, maskedoff1, base, vl);
 }
+
+// CHECK-RV32-LABEL: @test_vlseg2e32_v_u32mf2_tu(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlseg2.nxv1i32.i32( [[MERGE0:%.*]], 
 [[MERGE1:%.*]], ptr [[BASE:%.*]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , 
 } [[TMP0]], 0
+// CHECK-RV32-NEXT:store  [[TMP1]], ptr [[V0:%.*]], 
align 4
+// CHECK-RV32-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP0]], 1
+// CHECK-RV32-NEXT:store  [[TMP2]], ptr [[V1:%.*]], 
align 4
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: @test_vlseg2e32_v_u32mf2_tu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlseg2.nxv1i32.i64( [[MERGE0:%.*]], 
 [[MERGE1:%.*]], ptr [[BASE:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , 
 } [[TMP0]], 0
+// CHECK-RV64-NEXT:store  [[TMP1]], ptr [[V0:%.*]], 
align 4
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP0]], 1
+// CHECK-RV64-NEXT:store  [[TMP2]], ptr [[V1:%.*]], 
align 4
+// CHECK-RV64-NEXT:ret void
+//
+void test_vlseg2e32_v_u32mf2_tu(vuint32mf2_t *v0, vuint32mf2_t *v1, 
vuint32mf2_t merge0, vuint32mf2_t merge1, const uint32_t *base, size_t vl) {
+  return vlseg2e32_tu(v0, v1, merge0, merge1, base, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vlseg2e32_v_u32mf2_ta(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlseg2.nxv1i32.i32( poison,  poison, ptr [[BASE:%.*]], i32 [[VL:%.*]])
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , 
 } [[TMP0]], 0
+// CHECK-RV32-NEXT:store  [[TMP1]], ptr [[V0:%.*]], 
align 4
+// CHECK-RV32-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP0]], 1
+// CHECK-RV32-NEXT:store  [[TMP2]], ptr [[V1:%.*]], 
align 4
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: @test_vlseg2e32_v_u32mf2_ta(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlseg2.nxv1i32.i64( poison,  poison, ptr [[BASE:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , 
 } [[TMP0]], 0
+// CHECK-RV64-NEXT:store  [[TMP1]], ptr [[V0:%.*]], 
align 4
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP0]], 1
+// CHECK-RV64-NEXT:store  [[TMP2]], ptr [[V1:%.*]], 
align 4
+// CHECK-RV64-NEXT:ret void
+//
+void test_vlseg2e32_v_u32mf2_ta(vuint32mf2_t *v0, vuint32mf2_t *v1, const 
uint32_t *base, size_t vl) {
+  return vlseg2e32_ta(v0, v1, base, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vlseg2e32_v_u32mf2_tuma(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlseg2.mask.nxv1i32.i32( [[MERGE0:%.*]], 
 [[MERGE1:%.*]], ptr [[BASE:%.*]],  
[[MASK:%.*]], i32 [[VL:%.*]], i32 2)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , 
 } [[TMP0]], 0
+// CHECK-RV32-NEXT:store  [[TMP1]], ptr [[V0:%.*]], 
align 4
+// CHECK-RV32-NEXT:[[TMP2:%.*]] = extractvalue { , 
 } [[TMP0]], 1
+// CHECK-RV32-NEXT:store  [[TMP2]], ptr [[V1:%.*]], 
align 4
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: @test_vlseg2e32_v_u32mf2_tuma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { ,  } @llvm.riscv.vlseg2.mask.nxv1i32.i64( [[MERGE0:%.*]], 
 [[MERGE1:%.*]], ptr [[BASE:%.*]],  
[[MASK:%.*]], i64 [[VL:%.*]], i64 2)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , 
 } [[TMP0]], 0
+// CHECK-RV64-NEXT:store  

[PATCH] D139387: [NFC][Clang] Add missing test cases for segment load

2022-12-11 Thread Brandon Wu 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 rG4ca9c6a84f91: [NFC][Clang] Add missing test cases for 
segment load (authored by khchen, committed by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139387

Files:
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlseg_mask.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vlsegff_mask.c
@@ -8204,3 +8204,107 @@
 void test_vlseg2e16ff_v_f16m4_m (vfloat16m4_t *v0, vfloat16m4_t *v1, vbool4_t mask, vfloat16m4_t maskedoff0, vfloat16m4_t maskedoff1, const _Float16 *base, size_t *new_vl, size_t vl) {
   return vlseg2e16ff_v_f16m4_m(v0, v1, mask, maskedoff0, maskedoff1, base, new_vl, vl);
 }
+
+// CHECK-RV32-LABEL: @test_vlseg2e32ff_v_u32mf2_tuma(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { , , i32 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i32( [[MERGE0:%.*]],  [[MERGE1:%.*]], ptr [[BASE:%.*]],  [[MASK:%.*]], i32 [[VL:%.*]], i32 2)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , , i32 } [[TMP0]], 0
+// CHECK-RV32-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP2:%.*]] = extractvalue { , , i32 } [[TMP0]], 1
+// CHECK-RV32-NEXT:store  [[TMP2]], ptr [[V1:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP3:%.*]] = extractvalue { , , i32 } [[TMP0]], 2
+// CHECK-RV32-NEXT:store i32 [[TMP3]], ptr [[NEW_VL:%.*]], align 4
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: @test_vlseg2e32ff_v_u32mf2_tuma(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { , , i64 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i64( [[MERGE0:%.*]],  [[MERGE1:%.*]], ptr [[BASE:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 2)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , , i64 } [[TMP0]], 0
+// CHECK-RV64-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , , i64 } [[TMP0]], 1
+// CHECK-RV64-NEXT:store  [[TMP2]], ptr [[V1:%.*]], align 4
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , , i64 } [[TMP0]], 2
+// CHECK-RV64-NEXT:store i64 [[TMP3]], ptr [[NEW_VL:%.*]], align 4
+// CHECK-RV64-NEXT:ret void
+//
+void test_vlseg2e32ff_v_u32mf2_tuma(vuint32mf2_t *v0, vuint32mf2_t *v1, vbool64_t mask, vuint32mf2_t merge0, vuint32mf2_t merge1, const uint32_t *base, size_t *new_vl, size_t vl) {
+  return vlseg2e32ff_v_u32mf2_tuma(v0, v1, mask, merge0, merge1, base, new_vl, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vlseg2e32ff_v_u32mf2_tumu(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { , , i32 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i32( [[MERGE0:%.*]],  [[MERGE1:%.*]], ptr [[BASE:%.*]],  [[MASK:%.*]], i32 [[VL:%.*]], i32 0)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , , i32 } [[TMP0]], 0
+// CHECK-RV32-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP2:%.*]] = extractvalue { , , i32 } [[TMP0]], 1
+// CHECK-RV32-NEXT:store  [[TMP2]], ptr [[V1:%.*]], align 4
+// CHECK-RV32-NEXT:[[TMP3:%.*]] = extractvalue { , , i32 } [[TMP0]], 2
+// CHECK-RV32-NEXT:store i32 [[TMP3]], ptr [[NEW_VL:%.*]], align 4
+// CHECK-RV32-NEXT:ret void
+//
+// CHECK-RV64-LABEL: @test_vlseg2e32ff_v_u32mf2_tumu(
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call { , , i64 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i64( [[MERGE0:%.*]],  [[MERGE1:%.*]], ptr [[BASE:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = extractvalue { , , i64 } [[TMP0]], 0
+// CHECK-RV64-NEXT:store  [[TMP1]], ptr [[V0:%.*]], align 4
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { , , i64 } [[TMP0]], 1
+// CHECK-RV64-NEXT:store  [[TMP2]], ptr [[V1:%.*]], align 4
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { , , i64 } [[TMP0]], 2
+// CHECK-RV64-NEXT:store i64 [[TMP3]], ptr [[NEW_VL:%.*]], align 4
+// CHECK-RV64-NEXT:ret void
+//
+void test_vlseg2e32ff_v_u32mf2_tumu(vuint32mf2_t *v0, vuint32mf2_t *v1, vbool64_t mask, vuint32mf2_t merge0, vuint32mf2_t merge1, const uint32_t *base, size_t *new_vl, size_t vl) {
+  return vlseg2e32ff_v_u32mf2_tumu(v0, v1, mask, merge0, merge1, base, new_vl, vl);
+}
+
+// CHECK-RV32-LABEL: @test_vlseg2e32ff_v_u32mf2_tama(
+// CHECK-RV32-NEXT:  entry:
+// CHECK-RV32-NEXT:[[TMP0:%.*]] = call { , , i32 } @llvm.riscv.vlseg2ff.mask.nxv1i32.i32( poison,  poison, ptr [[BASE:%.*]],  [[MASK:%.*]], i32 [[VL:%.*]], i32 3)
+// CHECK-RV32-NEXT:[[TMP1:%.*]] = extractvalue { , , i32 } [[TMP0]], 0

[PATCH] D136554: Implement CWG2631

2022-12-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D136554#3987122 , @aeubanks wrote:

> no, I got
>
>   $ ninja -C out/MyClang/ content_unittests
>   ld.lld: error: undefined symbol: 
> mojo::Receiver mojo::RawPtrImplRefTraits>::Receiver(content::mojom::TestInterfaceForDefer*)
>   >>> referenced by mojo_binder_policy_applier_unittest.cc:90 
> (../../content/browser/mojo_binder_policy_applier_unittest.cc:90)
>   >>>   
> obj/content/test/content_unittests/mojo_binder_policy_applier_unittest.o:(content::TestReceiverCollector::TestReceiverCollector())
>   
>   ld.lld: error: undefined symbol: 
> mojo::Receiver mojo::RawPtrImplRefTraits>::Receiver(content::mojom::TestInterfaceForGrant*)
>   >>> referenced by mojo_binder_policy_applier_unittest.cc:91 
> (../../content/browser/mojo_binder_policy_applier_unittest.cc:91)
>   >>>   
> obj/content/test/content_unittests/mojo_binder_policy_applier_unittest.o:(content::TestReceiverCollector::TestReceiverCollector())
>   
>   ld.lld: error: undefined symbol: 
> mojo::Receiver mojo::RawPtrImplRefTraits>::Receiver(content::mojom::TestInterfaceForCancel*)
>   >>> referenced by mojo_binder_policy_applier_unittest.cc:92 
> (../../content/browser/mojo_binder_policy_applier_unittest.cc:92)
>   >>>   
> obj/content/test/content_unittests/mojo_binder_policy_applier_unittest.o:(content::TestReceiverCollector::TestReceiverCollector())
>   
>   ld.lld: error: undefined symbol: 
> mojo::Receiver mojo::RawPtrImplRefTraits>::Receiver(content::mojom::TestInterfaceForUnexpected*)
>   >>> referenced by mojo_binder_policy_applier_unittest.cc:93 
> (../../content/browser/mojo_binder_policy_applier_unittest.cc:93)
>   >>>   
> obj/content/test/content_unittests/mojo_binder_policy_applier_unittest.o:(content::TestReceiverCollector::TestReceiverCollector())
>   clang++: error: linker command failed with exit code 1 (use -v to see 
> invocation)
>
> https://crsrc.org/c/content/browser/mojo_binder_policy_applier_unittest.cc;drc=4e1b7bc33d42b401d7d9ad1dcba72883add3e2af;l=90

Thanks, that was really helpful.
After most of the day spent on compiling clang and reducing, i got it down to

  template  
  struct MissingCtr {
MissingCtr() {}
  };
  class k {
  //public:
MissingCtr a{};
  };
  struct b {
k c{};
  };
  int main() { b d; }

It would appear to be related to access. I had not yet encountered something 
access related with this patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D139287: [WIP][OpenMP] Introduce basic JIT support to OpenMP target offloading

2022-12-11 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 481960.
tianshilei1992 added a comment.

rebase and fix opt error


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139287

Files:
  openmp/libomptarget/plugins-nextgen/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/CMakeLists.txt
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/JIT.h
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp

Index: openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
@@ -358,6 +358,10 @@
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 return true;
   }
+
+  Triple::ArchType getTripleArch() const override {
+return Triple::LIBOMPTARGET_NEXTGEN_GENERIC_PLUGIN_TRIPLE;
+  }
 };
 
 GenericPluginTy *Plugin::createPlugin() { return new GenELF64PluginTy(); }
Index: openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -278,6 +278,14 @@
  GridValues.GV_Warp_Size))
   return Err;
 
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MAJOR,
+ ComputeCapability.Major))
+  return Err;
+
+if (auto Err = getDeviceAttr(CU_DEVICE_ATTRIBUTE_COMPUTE_CAPABILITY_MINOR,
+ ComputeCapability.Minor))
+  return Err;
+
 return Plugin::success();
   }
 
@@ -776,6 +784,8 @@
 return Plugin::check(Res, "Error in cuDeviceGetAttribute: %s");
   }
 
+  std::string getArch() const override { return ComputeCapability.str(); }
+
 private:
   using CUDAStreamManagerTy = GenericDeviceResourceManagerTy;
   using CUDAEventManagerTy = GenericDeviceResourceManagerTy;
@@ -792,6 +802,15 @@
 
   /// The CUDA device handler.
   CUdevice Device = CU_DEVICE_INVALID;
+
+  ///
+  struct ComputeCapabilityTy {
+uint32_t Major;
+uint32_t Minor;
+std::string str() const {
+  return "sm_" + std::to_string(Major * 10 + Minor);
+}
+  } ComputeCapability;
 };
 
 Error CUDAKernelTy::launchImpl(GenericDeviceTy ,
@@ -890,6 +909,11 @@
   /// Get the ELF code for recognizing the compatible image binary.
   uint16_t getMagicElfBits() const override { return ELF::EM_CUDA; }
 
+  Triple::ArchType getTripleArch() const override {
+// TODO: I think we can drop the support for 32-bit NVPTX devices.
+return Triple::nvptx64;
+  }
+
   /// Check whether the image is compatible with the available CUDA devices.
   Expected isImageCompatible(__tgt_image_info *Info) const override {
 for (int32_t DevId = 0; DevId < getNumDevices(); ++DevId) {
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
@@ -25,6 +25,7 @@
 #include "omptarget.h"
 
 #include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPGridValues.h"
 #include "llvm/Support/Allocator.h"
@@ -372,6 +373,17 @@
   }
   uint32_t getDynamicMemorySize() const { return OMPX_SharedMemorySize; }
 
+  /// Get target architecture.
+  virtual std::string getArch() const {
+llvm_unreachable("device doesn't support JIT");
+  }
+
+  /// Post processing after jit backend. The ownership of \p MB will be taken.
+  virtual Expected>
+  doJITPostProcessing(std::unique_ptr MB) const {
+return MB;
+  }
+
 private:
   /// Register offload entry for global variable.
   Error registerGlobalOffloadEntry(DeviceImageTy ,
@@ -482,6 +494,11 @@
   /// Get the ELF code to recognize the binary image of this plugin.
   virtual uint16_t getMagicElfBits() const = 0;
 
+  /// Get the target triple of this plugin.
+  virtual Triple::ArchType getTripleArch() const {
+llvm_unreachable("target doesn't support jit");
+  }
+
   /// Allocate a structure using the internal allocator.
   template  Ty *allocate() {
 return reinterpret_cast(Allocator.Allocate(sizeof(Ty), alignof(Ty)));
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp

[clang] 443b46e - [analyzer] Fix assertion in getAPSIntType

2022-12-11 Thread via cfe-commits

Author: einvbri
Date: 2022-12-11T17:56:51-06:00
New Revision: 443b46e6d3139c1306caddd06efa674dcea9f38f

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

LOG: [analyzer] Fix assertion in getAPSIntType

getAPSIntType crashes when analzying a simple case that uses a fixed
point type. getAPSIntType needs to handle fixed point types differently
to get sign information. LIT and Unittests were added since there were
 none previously added.

   clang: 
/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:155:
  clang::ento::APSIntType 
clang::ento::BasicValueFactory::getAPSIntType(clang::QualType) const:
  Assertion `T->isIntegralOrEnumerationType() || Loc::isLocType(T)' failed.

Program received signal SIGABRT, Aborted.
0x766e2387 in raise () from /lib64/libc.so.6
(gdb) bt
at 
/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:155
at 
/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:172
  LHS=0x108965a0, op=clang::BO_Shr, RHS=..., resultTy=...) at
  /clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:213
  (this=0x1088e460, state=..., op=clang::BO_Shr, lhs=..., rhs=..., 
resultTy=...)
  at /clang/lib/StaticAnalyzer/Core/SimpleSValBuilder.cpp:681

Reviewed By: steakhal

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

Added: 
clang/test/Analysis/fixed-point.c
clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp

Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
clang/unittests/StaticAnalyzer/CMakeLists.txt

Removed: 




diff  --git 
a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
index 59bfbe3dea77b..ec503b41b381a 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
@@ -152,9 +152,15 @@ class BasicValueFactory {
   T = AT->getValueType();
 }
 
-assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T));
-return APSIntType(Ctx.getIntWidth(T),
-  !T->isSignedIntegerOrEnumerationType());
+if (T->isIntegralOrEnumerationType() || Loc::isLocType(T)) {
+  return APSIntType(Ctx.getIntWidth(T),
+!T->isSignedIntegerOrEnumerationType());
+} else {
+  // implicitly handle case of T->isFixedPointType()
+  return APSIntType(Ctx.getIntWidth(T), T->isUnsignedFixedPointType());
+}
+
+llvm_unreachable("Unsupported type in getAPSIntType!");
   }
 
   /// Convert - Create a new persistent APSInt with the same value as 'From'

diff  --git a/clang/test/Analysis/fixed-point.c 
b/clang/test/Analysis/fixed-point.c
new file mode 100644
index 0..e8c7a4039510c
--- /dev/null
+++ b/clang/test/Analysis/fixed-point.c
@@ -0,0 +1,65 @@
+// RUN: %clang_analyze_cc1 -ffixed-point \
+// RUN:   -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// expected-no-diagnostics
+
+// Check that getAPSIntType does not crash
+// when using fixed point types.
+
+enum Kind { en_0 = 1 };
+
+void _enum(int c) {
+  (void)((enum Kind) c >> 4);
+}
+
+void _inttype(int c) {
+  (void)(c >> 4);
+}
+
+void _accum(int c) {
+  (void)((_Accum) c >> 4);
+}
+
+void _fract(int c) {
+  (void)((_Fract) c >> 4);
+}
+
+void _long_fract(int c) {
+  (void)((long _Fract) c >> 4);
+}
+
+void _unsigned_accum(int c) {
+  (void)((unsigned _Accum) c >> 4);
+}
+
+void _short_unsigned_accum(int c) {
+  (void)((short unsigned _Accum) c >> 4);
+}
+
+void _unsigned_fract(int c) {
+  (void)((unsigned _Fract) c >> 4);
+}
+
+void sat_accum(int c) {
+  (void)((_Sat _Accum) c >> 4);
+}
+
+void sat_fract(int c) {
+  (void)((_Sat _Fract) c >> 4);
+}
+
+void sat_long_fract(int c) {
+  (void)((_Sat long _Fract) c >> 4);
+}
+
+void sat_unsigned_accum(int c) {
+  (void)((_Sat unsigned _Accum) c >> 4);
+}
+
+void sat_short_unsigned_accum(int c) {
+  (void)((_Sat short unsigned _Accum) c >> 4);
+}
+
+void sat_unsigned_fract(int c) {
+  (void)((_Sat unsigned _Fract) c >> 4);
+}

diff  --git a/clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp 
b/clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
new file mode 100644
index 0..19adb1b77c675
--- /dev/null
+++ b/clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
@@ -0,0 +1,57 @@
+//===- unittest/StaticAnalyzer/APSIntTest.cpp - getAPSIntType  test --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//

[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

2022-12-11 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG443b46e6d313: [analyzer] Fix assertion in getAPSIntType 
(authored by einvbri vince.a.bridg...@ericsson.com).

Changed prior to commit:
  https://reviews.llvm.org/D139759?vs=481951=481955#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/test/Analysis/fixed-point.c
  clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt

Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -5,6 +5,7 @@
 
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
+  APSIntTypeTest.cpp
   BugReportInterestingnessTest.cpp
   CallDescriptionTest.cpp
   CallEventTest.cpp
Index: clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
@@ -0,0 +1,57 @@
+//===- unittest/StaticAnalyzer/APSIntTest.cpp - getAPSIntType  test --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+
+namespace {
+
+TEST(getAPSIntTypeTest, APSIntTypeTests) {
+  std::unique_ptr AST = clang::tooling::buildASTFromCode("");
+  clang::ASTContext  = AST->getASTContext();
+  llvm::BumpPtrAllocator Arena;
+  clang::ento::BasicValueFactory BVF{Context, Arena};
+
+  clang::ento::APSIntType Ty = BVF.getAPSIntType(Context.LongAccumTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());
+  EXPECT_FALSE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.UnsignedLongAccumTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());
+  EXPECT_TRUE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.LongFractTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongFractWidth());
+  EXPECT_FALSE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.UnsignedLongFractTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongFractWidth());
+  EXPECT_TRUE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.SignedCharTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getCharWidth());
+  EXPECT_FALSE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.UnsignedCharTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getCharWidth());
+  EXPECT_TRUE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.LongTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongWidth());
+  EXPECT_FALSE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.UnsignedLongTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongWidth());
+  EXPECT_TRUE(Ty.isUnsigned());
+}
+
+} // end namespace
Index: clang/test/Analysis/fixed-point.c
===
--- /dev/null
+++ clang/test/Analysis/fixed-point.c
@@ -0,0 +1,65 @@
+// RUN: %clang_analyze_cc1 -ffixed-point \
+// RUN:   -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// expected-no-diagnostics
+
+// Check that getAPSIntType does not crash
+// when using fixed point types.
+
+enum Kind { en_0 = 1 };
+
+void _enum(int c) {
+  (void)((enum Kind) c >> 4);
+}
+
+void _inttype(int c) {
+  (void)(c >> 4);
+}
+
+void _accum(int c) {
+  (void)((_Accum) c >> 4);
+}
+
+void _fract(int c) {
+  (void)((_Fract) c >> 4);
+}
+
+void _long_fract(int c) {
+  (void)((long _Fract) c >> 4);
+}
+
+void _unsigned_accum(int c) {
+  (void)((unsigned _Accum) c >> 4);
+}
+
+void _short_unsigned_accum(int c) {
+  (void)((short unsigned _Accum) c >> 4);
+}
+
+void _unsigned_fract(int c) {
+  (void)((unsigned _Fract) c >> 4);
+}
+
+void sat_accum(int c) {
+  (void)((_Sat _Accum) c >> 4);
+}
+
+void sat_fract(int c) {
+  (void)((_Sat _Fract) c >> 4);
+}
+
+void sat_long_fract(int c) {
+  (void)((_Sat long _Fract) c >> 4);
+}
+
+void sat_unsigned_accum(int c) {
+  (void)((_Sat unsigned _Accum) c >> 4);
+}
+
+void sat_short_unsigned_accum(int c) {
+  (void)((_Sat short unsigned _Accum) c >> 4);
+}
+
+void sat_unsigned_fract(int c) {
+  (void)((_Sat unsigned _Fract) c >> 4);
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h

[clang] 4d1c5b9 - [openmp] Fix a doc comment issue found by -Wdocumentation

2022-12-11 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2022-12-12T00:14:01+01:00
New Revision: 4d1c5b946ad7f10d398b43e7f20a528407fb79b9

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

LOG: [openmp] Fix a doc comment issue found by -Wdocumentation

Added: 


Modified: 
clang/include/clang/Sema/MultiplexExternalSemaSource.h

Removed: 




diff  --git a/clang/include/clang/Sema/MultiplexExternalSemaSource.h 
b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
index 704925577d269..b0bb15eccee1d 100644
--- a/clang/include/clang/Sema/MultiplexExternalSemaSource.h
+++ b/clang/include/clang/Sema/MultiplexExternalSemaSource.h
@@ -55,7 +55,7 @@ class MultiplexExternalSemaSource : public ExternalSemaSource 
{
 
   /// Appends new source to the source list.
   ///
-  ///\param[in] source - An ExternalSemaSource.
+  ///\param[in] Source - An ExternalSemaSource.
   ///
   void AddSource(ExternalSemaSource *Source);
 



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


[PATCH] D139485: [LLVM] Remove redundant .c_str() and .get() calls where they are not needed.

2022-12-11 Thread Alf via Phabricator via cfe-commits
gAlfonso-bit updated this revision to Diff 481954.
Herald added subscribers: cfe-commits, arichardson, emaste.
Herald added a project: clang-tools-extra.

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

https://reviews.llvm.org/D139485

Files:
  clang-tools-extra/modularize/ModuleAssistant.cpp
  clang/lib/Driver/OffloadBundler.cpp
  clang/lib/Driver/ToolChain.cpp
  lld/ELF/Writer.cpp
  lldb/include/lldb/DataFormatters/DumpValueObjectOptions.h
  lldb/include/lldb/Host/Editline.h
  lldb/include/lldb/Target/Process.h
  lldb/source/API/SBCommandReturnObject.cpp
  lldb/source/API/SBExpressionOptions.cpp
  lldb/source/API/SBInstruction.cpp
  lldb/source/API/SBPlatform.cpp
  lldb/source/API/SBSourceManager.cpp
  lldb/source/Breakpoint/BreakpointResolverScripted.cpp
  lldb/source/Commands/CommandObjectBreakpoint.cpp
  lldb/source/Commands/CommandObjectExpression.cpp
  lldb/source/Commands/CommandObjectHelp.cpp
  lldb/source/Commands/CommandObjectMultiword.cpp
  lldb/source/Commands/CommandObjectTarget.cpp
  lldb/source/Commands/CommandObjectThread.cpp
  lldb/source/Core/Disassembler.cpp
  lldb/source/Core/FormatEntity.cpp
  lldb/source/Core/IOHandlerCursesGUI.cpp
  lldb/source/Core/ValueObject.cpp
  lldb/source/Expression/REPL.cpp
  lldb/source/Host/common/ProcessLaunchInfo.cpp
  lldb/source/Host/posix/ConnectionFileDescriptorPosix.cpp
  lldb/source/Interpreter/CommandInterpreter.cpp
  lldb/source/Interpreter/CommandObject.cpp
  lldb/source/Interpreter/OptionArgParser.cpp
  lldb/source/Interpreter/OptionValueArch.cpp
  lldb/source/Interpreter/ScriptInterpreter.cpp
  lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
  lldb/source/Plugins/DynamicLoader/Hexagon-DYLD/HexagonDYLDRendezvous.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangExpressionParser.cpp
  lldb/source/Plugins/ExpressionParser/Clang/ClangPersistentVariables.cpp
  lldb/source/Plugins/ExpressionParser/Clang/NameSearchContext.cpp
  lldb/source/Plugins/InstrumentationRuntime/TSan/InstrumentationRuntimeTSan.cpp
  
lldb/source/Plugins/InstrumentationRuntime/UBSan/InstrumentationRuntimeUBSan.cpp
  lldb/source/Plugins/Language/ObjC/Cocoa.cpp
  lldb/source/Plugins/MemoryHistory/asan/MemoryHistoryASan.cpp
  lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp
  lldb/source/Plugins/Platform/Android/AdbClient.cpp
  lldb/source/Plugins/Platform/Android/PlatformAndroidRemoteGDBServer.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinDevice.cpp
  lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp
  
lldb/source/Plugins/Platform/MacOSX/objcxx/PlatformiOSSimulatorCoreSimulatorSupport.h
  lldb/source/Plugins/Platform/gdb-server/PlatformRemoteGDBServer.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunication.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationClient.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp
  lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp
  
lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerPlatform.cpp
  lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
  lldb/source/Plugins/SymbolFile/DWARF/SymbolFileDWARFDebugMap.cpp
  lldb/source/Plugins/SymbolFile/PDB/PDBASTParser.cpp
  lldb/source/Plugins/SymbolVendor/MacOSX/SymbolVendorMacOSX.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
  lldb/source/Plugins/UnwindAssembly/InstEmulation/UnwindAssemblyInstEmulation.h
  lldb/source/Symbol/LocateSymbolFileMacOSX.cpp
  lldb/source/Symbol/SymbolFile.cpp
  lldb/source/Target/LanguageRuntime.cpp
  lldb/source/Target/TargetList.cpp
  lldb/source/Target/Thread.cpp
  lldb/source/Target/ThreadPlanPython.cpp
  lldb/source/Target/ThreadPlanStack.cpp
  lldb/tools/debugserver/source/DNBTimer.h
  lldb/tools/debugserver/source/RNBRemote.cpp
  lldb/tools/lldb-vscode/BreakpointBase.cpp
  llvm/include/llvm/Analysis/RegionInfoImpl.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/include/llvm/Support/YAMLParser.h
  llvm/lib/DebugInfo/DWARF/DWARFUnit.cpp
  llvm/lib/DebugInfo/LogicalView/Core/LVElement.cpp
  llvm/lib/DebugInfo/LogicalView/Core/LVScope.cpp
  llvm/lib/DebugInfo/LogicalView/Readers/LVBinaryReader.cpp
  llvm/lib/ObjCopy/MachO/MachOObjcopy.cpp
  llvm/lib/Target/BPF/BTFDebug.cpp
  llvm/tools/dsymutil/BinaryHolder.cpp
  llvm/tools/llvm-cfi-verify/lib/FileAnalysis.cpp
  llvm/tools/llvm-cov/CodeCoverage.cpp
  llvm/tools/llvm-pdbutil/PrettyClassLayoutGraphicalDumper.cpp
  llvm/tools/obj2yaml/elf2yaml.cpp
  llvm/tools/obj2yaml/macho2yaml.cpp

Index: llvm/tools/obj2yaml/macho2yaml.cpp
===
--- llvm/tools/obj2yaml/macho2yaml.cpp
+++ llvm/tools/obj2yaml/macho2yaml.cpp
@@ -192,7 +192,7 @@
   if (SecName.startswith("__debug_")) {
 // If the DWARF section cannot be successfully parsed, emit raw content
 // instead of an entry in the DWARF section of 

[PATCH] D135247: [clang][analyzer] Add stream functions to StdLibraryFunctionsChecker.

2022-12-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

The patch looks OK now, I'll get to inspecting the others.

In D135247#3977403 , @balazske wrote:

> The "strange" test failures that showed up earlier were probably caused by a 
> bug that is fixed in the D137722 . I just 
> read that this patch is rebased to D137722  
> too, fixed the dependency stack.

Very well!

> There was another problem with circular dependencies (because 
> **StdCLibraryFunctionArgsChecker** had a dependency to StreamChecker, this is 
> removed in the last patch). The checker option must be not a problem, the 
> checker (`StdLibraryFunctionsChecker`) can be disabled (but is normally not 
> because it is an **apiModeling** checker) or the **ModelPOSIX** option turned 
> off independently if `StreamChecker` is enabled or not.

Okay, so the checker behaves OK if `StdLibraryFunctionsChecker` is disabled. As 
long as it doesn't crash, this is fine, you shouldn't disable it in practice 
anyways!

> The goal (should work at the end of this patch stack) is that StreamChecker 
> can report all bugs that it can find, and there is no case when both checkers 
> report a bug (in different way). If **ModelPOSIX** is turned off and 
> StreamChecker is enabled, for `fseek` for example no bug is found if stream 
> is NULL, and value of `errno` is just invalidated in all cases (like it works 
> if StreamChecker is disabled too), but the stream state and file position is 
> still checked by StreamChecker for all functions.

This sounds reasonable. It means that no parts of `StdLibraryFunctionsChecker` 
(including its option) is a "hard" dependency.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D135247

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


[PATCH] D137722: [clang][analyzer] No new nodes when bug is detected in StdLibraryFunctionsChecker.

2022-12-11 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:953
 if (FailureSt && !SuccessSt) {
-  if (ExplodedNode *N = C.generateErrorNode(NewState))
+  if (ExplodedNode *N = C.generateErrorNode(NewState, NewNode))
 reportBug(Call, N, Constraint.get(), Summary, C);

Let me know if I got this right. The reason behind `generateErrorNode` not 
behaving like it usually does for other checkers is because of the explicitly 
supplied `NewState` parameter -- in its absence, the //current// path of 
execution is sunk. With this parameter, a new parallel node is. Correct?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137722

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


[clang] 8d43423 - [openmp] Fix a doc comment issue found by -Wdocumentation

2022-12-11 Thread Dmitri Gribenko via cfe-commits

Author: Dmitri Gribenko
Date: 2022-12-11T23:58:28+01:00
New Revision: 8d434235569fe4472c5de43d5f97e3a0bd1f

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

LOG: [openmp] Fix a doc comment issue found by -Wdocumentation

Added: 


Modified: 
clang/include/clang/AST/OpenMPClause.h

Removed: 




diff  --git a/clang/include/clang/AST/OpenMPClause.h 
b/clang/include/clang/AST/OpenMPClause.h
index 59b763335fe2d..3070f573b41d1 100644
--- a/clang/include/clang/AST/OpenMPClause.h
+++ b/clang/include/clang/AST/OpenMPClause.h
@@ -1747,7 +1747,7 @@ class OMPMessageClause final : public OMPClause {
 public:
   /// Build 'message' clause with message string argument
   ///
-  /// \param A Argument of the clause (message string).
+  /// \param MS Argument of the clause (message string).
   /// \param StartLoc Starting location of the clause.
   /// \param LParenLoc Location of '('.
   /// \param EndLoc Ending location of the clause.



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


[PATCH] D139586: [Clang][C++23] Lifetime extension in range-based for loops

2022-12-11 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

Thanks for picking this up! :)

The (non-wording) paper makes a pretty convincing case to just apply this 
retroactively to any C++11 code 
(https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2022/p2644r1.pdf). I think 
we should apply this retroactively, maybe add a pedantic warning when we do a 
lifetime extension on code before C++23.

Also, +1 to more tests. Specifically constexpr and dependent contexts would be 
good to see.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139586

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


[PATCH] D139801: [clang-format] Adds 'friend' to QualifierOrder.

2022-12-11 Thread Micah Weston via Phabricator via cfe-commits
red1bluelost created this revision.
red1bluelost added a reviewer: MyDeveloperDay.
Herald added a project: All.
red1bluelost requested review of this revision.
Herald added a project: clang.

For cases of defining friend functions, qualifier ordering can allow multiple
positions for the 'friend' token.

  c++
  struct S {
int i;
  
friend constexpr auto operator<=>(const S&, const S&) noexcept = default;
  };



  1. Changes
- Adds `friend` to `getTokenFromQualifier`
- Updates documentation in `Format.h` and `ClangFormatStyleOptions.rst`
- Adds tests to `QualifierFixerTest.cpp`

Testing
---

Ran FormatTest with no errors.

GitHub Issue


https://github.com/llvm/llvm-project/issues/59450


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139801

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -133,6 +133,8 @@
 tok::kw_static);
   
EXPECT_EQ(LeftRightQualifierAlignmentFixer::getTokenFromQualifier("restrict"),
 tok::kw_restrict);
+  EXPECT_EQ(LeftRightQualifierAlignmentFixer::getTokenFromQualifier("friend"),
+tok::kw_friend);
 }
 
 TEST_F(QualifierFixerTest, FailQualifierInvalidConfiguration) {
@@ -196,8 +198,8 @@
 TEST_F(QualifierFixerTest, QualifiersCustomOrder) {
   FormatStyle Style = getLLVMStyle();
   Style.QualifierAlignment = FormatStyle::QAS_Left;
-  Style.QualifierOrder = {"inline", "constexpr", "static",
-  "const",  "volatile",  "type"};
+  Style.QualifierOrder = {"friend", "inline",   "constexpr", "static",
+  "const",  "volatile", "type"};
 
   verifyFormat("const volatile int a;", "const volatile int a;", Style);
   verifyFormat("const volatile int a;", "volatile const int a;", Style);
@@ -216,6 +218,15 @@
   verifyFormat("constexpr static LPINT Bar;", "static constexpr LPINT Bar;",
Style);
   verifyFormat("const const int a;", "const int const a;", Style);
+
+  verifyFormat(
+  "friend constexpr auto operator<=>(const foo &, const foo &) = default;",
+  "constexpr friend auto operator<=>(const foo &, const foo &) = default;",
+  Style);
+  verifyFormat(
+  "friend constexpr bool operator==(const foo &, const foo &) = default;",
+  "constexpr bool friend operator==(const foo &, const foo &) = default;",
+  Style);
 }
 
 TEST_F(QualifierFixerTest, LeftRightQualifier) {
@@ -723,9 +734,10 @@
   ConfiguredTokens.push_back(tok::kw_inline);
   ConfiguredTokens.push_back(tok::kw_restrict);
   ConfiguredTokens.push_back(tok::kw_constexpr);
+  ConfiguredTokens.push_back(tok::kw_friend);
 
-  auto Tokens =
-  annotate("const static inline auto restrict int double long constexpr");
+  auto Tokens = annotate(
+  "const static inline auto restrict int double long constexpr friend");
 
   EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
   Tokens[0], ConfiguredTokens));
@@ -745,6 +757,8 @@
   Tokens[7], ConfiguredTokens));
   EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
   Tokens[8], ConfiguredTokens));
+  EXPECT_TRUE(LeftRightQualifierAlignmentFixer::isQualifierOrType(
+  Tokens[9], ConfiguredTokens));
 
   auto NotTokens = annotate("for while do Foo Bar ");
 
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -414,6 +414,7 @@
   .Case("inline", tok::kw_inline)
   .Case("constexpr", tok::kw_constexpr)
   .Case("restrict", tok::kw_restrict)
+  .Case("friend", tok::kw_friend)
   .Default(tok::identifier);
 }
 
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2970,6 +2970,7 @@
   ///   * const
   ///   * inline
   ///   * static
+  ///   * friend
   ///   * constexpr
   ///   * volatile
   ///   * restrict
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3712,6 +3712,7 @@
 * const
 * inline
 * static
+* friend
 * constexpr
 * volatile
 * restrict


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -133,6 +133,8 @@
 tok::kw_static);
   

[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

2022-12-11 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.

The fix feels suboptimal in readability but let it be whatever.

Functionally feels good. Tests are there and gets the job done.
I wont object.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:158
+!T->isSignedIntegerOrEnumerationType());
+} else if (T->isFixedPointType()) {
+  return APSIntType(Ctx.getIntWidth(T), !T->isSignedFixedPointType());

else, or else if just complicates the control flow after a return statement.

And I also intentionally recommended to use the isUnsigned.. stuff to make it 
easier to read withoutthe negation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

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


[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

2022-12-11 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

I think that addresses the last comments. Thanks again :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

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


[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

2022-12-11 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 481951.
vabridgers marked 7 inline comments as done.
vabridgers added a comment.

clean up pass per comments from @steakhal


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/test/Analysis/fixed-point.c
  clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt

Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -5,6 +5,7 @@
 
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
+  APSIntTypeTest.cpp
   BugReportInterestingnessTest.cpp
   CallDescriptionTest.cpp
   CallEventTest.cpp
Index: clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
@@ -0,0 +1,57 @@
+//===- unittest/StaticAnalyzer/APSIntTest.cpp - getAPSIntType  test --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+
+namespace {
+
+TEST(getAPSIntTypeTest, APSIntTypeTests) {
+  std::unique_ptr AST = clang::tooling::buildASTFromCode("");
+  clang::ASTContext  = AST->getASTContext();
+  llvm::BumpPtrAllocator Arena;
+  clang::ento::BasicValueFactory BVF{Context, Arena};
+
+  clang::ento::APSIntType Ty = BVF.getAPSIntType(Context.LongAccumTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());
+  EXPECT_FALSE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.UnsignedLongAccumTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());
+  EXPECT_TRUE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.LongFractTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongFractWidth());
+  EXPECT_FALSE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.UnsignedLongFractTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongFractWidth());
+  EXPECT_TRUE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.SignedCharTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getCharWidth());
+  EXPECT_FALSE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.UnsignedCharTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getCharWidth());
+  EXPECT_TRUE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.LongTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongWidth());
+  EXPECT_FALSE(Ty.isUnsigned());
+
+  Ty = BVF.getAPSIntType(Context.UnsignedLongTy);
+  EXPECT_TRUE(Ty.getBitWidth() == Context.getTargetInfo().getLongWidth());
+  EXPECT_TRUE(Ty.isUnsigned());
+}
+
+} // end namespace
Index: clang/test/Analysis/fixed-point.c
===
--- /dev/null
+++ clang/test/Analysis/fixed-point.c
@@ -0,0 +1,65 @@
+// RUN: %clang_analyze_cc1 -ffixed-point \
+// RUN:   -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// expected-no-diagnostics
+
+// Check that getAPSIntType does not crash
+// when using fixed point types.
+
+enum Kind { en_0 = 1 };
+
+void _enum(int c) {
+  (void)((enum Kind) c >> 4);
+}
+
+void _inttype(int c) {
+  (void)(c >> 4);
+}
+
+void _accum(int c) {
+  (void)((_Accum) c >> 4);
+}
+
+void _fract(int c) {
+  (void)((_Fract) c >> 4);
+}
+
+void _long_fract(int c) {
+  (void)((long _Fract) c >> 4);
+}
+
+void _unsigned_accum(int c) {
+  (void)((unsigned _Accum) c >> 4);
+}
+
+void _short_unsigned_accum(int c) {
+  (void)((short unsigned _Accum) c >> 4);
+}
+
+void _unsigned_fract(int c) {
+  (void)((unsigned _Fract) c >> 4);
+}
+
+void sat_accum(int c) {
+  (void)((_Sat _Accum) c >> 4);
+}
+
+void sat_fract(int c) {
+  (void)((_Sat _Fract) c >> 4);
+}
+
+void sat_long_fract(int c) {
+  (void)((_Sat long _Fract) c >> 4);
+}
+
+void sat_unsigned_accum(int c) {
+  (void)((_Sat unsigned _Accum) c >> 4);
+}
+
+void sat_short_unsigned_accum(int c) {
+  (void)((_Sat short unsigned _Accum) c >> 4);
+}
+
+void sat_unsigned_fract(int c) {
+  (void)((_Sat unsigned _Fract) c >> 4);
+}
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
===
--- 

[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev marked an inline comment as done.
v.g.vassilev added inline comments.



Comment at: clang/test/Interpreter/execute-stmts.cpp:34
+
+for (; i > 4; --i) printf("i = %d\n", i);
+// CHECK-NEXT: i = 5

UnionType wrote:
> It seems that top-level statements wrapped in braces cannot be handled, maybe 
> I made a mistake.
> ```
> for (; i > 4; --i) { printf("i = %d\n", i); }
> 
> { i++; }
> ```
Ah, you are right. I have a fix for this case here: 
https://reviews.llvm.org/D139798


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D139798: [clang-repl] Support compound statement as a top-level statement.

2022-12-11 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev created this revision.
v.g.vassilev added reviewers: aaron.ballman, rsmith.
Herald added a project: All.
v.g.vassilev requested review of this revision.

This patch teaches our incremental compilation infrastructure to push and pop a 
fake function scope making the Parser happy when parsing compound statements as 
part of a top-leve statement declaration.


Repository:
  rC Clang

https://reviews.llvm.org/D139798

Files:
  clang/lib/Parse/ParseDecl.cpp
  clang/test/Interpreter/execute-stmts.cpp


Index: clang/test/Interpreter/execute-stmts.cpp
===
--- clang/test/Interpreter/execute-stmts.cpp
+++ clang/test/Interpreter/execute-stmts.cpp
@@ -34,5 +34,10 @@
 for (; i > 4; --i) printf("i = %d\n", i);
 // CHECK-NEXT: i = 5
 
+{++i;}
+
+for (; i > 4; --i) { printf("i = %d\n", i); };
+// CHECK-NEXT: i = 5
+
 int j = i; printf("j = %d\n", j);
 // CHECK-NEXT: j = 4
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5387,7 +5387,9 @@
   // Parse a top-level-stmt.
   Parser::StmtVector Stmts;
   ParsedStmtContext SubStmtCtx = ParsedStmtContext();
+  Actions.PushFunctionScope();
   StmtResult R = ParseStatementOrDeclaration(Stmts, SubStmtCtx);
+  Actions.PopFunctionScopeInfo();
   if (!R.isUsable())
 return nullptr;
 


Index: clang/test/Interpreter/execute-stmts.cpp
===
--- clang/test/Interpreter/execute-stmts.cpp
+++ clang/test/Interpreter/execute-stmts.cpp
@@ -34,5 +34,10 @@
 for (; i > 4; --i) printf("i = %d\n", i);
 // CHECK-NEXT: i = 5
 
+{++i;}
+
+for (; i > 4; --i) { printf("i = %d\n", i); };
+// CHECK-NEXT: i = 5
+
 int j = i; printf("j = %d\n", j);
 // CHECK-NEXT: j = 4
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -5387,7 +5387,9 @@
   // Parse a top-level-stmt.
   Parser::StmtVector Stmts;
   ParsedStmtContext SubStmtCtx = ParsedStmtContext();
+  Actions.PushFunctionScope();
   StmtResult R = ParseStatementOrDeclaration(Stmts, SubStmtCtx);
+  Actions.PopFunctionScopeInfo();
   if (!R.isUsable())
 return nullptr;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

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

Really good progress. Nicestuff. I really appreciate the unittest.
However Ive got some minor comments there :D




Comment at: clang/test/Analysis/fixed-point.c:9
+
+enum en_t { en_0 = 1 };
+

I would suggest 'Kind' or something similar. So by reading it would feel 
natural that is an enum.
Its probably a personal preference though. Disregard if you want.



Comment at: clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp:1
+//===- unittest/StaticAnalyzer/AnalyzerOptionsTest.cpp - SA Options test 
--===//
+//

Copypaste typo: SA Options?. Check the rest.



Comment at: clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp:13
+#include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"

Do we really need checkers here? Check the rest of the includes. It will reduce 
compile times inthe long run.



Comment at: clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp:20
+
+namespace clang {
+namespace ento {

Should the content really be inside the ento namespace?
I would probably advocate for anonymous namespaces instead.



Comment at: clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp:23
+
+TEST(getAPSIntTypeTest, foo) {
+  std::unique_ptr AST = tooling::buildASTFromCode("");

Give a meaningful name for this.



Comment at: clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp:29
+
+  APSIntType ty = BVF.getAPSIntType(Context.LongAccumTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());

We use Upper Camel Case for variables as per llvm. In addition we usually refer 
to QualTypes by 'Ty'.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

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


[PATCH] D139786: [clang-format] AllowShortRequiresExpressionOnASingleLine and AllowShortCompoundRequirementOnASingleLine

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

I don't know if adding two options at once (and I think you want to add a 
third), splitting that up might be a better idea.

Anyway you need to tun `clang/docs/tools/dump_format_style.py` and add an entry 
in the changelog.




Comment at: clang/include/clang/Format/Format.h:542
+  /// \code
+  ///   true:
+  ///   template 

We have both, but I like the variant with `true` and `false` next to each 
other, not below.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1105
   }
+
   nextToken();

Unrelated.



Comment at: clang/unittests/Format/FormatTest.cpp:2911
+   "  a + b;\n"
+   "};");
+  // TODO: support BraceWrapping.AfterRequiresExpression.

You need to add the Style.


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

https://reviews.llvm.org/D139786

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


[PATCH] D137343: [clang] add -Wvla-stack-allocation

2022-12-11 Thread Martin Uecker via Phabricator via cfe-commits
uecker added a comment.

I would still suggest to change the behavior of -Wvla  to warn only about VLAs 
which are allocated on the stack as the most useful warning. Portability 
warnings should be turned on for -Wc++-compat.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137343

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


[PATCH] D136554: Implement CWG2631

2022-12-11 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

no, I got

  $ ninja -C out/MyClang/ content_unittests
  ld.lld: error: undefined symbol: 
mojo::Receiver>::Receiver(content::mojom::TestInterfaceForDefer*)
  >>> referenced by mojo_binder_policy_applier_unittest.cc:90 
(../../content/browser/mojo_binder_policy_applier_unittest.cc:90)
  >>>   
obj/content/test/content_unittests/mojo_binder_policy_applier_unittest.o:(content::TestReceiverCollector::TestReceiverCollector())
  
  ld.lld: error: undefined symbol: 
mojo::Receiver>::Receiver(content::mojom::TestInterfaceForGrant*)
  >>> referenced by mojo_binder_policy_applier_unittest.cc:91 
(../../content/browser/mojo_binder_policy_applier_unittest.cc:91)
  >>>   
obj/content/test/content_unittests/mojo_binder_policy_applier_unittest.o:(content::TestReceiverCollector::TestReceiverCollector())
  
  ld.lld: error: undefined symbol: 
mojo::Receiver>::Receiver(content::mojom::TestInterfaceForCancel*)
  >>> referenced by mojo_binder_policy_applier_unittest.cc:92 
(../../content/browser/mojo_binder_policy_applier_unittest.cc:92)
  >>>   
obj/content/test/content_unittests/mojo_binder_policy_applier_unittest.o:(content::TestReceiverCollector::TestReceiverCollector())
  
  ld.lld: error: undefined symbol: 
mojo::Receiver>::Receiver(content::mojom::TestInterfaceForUnexpected*)
  >>> referenced by mojo_binder_policy_applier_unittest.cc:93 
(../../content/browser/mojo_binder_policy_applier_unittest.cc:93)
  >>>   
obj/content/test/content_unittests/mojo_binder_policy_applier_unittest.o:(content::TestReceiverCollector::TestReceiverCollector())
  clang++: error: linker command failed with exit code 1 (use -v to see 
invocation)

https://crsrc.org/c/content/browser/mojo_binder_policy_applier_unittest.cc;drc=4e1b7bc33d42b401d7d9ad1dcba72883add3e2af;l=90


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

2022-12-11 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked an inline comment as done.
vabridgers added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:157-158
+   Loc::isLocType(T));
 return APSIntType(Ctx.getIntWidth(T),
   !T->isSignedIntegerOrEnumerationType());
   }

vabridgers wrote:
> steakhal wrote:
> > vabridgers wrote:
> > > steakhal wrote:
> > > > I don't think you are supposed to call 
> > > > `isSignedIntegerOrEnumerationType()` if you have a //fixed-point// type.
> > > > ```lang=C++
> > > > inline bool Type::isSignedFixedPointType() const {
> > > >   if (const auto *BT = dyn_cast(CanonicalType)) {
> > > > return ((BT->getKind() >= BuiltinType::ShortAccum &&
> > > >  BT->getKind() <= BuiltinType::LongAccum) ||
> > > > (BT->getKind() >= BuiltinType::ShortFract &&
> > > >  BT->getKind() <= BuiltinType::LongFract) ||
> > > > (BT->getKind() >= BuiltinType::SatShortAccum &&
> > > >  BT->getKind() <= BuiltinType::SatLongAccum) ||
> > > > (BT->getKind() >= BuiltinType::SatShortFract &&
> > > >  BT->getKind() <= BuiltinType::SatLongFract));
> > > >   }
> > > >   return false;
> > > > }
> > > > ```
> > > > By looking at the implementation of this, I don't think you could 
> > > > substitute that with `isSignedIntegerOrEnumerationType()`.
> > > > Am I wrong about this?
> > > > 
> > > > Please demonstrate this by tests.
> > > I tried using isSignedIntegerOrEnumerationType() instead of 
> > > (T->isIntegralOrEnumerationType() || T->isFixedPointType() ... ), but got 
> > > the same assert :/  
> > > 
> > > I corrected the formatting and expanded the test cases. 
> > Is hould have clarified, sorry.
> > 
> > My point is that for constructing the APSIntType, we calculate the bitwidth 
> > and the signedness.
> > 
> > My problem is that the calculation is wrong for the signedness in case we 
> > have a signed fixedpointtype.
> > It is wrong because we reach `isSignedIntegerOrEnumerationType()` with a 
> > fixedpoint type. For that even though its signed, it will return false!
> > 
> > And in the end we will have an APSIntType with the wrong signednss.
> > 
> > So my point is that we should probably handle fixedpoint types separately 
> > to have a distict return statement for it.
> > But im jumping to the solution, what I originally wanted to highlight was 
> > this.
> > That was why I requested changes.
> > And this is what I wanted to see some how intests, but I wont insist if its 
> > too difficult to craft.
> In retrospect, your original comment was clear. I did not fully comprehend 
> the comment. 
> 
> I'll explore a few options. I checked the unittests for a "reference", and it 
> seems our static analysis unittest coverage is sparse. Not sure I need to go 
> that far, but I'll explore the possibility of crafting a unittest for this 
> case that demonstrates the problem and solution. 
> 
> Thanks again - best!
Thanks for your insightful comments, in retrospect I should have dug into this 
more from the very beginning. Turns out there is an API get the fixed point 
sign I should be using, and creating a simple unittest had value in working 
this out (imagine that ! :) ). 

So, I updated with the correction and a simple unittest. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

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


[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

2022-12-11 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers updated this revision to Diff 481940.
vabridgers added a comment.

correct handling of sign type per @steakhal comments. Thank you, sir :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h
  clang/test/Analysis/fixed-point.c
  clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
  clang/unittests/StaticAnalyzer/CMakeLists.txt

Index: clang/unittests/StaticAnalyzer/CMakeLists.txt
===
--- clang/unittests/StaticAnalyzer/CMakeLists.txt
+++ clang/unittests/StaticAnalyzer/CMakeLists.txt
@@ -5,6 +5,7 @@
 
 add_clang_unittest(StaticAnalysisTests
   AnalyzerOptionsTest.cpp
+  APSIntTypeTest.cpp
   BugReportInterestingnessTest.cpp
   CallDescriptionTest.cpp
   CallEventTest.cpp
Index: clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
===
--- /dev/null
+++ clang/unittests/StaticAnalyzer/APSIntTypeTest.cpp
@@ -0,0 +1,63 @@
+//===- unittest/StaticAnalyzer/AnalyzerOptionsTest.cpp - SA Options test --===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/Builtins.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TargetInfo.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace ento {
+
+TEST(getAPSIntTypeTest, foo) {
+  std::unique_ptr AST = tooling::buildASTFromCode("");
+  ASTContext  = AST->getASTContext();
+  llvm::BumpPtrAllocator Arena;
+  BasicValueFactory BVF{Context, Arena};
+
+  APSIntType ty = BVF.getAPSIntType(Context.LongAccumTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());
+  EXPECT_FALSE(ty.isUnsigned());
+
+  ty = BVF.getAPSIntType(Context.UnsignedLongAccumTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getLongAccumWidth());
+  EXPECT_TRUE(ty.isUnsigned());
+
+  ty = BVF.getAPSIntType(Context.LongFractTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getLongFractWidth());
+  EXPECT_FALSE(ty.isUnsigned());
+
+  ty = BVF.getAPSIntType(Context.UnsignedLongFractTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getLongFractWidth());
+  EXPECT_TRUE(ty.isUnsigned());
+
+  ty = BVF.getAPSIntType(Context.SignedCharTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getCharWidth());
+  EXPECT_FALSE(ty.isUnsigned());
+
+  ty = BVF.getAPSIntType(Context.UnsignedCharTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getCharWidth());
+  EXPECT_TRUE(ty.isUnsigned());
+
+  ty = BVF.getAPSIntType(Context.LongTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getLongWidth());
+  EXPECT_FALSE(ty.isUnsigned());
+
+  ty = BVF.getAPSIntType(Context.UnsignedLongTy);
+  EXPECT_TRUE(ty.getBitWidth() == Context.getTargetInfo().getLongWidth());
+  EXPECT_TRUE(ty.isUnsigned());
+}
+
+} // end namespace ento
+} // end namespace clang
Index: clang/test/Analysis/fixed-point.c
===
--- /dev/null
+++ clang/test/Analysis/fixed-point.c
@@ -0,0 +1,65 @@
+// RUN: %clang_analyze_cc1 -ffixed-point \
+// RUN:   -analyzer-checker=core,debug.ExprInspection -verify %s
+
+// expected-no-diagnostics
+
+// Check that getAPSIntType does not crash
+// when using fixed point types.
+
+enum en_t { en_0 = 1 };
+
+void _enum(int c) {
+  (void)((enum en_t) c >> 4);
+}
+
+void _inttype(int c) {
+  (void)(c >> 4);
+}
+
+void _accum(int c) {
+  (void)((_Accum) c >> 4);
+}
+
+void _fract(int c) {
+  (void)((_Fract) c >> 4);
+}
+
+void _long_fract(int c) {
+  (void)((long _Fract) c >> 4);
+}
+
+void _unsigned_accum(int c) {
+  (void)((unsigned _Accum) c >> 4);
+}
+
+void _short_unsigned_accum(int c) {
+  (void)((short unsigned _Accum) c >> 4);
+}
+
+void _unsigned_fract(int c) {
+  (void)((unsigned _Fract) c >> 4);
+}
+
+void sat_accum(int c) {
+  (void)((_Sat _Accum) c >> 4);
+}
+
+void sat_fract(int c) {
+  (void)((_Sat _Fract) c >> 4);
+}
+
+void sat_long_fract(int c) {
+  (void)((_Sat long _Fract) c >> 4);
+}
+
+void sat_unsigned_accum(int c) {
+  (void)((_Sat unsigned _Accum) c >> 4);
+}
+
+void sat_short_unsigned_accum(int c) {
+  (void)((_Sat short unsigned _Accum) c >> 4);
+}
+
+void sat_unsigned_fract(int c) {
+  (void)((_Sat unsigned _Fract) c >> 4);
+}
Index: 

[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-12-11 Thread Mark de Wever via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Mordante marked an inline comment as done.
Closed by commit rGd40dc417389e: [CMake] Warn when the version is older than 
3.20.0. (authored by Mordante).

Changed prior to commit:
  https://reviews.llvm.org/D137724?vs=474295=481933#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

Files:
  clang/CMakeLists.txt
  compiler-rt/CMakeLists.txt
  compiler-rt/lib/builtins/CMakeLists.txt
  compiler-rt/lib/crt/CMakeLists.txt
  flang/CMakeLists.txt
  flang/runtime/CMakeLists.txt
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/tools/debugserver/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/docs/ReleaseNotes.rst
  mlir/CMakeLists.txt
  openmp/CMakeLists.txt
  polly/CMakeLists.txt
  runtimes/CMakeLists.txt

Index: runtimes/CMakeLists.txt
===
--- runtimes/CMakeLists.txt
+++ runtimes/CMakeLists.txt
@@ -1,5 +1,12 @@
 # This file handles building LLVM runtime sub-projects.
 cmake_minimum_required(VERSION 3.13.4)
+if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+  message(WARNING
+"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+"minimum version of CMake required to build LLVM will become 3.20.0, and "
+"using an older CMake will become an error. Please upgrade your CMake to "
+"at least 3.20.0 now to avoid issues in the future!")
+endif()
 project(Runtimes C CXX ASM)
 
 # Add path for custom and the LLVM build's modules to the CMake module path.
Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -2,6 +2,13 @@
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   project(Polly)
   cmake_minimum_required(VERSION 3.13.4)
+  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+message(WARNING
+  "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+  "minimum version of CMake required to build LLVM will become 3.20.0, and "
+  "using an older CMake will become an error. Please upgrade your CMake to "
+  "at least 3.20.0 now to avoid issues in the future!")
+  endif()
   set(POLLY_STANDALONE_BUILD TRUE)
 endif()
 
Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -12,6 +12,13 @@
 if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
   set(OPENMP_STANDALONE_BUILD TRUE)
   project(openmp C CXX)
+  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+message(WARNING
+  "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+  "minimum version of CMake required to build LLVM will become 3.20.0, and "
+  "using an older CMake will become an error. Please upgrade your CMake to "
+  "at least 3.20.0 now to avoid issues in the future!")
+  endif()
 endif()
 
 # Must go below project(..)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -11,6 +11,13 @@
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   project(mlir)
   set(MLIR_STANDALONE_BUILD TRUE)
+  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+message(WARNING
+  "Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+  "minimum version of CMake required to build LLVM will become 3.20.0, and "
+  "using an older CMake will become an error. Please upgrade your CMake to "
+  "at least 3.20.0 now to avoid issues in the future!")
+  endif()
 endif()
 
 # Must go below project(..)
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -64,6 +64,17 @@
 * Apple Clang >= 10.0
 * Visual Studio 2019 >= 16.7
 
+With LLVM 16.x we will raise the version requirement of CMake used to build
+LLVM. The new requirements are as follows:
+
+* CMake >= 3.20.0
+
+In LLVM 16.x this requirement will be "soft", there will only be a diagnostic.
+
+With the release of LLVM 17.x this requirement will be hard and LLVM developers
+can start using CMake 3.20.0 features, making it impossible to build with older
+versions of CMake.
+
 Changes to the LLVM IR
 --
 
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -1,6 +1,13 @@
 # See docs/CMake.html for instructions about how to build LLVM with CMake.
 
 cmake_minimum_required(VERSION 3.13.4)
+if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+  message(WARNING
+"Your CMake version is ${CMAKE_VERSION}. Starting with LLVM 17.0.0, the "
+"minimum version of CMake required to build LLVM 

[PATCH] D137724: [CMake] Warn when the version is older than 3.20.0.

2022-12-11 Thread Mark de Wever via Phabricator via cfe-commits
Mordante marked an inline comment as done.
Mordante added a comment.

Thanks for all reviews!

In D137724#3974764 , @thieta wrote:

> I think this is ready to land @Mordante or is there anything else missing?

No but I've been quite busy. I needed some time to find the list of buildbot 
owners to mail after landing this.




Comment at: clang/CMakeLists.txt:14
   set(CLANG_BUILT_STANDALONE TRUE)
+  if ("${CMAKE_VERSION}" VERSION_LESS "3.20.0")
+message(WARNING

mgorny wrote:
> I wonder if we could move this to `CMakePolicy.cmake`, though admittedly 
> you'd have to somehow avoid warning multiple times in in-tree builds.
Yes I prefer to keep it this way. The warning will be removed once 3.20.0 or 
newer is mandated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137724

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


[PATCH] D139786: [clang-format] AllowShortRequiresExpressionOnASingleLine and AllowShortCompoundRequirementOnASingleLine

2022-12-11 Thread Zhikai Zeng via Phabricator via cfe-commits
Backl1ght updated this revision to Diff 481918.

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

https://reviews.llvm.org/D139786

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2899,6 +2899,35 @@
Style);
 }
 
+TEST_F(FormatTest, ShortRequiresExpression) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortRequiresExpressionOnASingleLine);
+  verifyFormat("template \n"
+   "concept c = requires(T a, T b) { a + b; };");
+  Style.AllowShortRequiresExpressionOnASingleLine = false;
+  verifyFormat("template \n"
+   "concept c = requires(T a, T b) {\n"
+   "  a + b;\n"
+   "};");
+  // TODO: support BraceWrapping.AfterRequiresExpression.
+}
+
+TEST_F(FormatTest, ShortCompoundRequirement) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortCompoundRequirementOnASingleLine);
+  verifyFormat("template \n"
+   "concept c = requires(T x) {\n"
+   "  { x + 1 } -> std::same_as;\n"
+   "};");
+  Style.AllowShortCompoundRequirementOnASingleLine = false;
+  verifyFormat("template \n"
+   "concept c = requires(T x) {\n"
+   "  {\n"
+   "x + 1\n"
+   "  } -> std::same_as;\n"
+   "};");
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -147,8 +147,10 @@
   CHECK_PARSE_BOOL(AllowAllArgumentsOnNextLine);
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortCompoundRequirementOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortRequiresExpressionOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,6 +1085,12 @@
   FormatTok->setBlockKind(BK_Block);
   const FormatToken *OpeningBrace = FormatTok;
   nextToken();
+
+  if (NextLBracesType == TT_CompoundRequirementLBrace &&
+  !Style.AllowShortRequiresExpressionOnASingleLine) {
+addUnwrappedLine();
+  }
+
   {
 bool SkipIndent = (Style.isJavaScript() &&
(isGoogScope(*Line) || isIIFE(*Line, Keywords)));
@@ -1096,6 +1102,7 @@
 flushComments(isOnNewLine(*FormatTok));
 Line->Level -= SkipIndent ? 0 : 1;
   }
+
   nextToken();
 }
 
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -502,6 +502,10 @@
   // Try to merge records.
   if (TheLine->Last->is(TT_EnumLBrace)) {
 ShouldMerge = Style.AllowShortEnumsOnASingleLine;
+  } else if (TheLine->Last->is(TT_RequiresExpressionLBrace)) {
+ShouldMerge = Style.AllowShortRequiresExpressionOnASingleLine;
+  } else if (TheLine->Last->is(TT_CompoundRequirementLBrace)) {
+ShouldMerge = Style.AllowShortCompoundRequirementOnASingleLine;
   } else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace)) {
 // NOTE: We use AfterClass (whereas AfterStruct exists) for both classes
 // and structs, but it seems that wrapping is still handled correctly
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -806,6 +806,8 @@
Style.AllowShortBlocksOnASingleLine);
 IO.mapOptional("AllowShortCaseLabelsOnASingleLine",
Style.AllowShortCaseLabelsOnASingleLine);
+IO.mapOptional("AllowShortCompoundRequirementOnASingleLine",
+   Style.AllowShortCompoundRequirementOnASingleLine);
 IO.mapOptional("AllowShortEnumsOnASingleLine",
Style.AllowShortEnumsOnASingleLine);
 IO.mapOptional("AllowShortFunctionsOnASingleLine",
@@ -816,6 +818,8 @@
Style.AllowShortLambdasOnASingleLine);

[PATCH] D139786: [clang-format] AllowShortRequiresExpressionOnASingleLine and AllowShortCompoundRequirementOnASingleLine

2022-12-11 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added a comment.

Please re-upload with full context. See 
https://llvm.org/docs/Phabricator.html#requesting-a-review-via-the-web-interface




Comment at: clang/lib/Format/Format.cpp:811
Style.AllowShortEnumsOnASingleLine);
+IO.mapOptional("AllowShortRequiresExpressionOnASingleLine",
+   Style.AllowShortRequiresExpressionOnASingleLine);

I'm pretty sure these options should be in alphabetical order (and below too)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139786

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


[PATCH] D139774: [libclang] Add API to set temporary directory location

2022-12-11 Thread Igor Kushnir via Phabricator via cfe-commits
vedgy updated this revision to Diff 481913.
vedgy edited the summary of this revision.
vedgy added a comment.

Extract identical code from the two Path.inc files into Path.cpp

One of the Path.inc files is #include-d into this Path.cpp file and nowhere 
else.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139774

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang-c/Index.h
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/libclang.map
  llvm/include/llvm/Support/Path.h
  llvm/lib/Support/Path.cpp
  llvm/lib/Support/Unix/Path.inc
  llvm/lib/Support/Windows/Path.inc
  llvm/unittests/Support/Path.cpp

Index: llvm/unittests/Support/Path.cpp
===
--- llvm/unittests/Support/Path.cpp
+++ llvm/unittests/Support/Path.cpp
@@ -591,6 +591,26 @@
   EXPECT_TRUE(!TempDir.empty());
 }
 
+TEST(Support, SetTempDirectory) {
+  SmallString<64> DefaultTempDir;
+  path::system_temp_directory(true, DefaultTempDir);
+  EXPECT_TRUE(!DefaultTempDir.empty());
+
+  auto CustomTempDir = DefaultTempDir;
+  path::append(CustomTempDir, "/llvm/test_temp_dir");
+  path::native(CustomTempDir);
+  path::set_system_temp_directory_erased_on_reboot(CustomTempDir.c_str());
+
+  SmallString<64> TempDir;
+  path::system_temp_directory(true, TempDir);
+  EXPECT_EQ(CustomTempDir, TempDir);
+
+  path::set_system_temp_directory_erased_on_reboot(nullptr);
+  TempDir.clear();
+  path::system_temp_directory(true, TempDir);
+  EXPECT_EQ(DefaultTempDir, TempDir);
+}
+
 #ifdef _WIN32
 static std::string path2regex(std::string Path) {
   size_t Pos = 0;
Index: llvm/lib/Support/Windows/Path.inc
===
--- llvm/lib/Support/Windows/Path.inc
+++ llvm/lib/Support/Windows/Path.inc
@@ -1472,11 +1472,16 @@
   (void)ErasedOnReboot;
   Result.clear();
 
+  if (tempDirErasedOnRebootUtf8) {
+const auto len = strlen(tempDirErasedOnRebootUtf8);
+Result.append(tempDirErasedOnRebootUtf8, tempDirErasedOnRebootUtf8 + len);
+  }
+
   // Check whether the temporary directory is specified by an environment var.
   // This matches GetTempPath logic to some degree. GetTempPath is not used
   // directly as it cannot handle evn var longer than 130 chars on Windows 7
   // (fixed on Windows 8).
-  if (getTempDirEnvVar(Result)) {
+  if (!Result.empty() || getTempDirEnvVar(Result)) {
 assert(!Result.empty() && "Unexpected empty path");
 native(Result); // Some Unix-like shells use Unix path separator in $TMP.
 fs::make_absolute(Result); // Make it absolute if not already.
Index: llvm/lib/Support/Unix/Path.inc
===
--- llvm/lib/Support/Unix/Path.inc
+++ llvm/lib/Support/Unix/Path.inc
@@ -1451,8 +1451,11 @@
   Result.clear();
 
   if (ErasedOnReboot) {
+const char *RequestedDir = tempDirErasedOnRebootUtf8;
 // There is no env variable for the cache directory.
-if (const char *RequestedDir = getEnvTempDir()) {
+if (!RequestedDir)
+  RequestedDir = getEnvTempDir();
+if (RequestedDir) {
   Result.append(RequestedDir, RequestedDir + strlen(RequestedDir));
   return;
 }
Index: llvm/lib/Support/Path.cpp
===
--- llvm/lib/Support/Path.cpp
+++ llvm/lib/Support/Path.cpp
@@ -780,6 +780,12 @@
   return true;
 }
 
+static const char *tempDirErasedOnRebootUtf8 = nullptr;
+
+void set_system_temp_directory_erased_on_reboot(const char *tempDirUtf8) {
+  tempDirErasedOnRebootUtf8 = tempDirUtf8;
+}
+
 } // end namespace path
 
 namespace fs {
Index: llvm/include/llvm/Support/Path.h
===
--- llvm/include/llvm/Support/Path.h
+++ llvm/include/llvm/Support/Path.h
@@ -412,6 +412,16 @@
 /// @param result Holds the resulting path name.
 void system_temp_directory(bool erasedOnReboot, SmallVectorImpl );
 
+/// Override the temporary directory path returned by
+/// system_temp_directory(true, result).
+///
+/// @param tempDirUtf8 UTF-8-encoded path to the desired temporary directory.
+/// The pointer is owned by the caller and must be always valid. Pass nullptr to
+/// this function in order to reset the temporary directory to the default value
+/// from the environment. Such a resetting should be done before deleting a
+/// tempDirUtf8 pointer previously passed to this function.
+void set_system_temp_directory_erased_on_reboot(const char *tempDirUtf8);
+
 /// Get the user's home directory.
 ///
 /// @param result Holds the resulting path name.
Index: clang/tools/libclang/libclang.map
===
--- clang/tools/libclang/libclang.map
+++ clang/tools/libclang/libclang.map
@@ -407,6 +407,7 @@
 
 LLVM_16 {
   global:
+clang_setTemporaryDirectory;
 clang_getUnqualifiedType;
 

[PATCH] D139745: [Clang]Use poison instead of undef where its used as placeholder[NFC]

2022-12-11 Thread Nuno Lopes 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 rG2482dbff461e: [Clang] Use poison instead of undef where its 
used as placeholder [NFC] (authored by ManuelJBrito, committed by nlopes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139745

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/builtinshufflevector2.c
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp
  clang/test/CodeGenCXX/vla-consruct.cpp
  clang/test/CodeGenCoroutines/coro-eh-cleanup-exp-namespace.cpp
  clang/test/CodeGenCoroutines/coro-eh-cleanup.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/threadprivate_codegen.cpp

Index: clang/test/OpenMP/threadprivate_codegen.cpp
===
--- clang/test/OpenMP/threadprivate_codegen.cpp
+++ clang/test/OpenMP/threadprivate_codegen.cpp
@@ -1123,7 +1123,7 @@
 // CHECK1:   eh.resume:
 // CHECK1-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK1-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK1-NEXT:[[LPAD_VAL28:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK1-NEXT:resume { ptr, i32 } [[LPAD_VAL28]]
 //
@@ -1331,7 +1331,7 @@
 // CHECK1:   eh.resume:
 // CHECK1-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK1-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK1-NEXT:[[LPAD_VAL22:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK1-NEXT:resume { ptr, i32 } [[LPAD_VAL22]]
 //
@@ -1446,7 +1446,7 @@
 // CHECK1:   eh.resume:
 // CHECK1-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK1-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK1-NEXT:[[LPAD_VAL15:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK1-NEXT:resume { ptr, i32 } [[LPAD_VAL15]]
 //
@@ -1854,7 +1854,7 @@
 // CHECK2:   eh.resume:
 // CHECK2-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK2-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK2-NEXT:[[LPAD_VAL22:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK2-NEXT:resume { ptr, i32 } [[LPAD_VAL22]]
 //
@@ -1975,7 +1975,7 @@
 // CHECK2:   eh.resume:
 // CHECK2-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK2-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK2-NEXT:[[LPAD_VAL28:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK2-NEXT:resume { ptr, i32 } [[LPAD_VAL28]]
 //
@@ -2100,7 +2100,7 @@
 // CHECK2:   eh.resume:
 // CHECK2-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK2-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK2-NEXT:[[LPAD_VAL15:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK2-NEXT:resume { ptr, i32 } [[LPAD_VAL15]]
 //
@@ -2529,7 +2529,7 @@
 // SIMD1:   eh.resume:
 // SIMD1-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // SIMD1-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// SIMD1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// SIMD1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // SIMD1-NEXT:[[LPAD_VAL22:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], 

[clang] 2482dbf - [Clang] Use poison instead of undef where its used as placeholder [NFC]

2022-12-11 Thread Nuno Lopes via cfe-commits

Author: Manuel Brito
Date: 2022-12-11T16:18:06Z
New Revision: 2482dbff461e981203f9c691b24d6017de46a441

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

LOG: [Clang] Use poison instead of undef where its used as placeholder [NFC]

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

Added: 


Modified: 
clang/lib/CodeGen/CGException.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/test/CodeGen/builtinshufflevector2.c
clang/test/CodeGenCXX/nrvo.cpp
clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp
clang/test/CodeGenCXX/vla-consruct.cpp
clang/test/CodeGenCoroutines/coro-eh-cleanup-exp-namespace.cpp
clang/test/CodeGenCoroutines/coro-eh-cleanup.cpp
clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
clang/test/OpenMP/single_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
clang/test/OpenMP/threadprivate_codegen.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGException.cpp 
b/clang/lib/CodeGen/CGException.cpp
index e5558baf89770..6fa7871588f78 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -1625,7 +1625,7 @@ llvm::BasicBlock *CodeGenFunction::getEHResumeBlock(bool 
isCleanup) {
   llvm::Value *Sel = getSelectorFromSlot();
 
   llvm::Type *LPadType = llvm::StructType::get(Exn->getType(), Sel->getType());
-  llvm::Value *LPadVal = llvm::UndefValue::get(LPadType);
+  llvm::Value *LPadVal = llvm::PoisonValue::get(LPadType);
   LPadVal = Builder.CreateInsertValue(LPadVal, Exn, 0, "lpad.val");
   LPadVal = Builder.CreateInsertValue(LPadVal, Sel, 1, "lpad.val");
 

diff  --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 27580705acd81..6e67d3da6f2b6 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1667,7 +1667,7 @@ Value 
*ScalarExprEmitter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {
 //   newv = insert newv, x, i
 auto *RTy = llvm::FixedVectorType::get(LTy->getElementType(),
MTy->getNumElements());
-Value* NewV = llvm::UndefValue::get(RTy);
+Value* NewV = llvm::PoisonValue::get(RTy);
 for (unsigned i = 0, e = MTy->getNumElements(); i != e; ++i) {
   Value *IIndx = llvm::ConstantInt::get(CGF.SizeTy, i);
   Value *Indx = Builder.CreateExtractElement(Mask, IIndx, "shuf_idx");

diff  --git a/clang/test/CodeGen/builtinshufflevector2.c 
b/clang/test/CodeGen/builtinshufflevector2.c
index 8b9e452d7ef3a..10e8fe19f9b77 100644
--- a/clang/test/CodeGen/builtinshufflevector2.c
+++ b/clang/test/CodeGen/builtinshufflevector2.c
@@ -12,7 +12,7 @@ void clang_shufflevector_v_v( float4* A, float4 x, uint4 mask 
) {
 // Here is where ToT Clang code generation makes a mistake.  
 // It uses [[I]] as the insertion index instead of 0.
 // Similarly on the remaining insertelement.
-// CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> undef, float 
[[E]], i{{[0-9]+}} 0
+// CHECK: [[V:%[a-zA-Z0-9._]+]] = insertelement <4 x float> poison, float 
[[E]], i{{[0-9]+}} 0
 
 // CHECK: [[I:%.*]] = extractelement <4 x i32> [[MASK]], i{{[0-9]+}} 1
 // CHECK: [[E:%.*]] = extractelement <4 x float> [[X]], i{{[0-9]+}} [[I]]

diff  --git a/clang/test/CodeGenCXX/nrvo.cpp b/clang/test/CodeGenCXX/nrvo.cpp
index c092ff21ef52b..6ac5afcc2ac19 100644
--- a/clang/test/CodeGenCXX/nrvo.cpp
+++ b/clang/test/CodeGenCXX/nrvo.cpp
@@ -268,7 +268,7 @@ X test1(bool B) {
 // CHECK-EH-03:   eh.resume:
 // CHECK-EH-03-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 4
 // CHECK-EH-03-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 
4
-// CHECK-EH-03-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr 
[[EXN]], 0
+// CHECK-EH-03-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, 
ptr [[EXN]], 0
 // CHECK-EH-03-NEXT:[[LPAD_VAL8:%.*]] = insertvalue { ptr, i32 } 
[[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK-EH-03-NEXT:resume { ptr, i32 } [[LPAD_VAL8]]
 // CHECK-EH-03:   terminate.lpad:
@@ -336,7 +336,7 @@ X test1(bool B) {
 // CHECK-EH-11:   eh.resume:
 // CHECK-EH-11-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 4
 // CHECK-EH-11-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 
4
-// CHECK-EH-11-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr 
[[EXN]], 0
+// CHECK-EH-11-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, 
ptr [[EXN]], 0
 // CHECK-EH-11-NEXT:[[LPAD_VAL5:%.*]] = insertvalue { ptr, i32 } 
[[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK-EH-11-NEXT:resume { ptr, 

[PATCH] D139745: [Clang]Use poison instead of undef where its used as placeholder[NFC]

2022-12-11 Thread Nuno Lopes via Phabricator via cfe-commits
nlopes accepted this revision.
nlopes added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139745

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


[PATCH] D139745: [Clang]Use poison instead of undef where its used as placeholder[NFC]

2022-12-11 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito updated this revision to Diff 481908.
ManuelJBrito retitled this revision from "Use poison instead of undef where its 
used as placeholder[NFC]" to "[Clang]Use poison instead of undef where its used 
as placeholder[NFC]".
ManuelJBrito added a comment.

Splitting the diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139745

Files:
  clang/lib/CodeGen/CGException.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/builtinshufflevector2.c
  clang/test/CodeGenCXX/nrvo.cpp
  clang/test/CodeGenCXX/pr40771-ctad-with-lambda-copy-capture.cpp
  clang/test/CodeGenCXX/vla-consruct.cpp
  clang/test/CodeGenCoroutines/coro-eh-cleanup-exp-namespace.cpp
  clang/test/CodeGenCoroutines/coro-eh-cleanup.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/single_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/threadprivate_codegen.cpp

Index: clang/test/OpenMP/threadprivate_codegen.cpp
===
--- clang/test/OpenMP/threadprivate_codegen.cpp
+++ clang/test/OpenMP/threadprivate_codegen.cpp
@@ -1123,7 +1123,7 @@
 // CHECK1:   eh.resume:
 // CHECK1-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK1-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK1-NEXT:[[LPAD_VAL28:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK1-NEXT:resume { ptr, i32 } [[LPAD_VAL28]]
 //
@@ -1331,7 +1331,7 @@
 // CHECK1:   eh.resume:
 // CHECK1-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK1-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK1-NEXT:[[LPAD_VAL22:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK1-NEXT:resume { ptr, i32 } [[LPAD_VAL22]]
 //
@@ -1446,7 +1446,7 @@
 // CHECK1:   eh.resume:
 // CHECK1-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK1-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK1-NEXT:[[LPAD_VAL15:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK1-NEXT:resume { ptr, i32 } [[LPAD_VAL15]]
 //
@@ -1854,7 +1854,7 @@
 // CHECK2:   eh.resume:
 // CHECK2-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK2-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK2-NEXT:[[LPAD_VAL22:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK2-NEXT:resume { ptr, i32 } [[LPAD_VAL22]]
 //
@@ -1975,7 +1975,7 @@
 // CHECK2:   eh.resume:
 // CHECK2-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK2-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK2-NEXT:[[LPAD_VAL28:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK2-NEXT:resume { ptr, i32 } [[LPAD_VAL28]]
 //
@@ -2100,7 +2100,7 @@
 // CHECK2:   eh.resume:
 // CHECK2-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // CHECK2-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// CHECK2-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // CHECK2-NEXT:[[LPAD_VAL15:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], i32 [[SEL]], 1
 // CHECK2-NEXT:resume { ptr, i32 } [[LPAD_VAL15]]
 //
@@ -2529,7 +2529,7 @@
 // SIMD1:   eh.resume:
 // SIMD1-NEXT:[[EXN:%.*]] = load ptr, ptr [[EXN_SLOT]], align 8
 // SIMD1-NEXT:[[SEL:%.*]] = load i32, ptr [[EHSELECTOR_SLOT]], align 4
-// SIMD1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } undef, ptr [[EXN]], 0
+// SIMD1-NEXT:[[LPAD_VAL:%.*]] = insertvalue { ptr, i32 } poison, ptr [[EXN]], 0
 // SIMD1-NEXT:[[LPAD_VAL22:%.*]] = insertvalue { ptr, i32 } [[LPAD_VAL]], 

[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

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

I think we could settle on something like this:

 APSIntType getAPSIntType(QualType T) const {
  +if (T->isFixedPointType())
  +  return APSIntType(Ctx.getIntWidth(T), T->isUnsignedFixedPointType());
  +
   // For the purposes of the analysis and constraints, we treat atomics
   // as their underlying types.
   if (const AtomicType *AT = T->getAs()) {
 T = AT->getValueType();
   }
   
   assert(T->isIntegralOrEnumerationType() || Loc::isLocType(T));
   return APSIntType(Ctx.getIntWidth(T),
  -  !T->isSignedIntegerOrEnumerationType());
  +  T->isUnsignedIntegerOrEnumerationType());
 }

Your original test should be enough.
In a follow-up patch, you could extend the cases and maybe uncover more crashes.
I wouldn't want to block you. It's good enough.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-12-11 Thread tangcp via Phabricator via cfe-commits
UnionType added inline comments.



Comment at: clang/test/Interpreter/execute-stmts.cpp:34
+
+for (; i > 4; --i) printf("i = %d\n", i);
+// CHECK-NEXT: i = 5

It seems that top-level statements wrapped in braces cannot be handled, maybe I 
made a mistake.
```
for (; i > 4; --i) { printf("i = %d\n", i); }

{ i++; }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127284

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


[PATCH] D139786: [clang-format] AllowShortRequiresExpressionOnASingleLine and AllowShortCompoundRequirementOnASingleLine

2022-12-11 Thread Zhikai Zeng via Phabricator via cfe-commits
Backl1ght created this revision.
Backl1ght added a reviewer: OwenCax.
Backl1ght added a project: clang-format.
Herald added a project: All.
Backl1ght requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

clang-format did not take requires into consideration, support 
AllowShortRequiresExpressionOnASingleLine and 
AllowShortCompoundRequirementOnASingleLine, add 
BrackWrapping.AfterRequiresExpression as TODO.

https://github.com/llvm/llvm-project/issues/59412


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139786

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -2899,6 +2899,35 @@
Style);
 }
 
+TEST_F(FormatTest, ShortRequiresExpression) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortRequiresExpressionOnASingleLine);
+  verifyFormat("template \n"
+   "concept c = requires(T a, T b) { a + b; };");
+  Style.AllowShortRequiresExpressionOnASingleLine = false;
+  verifyFormat("template \n"
+   "concept c = requires(T a, T b) {\n"
+   "  a + b;\n"
+   "};");
+  // TODO: support BraceWrapping.AfterRequiresExpression.
+}
+
+TEST_F(FormatTest, ShortCompoundRequirements) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_TRUE(Style.AllowShortCompoundRequirementOnASingleLine);
+  verifyFormat("template \n"
+   "concept c = requires(T x) {\n"
+   "  { x + 1 } -> std::same_as;\n"
+   "};");
+  Style.AllowShortCompoundRequirementOnASingleLine = false;
+  verifyFormat("template \n"
+   "concept c = requires(T x) {\n"
+   "  {\n"
+   "x + 1\n"
+   "  } -> std::same_as;\n"
+   "};");
+}
+
 TEST_F(FormatTest, ShortCaseLabels) {
   FormatStyle Style = getLLVMStyle();
   Style.AllowShortCaseLabelsOnASingleLine = true;
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -148,6 +148,8 @@
   CHECK_PARSE_BOOL(AllowAllParametersOfDeclarationOnNextLine);
   CHECK_PARSE_BOOL(AllowShortCaseLabelsOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortEnumsOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortRequiresExpressionOnASingleLine);
+  CHECK_PARSE_BOOL(AllowShortCompoundRequirementOnASingleLine);
   CHECK_PARSE_BOOL(AllowShortLoopsOnASingleLine);
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,6 +1085,12 @@
   FormatTok->setBlockKind(BK_Block);
   const FormatToken *OpeningBrace = FormatTok;
   nextToken();
+
+  if (NextLBracesType == TT_CompoundRequirementLBrace &&
+  !Style.AllowShortRequiresExpressionOnASingleLine) {
+addUnwrappedLine();
+  }
+
   {
 bool SkipIndent = (Style.isJavaScript() &&
(isGoogScope(*Line) || isIIFE(*Line, Keywords)));
@@ -1096,6 +1102,7 @@
 flushComments(isOnNewLine(*FormatTok));
 Line->Level -= SkipIndent ? 0 : 1;
   }
+
   nextToken();
 }
 
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -502,6 +502,10 @@
   // Try to merge records.
   if (TheLine->Last->is(TT_EnumLBrace)) {
 ShouldMerge = Style.AllowShortEnumsOnASingleLine;
+  } else if (TheLine->Last->is(TT_RequiresExpressionLBrace)) {
+ShouldMerge = Style.AllowShortRequiresExpressionOnASingleLine;
+  } else if (TheLine->Last->is(TT_CompoundRequirementLBrace)) {
+ShouldMerge = Style.AllowShortCompoundRequirementOnASingleLine;
   } else if (TheLine->Last->isOneOf(TT_ClassLBrace, TT_StructLBrace)) {
 // NOTE: We use AfterClass (whereas AfterStruct exists) for both classes
 // and structs, but it seems that wrapping is still handled correctly
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -808,6 +808,10 @@
Style.AllowShortCaseLabelsOnASingleLine);
 IO.mapOptional("AllowShortEnumsOnASingleLine",
Style.AllowShortEnumsOnASingleLine);
+

[PATCH] D139759: [analyzer] Fix assertion in getAPSIntType

2022-12-11 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers marked an inline comment as done.
vabridgers added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/BasicValueFactory.h:157-158
+   Loc::isLocType(T));
 return APSIntType(Ctx.getIntWidth(T),
   !T->isSignedIntegerOrEnumerationType());
   }

steakhal wrote:
> vabridgers wrote:
> > steakhal wrote:
> > > I don't think you are supposed to call 
> > > `isSignedIntegerOrEnumerationType()` if you have a //fixed-point// type.
> > > ```lang=C++
> > > inline bool Type::isSignedFixedPointType() const {
> > >   if (const auto *BT = dyn_cast(CanonicalType)) {
> > > return ((BT->getKind() >= BuiltinType::ShortAccum &&
> > >  BT->getKind() <= BuiltinType::LongAccum) ||
> > > (BT->getKind() >= BuiltinType::ShortFract &&
> > >  BT->getKind() <= BuiltinType::LongFract) ||
> > > (BT->getKind() >= BuiltinType::SatShortAccum &&
> > >  BT->getKind() <= BuiltinType::SatLongAccum) ||
> > > (BT->getKind() >= BuiltinType::SatShortFract &&
> > >  BT->getKind() <= BuiltinType::SatLongFract));
> > >   }
> > >   return false;
> > > }
> > > ```
> > > By looking at the implementation of this, I don't think you could 
> > > substitute that with `isSignedIntegerOrEnumerationType()`.
> > > Am I wrong about this?
> > > 
> > > Please demonstrate this by tests.
> > I tried using isSignedIntegerOrEnumerationType() instead of 
> > (T->isIntegralOrEnumerationType() || T->isFixedPointType() ... ), but got 
> > the same assert :/  
> > 
> > I corrected the formatting and expanded the test cases. 
> Is hould have clarified, sorry.
> 
> My point is that for constructing the APSIntType, we calculate the bitwidth 
> and the signedness.
> 
> My problem is that the calculation is wrong for the signedness in case we 
> have a signed fixedpointtype.
> It is wrong because we reach `isSignedIntegerOrEnumerationType()` with a 
> fixedpoint type. For that even though its signed, it will return false!
> 
> And in the end we will have an APSIntType with the wrong signednss.
> 
> So my point is that we should probably handle fixedpoint types separately to 
> have a distict return statement for it.
> But im jumping to the solution, what I originally wanted to highlight was 
> this.
> That was why I requested changes.
> And this is what I wanted to see some how intests, but I wont insist if its 
> too difficult to craft.
In retrospect, your original comment was clear. I did not fully comprehend the 
comment. 

I'll explore a few options. I checked the unittests for a "reference", and it 
seems our static analysis unittest coverage is sparse. Not sure I need to go 
that far, but I'll explore the possibility of crafting a unittest for this case 
that demonstrates the problem and solution. 

Thanks again - best!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139759

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


[PATCH] D136554: Implement CWG2631

2022-12-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D136554#3986779 , @cor3ntin wrote:

> In D136554#3986713 , @aeubanks 
> wrote:
>
>> yes, it was chrome
>> I went ahead and tried the latest patch, it successfully compiles the file 
>> that crashed before. I built all of chrome, and now I'm getting one last 
>> linker error, I'll try to get some more info about that
>
> Thanks for confirming :)
> If you have the message of that linker error, i might be able to infer a 
> repro from that. Otherwise, I'm going to build chromium

I got 
`x86_64-linux-gnu/libnspr4.so: undefined reference to gettid`

But otherwise it works fine.
linking with `mold` fixes the issue.
I can't find an instance of `gettid()` that would be called from a default 
parameter or mem initializer list so I would be surprise if it's related. Was 
that the issue you encountered?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[PATCH] D112932: [WIP] Use llvm.is_fpclass to implement FP classification functions

2022-12-11 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 481901.
sepavloff added a comment.
Herald added a subscriber: pengfei.

Prepare the patch for review

In this patch the callback `TargetCodeGenInfo::testFPKind` is
preserved, to make this change safer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112932

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/X86/strictfp_builtins.c
  clang/test/CodeGen/aarch64-strictfp-builtins.c
  clang/test/CodeGen/builtin_float.c
  clang/test/CodeGen/builtin_float_strictfp.c
  clang/test/CodeGen/builtins.c
  clang/test/CodeGen/strictfp_builtins.c

Index: clang/test/CodeGen/strictfp_builtins.c
===
--- clang/test/CodeGen/strictfp_builtins.c
+++ clang/test/CodeGen/strictfp_builtins.c
@@ -17,7 +17,7 @@
 // CHECK-NEXT:store i32 [[X:%.*]], ptr [[X_ADDR]], align 4
 // CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[STR_ADDR]], align 8
 // CHECK-NEXT:[[TMP1:%.*]] = load i32, ptr [[X_ADDR]], align 4
-// CHECK-NEXT:[[CALL:%.*]] = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef [[TMP0]], i32 noundef [[TMP1]]) [[ATTR4:#.*]]
+// CHECK-NEXT:[[CALL:%.*]] = call i32 (ptr, ...) @printf(ptr noundef @.str, ptr noundef [[TMP0]], i32 noundef [[TMP1]]) #[[ATTR4:[0-9]+]]
 // CHECK-NEXT:ret void
 //
 void p(char *str, int x) {
@@ -31,21 +31,21 @@
 // CHECK-NEXT:[[D_ADDR:%.*]] = alloca double, align 8
 // CHECK-NEXT:store double [[D:%.*]], ptr [[D_ADDR]], align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load double, ptr [[D_ADDR]], align 8
-// CHECK-NEXT:[[ISZERO:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double 0.00e+00, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[ISZERO:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double 0.00e+00, metadata !"oeq", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:br i1 [[ISZERO]], label [[FPCLASSIFY_END:%.*]], label [[FPCLASSIFY_NOT_ZERO:%.*]]
 // CHECK:   fpclassify_end:
 // CHECK-NEXT:[[FPCLASSIFY_RESULT:%.*]] = phi i32 [ 4, [[ENTRY:%.*]] ], [ 0, [[FPCLASSIFY_NOT_ZERO]] ], [ 1, [[FPCLASSIFY_NOT_NAN:%.*]] ], [ [[TMP2:%.*]], [[FPCLASSIFY_NOT_INF:%.*]] ]
-// CHECK-NEXT:call void @p(ptr noundef @.str.1, i32 noundef [[FPCLASSIFY_RESULT]]) [[ATTR4]]
+// CHECK-NEXT:call void @p(ptr noundef @.str.1, i32 noundef [[FPCLASSIFY_RESULT]]) #[[ATTR4]]
 // CHECK-NEXT:ret void
 // CHECK:   fpclassify_not_zero:
-// CHECK-NEXT:[[CMP:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double [[TMP0]], metadata !"uno", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[CMP:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP0]], double [[TMP0]], metadata !"uno", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:br i1 [[CMP]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_NAN]]
 // CHECK:   fpclassify_not_nan:
-// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) [[ATTR5:#.*]]
-// CHECK-NEXT:[[ISINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[TMP1:%.*]] = call double @llvm.fabs.f64(double [[TMP0]]) #[[ATTR5:[0-9]+]]
+// CHECK-NEXT:[[ISINF:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x7FF0, metadata !"oeq", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:br i1 [[ISINF]], label [[FPCLASSIFY_END]], label [[FPCLASSIFY_NOT_INF]]
 // CHECK:   fpclassify_not_inf:
-// CHECK-NEXT:[[ISNORMAL:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x10, metadata !"uge", metadata !"fpexcept.strict") [[ATTR4]]
+// CHECK-NEXT:[[ISNORMAL:%.*]] = call i1 @llvm.experimental.constrained.fcmp.f64(double [[TMP1]], double 0x10, metadata !"uge", metadata !"fpexcept.strict") #[[ATTR4]]
 // CHECK-NEXT:[[TMP2]] = select i1 [[ISNORMAL]], i32 2, i32 3
 // CHECK-NEXT:br label [[FPCLASSIFY_END]]
 //
@@ -57,14 +57,12 @@
 
 // CHECK-LABEL: @test_fp16_isinf(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[LD_ADDR:%.*]] = alloca half, align 2
-// CHECK-NEXT:store half [[H:%.*]], ptr [[LD_ADDR]], align 2
-// CHECK-NEXT:[[TMP0:%.*]] = load half, ptr [[LD_ADDR]], align 2
-// CHECK-NEXT:[[BITCAST:%.*]] = bitcast half [[TMP0]] to i16
-// CHECK-NEXT:[[SHL1:%.*]] = shl i16 [[BITCAST]], 1
-// CHECK-NEXT:[[CMP:%.*]] = icmp eq i16 [[SHL1]], -2048
-// CHECK-NEXT:[[RES:%.*]] = zext i1 [[CMP]] to i32
-// CHECK-NEXT:call void @p(ptr noundef @.str.[[#STRID:2]], i32 noundef [[RES]]) [[ATTR4]]
+// CHECK-NEXT:[[H_ADDR:%.*]] = alloca half, align 2
+// CHECK-NEXT:store half [[H:%.*]], ptr 

[PATCH] D136554: Implement CWG2631

2022-12-11 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D136554#3986713 , @aeubanks wrote:

> yes, it was chrome
> I went ahead and tried the latest patch, it successfully compiles the file 
> that crashed before. I built all of chrome, and now I'm getting one last 
> linker error, I'll try to get some more info about that

Thanks for confirming :)
If you have the message of that linker error, i might be able to infer a repro 
from that. Otherwise, I'm going to build chromium


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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