[PATCH] D118021: [Driver] Use libatomic for 32-bit SPARC atomics support

2022-02-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/test/Driver/solaris-ld.c:20
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-SPARC32-SAME: "-zignore"
+// CHECK-LD-SPARC32-SAME: "-latomic"

If they are consecutive.



Comment at: clang/test/Driver/solaris-ld.c:46
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
+// CHECK-LD-SPARC64-NOT:  "-zignore"
+// CHECK-LD-SPARC64-NOT:  "-latomic"

Such NOT patterns are usually inadequate and may go stale pretty easily, since 
technically the patterns can occur in many places.

One idea is to use --implicit-check-not; another is to enumerate all options 
and use the `{{^}}` style I picked in linux-cross.cpp, but perhaps your style 
is good enough if we can remember these library after after -L and before 
-lgcc_s


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118021

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


[PATCH] D119326: [clang] [MinGW] Default to DWARF 4

2022-02-10 Thread Mateusz Mikuła via Phabricator via cfe-commits
mati865 accepted this revision.
mati865 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/D119326/new/

https://reviews.llvm.org/D119326

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


[PATCH] D119364: Refactor nested if else with ternary operator in CGExprScalar.cpp

2022-02-10 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Sure, LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119364

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


[PATCH] D119326: [clang] [MinGW] Default to DWARF 4

2022-02-10 Thread Martin Storsjö via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6cf64b2d2858: [clang] [MinGW] Default to DWARF 4 (authored 
by mstorsjo).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119326

Files:
  clang/lib/Driver/ToolChains/MinGW.h
  clang/test/CodeGen/dwarf-version.c


Index: clang/test/CodeGen/dwarf-version.c
===
--- clang/test/CodeGen/dwarf-version.c
+++ clang/test/CodeGen/dwarf-version.c
@@ -32,6 +32,11 @@
 // Explicitly request both.
 // RUN: %clang -target i686-pc-windows-msvc -gdwarf -gcodeview -S -emit-llvm 
-o - %s \
 // RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW
+
+// Check what version of dwarf is used for MinGW targets.
+// RUN: %clang -target i686-pc-windows-gnu -g -S -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=VER4
+
 // RUN: %clang -target powerpc-ibm-aix-xcoff -g -S -emit-llvm -o - %s | \
 // RUN:   FileCheck %s --check-prefix=VER3
 // RUN: %clang -target powerpc-ibm-aix-xcoff -gdwarf-2 -S -emit-llvm -o - %s | 
\
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -90,6 +90,8 @@
 
   void printVerboseInfo(raw_ostream &OS) const override;
 
+  unsigned GetDefaultDwarfVersion() const override { return 4; }
+
 protected:
   Tool *getTool(Action::ActionClass AC) const override;
   Tool *buildLinker() const override;


Index: clang/test/CodeGen/dwarf-version.c
===
--- clang/test/CodeGen/dwarf-version.c
+++ clang/test/CodeGen/dwarf-version.c
@@ -32,6 +32,11 @@
 // Explicitly request both.
 // RUN: %clang -target i686-pc-windows-msvc -gdwarf -gcodeview -S -emit-llvm -o - %s \
 // RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW
+
+// Check what version of dwarf is used for MinGW targets.
+// RUN: %clang -target i686-pc-windows-gnu -g -S -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=VER4
+
 // RUN: %clang -target powerpc-ibm-aix-xcoff -g -S -emit-llvm -o - %s | \
 // RUN:   FileCheck %s --check-prefix=VER3
 // RUN: %clang -target powerpc-ibm-aix-xcoff -gdwarf-2 -S -emit-llvm -o - %s | \
Index: clang/lib/Driver/ToolChains/MinGW.h
===
--- clang/lib/Driver/ToolChains/MinGW.h
+++ clang/lib/Driver/ToolChains/MinGW.h
@@ -90,6 +90,8 @@
 
   void printVerboseInfo(raw_ostream &OS) const override;
 
+  unsigned GetDefaultDwarfVersion() const override { return 4; }
+
 protected:
   Tool *getTool(Action::ActionClass AC) const override;
   Tool *buildLinker() const override;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6cf64b2 - [clang] [MinGW] Default to DWARF 4

2022-02-10 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2022-02-10T10:59:05+02:00
New Revision: 6cf64b2d2858dc93c3ec93438bdaca2807847e9b

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

LOG: [clang] [MinGW] Default to DWARF 4

Neither LLDB nor GDB seem to work with DWARF 5 debug information on
Windows right now.

This applies the same change as in
9c6272861032f511a23784ce0c5cc8f6ac2f625b (Default to DWARFv4 on Windows)
to the MinGW driver too.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/MinGW.h
clang/test/CodeGen/dwarf-version.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/MinGW.h 
b/clang/lib/Driver/ToolChains/MinGW.h
index c3de19b977246..c9553b4f46520 100644
--- a/clang/lib/Driver/ToolChains/MinGW.h
+++ b/clang/lib/Driver/ToolChains/MinGW.h
@@ -90,6 +90,8 @@ class LLVM_LIBRARY_VISIBILITY MinGW : public ToolChain {
 
   void printVerboseInfo(raw_ostream &OS) const override;
 
+  unsigned GetDefaultDwarfVersion() const override { return 4; }
+
 protected:
   Tool *getTool(Action::ActionClass AC) const override;
   Tool *buildLinker() const override;

diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index 47025e241d13c..0a6fa4768026d 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -32,6 +32,11 @@
 // Explicitly request both.
 // RUN: %clang -target i686-pc-windows-msvc -gdwarf -gcodeview -S -emit-llvm 
-o - %s \
 // RUN: | FileCheck %s --check-prefixes=VER4,CODEVIEW
+
+// Check what version of dwarf is used for MinGW targets.
+// RUN: %clang -target i686-pc-windows-gnu -g -S -emit-llvm -o - %s | \
+// RUN:   FileCheck %s --check-prefixes=VER4
+
 // RUN: %clang -target powerpc-ibm-aix-xcoff -g -S -emit-llvm -o - %s | \
 // RUN:   FileCheck %s --check-prefix=VER3
 // RUN: %clang -target powerpc-ibm-aix-xcoff -gdwarf-2 -S -emit-llvm -o - %s | 
\



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


[clang] c70b935 - [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-10 Thread via cfe-commits

Author: tyb0807
Date: 2022-02-10T09:08:35Z
New Revision: c70b9350890152fdcc5e65201c8f8146e977658a

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

LOG: [AArch64] ACLE feature macro for Armv8.8-A MOPS

This introduces the new __ARM_FEATURE_MOPS ACLE feature test macro,
which signals the availability of the new Armv8.8-A/Armv9.3-A
instructions for standardising memcpy, memset and memmove operations.

This patch supersedes the one from https://reviews.llvm.org/D116160.

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

Added: 


Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/test/CodeGen/aarch64-mops.c
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index 34bdb58dffc1c..b04508570ad75 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -226,6 +226,8 @@ void AArch64TargetInfo::getTargetDefinesARMV87A(const 
LangOptions &Opts,
 
 void AArch64TargetInfo::getTargetDefinesARMV88A(const LangOptions &Opts,
 MacroBuilder &Builder) const {
+  // FIXME: this does not handle the case where MOPS is disabled using +nomops
+  Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
   // Also include the Armv8.7 defines
   getTargetDefinesARMV87A(Opts, Builder);
 }
@@ -435,6 +437,9 @@ void AArch64TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   if (HasRandGen)
 Builder.defineMacro("__ARM_FEATURE_RNG", "1");
 
+  if (HasMOPS)
+Builder.defineMacro("__ARM_FEATURE_MOPS", "1");
+
   switch (ArchKind) {
   default:
 break;
@@ -662,6 +667,8 @@ bool 
AArch64TargetInfo::handleTargetFeatures(std::vector &Features,
   HasFlagM = true;
 if (Feature == "+hbc")
   HasHBC = true;
+if (Feature == "+mops")
+  HasMOPS = true;
   }
 
   setDataLayout();

diff  --git a/clang/test/CodeGen/aarch64-mops.c 
b/clang/test/CodeGen/aarch64-mops.c
index 0b6a2c26c1e82..3aada04bdc663 100644
--- a/clang/test/CodeGen/aarch64-mops.c
+++ b/clang/test/CodeGen/aarch64-mops.c
@@ -1,153 +1,77 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops 
-target-feature +mte -w -S -emit-llvm -o - %s  | FileCheck 
--check-prefix=CHECK-MOPS   %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops  
-w -S -emit-llvm -o - %s  | FileCheck 
--check-prefix=CHECK-NOMOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi   
-target-feature +mte -w -S -emit-llvm -o - %s  | FileCheck 
--check-prefix=CHECK-NOMOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi
-w -S -emit-llvm -o - %s  | FileCheck 
--check-prefix=CHECK-NOMOPS %s
 
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops 
-target-feature +mte -S -emit-llvm -o - %s  | FileCheck %s
-
-#define __ARM_FEATURE_MOPS 1
 #include 
 #include 
 
-// CHECK-LABEL: @bzero_0(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca i8*, align 8
-// CHECK-NEXT:store i8* [[DST:%.*]], i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* 
[[TMP0]], i8 0, i64 0)
-// CHECK-NEXT:ret i8* [[TMP1]]
-//
+// CHECK-LABEL:   @bzero_0(
+// CHECK-MOPS:@llvm.aarch64.mops.memset.tag
+// CHECK-NOMOPS-NOT:  @llvm.aarch64.mops.memset.tag
 void *bzero_0(void *dst) {
   return __arm_mops_memset_tag(dst, 0, 0);
 }
 
-// CHECK-LABEL: @bzero_1(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca i8*, align 8
-// CHECK-NEXT:store i8* [[DST:%.*]], i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* 
[[TMP0]], i8 0, i64 1)
-// CHECK-NEXT:ret i8* [[TMP1]]
-//
+// CHECK-LABEL:   @bzero_1(
+// CHECK-MOPS:@llvm.aarch64.mops.memset.tag
+// CHECK-NOMOPS-NOT:  @llvm.aarch64.mops.memset.tag
 void *bzero_1(void *dst) {
   return __arm_mops_memset_tag(dst, 0, 1);
 }
 
-// CHECK-LABEL: @bzero_10(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca i8*, align 8
-// CHECK-NEXT:store i8* [[DST:%.*]], i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* 
[[TMP0]], i8 0, i64 10)
-// CHECK-NEXT:ret i8* [[TMP1]]
-//
+// CHECK-LABEL:   @bzero_10(
+// CHECK-MOPS:@llvm.aarch64.mops.memset.tag
+// CHECK-NOM

[PATCH] D118199: [AArch64] ACLE feature macro for Armv8.8-A MOPS

2022-02-10 Thread Son Tuan Vu 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 rGc70b93508901: [AArch64] ACLE feature macro for Armv8.8-A 
MOPS (authored by tyb0807).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118199

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/aarch64-mops.c
  clang/test/Preprocessor/aarch64-target-features.c

Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -510,9 +510,21 @@
 // CHECK-NO-SVE-VECTOR-BITS-NOT: __ARM_FEATURE_SVE_BITS
 // CHECK-NO-SVE-VECTOR-BITS-NOT: __ARM_FEATURE_SVE_VECTOR_OPERATORS
 
-// == Check Largse System Extensions (LSE)
+// == Check Large System Extensions (LSE)
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8-a+lse -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target aarch64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // RUN: %clang -target arm64-none-linux-gnu -march=armv8.1-a -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-LSE %s
 // CHECK-LSE: __ARM_FEATURE_ATOMICS 1
+
+// == Check Armv8.8-A/Armv9.3-A memcpy and memset acceleration instructions (MOPS)
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a  -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.7-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS   %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a  -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS   %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv8.8-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS   %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a  -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.2-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS   %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a  -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS   %s
+// RUN: %clang -target aarch64-arm-none-eabi -march=armv9.3-a+mops -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-MOPS   %s
+// CHECK-MOPS: __ARM_FEATURE_MOPS 1
+// CHECK-NOMOPS-NOT: __ARM_FEATURE_MOPS 1
Index: clang/test/CodeGen/aarch64-mops.c
===
--- clang/test/CodeGen/aarch64-mops.c
+++ clang/test/CodeGen/aarch64-mops.c
@@ -1,153 +1,77 @@
-// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-MOPS   %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops  -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi   -target-feature +mte -w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
+// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi-w -S -emit-llvm -o - %s  | FileCheck --check-prefix=CHECK-NOMOPS %s
 
-// RUN: %clang_cc1 -triple aarch64-arm-unknown-eabi -target-feature +mops -target-feature +mte -S -emit-llvm -o - %s  | FileCheck %s
-
-#define __ARM_FEATURE_MOPS 1
 #include 
 #include 
 
-// CHECK-LABEL: @bzero_0(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca i8*, align 8
-// CHECK-NEXT:store i8* [[DST:%.*]], i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* [[TMP0]], i8 0, i64 0)
-// CHECK-NEXT:ret i8* [[TMP1]]
-//
+// CHECK-LABEL:   @bzero_0(
+// CHECK-MOPS:@llvm.aarch64.mops.memset.tag
+// CHECK-NOMOPS-NOT:  @llvm.aarch64.mops.memset.tag
 void *bzero_0(void *dst) {
   return __arm_mops_memset_tag(dst, 0, 0);
 }
 
-// CHECK-LABEL: @bzero_1(
-// CHECK-NEXT:  entry:
-// CHECK-NEXT:[[DST_ADDR:%.*]] = alloca i8*, align 8
-// CHECK-NEXT:store i8* [[DST:%.*]], i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP0:%.*]] = load i8*, i8** [[DST_ADDR]], align 8
-// CHECK-NEXT:[[TMP1:%.*]] = call i8* @llvm.aarch64.mops.memset.tag(i8* [[TMP0]], i8 0, i64 1)
-// CHECK-NEXT:ret i8* [[TMP1]]
-//
+// CHECK-LABEL:   @bzero_1(
+// CHECK-MOPS:@llvm.aarch64.mops.memset.tag
+// CHEC

[clang] 8d37043 - [OpenCL] Refactor cl_ext_float_atomics declarations; NFC

2022-02-10 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2022-02-10T09:43:32Z
New Revision: 8d37043520f57e63e032c9d0ba4cba8701a3cd35

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

LOG: [OpenCL] Refactor cl_ext_float_atomics declarations; NFC

Reduce the amount of repetition in the declarations by leveraging more
TableGen constructs.  This is in preparation for adding the OpenCL 3.0
atomics feature optionality.

Added: 


Modified: 
clang/lib/Sema/OpenCLBuiltins.td

Removed: 




diff  --git a/clang/lib/Sema/OpenCLBuiltins.td 
b/clang/lib/Sema/OpenCLBuiltins.td
index 60a05f95fbec8..4d36df352d5ec 100644
--- a/clang/lib/Sema/OpenCLBuiltins.td
+++ b/clang/lib/Sema/OpenCLBuiltins.td
@@ -90,27 +90,27 @@ def FuncExtOpenCLCNamedAddressSpaceBuiltins : 
FunctionExtension<"__opencl_c_name
 def FuncExtOpenCLCPipes  : 
FunctionExtension<"__opencl_c_pipes">;
 def FuncExtOpenCLCWGCollectiveFunctions  : 
FunctionExtension<"__opencl_c_work_group_collective_functions">;
 def FuncExtOpenCLCReadWriteImages: 
FunctionExtension<"__opencl_c_read_write_images">;
-def FuncExtFloatAtomicsFp16GlobalLoadStore  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store">;
-def FuncExtFloatAtomicsFp16LocalLoadStore   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_load_store">;
-def FuncExtFloatAtomicsFp16GenericLoadStore : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store 
__opencl_c_ext_fp16_local_atomic_load_store">;
-def FuncExtFloatAtomicsFp16GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_global_atomic_add">;
-def FuncExtFloatAtomicsFp32GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_global_atomic_add">;
-def FuncExtFloatAtomicsFp64GlobalAdd : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_global_atomic_add">;
-def FuncExtFloatAtomicsFp16LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_local_atomic_add">;
-def FuncExtFloatAtomicsFp32LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_local_atomic_add">;
-def FuncExtFloatAtomicsFp64LocalAdd  : 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_local_atomic_add">;
-def FuncExtFloatAtomicsFp16GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_local_atomic_add 
__opencl_c_ext_fp16_global_atomic_add">;
-def FuncExtFloatAtomicsFp32GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_local_atomic_add 
__opencl_c_ext_fp32_global_atomic_add">;
-def FuncExtFloatAtomicsFp64GenericAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp64_local_atomic_add 
__opencl_c_ext_fp64_global_atomic_add">;
-def FuncExtFloatAtomicsFp16GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp32GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp64GlobalMinMax  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp16LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp32LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp64LocalMinMax   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_local_atomic_min_max">;
-def FuncExtFloatAtomicsFp16GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_min_max 
__opencl_c_ext_fp16_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp32GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp32_local_atomic_min_max 
__opencl_c_ext_fp32_global_atomic_min_max">;
-def FuncExtFloatAtomicsFp64GenericMinMax : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp64_local_atomic_min_max 
__opencl_c_ext_fp64_global_atomic_min_max">;
+def FuncExtFloatAtomicsFp16GlobalASLoadStore  : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store">;
+def FuncExtFloatAtomicsFp16LocalASLoadStore   : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_local_atomic_load_store">;
+def FuncExtFloatAtomicsFp16GenericASLoadStore : 
FunctionExtension<"cl_ext_float_atomics 
__opencl_c_ext_fp16_global_atomic_load_store 
__opencl_c_ext_fp16_local_atomic_load_store">;
+def FuncExtFloatAtomicsFp16GlobalASAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp16_global_atomic_add">;
+def FuncExtFloatAtomicsFp32GlobalASAdd: 
FunctionExtension<"cl_ext_float_atomics __opencl_c_ext_fp32_glob

[clang] 4efde1e - [clang-format] Move FormatToken::opensBlockOrBlockTypeList to source file. NFC.

2022-02-10 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-10T10:51:03+01:00
New Revision: 4efde1e554cce3f017b3d1ce700bd1860eed2ccd

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

LOG: [clang-format] Move FormatToken::opensBlockOrBlockTypeList to source file. 
NFC.

Added: 


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

Removed: 




diff  --git a/clang/lib/Format/FormatToken.cpp 
b/clang/lib/Format/FormatToken.cpp
index 40aa8f5cacb25..5577918d70927 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -74,6 +74,20 @@ bool FormatToken::isTypeOrIdentifier() const {
   return isSimpleTypeSpecifier() || Tok.isOneOf(tok::kw_auto, tok::identifier);
 }
 
+bool FormatToken::opensBlockOrBlockTypeList(const FormatStyle &Style) const {
+  // C# Does not indent object initialisers as continuations.
+  if (is(tok::l_brace) && getBlockKind() == BK_BracedInit && Style.isCSharp())
+return true;
+  if (is(TT_TemplateString) && opensScope())
+return true;
+  return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) ||
+ (is(tok::l_brace) &&
+  (getBlockKind() == BK_Block || is(TT_DictLiteral) ||
+   (!Style.Cpp11BracedListStyle && NestingLevel == 0))) ||
+ (is(tok::less) && (Style.Language == FormatStyle::LK_Proto ||
+Style.Language == FormatStyle::LK_TextProto));
+}
+
 TokenRole::~TokenRole() {}
 
 void TokenRole::precomputeFormattingInfos(const FormatToken *Token) {}

diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index f116a89ac6440..6586ababd1e7b 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -696,19 +696,7 @@ struct FormatToken {
 
   /// Returns \c true if this tokens starts a block-type list, i.e. a
   /// list that should be indented with a block indent.
-  bool opensBlockOrBlockTypeList(const FormatStyle &Style) const {
-// C# Does not indent object initialisers as continuations.
-if (is(tok::l_brace) && getBlockKind() == BK_BracedInit && 
Style.isCSharp())
-  return true;
-if (is(TT_TemplateString) && opensScope())
-  return true;
-return is(TT_ArrayInitializerLSquare) || is(TT_ProtoExtensionLSquare) ||
-   (is(tok::l_brace) &&
-(getBlockKind() == BK_Block || is(TT_DictLiteral) ||
- (!Style.Cpp11BracedListStyle && NestingLevel == 0))) ||
-   (is(tok::less) && (Style.Language == FormatStyle::LK_Proto ||
-  Style.Language == FormatStyle::LK_TextProto));
-  }
+  LLVM_NODISCARD bool opensBlockOrBlockTypeList(const FormatStyle &Style) 
const;
 
   /// Returns whether the token is the left square bracket of a C++
   /// structured binding declaration.



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


[PATCH] D113393: [c++2b] Implement P0849R8 auto(x)

2022-02-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 407425.
lichray added a comment.

  Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113393

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
  clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
  clang/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
  clang/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp
  clang/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
  clang/test/Parser/cxx2b-auto-x.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1388,6 +1388,11 @@
   https://wg21.link/P2360R0";>P2360R0
   Clang 14
 
+
+  auto(x): decay-copy in the language
+  https://wg21.link/P0849R8";>P0849R8
+  Clang 14
+
 
 
   Attributes on Lambda-Expressions
Index: clang/test/SemaCXX/deduced-return-type-cxx14.cpp
===
--- clang/test/SemaCXX/deduced-return-type-cxx14.cpp
+++ clang/test/SemaCXX/deduced-return-type-cxx14.cpp
@@ -442,6 +442,15 @@
   B() : decltype(auto)() {} // expected-error {{'decltype(auto)' not allowed here}}
 };
   }
+
+  namespace Cast {
+void foo() {
+  (void)decltype(auto)(0); // cxx14_20-error{{'decltype(auto)' not allowed here}} \
+  cxx2b-warning{{ISO C++23 DIS does not allow functional-style cast to 'decltype(auto)'}}
+  (void)decltype(auto){0}; // cxx14_20-error{{'decltype(auto)' not allowed here}} \
+  cxx2b-warning{{ISO C++23 DIS does not allow functional-style cast to 'decltype(auto)'}}
+}
+  }
 }
 
 namespace CurrentInstantiation {
Index: clang/test/Parser/cxx2b-auto-x.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-auto-x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx2b -std=c++2b -Wpre-c++2b-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 -std=c++20 %s
+
+void looks_like_decltype_auto() {
+  decltype(auto(42)) b = 42; // cxx20-error {{'auto' not allowed here}} \
+cxx2b-warning {{'auto' as a functional-style cast is incompatible with C++ standards before C++2b}}
+  decltype(long *) a = 42;   // expected-error {{expected '(' for function-style cast or type construction}} \
+expected-error {{expected expression}}
+  decltype(auto *) a = 42;   // expected-error {{expected '(' for function-style cast or type construction}} \
+expected-error {{expected expression}}
+  decltype(auto()) c = 42;   // cxx2b-error {{initializer for functional-style cast to 'auto' is empty}} \
+cxx20-error {{'auto' not allowed here}}
+}
+
+struct looks_like_declaration {
+  int n;
+} a;
+
+using T = looks_like_declaration *;
+void f() { T(&a)->n = 1; }
+// FIXME: They should be deemed expressions without breaking function pointer
+//parameter declarations with trailing return types.
+// void g() { auto(&a)->n = 0; }
+// void h() { auto{&a}->n = 0; }
Index: clang/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
===
--- clang/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
+++ clang/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
@@ -1,11 +1,30 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -pedantic
 
+// [expr.new]p2 ... the invented declaration: T x init ;
+// C++2b [dcl.type.auto.deduct]p2.2
+// For a variable declared with a type that contains a placeholder type, T is the declared type of the variable.
 void f() {
+  // - If the initializer is a parenthesized expression-list, the expression-list shall be a single assignmentexpression and E is the assignment-expression.
   new auto('a');
-  new auto {2};
-  new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
-  new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}
-  new decltype(auto)({1});
-  new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}}
+  new decltype(auto)('a');
+  // - If the initializer is a braced-init-list, it shall consist of a single brace-enclosed assignm

[PATCH] D113393: [c++2b] Implement P0849R8 auto(x)

2022-02-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 407427.
lichray added a comment.

- Retarget Clang 15


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113393

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p5.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp
  clang/test/CXX/expr/expr.post/expr.type.conv/p1-2b.cpp
  clang/test/CXX/expr/expr.unary/expr.new/p2-cxx0x.cpp
  clang/test/CXX/expr/expr.unary/expr.new/p2-cxx14.cpp
  clang/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
  clang/test/Parser/cxx2b-auto-x.cpp
  clang/test/SemaCXX/deduced-return-type-cxx14.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1388,6 +1388,11 @@
   https://wg21.link/P2360R0";>P2360R0
   Clang 14
 
+
+  auto(x): decay-copy in the language
+  https://wg21.link/P0849R8";>P0849R8
+  Clang 15
+
 
 
   Attributes on Lambda-Expressions
Index: clang/test/SemaCXX/deduced-return-type-cxx14.cpp
===
--- clang/test/SemaCXX/deduced-return-type-cxx14.cpp
+++ clang/test/SemaCXX/deduced-return-type-cxx14.cpp
@@ -442,6 +442,15 @@
   B() : decltype(auto)() {} // expected-error {{'decltype(auto)' not allowed here}}
 };
   }
+
+  namespace Cast {
+void foo() {
+  (void)decltype(auto)(0); // cxx14_20-error{{'decltype(auto)' not allowed here}} \
+  cxx2b-warning{{ISO C++23 DIS does not allow functional-style cast to 'decltype(auto)'}}
+  (void)decltype(auto){0}; // cxx14_20-error{{'decltype(auto)' not allowed here}} \
+  cxx2b-warning{{ISO C++23 DIS does not allow functional-style cast to 'decltype(auto)'}}
+}
+  }
 }
 
 namespace CurrentInstantiation {
Index: clang/test/Parser/cxx2b-auto-x.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-auto-x.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx2b -std=c++2b -Wpre-c++2b-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 -std=c++20 %s
+
+void looks_like_decltype_auto() {
+  decltype(auto(42)) b = 42; // cxx20-error {{'auto' not allowed here}} \
+cxx2b-warning {{'auto' as a functional-style cast is incompatible with C++ standards before C++2b}}
+  decltype(long *) a = 42;   // expected-error {{expected '(' for function-style cast or type construction}} \
+expected-error {{expected expression}}
+  decltype(auto *) a = 42;   // expected-error {{expected '(' for function-style cast or type construction}} \
+expected-error {{expected expression}}
+  decltype(auto()) c = 42;   // cxx2b-error {{initializer for functional-style cast to 'auto' is empty}} \
+cxx20-error {{'auto' not allowed here}}
+}
+
+struct looks_like_declaration {
+  int n;
+} a;
+
+using T = looks_like_declaration *;
+void f() { T(&a)->n = 1; }
+// FIXME: They should be deemed expressions without breaking function pointer
+//parameter declarations with trailing return types.
+// void g() { auto(&a)->n = 0; }
+// void h() { auto{&a}->n = 0; }
Index: clang/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
===
--- clang/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
+++ clang/test/CXX/expr/expr.unary/expr.new/p2-cxx1z.cpp
@@ -1,11 +1,30 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++14
 // RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++17 -pedantic
 
+// [expr.new]p2 ... the invented declaration: T x init ;
+// C++2b [dcl.type.auto.deduct]p2.2
+// For a variable declared with a type that contains a placeholder type, T is the declared type of the variable.
 void f() {
+  // - If the initializer is a parenthesized expression-list, the expression-list shall be a single assignmentexpression and E is the assignment-expression.
   new auto('a');
-  new auto {2};
-  new auto {1, 2}; // expected-error{{new expression for type 'auto' contains multiple constructor arguments}}
-  new auto {}; // expected-error{{new expression for type 'auto' requires a constructor argument}}
-  new decltype(auto)({1});
-  new decltype(auto)({1, 2}); // expected-error{{new expression for type 'decltype(auto)' contains multiple constructor arguments}}
+  new decltype(auto)('a');
+  // - If the initializer is a braced-init-list, it shall consist of a single brace-enclos

[PATCH] D119419: [clang-format] Do not remove required spaces when aligning tokens.

2022-02-10 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: MyDeveloperDay, HazardyKnusperkeks, owenpan.
curdeius requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes https://github.com/llvm/llvm-project/issues/44292.
Fixes https://github.com/llvm/llvm-project/issues/45874.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119419

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17277,6 +17277,31 @@
"const unsigned   g;\n"
"Const unsigned   h;",
Alignment);
+
+  // See PR46529
+  FormatStyle BracedAlign = getLLVMStyle();
+  BracedAlign.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("const auto result{[]() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "}};\n",
+   BracedAlign);
+  verifyFormat("int foo{[]() {\n"
+   "  int bar{0};\n"
+   "  return 0;\n"
+   "}()};",
+   BracedAlign);
+  BracedAlign.Cpp11BracedListStyle = false;
+  verifyFormat("const auto result{ []() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "} };\n",
+   BracedAlign);
+  verifyFormat("int foo{ []() {\n"
+   "  int bar{ 0 };\n"
+   "  return 0;\n"
+   "}() };",
+   BracedAlign);
 }
 
 TEST_F(FormatTest, AlignWithLineBreaks) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -331,6 +331,10 @@
   FoundMatchOnLine = true;
   Shift = Column - Changes[i].StartOfTokenColumn;
   Changes[i].Spaces += Shift;
+  if (Changes[i].NewlinesBefore == 0)
+Changes[i].Spaces =
+std::max(Changes[i].Spaces,
+ static_cast(Changes[i].Tok->SpacesRequiredBefore));
 }
 
 // This is for function parameters that are split across multiple lines,
@@ -399,6 +403,12 @@
 if (ContinuedStringLiteral)
   Changes[i].Spaces += Shift;
 
+// We should not remove required spaces unless we break the line before.
+assert(Changes[i].NewlinesBefore ||
+   Changes[i].Spaces >=
+   static_cast(Changes[i].Tok->SpacesRequiredBefore) ||
+   Changes[i].Tok->is(tok::eof));
+
 Changes[i].StartOfTokenColumn += Shift;
 if (i + 1 != Changes.size())
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17277,6 +17277,31 @@
"const unsigned   g;\n"
"Const unsigned   h;",
Alignment);
+
+  // See PR46529
+  FormatStyle BracedAlign = getLLVMStyle();
+  BracedAlign.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("const auto result{[]() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "}};\n",
+   BracedAlign);
+  verifyFormat("int foo{[]() {\n"
+   "  int bar{0};\n"
+   "  return 0;\n"
+   "}()};",
+   BracedAlign);
+  BracedAlign.Cpp11BracedListStyle = false;
+  verifyFormat("const auto result{ []() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "} };\n",
+   BracedAlign);
+  verifyFormat("int foo{ []() {\n"
+   "  int bar{ 0 };\n"
+   "  return 0;\n"
+   "}() };",
+   BracedAlign);
 }
 
 TEST_F(FormatTest, AlignWithLineBreaks) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -331,6 +331,10 @@
   FoundMatchOnLine = true;
   Shift = Column - Changes[i].StartOfTokenColumn;
   Changes[i].Spaces += Shift;
+  if (Changes[i].NewlinesBefore == 0)
+Changes[i].Spaces =
+std::max(Changes[i].Spaces,
+ static_cast(Changes[i].Tok->SpacesRequiredBefore));
 }
 
 // This is for function parameters that are split across multiple lines,
@@ -399,6 +403,12 @@
 if (ContinuedStringLiteral)
   Changes[i].Spaces += Shift;
 
+// We should not remove required spaces unless we break the line before.
+assert(Changes[i].NewlinesBefore ||
+   Changes[i].Spaces >=
+   static_cast(Cha

[PATCH] D119419: [clang-format] Do not remove required spaces when aligning tokens.

2022-02-10 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/WhitespaceManager.cpp:334-337
+  if (Changes[i].NewlinesBefore == 0)
+Changes[i].Spaces =
+std::max(Changes[i].Spaces,
+ static_cast(Changes[i].Tok->SpacesRequiredBefore));

On a second thought, it seems like a workaround only and a real solution would 
be to fix https://github.com/llvm/llvm-project/issues/53699 that I've just 
created.
It fixes an immediate problem though.
I'll add a fixme in a later revision (or when landing) to remove this when the 
abovementioned bug is solved properly.
Then, this problem should be caught by the assertion added later below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119419

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


[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans 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/D118428/new/

https://reviews.llvm.org/D118428

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


[PATCH] D119419: [clang-format] Do not remove required spaces when aligning tokens.

2022-02-10 Thread Owen Pan via Phabricator via cfe-commits
owenpan accepted this revision.
owenpan added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/Format/WhitespaceManager.cpp:407
+// We should not remove required spaces unless we break the line before.
+assert(Changes[i].NewlinesBefore ||
+   Changes[i].Spaces >=





Comment at: clang/unittests/Format/FormatTest.cpp:17287
+   "  return 2;\n"
+   "}};\n",
+   BracedAlign);





Comment at: clang/unittests/Format/FormatTest.cpp:17298
+   "  return 2;\n"
+   "} };\n",
+   BracedAlign);




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119419

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


[PATCH] D119420: [OpenCL] Add OpenCL 3.0 atomics to -fdeclare-opencl-builtins

2022-02-10 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.
svenvh added reviewers: Anastasia, haonanya.
svenvh added a project: clang.
Herald added subscribers: Naghasan, ldrumm, yaxunl.
svenvh requested review of this revision.
Herald added a subscriber: cfe-commits.

Add the atomic overloads for the `global` and `local` address spaces,
which are new in OpenCL 3.0.  Ensure the preexisting `generic`
overloads are guarded by the generic address space feature macro.

Ensure a subset of the atomic builtins are guarded by the
`__opencl_c_atomic_order_seq_cst` and `__opencl_c_atomic_scope_device`
feature macros, and enable those macros for SPIR/SPIR-V targets in
`opencl-c-base.h`.

Also guard the `cl_ext_float_atomics` builtins with the atomic order
and scope feature macros.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119420

Files:
  clang/lib/Headers/opencl-c-base.h
  clang/lib/Sema/OpenCLBuiltins.td
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -9,6 +9,7 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CLC++2021 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header -cl-ext=-cl_khr_fp64 -DNO_FP64
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL3.0 -fdeclare-opencl-builtins -finclude-default-header -DNO_ATOMSCOPE
 
 // Test the -fdeclare-opencl-builtins option.  This is not a completeness
 // test, so it should not test for all builtins defined by OpenCL.  Instead
@@ -80,6 +81,11 @@
 #define __opencl_c_read_write_images 1
 #endif
 
+#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
+#define __opencl_c_atomic_order_seq_cst 1
+#define __opencl_c_atomic_scope_device 1
+#endif
+
 #define __opencl_c_named_address_space_builtins 1
 #endif
 
@@ -98,6 +104,7 @@
 #if !defined(NO_HEADER) && (defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= 200)
 kernel void test_enum_args(volatile global atomic_int *global_p, global int *expected) {
   int desired;
+  atomic_work_item_fence(CLK_GLOBAL_MEM_FENCE, memory_order_acq_rel, memory_scope_device);
   atomic_compare_exchange_strong_explicit(global_p, expected, desired,
   memory_order_acq_rel,
   memory_order_relaxed,
@@ -156,6 +163,27 @@
 }
 #endif // !defined(NO_HEADER) && __OPENCL_C_VERSION__ >= 200
 
+#if defined(NO_ATOMSCOPE) && __OPENCL_C_VERSION__ >= 300
+// Disable the feature by undefining the feature macro.
+#undef __opencl_c_atomic_scope_device
+
+// Test that only the overload with explicit order and scope arguments is
+// available when the __opencl_c_atomic_scope_device feature is disabled.
+void test_atomics_without_scope_device(volatile __generic atomic_int *a_int) {
+  int d;
+
+  atomic_exchange(a_int, d);
+  // expected-error@-1{{implicit declaration of function 'atomic_exchange' is invalid in OpenCL}}
+
+  atomic_exchange_explicit(a_int, d, memory_order_seq_cst);
+  // expected-error@-1{{no matching function for call to 'atomic_exchange_explicit'}}
+  // expected-note@-2 + {{candidate function not viable}}
+
+  atomic_exchange_explicit(a_int, d, memory_order_seq_cst, memory_scope_work_group);
+}
+
+#endif
+
 // Test old atomic overloaded with generic address space in C++ for OpenCL.
 #if __OPENCL_C_VERSION__ >= 200
 void test_legacy_atomics_cpp(__generic volatile unsigned int *a) {
Index: clang/lib/Sema/OpenCLBuiltins.td
===
--- clang/lib/Sema/OpenCLBuiltins.td
+++ clang/lib/Sema/OpenCLBuiltins.td
@@ -57,6 +57,23 @@
 // disabled.
 class TypeExtension : AbstractExtension<_Ext>;
 
+// Concatenate zero or more space-separated extensions in NewExts to Base and
+// return the resulting FunctionExtension in ret.
+class concatExtension {
+  FunctionExtension ret = FunctionExtension<
+!cond(
+  // Return Base extension if NewExts is empty,
+  !empty(NewExts) : Base.ExtName,
+
+  // otherwise, return NewExts if Base extension is empty,
+  !empty(Base.ExtName) : NewExts,
+
+  // otherwise, concatenate NewExts to Base.
+  true : Base.ExtName # " " # NewExts
+)
+  >;
+}
+
 // TypeExtension definitions.
 def NoTypeExt   : TypeExtension<"">;
 def Fp16TypeExt : TypeExtension<"cl_khr_fp16">;
@@ -1043,40 +1060,57 @@
 // OpenCL v2.0 s6.13.11 - Atomic Functions.
 
 // An atomic builtin with 2 additional _explicit variants.
-multiclass BuiltinAtomic

[PATCH] D119375: [Clang][Sema] Do not evaluate value-dependent immediate invocations

2022-02-10 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a subscriber: erichkeane.
cor3ntin added a comment.

This looks like the right fix to me but I would prefer @aaron.ballman or 
@erichkeane to have the final say.




Comment at: clang/lib/Sema/SemaExpr.cpp:16731
   /*IsImmediateInvocation*/ true);
-  ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
+  /// Value-dependent constant expression are not meant to be calculated.
+  /// Each template instantiation will calculate its own value later.

I'd say something like

/// Value-dependent constant expressionS should not be immediately
// evaluated until they are instantiated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119375

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


[PATCH] D118605: [OpenCL] Add support of language builtins for OpenCL C 3.0

2022-02-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Basic/Builtins.cpp:79
+  bool OclBlocksUnsupported =
+  (LangOpts.getOpenCLCompatibleVersion() < 200 || !LangOpts.Blocks) &&
+  (BuiltinInfo.Langs & OCL_BLOCKS);

svenvh wrote:
> azabaznov wrote:
> > This check is needed as //-cl-std=CL1.2// can be used together with 
> > //-fblocks//. But in 3.0 block support requires 
> > //__opencl_c_device_enqueue// feature.
> > This check is needed as -cl-std=CL1.2 can be used together with -fblocks.
> 
> That surprised me, I cannot find anything in the OpenCL 1.2 spec about this. 
> @Anastasia do you know if this is an (undocumented?) Clang extension?
> 
> There are tests checking for this (e.g. `clang/test/Frontend/opencl.cl`), so 
> we need this check to preserve the existing behavior indeed.
I think blocks is a clang language feature that can be enabled using `-fblocks` 
and activate extra functionality of blocks used as lambda only in C-based 
languages. But the `enqueue_kernel` is only supported from OpenCL 2.0 onwards 
since it requires functionality outside of frontend so I think this check is 
reasonable. I feel perhaps we should rename to something like:

`OCL_BLOCKS` -> `OCL_KERNEL_ENQUEUE` or `OCL_DSE`?

Since the builtins are not about blocks but about enqueueing kernels from 
device...

Also I would suggest a comment explaining that we check for `Blocks` because it 
is coupled with enqueue kernel functionality.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118605

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


[PATCH] D119419: [clang-format] Do not remove required spaces when aligning tokens.

2022-02-10 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius updated this revision to Diff 407442.
curdeius marked 3 inline comments as done.
curdeius added a comment.

Address review comments. Add a fixme note.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119419

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17277,6 +17277,31 @@
"const unsigned   g;\n"
"Const unsigned   h;",
Alignment);
+
+  // See PR46529
+  FormatStyle BracedAlign = getLLVMStyle();
+  BracedAlign.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("const auto result{[]() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "}};",
+   BracedAlign);
+  verifyFormat("int foo{[]() {\n"
+   "  int bar{0};\n"
+   "  return 0;\n"
+   "}()};",
+   BracedAlign);
+  BracedAlign.Cpp11BracedListStyle = false;
+  verifyFormat("const auto result{ []() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "} };",
+   BracedAlign);
+  verifyFormat("int foo{ []() {\n"
+   "  int bar{ 0 };\n"
+   "  return 0;\n"
+   "}() };",
+   BracedAlign);
 }
 
 TEST_F(FormatTest, AlignWithLineBreaks) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -331,6 +331,12 @@
   FoundMatchOnLine = true;
   Shift = Column - Changes[i].StartOfTokenColumn;
   Changes[i].Spaces += Shift;
+  // FIXME: This is a workaround that should be removed when we fix
+  // http://llvm.org/PR53699. An assertion later below verifies this.
+  if (Changes[i].NewlinesBefore == 0)
+Changes[i].Spaces =
+std::max(Changes[i].Spaces,
+ static_cast(Changes[i].Tok->SpacesRequiredBefore));
 }
 
 // This is for function parameters that are split across multiple lines,
@@ -399,6 +405,12 @@
 if (ContinuedStringLiteral)
   Changes[i].Spaces += Shift;
 
+// We should not remove required spaces unless we break the line before.
+assert(Changes[i].NewlinesBefore > 0 ||
+   Changes[i].Spaces >=
+   static_cast(Changes[i].Tok->SpacesRequiredBefore) ||
+   Changes[i].Tok->is(tok::eof));
+
 Changes[i].StartOfTokenColumn += Shift;
 if (i + 1 != Changes.size())
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17277,6 +17277,31 @@
"const unsigned   g;\n"
"Const unsigned   h;",
Alignment);
+
+  // See PR46529
+  FormatStyle BracedAlign = getLLVMStyle();
+  BracedAlign.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("const auto result{[]() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "}};",
+   BracedAlign);
+  verifyFormat("int foo{[]() {\n"
+   "  int bar{0};\n"
+   "  return 0;\n"
+   "}()};",
+   BracedAlign);
+  BracedAlign.Cpp11BracedListStyle = false;
+  verifyFormat("const auto result{ []() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "} };",
+   BracedAlign);
+  verifyFormat("int foo{ []() {\n"
+   "  int bar{ 0 };\n"
+   "  return 0;\n"
+   "}() };",
+   BracedAlign);
 }
 
 TEST_F(FormatTest, AlignWithLineBreaks) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -331,6 +331,12 @@
   FoundMatchOnLine = true;
   Shift = Column - Changes[i].StartOfTokenColumn;
   Changes[i].Spaces += Shift;
+  // FIXME: This is a workaround that should be removed when we fix
+  // http://llvm.org/PR53699. An assertion later below verifies this.
+  if (Changes[i].NewlinesBefore == 0)
+Changes[i].Spaces =
+std::max(Changes[i].Spaces,
+ static_cast(Changes[i].Tok->SpacesRequiredBefore));
 }
 
 // This is for function parameters that are split across multiple lines,
@@ -399,6 +405,12 @@
 if (ContinuedStringLiteral)
   Changes[i].Spaces += Shift;

[PATCH] D119407: [PowerPC] [Clang] Add SSE4 and BMI compatible intrinsics implementation for PowerPC

2022-02-10 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 407444.
Herald added a subscriber: mgorny.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119407

Files:
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/ppc_wrappers/bmi2intrin.h
  clang/lib/Headers/ppc_wrappers/bmiintrin.h
  clang/lib/Headers/ppc_wrappers/emmintrin.h
  clang/lib/Headers/ppc_wrappers/immintrin.h
  clang/lib/Headers/ppc_wrappers/nmmintrin.h
  clang/lib/Headers/ppc_wrappers/pmmintrin.h
  clang/lib/Headers/ppc_wrappers/smmintrin.h
  clang/lib/Headers/ppc_wrappers/tmmintrin.h
  clang/lib/Headers/ppc_wrappers/x86gprintrin.h
  clang/lib/Headers/ppc_wrappers/x86intrin.h
  clang/lib/Headers/ppc_wrappers/xmmintrin.h
  clang/test/CodeGen/PowerPC/ppc-smmintrin.c
  clang/test/CodeGen/PowerPC/ppc-x86gprintrin.c

Index: clang/test/CodeGen/PowerPC/ppc-x86gprintrin.c
===
--- /dev/null
+++ clang/test/CodeGen/PowerPC/ppc-x86gprintrin.c
@@ -0,0 +1,239 @@
+// REQUIRES: powerpc-registered-target
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-linux-gnu -mcpu=pwr7 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-linux-gnu -mcpu=pwr7 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+
+// RUN: %clang -S -emit-llvm -target powerpc64le-unknown-freebsd13.0 -mcpu=pwr7 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+// RUN: %clang -S -emit-llvm -target powerpc64-unknown-freebsd13.0 -mcpu=pwr7 -ffreestanding -DNO_WARN_X86_INTRINSICS %s \
+// RUN:   -fno-discard-value-names -mllvm -disable-llvm-optzns -o - | llvm-cxxfilt -n | FileCheck %s
+
+#include 
+
+unsigned short us;
+unsigned ui;
+unsigned long long ul;
+
+void __attribute__((noinline))
+test_bmiintrin() {
+  __tzcnt_u16(us);
+  __andn_u32(ui, ui);
+  _bextr_u32(ui, ui, ui);
+  __bextr_u32(ui, ui);
+  __blsi_u32(ui);
+  _blsi_u32(ui);
+  __blsmsk_u32(ui);
+  _blsmsk_u32(ui);
+  __blsr_u32(ui);
+  _blsr_u32(ui);
+  __tzcnt_u32(ui);
+  _tzcnt_u32(ui);
+  __andn_u64(ul, ul);
+  _bextr_u64(ul, ui, ui);
+  __bextr_u64(ul, ul);
+  __blsi_u64(ul);
+  _blsi_u64(ul);
+  __blsmsk_u64(ul);
+  _blsmsk_u64(ul);
+  __blsr_u64(ul);
+  _blsr_u64(ul);
+  __tzcnt_u64(ul);
+  _tzcnt_u64(ul);
+}
+
+// CHECK-LABEL: @test_bmiintrin
+
+// CHECK-LABEL: define available_externally zeroext i16 @__tzcnt_u16(i16 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: %[[CONV:[0-9a-zA-Z._]+]] = zext i16 %{{[0-9a-zA-Z._]+}} to i32
+// CHECK: %[[CALL:[0-9a-zA-Z._]+]] = call i32 @llvm.cttz.i32(i32 %[[CONV]], i1 false)
+// CHECK: trunc i32 %[[CALL]] to i16
+
+// CHECK-LABEL: define available_externally zeroext i32 @__andn_u32(i32 noundef zeroext %{{[0-9a-zA-Z._]+}}, i32 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: %[[NEG:[0-9a-zA-Z._]+]] = xor i32 %{{[0-9a-zA-Z._]+}}, -1
+// CHECK: and i32 %[[NEG]], %1
+
+// CHECK-LABEL: define available_externally zeroext i32 @_bextr_u32(i32 noundef zeroext %{{[0-9a-zA-Z._]+}}, i32 noundef zeroext %{{[0-9a-zA-Z._]+}}, i32 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: %[[ADD:[0-9a-zA-Z._]+]] = add i32 %{{[0-9a-zA-Z._]+}}, %{{[0-9a-zA-Z._]+}}
+// CHECK: %[[SUB:[0-9a-zA-Z._]+]] = sub i32 32, %[[ADD]]
+// CHECK: %[[SHL:[0-9a-zA-Z._]+]] = shl i32 %{{[0-9a-zA-Z._]+}}, %[[SUB]]
+// CHECK: %[[SUB]]1 = sub i32 32, %{{[0-9a-zA-Z._]+}}
+// CHECK: lshr i32 %[[SHL]], %[[SUB]]1
+
+// CHECK-LABEL: define available_externally zeroext i32 @__bextr_u32(i32 noundef zeroext %{{[0-9a-zA-Z._]+}}, i32 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: %[[AND:[0-9a-zA-Z._]+]] = and i32 %{{[0-9a-zA-Z._]+}}, 255
+// CHECK: %[[SHR:[0-9a-zA-Z._]+]] = lshr i32 %{{[0-9a-zA-Z._]+}}, 8
+// CHECK: and i32 %[[SHR]], 255
+// CHECK: call zeroext i32 @_bextr_u32
+
+// CHECK-LABEL: define available_externally zeroext i32 @__blsi_u32(i32 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: %[[SUB:[0-9a-zA-Z._]+]] = sub i32 0, %1
+// CHECK: and i32 %0, %[[SUB]]
+
+// CHECK-LABEL: define available_externally zeroext i32 @_blsi_u32(i32 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: call zeroext i32 @__blsi_u32
+
+// CHECK-LABEL: define available_externally zeroext i32 @__blsmsk_u32(i32 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: %[[SUB:[0-9a-zA-Z._]+]] = sub i32 %{{[0-9a-zA-Z._]+}}, 1
+// CHECK: xor i32 %{{[0-9a-zA-Z._]+}}, %[[SUB]]
+
+// CHECK-LABEL: define available_externally zeroext i32 @_blsmsk_u32(i32 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: call zeroext i32 @__blsmsk_u32
+
+// CHECK-LABEL: define available_externally zeroext i32 @__blsr_u32(i32 noundef zeroext %{{[0-9a-zA-Z._]+}})
+// CHECK: %[[SUB:[0-9a-zA-Z._]+]] = sub i32 %{{[0-9a-zA-Z._]+}}, 1
+/

[PATCH] D119301: [AArch64][ARM] add -Wunaligned-access only for clang

2022-02-10 Thread Sam Elliott via Phabricator via cfe-commits
lenary accepted this revision.
lenary added a comment.
This revision is now accepted and ready to land.

Ah, I see.

Please can you also remove the `CmdArgs` parameter from 
`arm::getARMTargetFeatures` when you commit this? This would be useful, along 
with a comment at the top of `getTargetFeatures` to discourage targets adding 
to or using `CmdArgs` in their `getTargetFeatures` functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119301

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


[PATCH] D118021: [Driver] Use libatomic for 32-bit SPARC atomics support

2022-02-10 Thread Rainer Orth via Phabricator via cfe-commits
ro marked an inline comment as done.
ro added inline comments.



Comment at: clang/test/Driver/solaris-ld.c:20
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-SPARC32-SAME: "-zignore"
+// CHECK-LD-SPARC32-SAME: "-latomic"

MaskRay wrote:
> If they are consecutive.
The are, patch amended.



Comment at: clang/test/Driver/solaris-ld.c:46
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
+// CHECK-LD-SPARC64-NOT:  "-zignore"
+// CHECK-LD-SPARC64-NOT:  "-latomic"

MaskRay wrote:
> Such NOT patterns are usually inadequate and may go stale pretty easily, 
> since technically the patterns can occur in many places.
> 
> One idea is to use --implicit-check-not; another is to enumerate all options 
> and use the `{{^}}` style I picked in linux-cross.cpp, but perhaps your style 
> is good enough if we can remember these library after after -L and before 
> -lgcc_s
> Such NOT patterns are usually inadequate and may go stale pretty easily, 
> since technically the patterns can occur in many places.

I wondered so myself: while this is currently the only instance of 
`-zignore`/`-zrecord`, `-lgcc_s` requires similar treatment.

> One idea is to use --implicit-check-not; another is to enumerate all options 
> and use the `{{^}}` style I picked in linux-cross.cpp, but perhaps your style 
> is good enough if we can remember these library after after -L and before 
> -lgcc_s

I'll check those.  However, it occured to me that the crucial check is that 
`-latomic` isn't added at all, `-zignore`/`-zrecord` or no, so maybe just check 
for that and avoid the issue for the moment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118021

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


[PATCH] D119375: [Clang][Sema] Do not evaluate value-dependent immediate invocations

2022-02-10 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron updated this revision to Diff 407449.
Izaron added a comment.

Fix comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119375

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -613,6 +613,26 @@
 
 } // namespace unevaluated
 
+namespace value_dependent {
+
+consteval int foo(int x) {
+  return x;
+}
+
+template  constexpr int bar() {
+  return foo(X);
+}
+
+template  constexpr int baz() {
+  constexpr int t = sizeof(T);
+  return foo(t);
+}
+
+static_assert(bar<15>() == 15);
+static_assert(baz() == sizeof(int));
+
+} // namespace value_dependent
+
 namespace PR50779 {
 struct derp {
   int b = 0;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16747,7 +16747,10 @@
   ConstantExpr::getStorageKind(Decl->getReturnType().getTypePtr(),
getASTContext()),
   /*IsImmediateInvocation*/ true);
-  ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
+  /// Value-dependent constant expressions should not be immediately
+  /// evaluated until they are instantiated.
+  if (!Res->isValueDependent())
+ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
   return Res;
 }
 


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -613,6 +613,26 @@
 
 } // namespace unevaluated
 
+namespace value_dependent {
+
+consteval int foo(int x) {
+  return x;
+}
+
+template  constexpr int bar() {
+  return foo(X);
+}
+
+template  constexpr int baz() {
+  constexpr int t = sizeof(T);
+  return foo(t);
+}
+
+static_assert(bar<15>() == 15);
+static_assert(baz() == sizeof(int));
+
+} // namespace value_dependent
+
 namespace PR50779 {
 struct derp {
   int b = 0;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16747,7 +16747,10 @@
   ConstantExpr::getStorageKind(Decl->getReturnType().getTypePtr(),
getASTContext()),
   /*IsImmediateInvocation*/ true);
-  ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
+  /// Value-dependent constant expressions should not be immediately
+  /// evaluated until they are instantiated.
+  if (!Res->isValueDependent())
+ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
   return Res;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119375: [Clang][Sema] Do not evaluate value-dependent immediate invocations

2022-02-10 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron marked an inline comment as done.
Izaron added inline comments.



Comment at: clang/lib/Sema/SemaExpr.cpp:16731
   /*IsImmediateInvocation*/ true);
-  ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
+  /// Value-dependent constant expression are not meant to be calculated.
+  /// Each template instantiation will calculate its own value later.

cor3ntin wrote:
> I'd say something like
> 
> /// Value-dependent constant expressionS should not be immediately
> // evaluated until they are instantiated.
Sure, thanks! I'm bad at writing comments =)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119375

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


[PATCH] D118021: [Driver] Use libatomic for 32-bit SPARC atomics support

2022-02-10 Thread Rainer Orth via Phabricator via cfe-commits
ro updated this revision to Diff 407455.
ro marked an inline comment as done.
ro added a comment.

Simplify test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118021

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/Driver/solaris-ld.c


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -17,6 +17,7 @@
 // CHECK-LD-SPARC32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 // CHECK-LD-SPARC32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-SPARC32-SAME: "-zignore" "-latomic" "-zrecord"
 // CHECK-LD-SPARC32-SAME: "-lgcc_s"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
@@ -40,6 +41,7 @@
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
+// CHECK-LD-SPARC64-NOT:  "-latomic"
 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
 // CHECK-LD-SPARC64-SAME: "-lc"
 // CHECK-LD-SPARC64-SAME: "-lgcc"
@@ -63,6 +65,7 @@
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4"
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-X32-NOT:  "-latomic"
 // CHECK-LD-X32-SAME: "-lgcc_s"
 // CHECK-LD-X32-SAME: "-lc"
 // CHECK-LD-X32-SAME: "-lgcc"
@@ -86,6 +89,7 @@
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64"
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../../amd64"
 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/lib/amd64"
+// CHECK-LD-X64-NOT:  "-latomic"
 // CHECK-LD-X64-SAME: "-lgcc_s"
 // CHECK-LD-X64-SAME: "-lc"
 // CHECK-LD-X64-SAME: "-lgcc"
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -132,6 +132,13 @@
   CmdArgs.push_back("-lssp_nonshared");
   CmdArgs.push_back("-lssp");
 }
+// LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
+// forcibly link with libatomic as a workaround.
+if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
+  CmdArgs.push_back(getAsNeededOption(getToolChain(), true));
+  CmdArgs.push_back("-latomic");
+  CmdArgs.push_back(getAsNeededOption(getToolChain(), false));
+}
 CmdArgs.push_back("-lgcc_s");
 CmdArgs.push_back("-lc");
 if (!Args.hasArg(options::OPT_shared)) {
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -117,6 +117,8 @@
   bool ForceStaticHostRuntime = false,
   bool IsOffloadingHost = false, bool GompNeedsRT = false);
 
+const char *getAsNeededOption(const ToolChain &TC, bool as_needed);
+
 llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
 llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -756,7 +756,7 @@
   return false;
 }
 
-static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) {
+const char *tools::getAsNeededOption(const ToolChain &TC, bool as_needed) {
   assert(!TC.getTriple().isOSAIX() &&
  "AIX linker does not support any form of --as-needed option yet.");
 


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -17,6 +17,7 @@
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-SPARC32-SAME: "-zignore" "-latomic" "-zrecord"
 // CHECK-LD-SPARC32-SAME: "-lgcc_s"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
@@ -40,6 +41,7 @@
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
 // CHECK-LD-SPARC64-SAME: "-L

[PATCH] D118021: [Driver] Use libatomic for 32-bit SPARC atomics support

2022-02-10 Thread Rainer Orth via Phabricator via cfe-commits
ro added inline comments.



Comment at: clang/test/Driver/solaris-ld.c:46
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
+// CHECK-LD-SPARC64-NOT:  "-zignore"
+// CHECK-LD-SPARC64-NOT:  "-latomic"

ro wrote:
> MaskRay wrote:
> > Such NOT patterns are usually inadequate and may go stale pretty easily, 
> > since technically the patterns can occur in many places.
> > 
> > One idea is to use --implicit-check-not; another is to enumerate all 
> > options and use the `{{^}}` style I picked in linux-cross.cpp, but perhaps 
> > your style is good enough if we can remember these library after after -L 
> > and before -lgcc_s
> > Such NOT patterns are usually inadequate and may go stale pretty easily, 
> > since technically the patterns can occur in many places.
> 
> I wondered so myself: while this is currently the only instance of 
> `-zignore`/`-zrecord`, `-lgcc_s` requires similar treatment.
> 
> > One idea is to use --implicit-check-not; another is to enumerate all 
> > options and use the `{{^}}` style I picked in linux-cross.cpp, but perhaps 
> > your style is good enough if we can remember these library after after -L 
> > and before -lgcc_s
> 
> I'll check those.  However, it occured to me that the crucial check is that 
> `-latomic` isn't added at all, `-zignore`/`-zrecord` or no, so maybe just 
> check for that and avoid the issue for the moment.
In the end, I've decided to go for the simple `*-NOT: "-latomic" form: it's 
simple and robust, which is all the more important since this patch needs to go 
into the `release/14.x` branch, too.

Going forward, I thing going for the `linux-cross.cpp` style is best.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118021

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


[clang] a6afa9e - [Driver] Use libatomic for 32-bit SPARC atomics support

2022-02-10 Thread Rainer Orth via cfe-commits

Author: Rainer Orth
Date: 2022-02-10T12:40:32+01:00
New Revision: a6afa9e6b0d9a08ecc878e62343a2af80ff30435

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

LOG: [Driver] Use libatomic for 32-bit SPARC atomics support

Even after D86621 , `clang -m32` on
Solaris/sparcv9 doesn't inline atomics with 8-byte operands, unlike `gcc`.
This leads to many link failures in the testsuite (undefined references to
`__atomic_load_8` and `__sync_val_compare_and_swap_8`.  Until a proper
codegen fix can be implemented, this patch works around the first of those
by linking with `-latomic`.

Tested on `sparcv9-sun-solaris2.11`.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
clang/lib/Driver/ToolChains/Solaris.cpp
clang/test/Driver/solaris-ld.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 40364d23c5599..71f5bd7cb2820 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -756,7 +756,7 @@ static bool addSanitizerDynamicList(const ToolChain &TC, 
const ArgList &Args,
   return false;
 }
 
-static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) {
+const char *tools::getAsNeededOption(const ToolChain &TC, bool as_needed) {
   assert(!TC.getTriple().isOSAIX() &&
  "AIX linker does not support any form of --as-needed option yet.");
 

diff  --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 646fa76949b78..23012dc247e41 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -117,6 +117,8 @@ bool addOpenMPRuntime(llvm::opt::ArgStringList &CmdArgs, 
const ToolChain &TC,
   bool ForceStaticHostRuntime = false,
   bool IsOffloadingHost = false, bool GompNeedsRT = false);
 
+const char *getAsNeededOption(const ToolChain &TC, bool as_needed);
+
 llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
 llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
 

diff  --git a/clang/lib/Driver/ToolChains/Solaris.cpp 
b/clang/lib/Driver/ToolChains/Solaris.cpp
index 4d1af094f4814..24f18b92dd661 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -132,6 +132,13 @@ void solaris::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-lssp_nonshared");
   CmdArgs.push_back("-lssp");
 }
+// LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
+// forcibly link with libatomic as a workaround.
+if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
+  CmdArgs.push_back(getAsNeededOption(getToolChain(), true));
+  CmdArgs.push_back("-latomic");
+  CmdArgs.push_back(getAsNeededOption(getToolChain(), false));
+}
 CmdArgs.push_back("-lgcc_s");
 CmdArgs.push_back("-lc");
 if (!Args.hasArg(options::OPT_shared)) {

diff  --git a/clang/test/Driver/solaris-ld.c b/clang/test/Driver/solaris-ld.c
index 59d03c4d82253..d40e5dac2da9e 100644
--- a/clang/test/Driver/solaris-ld.c
+++ b/clang/test/Driver/solaris-ld.c
@@ -17,6 +17,7 @@
 // CHECK-LD-SPARC32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 // CHECK-LD-SPARC32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-SPARC32-SAME: "-zignore" "-latomic" "-zrecord"
 // CHECK-LD-SPARC32-SAME: "-lgcc_s"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
@@ -40,6 +41,7 @@
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
+// CHECK-LD-SPARC64-NOT:  "-latomic"
 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
 // CHECK-LD-SPARC64-SAME: "-lc"
 // CHECK-LD-SPARC64-SAME: "-lgcc"
@@ -63,6 +65,7 @@
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4"
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-X32-NOT:  "-latomic"
 // CHECK-LD-X32-SAME: "-lgcc_s"
 // CHECK-LD-X32-SAME: "-lc"
 // CHECK-LD-X32-SAME: "-lgcc"
@@ -86,6 +89,7 @@
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64"
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.

[PATCH] D118021: [Driver] Use libatomic for 32-bit SPARC atomics support

2022-02-10 Thread Rainer Orth 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 rGa6afa9e6b0d9: [Driver] Use libatomic for 32-bit SPARC 
atomics support (authored by ro).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118021

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/lib/Driver/ToolChains/CommonArgs.h
  clang/lib/Driver/ToolChains/Solaris.cpp
  clang/test/Driver/solaris-ld.c


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -17,6 +17,7 @@
 // CHECK-LD-SPARC32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 // CHECK-LD-SPARC32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-SPARC32-SAME: "-zignore" "-latomic" "-zrecord"
 // CHECK-LD-SPARC32-SAME: "-lgcc_s"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
@@ -40,6 +41,7 @@
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
 // CHECK-LD-SPARC64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../../sparcv9"
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/lib/sparcv9"
+// CHECK-LD-SPARC64-NOT:  "-latomic"
 // CHECK-LD-SPARC64-SAME: "-lgcc_s"
 // CHECK-LD-SPARC64-SAME: "-lc"
 // CHECK-LD-SPARC64-SAME: "-lgcc"
@@ -63,6 +65,7 @@
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4"
 // CHECK-LD-X32-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../.."
 // CHECK-LD-X32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-X32-NOT:  "-latomic"
 // CHECK-LD-X32-SAME: "-lgcc_s"
 // CHECK-LD-X32-SAME: "-lc"
 // CHECK-LD-X32-SAME: "-lgcc"
@@ -86,6 +89,7 @@
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64"
 // CHECK-LD-X64-SAME: 
"-L[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/../../../amd64"
 // CHECK-LD-X64-SAME: "-L[[SYSROOT]]/usr/lib/amd64"
+// CHECK-LD-X64-NOT:  "-latomic"
 // CHECK-LD-X64-SAME: "-lgcc_s"
 // CHECK-LD-X64-SAME: "-lc"
 // CHECK-LD-X64-SAME: "-lgcc"
Index: clang/lib/Driver/ToolChains/Solaris.cpp
===
--- clang/lib/Driver/ToolChains/Solaris.cpp
+++ clang/lib/Driver/ToolChains/Solaris.cpp
@@ -132,6 +132,13 @@
   CmdArgs.push_back("-lssp_nonshared");
   CmdArgs.push_back("-lssp");
 }
+// LLVM support for atomics on 32-bit SPARC V8+ is incomplete, so
+// forcibly link with libatomic as a workaround.
+if (getToolChain().getTriple().getArch() == llvm::Triple::sparc) {
+  CmdArgs.push_back(getAsNeededOption(getToolChain(), true));
+  CmdArgs.push_back("-latomic");
+  CmdArgs.push_back(getAsNeededOption(getToolChain(), false));
+}
 CmdArgs.push_back("-lgcc_s");
 CmdArgs.push_back("-lc");
 if (!Args.hasArg(options::OPT_shared)) {
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -117,6 +117,8 @@
   bool ForceStaticHostRuntime = false,
   bool IsOffloadingHost = false, bool GompNeedsRT = false);
 
+const char *getAsNeededOption(const ToolChain &TC, bool as_needed);
+
 llvm::opt::Arg *getLastProfileUseArg(const llvm::opt::ArgList &Args);
 llvm::opt::Arg *getLastProfileSampleUseArg(const llvm::opt::ArgList &Args);
 
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -756,7 +756,7 @@
   return false;
 }
 
-static const char *getAsNeededOption(const ToolChain &TC, bool as_needed) {
+const char *tools::getAsNeededOption(const ToolChain &TC, bool as_needed) {
   assert(!TC.getTriple().isOSAIX() &&
  "AIX linker does not support any form of --as-needed option yet.");
 


Index: clang/test/Driver/solaris-ld.c
===
--- clang/test/Driver/solaris-ld.c
+++ clang/test/Driver/solaris-ld.c
@@ -17,6 +17,7 @@
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2"
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/../../.."
 // CHECK-LD-SPARC32-SAME: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD-SPARC32-SAME: "-zignore" "-latomic" "-zrecord"
 // CHECK-LD-SPARC32-SAME: "-lgcc_s"
 // CHECK-LD-SPARC32-SAME: "-lc"
 // CHECK-LD-SPARC32-SAME: "-lgcc"
@@ -40,6 +41,7 @@
 // CHECK-LD-SPARC64-SAME: "-L[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9"
 // CHECK-LD-SP

[PATCH] D119420: [OpenCL] Add OpenCL 3.0 atomics to -fdeclare-opencl-builtins

2022-02-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Sema/OpenCLBuiltins.td:1151
   foreach addrspace = [GlobalAS, LocalAS, GenericAS] in {
-let Extension = !cast("FuncExtFloatAtomicsFp16" # 
addrspace # "LoadStore") in {
-  defm : BuiltinAtomicExplicit<"atomic_store",
-  [Void, PointerType, addrspace>, 
AtomicHalf]>;
-  defm : BuiltinAtomicExplicit<"atomic_load",
-  [Half, PointerType, addrspace>]>;
-  defm : BuiltinAtomicExplicit<"atomic_exchange",
-  [Half, PointerType, addrspace>, Half]>;
-}
+defvar extension = !cast("FuncExtFloatAtomicsFp16" # 
addrspace # "LoadStore");
+

maybe we can improve the name, so something like `extension_fp16`?

Same for below: `extension_fp16`, `extension_32`, `extension_64`?



Comment at: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl:84
 
+#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
+#define __opencl_c_atomic_order_seq_cst 1

Why do we need to set those for `__OPENCL_CPP_VERSION__ == 100` since those 
atomics are for OpenCL 2.0 onwards?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119420

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


[PATCH] D115031: [AST] Print NTTP args as string-literals when possible

2022-02-10 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 407464.
lichray added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115031

Files:
  clang/include/clang/AST/DeclTemplate.h
  clang/include/clang/AST/PrettyPrinter.h
  clang/include/clang/Basic/CharInfo.h
  clang/lib/AST/APValue.cpp
  clang/lib/AST/ASTDiagnostic.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/SemaCXX/cxx2a-nttp-printing.cpp
  clang/test/SemaTemplate/temp_arg_string_printing.cpp
  clang/unittests/AST/TypePrinterTest.cpp

Index: clang/unittests/AST/TypePrinterTest.cpp
===
--- clang/unittests/AST/TypePrinterTest.cpp
+++ clang/unittests/AST/TypePrinterTest.cpp
@@ -80,3 +80,34 @@
  varDecl(hasType(qualType().bind("id"))),
  "const f *", Clean));
 }
+
+TEST(TypePrinter, TemplateIdWithNTTP) {
+  constexpr char Code[] = R"cpp(
+template 
+struct Str {
+  constexpr Str(char const (&s)[N]) { __builtin_memcpy(value, s, N); }
+  char value[N];
+};
+template  class ASCII {};
+
+ASCII<"this nontype template argument is too long to print"> x;
+  )cpp";
+  auto Matcher = classTemplateSpecializationDecl(
+  hasName("ASCII"), has(cxxConstructorDecl(
+isMoveConstructor(),
+has(parmVarDecl(hasType(qualType().bind("id")));
+
+  ASSERT_TRUE(PrintedTypeMatches(
+  Code, {"-std=c++20"}, Matcher,
+  R"(ASCII<{"this nontype template argument is [...]"}> &&)",
+  [](PrintingPolicy &Policy) {
+Policy.EntireContentsOfLargeArray = false;
+  }));
+
+  ASSERT_TRUE(PrintedTypeMatches(
+  Code, {"-std=c++20"}, Matcher,
+  R"(ASCII<{"this nontype template argument is too long to print"}> &&)",
+  [](PrintingPolicy &Policy) {
+Policy.EntireContentsOfLargeArray = true;
+  }));
+}
Index: clang/test/SemaTemplate/temp_arg_string_printing.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/temp_arg_string_printing.cpp
@@ -0,0 +1,129 @@
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only -ast-print %s | FileCheck %s
+
+using size_t = __SIZE_TYPE__;
+static_assert(__has_builtin(__make_integer_seq));
+
+template  class idx_seq {};
+template  using make_idx_seq = __make_integer_seq;
+
+template 
+struct Str {
+  constexpr Str(CharT const (&s)[N]) : Str(s, make_idx_seq()) {}
+  CharT value[N];
+
+private:
+  template 
+  constexpr Str(CharT const (&s)[N], idx_seq) : value{s[I]...} {}
+};
+
+template  class ASCII {};
+
+void not_string() {
+  // CHECK{LITERAL}: ASCII<{{9, -1, 42}}>
+  new ASCII<(int[]){9, -1, 42}>;
+  // CHECK{LITERAL}: ASCII<{{3.14e+00, 0.00e+00, 4.20e+01}}>
+  new ASCII<(double[]){3.14, 0., 42.}>;
+}
+
+void narrow() {
+  // CHECK{LITERAL}: ASCII<{""}>
+  new ASCII<"">;
+  // CHECK{LITERAL}: ASCII<{"the quick brown fox jumps"}>
+  new ASCII<"the quick brown fox jumps">;
+  // CHECK{LITERAL}: ASCII<{"OVER THE LAZY DOG 0123456789"}>
+  new ASCII<"OVER THE LAZY DOG 0123456789">;
+  // CHECK{LITERAL}: ASCII<{"\\`~!@#$%^&*()_+-={}[]|\'\";:,.<>?/"}>
+  new ASCII?/)">;
+  // CHECK{LITERAL}: ASCII<{{101, 115, 99, 97, 112, 101, 0, 0}}>
+  new ASCII<"escape\0">;
+  // CHECK{LITERAL}: ASCII<{"escape\r\n"}>
+  new ASCII<"escape\r\n">;
+  // CHECK{LITERAL}: ASCII<{"escape\\\t\f\v"}>
+  new ASCII<"escape\\\t\f\v">;
+  // CHECK{LITERAL}: ASCII<{"escape\a\bc"}>
+  new ASCII<"escape\a\b\c">;
+  // CHECK{LITERAL}: ASCII<{{110, 111, 116, 17, 0}}>
+  new ASCII<"not\x11">;
+  // CHECK{LITERAL}: ASCII<{{18, 20, 127, 16, 1, 32, 97, 98, 99, 0}}>
+  new ASCII<"\x12\x14\x7f\x10\x01 abc">;
+  // CHECK{LITERAL}: ASCII<{{18, 20, 127, 16, 1, 32, 97, 98, 99, 100, 0}}>
+  new ASCII<"\x12\x14\x7f\x10\x01 abcd">;
+  // CHECK{LITERAL}: ASCII<{"print more characters as string"}>
+  new ASCII<"print more characters as string">;
+  // CHECK{LITERAL}: ASCII<{"print more characters as string, no uplimit"}>
+  new ASCII<"print more characters as string, no uplimit">;
+}
+
+void wide() {
+  // CHECK{LITERAL}: ASCII<{L""}>
+  new ASCII;
+  // CHECK{LITERAL}: ASCII<{L"the quick brown fox jumps"}>
+  new ASCII;
+  // CHECK{LITERAL}: ASCII<{L"OVER THE LAZY DOG 0123456789"}>
+  new ASCII;
+  // CHECK{LITERAL}: ASCII<{L"\\`~!@#$%^&*()_+-={}[]|\'\";:,.<>?/"}>
+  new ASCII?/)">;
+  // CHECK{LITERAL}: ASCII<{{101, 115, 99, 97, 112, 101, 0, 0}}>
+  new ASCII;
+  // CHECK{LITERAL}: ASCII<{L"escape\r\n"}>
+  new ASCII;
+  // CHECK{LITERAL}: ASCII<{L"escape\\\t\f\v"}>
+  new ASCII;
+  // CHECK{LITERAL}: ASCII<{L"escape\a\bc"}>
+  new ASCII;
+  // CHECK{LITERAL}: ASCII<{{110, 111, 116, 17, 0}}>
+  new ASCII;
+  // CHECK{LITERAL}: ASCII<{{18, 20, 255, 22909, 136, 32, 97, 98, 99, 0}}>
+

[PATCH] D119319: [AArch64] Emit TBAA metadata for SVE load/store intrinsics

2022-02-10 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm accepted this revision.
paulwalker-arm added a comment.
This revision is now accepted and ready to land.

I cannot say I fully understand all the connotations of this change but my gut 
feeling is that if failures occur it's likely the input program is malformed.  
Either way, we're early in the LLVM 15 development cycle so have plenty of time 
to react if necessary.




Comment at: llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp:888
   if (isAllActivePredicate(Pred)) {
-Builder.CreateStore(VecOp, VecPtr);
+auto *Store = Builder.CreateStore(VecOp, VecPtr);
+Store->copyMetadata(II);

If I'm nit picking you use `auto` here but then choose the explicit return type 
(i.e. `CallInst`) for the MaskedStore local. Is there a reason for this or just 
muscle memory?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119319

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


[PATCH] D119426: [C++20] [Modules] Check if modulemap exists to avoid crash in implicit used C++ module

2022-02-10 Thread Zezheng Li via Phabricator via cfe-commits
ZezhengLi created this revision.
ZezhengLi added reviewers: ChuanqiXu, rsmith, urnathan.
ZezhengLi added a project: clang.
ZezhengLi requested review of this revision.
Herald added a subscriber: cfe-commits.

An impilt used of module without prebuild path may cause crash.

For example:

  // ./dir1/C.cppm
  export module C;
  // ./dir2/B.cppm
  export module B;
  import C;
  // ./A.cpp
  import B;
  import C;

When we compile A.cpp without the prebuild path of C.pcm, the compiler will 
crash.

  clang++ -std=c++20 --precompile -c ./dir1/C.cppm -o dir1/C.pcm
  clang++ -std=c++20 --precompile -fprebuilt-module-path=./dir2  -c B.cppm -o 
B.pcm
  clang++ -std=c++20 -fprebuilt-module-path=./dir2 A.cpp

The prebuilt path of module C is cached when import module B, and in the 
function HeaderSearch::getCachedModuleFileName, the compiler try to get the 
filename by modulemap without check if modulemap exists,and there is no 
modulemap in C++ module.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119426

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/implicit-module-with-missing-path.cpp


Index: clang/test/Modules/implicit-module-with-missing-path.cpp
===
--- /dev/null
+++ clang/test/Modules/implicit-module-with-missing-path.cpp
@@ -0,0 +1,12 @@
+// This tests that the compiler wouldn't crash if the module path misses
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/subdir
+// RUN: echo "export module C;" >> %t/subdir/C.cppm
+// RUN: echo -e "export module B;\nimport C;" >> %t/B.cppm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/subdir/C.cppm -o 
%t/subdir/C.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface 
-fprebuilt-module-path=%t/subdir %t/B.cppm -o %t/B.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only 
-verify
+
+import B;
+import C; // expected-error {{module 'C' is needed but has not been provided, 
and implicit use of module files is disabled}}
\ No newline at end of file
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -172,6 +172,10 @@
 std::string HeaderSearch::getCachedModuleFileName(Module *Module) {
   const FileEntry *ModuleMap =
   getModuleMap().getModuleMapFileForUniquing(Module);
+  // The ModuleMap maybe a nullptr, when we load a cached C++ module without
+  // *.modulemap file. In this case, just return an empty string.
+  if (ModuleMap == nullptr)
+return {};
   return getCachedModuleFileName(Module->Name, ModuleMap->getName());
 }
 


Index: clang/test/Modules/implicit-module-with-missing-path.cpp
===
--- /dev/null
+++ clang/test/Modules/implicit-module-with-missing-path.cpp
@@ -0,0 +1,12 @@
+// This tests that the compiler wouldn't crash if the module path misses
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/subdir
+// RUN: echo "export module C;" >> %t/subdir/C.cppm
+// RUN: echo -e "export module B;\nimport C;" >> %t/B.cppm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/subdir/C.cppm -o %t/subdir/C.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t/subdir %t/B.cppm -o %t/B.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only -verify
+
+import B;
+import C; // expected-error {{module 'C' is needed but has not been provided, and implicit use of module files is disabled}}
\ No newline at end of file
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -172,6 +172,10 @@
 std::string HeaderSearch::getCachedModuleFileName(Module *Module) {
   const FileEntry *ModuleMap =
   getModuleMap().getModuleMapFileForUniquing(Module);
+  // The ModuleMap maybe a nullptr, when we load a cached C++ module without
+  // *.modulemap file. In this case, just return an empty string.
+  if (ModuleMap == nullptr)
+return {};
   return getCachedModuleFileName(Module->Name, ModuleMap->getName());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119426: [C++20] [Modules] Check if modulemap exists to avoid crash in implicit used C++ module

2022-02-10 Thread Zezheng Li via Phabricator via cfe-commits
ZezhengLi updated this revision to Diff 407466.
ZezhengLi added a comment.

Add endline.


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

https://reviews.llvm.org/D119426

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/implicit-module-with-missing-path.cpp


Index: clang/test/Modules/implicit-module-with-missing-path.cpp
===
--- /dev/null
+++ clang/test/Modules/implicit-module-with-missing-path.cpp
@@ -0,0 +1,12 @@
+// This tests that the compiler wouldn't crash if the module path misses
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/subdir
+// RUN: echo "export module C;" >> %t/subdir/C.cppm
+// RUN: echo -e "export module B;\nimport C;" >> %t/B.cppm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/subdir/C.cppm -o 
%t/subdir/C.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface 
-fprebuilt-module-path=%t/subdir %t/B.cppm -o %t/B.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only 
-verify
+
+import B;
+import C; // expected-error {{module 'C' is needed but has not been provided, 
and implicit use of module files is disabled}}
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -172,6 +172,10 @@
 std::string HeaderSearch::getCachedModuleFileName(Module *Module) {
   const FileEntry *ModuleMap =
   getModuleMap().getModuleMapFileForUniquing(Module);
+  // The ModuleMap maybe a nullptr, when we load a cached C++ module without
+  // *.modulemap file. In this case, just return an empty string.
+  if (ModuleMap == nullptr)
+return {};
   return getCachedModuleFileName(Module->Name, ModuleMap->getName());
 }
 


Index: clang/test/Modules/implicit-module-with-missing-path.cpp
===
--- /dev/null
+++ clang/test/Modules/implicit-module-with-missing-path.cpp
@@ -0,0 +1,12 @@
+// This tests that the compiler wouldn't crash if the module path misses
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/subdir
+// RUN: echo "export module C;" >> %t/subdir/C.cppm
+// RUN: echo -e "export module B;\nimport C;" >> %t/B.cppm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/subdir/C.cppm -o %t/subdir/C.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fprebuilt-module-path=%t/subdir %t/B.cppm -o %t/B.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %s -fsyntax-only -verify
+
+import B;
+import C; // expected-error {{module 'C' is needed but has not been provided, and implicit use of module files is disabled}}
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -172,6 +172,10 @@
 std::string HeaderSearch::getCachedModuleFileName(Module *Module) {
   const FileEntry *ModuleMap =
   getModuleMap().getModuleMapFileForUniquing(Module);
+  // The ModuleMap maybe a nullptr, when we load a cached C++ module without
+  // *.modulemap file. In this case, just return an empty string.
+  if (ModuleMap == nullptr)
+return {};
   return getCachedModuleFileName(Module->Name, ModuleMap->getName());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119405: [Clang][Sema] Use C++ standard terminology in clang diagnostics.

2022-02-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Thank you for the patch!

I don't think this is an improvement; the diagnostic text goes from being 
correct in C but odd in C++ to being correct in C++ but odd in C (the two 
standards use different terminology). We're already inconsistent with which we 
prefer (we have diagnostics that use `literal` and others that use `constant`), 
and perhaps it'd make sense to start using `%select{constant|literal}N` in the 
individual diagnostics to switch the wording based on the current language 
mode. That said, I don't know that there's a ton of value in that change (it 
seems unlikely that anyone is actually confused what the diagnostic is saying 
today).

Also, this changes the text of a diagnostic but doesn't update any tests, so 
precommit CI is failing. :-)

Before changing things in this review, I think we should go back to the bug 
report to find out why the request was made and what issues there are with the 
diagnostic. If it's a matter of "wrong terminology in a language mode", I'm of 
the opinion that's not really an issue in this particular case (unless there's 
other confusion that's caused by the terminology). I'll start the discussion 
there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119405

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


[PATCH] D72404: [ThinLTO/FullLTO] Support Os and Oz

2022-02-10 Thread Ayke via Phabricator via cfe-commits
aykevl added a comment.

@mehdi_amini thanks for explaining! D119342  
moves slightly closer to removing SizeLevel from the pass pipeline setup.

---

In other news, I found a workaround that can be used to avoid the size increase 
due to LoopRotate (until D119342  is merged). 
Basically, just pass the flags `-mllvm --rotation-max-header-size=0` to ld.lld 
when compiling with `-Oz`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72404

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


[PATCH] D119405: [Clang][Sema] Use C++ standard terminology in clang diagnostics.

2022-02-10 Thread Jun Zhang via Phabricator via cfe-commits
junaire added a comment.

In D119405#3310695 , @aaron.ballman 
wrote:

> Thank you for the patch!
>
> I don't think this is an improvement; the diagnostic text goes from being 
> correct in C but odd in C++ to being correct in C++ but odd in C (the two 
> standards use different terminology). We're already inconsistent with which 
> we prefer (we have diagnostics that use `literal` and others that use 
> `constant`), and perhaps it'd make sense to start using 
> `%select{constant|literal}N` in the individual diagnostics to switch the 
> wording based on the current language mode. That said, I don't know that 
> there's a ton of value in that change (it seems unlikely that anyone is 
> actually confused what the diagnostic is saying today).

Thanks for spending your valuable time reviewing this! I think your words make 
sense. And I wonder if the patch is rejected, what should I do? I mean does 
phabricator have something like close PR in github?

> Also, this changes the text of a diagnostic but doesn't update any tests, so 
> precommit CI is failing. :-)

Well, I already run `ninja check-clang` locally to make sure it doesn't break 
anything, and I didn't find any tests are falling in the CI, so I guess maybe 
the CI is just not stable enough?

> Before changing things in this review, I think we should go back to the bug 
> report to find out why the request was made and what issues there are with 
> the diagnostic. If it's a matter of "wrong terminology in a language mode", 
> I'm of the opinion that's not really an issue in this particular case (unless 
> there's other confusion that's caused by the terminology). I'll start the 
> discussion there.

Good point! thanks for telling me about how the community works, I'm still 
learning :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119405

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


[PATCH] D110485: Support [[no_unique_address]] for all targets.

2022-02-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D110485#3308878 , @mstorsjo wrote:

> In D110485#3308854 , @mstorsjo 
> wrote:
>
>> To pick up the thread here again, `[[no_unique_address]]` is done and 
>> settled in MSVC, with the slightly surprising semantics: 
>> `[[no_unique_address]]` is accepted, without any warning (in C++20 mode), 
>> but it has no effect. (This, not related to LLVM, but because they had 
>> shipped it in earlier versions without having an effect, and changing that 
>> later would break things.) `[[msvc::no_unique_address]]` does have an effect 
>> though. See 
>> https://github.com/microsoft/STL/issues/1364#issuecomment-1034167093 for a 
>> more authoritative source on that.
>>
>> So, separately from implementing `[[msvc::no_unique_address]]`, I think we 
>> also should also silence the current warning about unknown attribute for the 
>> standard `[[no_unique_address]]`, to match MSVC.
>
> Oh, also, according to 
> https://devblogs.microsoft.com/cppblog/msvc-cpp20-and-the-std-cpp20-switch/, 
> the plan is to change `[[no_unique_address]]` to actually have an effect the 
> next time the compiler breaks its C++ ABI at an unknown point in the future. 
> (This shouldn't be an issue for Clang, as we'd have to make a conscious 
> effort to implement the new ABI whenever that happens anyway.)

Thanks for the update! I'll have to think about the appropriate way forward 
here a bit more. We have a rule with attributes to issue an "attribute ignored" 
warning for any attribute that isn't accepted by Clang, and we typically extend 
that to attributes which are accepted by Clang but have no impact in a way the 
user may be surprised by (e.g., if they write it on the wrong construct, we 
don't silently eat the attribute, we warn the user that the attribute is being 
ignored). So my initial thinking is, have an on-by-default diagnostic (grouped 
separately under the ignored attributes warning flag) about a standard 
attribute being accepted and purposefully ignored that's only used for 
`[[no_unique_address]]` in MS compatibility mode (for now, we may get more such 
attributes in the future). Then users get a different warning than they do 
today, and they can control it separately from `-Wignored-attributes`. I think 
still having a diagnostic is useful for some class of users (but not all). 
People who only care about compatibility with MSVC likely want the warning off 
by default, while people who care about compatibility outside of MSVC likely 
want the warning on by default. Given the security implications of ignoring the 
attribute, I think erring on the side of caution and warning by default is 
appropriate (this is a standard attribute, not a vendor one, so users are 
understandably going to expect the attribute to do something if they've used it 
correctly according to the standard; silencing it is a minor burden that will 
not impact other kinds of ignored attributes). The fact that MS intends to 
support the attribute in the future (which breaks ABI) is all the more reason 
why I think we should warn by default; Clang users shouldn't be caught off 
guard when MSVC eventually breaks their ABI.


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

https://reviews.llvm.org/D110485

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


[PATCH] D119398: [OpenCL] Guard atomic_double with cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics

2022-02-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks

This might interfere with https://reviews.llvm.org/D119420


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119398

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


[clang] 815446c - [clang][NFC] Standard substitution checking cleanup

2022-02-10 Thread Nathan Sidwell via cfe-commits

Author: Nathan Sidwell
Date: 2022-02-10T04:44:48-08:00
New Revision: 815446cd3e164b8be010864648d4104ad178b129

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

LOG: [clang][NFC] Standard substitution checking cleanup

In preparing for module mangling changes I noticed some issues with
the way we check for std::basic_string instantiations and friends.

*) there's a single routine for std::basic_{i,o,io}stream but it is
 templatized on the length of the name.  Really?  just use a
 StringRef, rather than clone the entire routine just for
 'basic_iostream'.

*) We have a helper routine to check for char type, and call it from
 several places.  But given all the instantiations are of the form
 TPL ...> we could just check the first arg is char
 and the later templated args are instantiating that same type.  A
 simpler type comparison.

*) Because basic_string has a third allocator parameter, it is open
 coded, which I found a little confusing.  But otherwise it's exactly
 the same pattern as the iostream ones.  Just tell that checker about
 whether there's an expected allocator argument.[*]

*) We may as well return in each block of mangleStandardSubstitution
 once we determine it is not one of the entities of interest -- it
 certainly cannot be one of the other kinds of entities.

FWIW this shaves about 500 bytes off the executable.

[*] I suppose we could also have this routine a tri-value, with one to
indicat 'it is this name, but it's not the one you're looking for', to
avoid later calls trying different names?

Reviewd By: ChuanqiXu

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

Added: 


Modified: 
clang/lib/AST/ItaniumMangle.cpp

Removed: 




diff  --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index 2e734e2b28cdb..b15669d426bd6 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -5969,27 +5969,19 @@ bool CXXNameMangler::mangleSubstitution(uintptr_t Ptr) {
   return true;
 }
 
-static bool isCharType(QualType T) {
-  if (T.isNull())
+/// Returns whether S is a template specialization of std::Name with a single
+/// argument of type A.
+static bool isSpecializedAs(QualType S, llvm::StringRef Name, QualType A) {
+  if (S.isNull())
 return false;
 
-  return T->isSpecificBuiltinType(BuiltinType::Char_S) ||
-T->isSpecificBuiltinType(BuiltinType::Char_U);
-}
-
-/// Returns whether a given type is a template specialization of a given name
-/// with a single argument of type char.
-static bool isCharSpecialization(QualType T, const char *Name) {
-  if (T.isNull())
-return false;
-
-  const RecordType *RT = T->getAs();
+  const RecordType *RT = S->getAs();
   if (!RT)
 return false;
 
   const ClassTemplateSpecializationDecl *SD =
 dyn_cast(RT->getDecl());
-  if (!SD)
+  if (!SD || !SD->getIdentifier()->isStr(Name))
 return false;
 
   if (!isStdNamespace(getEffectiveDeclContext(SD)))
@@ -5999,26 +5991,37 @@ static bool isCharSpecialization(QualType T, const char 
*Name) {
   if (TemplateArgs.size() != 1)
 return false;
 
-  if (!isCharType(TemplateArgs[0].getAsType()))
+  if (TemplateArgs[0].getAsType() != A)
 return false;
 
-  return SD->getIdentifier()->getName() == Name;
+  return true;
 }
 
-template 
-static bool isStreamCharSpecialization(const 
ClassTemplateSpecializationDecl*SD,
-   const char (&Str)[StrLen]) {
-  if (!SD->getIdentifier()->isStr(Str))
+/// Returns whether SD is a template specialization std::Name [, std::allocator]>
+/// HasAllocator controls whether the 3rd template argument is needed.
+static bool isStdCharSpecialization(const ClassTemplateSpecializationDecl *SD,
+llvm::StringRef Name, bool HasAllocator) {
+  if (!SD->getIdentifier()->isStr(Name))
 return false;
 
   const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs();
-  if (TemplateArgs.size() != 2)
+  if (TemplateArgs.size() != (HasAllocator ? 3 : 2))
 return false;
 
-  if (!isCharType(TemplateArgs[0].getAsType()))
+  QualType A = TemplateArgs[0].getAsType();
+  if (A.isNull())
+return false;
+  // Plain 'char' is named Char_S or Char_U depending on the target ABI.
+  if (!A->isSpecificBuiltinType(BuiltinType::Char_S) &&
+  !A->isSpecificBuiltinType(BuiltinType::Char_U))
 return false;
 
-  if (!isCharSpecialization(TemplateArgs[1].getAsType(), "char_traits"))
+  if (!isSpecializedAs(TemplateArgs[1].getAsType(), "char_traits", A))
+return false;
+
+  if (HasAllocator &&
+  !isSpecializedAs(TemplateArgs[2].getAsType(), "allocator", A))
 return false;
 
   return true;
@@ -6031,6 +6034,7 @@ bool CXXNameMangler::mangleStandardSubstitution(const 
NamedDecl *ND) {
   Out << "St";

[PATCH] D119333: [clang][NFC] Standard substitution checking cleanup

2022-02-10 Thread Nathan Sidwell via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
urnathan marked an inline comment as done.
Closed by commit rG815446cd3e16: [clang][NFC] Standard substitution checking 
cleanup (authored by urnathan).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Changed prior to commit:
  https://reviews.llvm.org/D119333?vs=407142&id=407475#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119333

Files:
  clang/lib/AST/ItaniumMangle.cpp

Index: clang/lib/AST/ItaniumMangle.cpp
===
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -5969,27 +5969,19 @@
   return true;
 }
 
-static bool isCharType(QualType T) {
-  if (T.isNull())
+/// Returns whether S is a template specialization of std::Name with a single
+/// argument of type A.
+static bool isSpecializedAs(QualType S, llvm::StringRef Name, QualType A) {
+  if (S.isNull())
 return false;
 
-  return T->isSpecificBuiltinType(BuiltinType::Char_S) ||
-T->isSpecificBuiltinType(BuiltinType::Char_U);
-}
-
-/// Returns whether a given type is a template specialization of a given name
-/// with a single argument of type char.
-static bool isCharSpecialization(QualType T, const char *Name) {
-  if (T.isNull())
-return false;
-
-  const RecordType *RT = T->getAs();
+  const RecordType *RT = S->getAs();
   if (!RT)
 return false;
 
   const ClassTemplateSpecializationDecl *SD =
 dyn_cast(RT->getDecl());
-  if (!SD)
+  if (!SD || !SD->getIdentifier()->isStr(Name))
 return false;
 
   if (!isStdNamespace(getEffectiveDeclContext(SD)))
@@ -5999,26 +5991,37 @@
   if (TemplateArgs.size() != 1)
 return false;
 
-  if (!isCharType(TemplateArgs[0].getAsType()))
+  if (TemplateArgs[0].getAsType() != A)
 return false;
 
-  return SD->getIdentifier()->getName() == Name;
+  return true;
 }
 
-template 
-static bool isStreamCharSpecialization(const ClassTemplateSpecializationDecl*SD,
-   const char (&Str)[StrLen]) {
-  if (!SD->getIdentifier()->isStr(Str))
+/// Returns whether SD is a template specialization std::Name [, std::allocator]>
+/// HasAllocator controls whether the 3rd template argument is needed.
+static bool isStdCharSpecialization(const ClassTemplateSpecializationDecl *SD,
+llvm::StringRef Name, bool HasAllocator) {
+  if (!SD->getIdentifier()->isStr(Name))
 return false;
 
   const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs();
-  if (TemplateArgs.size() != 2)
+  if (TemplateArgs.size() != (HasAllocator ? 3 : 2))
 return false;
 
-  if (!isCharType(TemplateArgs[0].getAsType()))
+  QualType A = TemplateArgs[0].getAsType();
+  if (A.isNull())
+return false;
+  // Plain 'char' is named Char_S or Char_U depending on the target ABI.
+  if (!A->isSpecificBuiltinType(BuiltinType::Char_S) &&
+  !A->isSpecificBuiltinType(BuiltinType::Char_U))
 return false;
 
-  if (!isCharSpecialization(TemplateArgs[1].getAsType(), "char_traits"))
+  if (!isSpecializedAs(TemplateArgs[1].getAsType(), "char_traits", A))
+return false;
+
+  if (HasAllocator &&
+  !isSpecializedAs(TemplateArgs[2].getAsType(), "allocator", A))
 return false;
 
   return true;
@@ -6031,6 +6034,7 @@
   Out << "St";
   return true;
 }
+return false;
   }
 
   if (const ClassTemplateDecl *TD = dyn_cast(ND)) {
@@ -6048,6 +6052,7 @@
   Out << "Sb";
   return true;
 }
+return false;
   }
 
   if (const ClassTemplateSpecializationDecl *SD =
@@ -6058,46 +6063,34 @@
 // ::= Ss # ::std::basic_string,
 //::std::allocator >
-if (SD->getIdentifier()->isStr("basic_string")) {
-  const TemplateArgumentList &TemplateArgs = SD->getTemplateArgs();
-
-  if (TemplateArgs.size() != 3)
-return false;
-
-  if (!isCharType(TemplateArgs[0].getAsType()))
-return false;
-
-  if (!isCharSpecialization(TemplateArgs[1].getAsType(), "char_traits"))
-return false;
-
-  if (!isCharSpecialization(TemplateArgs[2].getAsType(), "allocator"))
-return false;
-
+if (isStdCharSpecialization(SD, "basic_string", /*HasAllocator=*/true)) {
   Out << "Ss";
   return true;
 }
 
 // ::= Si # ::std::basic_istream >
-if (isStreamCharSpecialization(SD, "basic_istream")) {
+if (isStdCharSpecialization(SD, "basic_istream", /*HasAllocator=*/false)) {
   Out << "Si";
   return true;
 }
 
 // ::= So # ::std::basic_ostream >
-if (isStreamCharSpecialization(SD, "basic_ostream")) {
+if (isStdCharSpecialization(SD, "basic_ostream", /*HasAllocator=*/false)) {
   Out << "So";
   return true;
 }
 
 // ::= Sd # ::std::basic_iostream >
-if (isStreamCharSpecialization(SD, "basic_iostream")) {
+if (isStdCharSpeci

[PATCH] D119398: [OpenCL] Guard atomic_double with cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics

2022-02-10 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

In D119398#3310746 , @Anastasia wrote:

> This might interfere with https://reviews.llvm.org/D119420

Yes it will conflict.

Atomic doubles are not guarded properly for other builtins (outside of the 
`cl_ext_float_atomics` extensions) either, and I have a different solution in 
mind to solve it for all uses and extensions.  So we could leave out the .td 
changes from this patch and only merge the `opencl-c.h` changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119398

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2022-02-10 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 407482.
achieveartificialintelligence marked 2 inline comments as done.
achieveartificialintelligence added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

Files:
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfoD.td
  llvm/lib/Target/RISCV/RISCVInstrInfoF.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZfh.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-invalid.s
  llvm/test/MC/RISCV/rv32zdinx-valid.s
  llvm/test/MC/RISCV/rv32zfinx-invalid.s
  llvm/test/MC/RISCV/rv32zfinx-valid.s
  llvm/test/MC/RISCV/rv32zhinx-invalid.s
  llvm/test/MC/RISCV/rv32zhinx-valid.s
  llvm/test/MC/RISCV/rv32zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv32zhinxmin-valid.s
  llvm/test/MC/RISCV/rv64zdinx-invalid.s
  llvm/test/MC/RISCV/rv64zdinx-valid.s
  llvm/test/MC/RISCV/rv64zfinx-invalid.s
  llvm/test/MC/RISCV/rv64zfinx-valid.s
  llvm/test/MC/RISCV/rv64zhinx-invalid.s
  llvm/test/MC/RISCV/rv64zhinx-valid.s
  llvm/test/MC/RISCV/rv64zhinxmin-invalid.s
  llvm/test/MC/RISCV/rv64zhinxmin-valid.s
  llvm/test/MC/RISCV/rvzdinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzfinx-aliases-valid.s
  llvm/test/MC/RISCV/rvzhinx-aliases-valid.s

Index: llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzhinx-aliases-valid.s
@@ -0,0 +1,82 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zhinx -riscv-no-aliases \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zhinx \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx -M no-aliases - \
+# RUN: | FileCheck -check-prefix=CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+zhinx %s \
+# RUN: | llvm-objdump -d --mattr=+zhinx - \
+# RUN: | FileCheck -check-prefix=CHECK-ALIAS %s
+
+##===--===##
+## Assembler Pseudo Instructions (User-Level ISA, Version 2.2, Chapter 20)
+##===--===##
+
+# CHECK-INST: fsgnjx.h s1, s2, s2
+# CHECK-ALIAS: fabs.h s1, s2
+fabs.h s1, s2
+# CHECK-INST: fsgnjn.h s2, s3, s3
+# CHECK-ALIAS: fneg.h s2, s3
+fneg.h s2, s3
+
+# CHECK-INST: flt.h tp, s6, s5
+# CHECK-ALIAS: flt.h tp, s6, s5
+fgt.h x4, s5, s6
+# CHECK-INST: fle.h t2, s1, s0
+# CHECK-ALIAS: fle.h t2, s1, s0
+fge.h x7, x8, x9
+
+##===--===##
+## Aliases which omit the rounding mode.
+##===--===##
+
+# CHECK-INST: fmadd.h a0, a1, a2, a3, dyn
+# CHECK-ALIAS: fmadd.h a0, a1, a2, a3
+fmadd.h x10, x11, x12, x13
+# CHECK-INST: fmsub.h a4, a5, a6, a7, dyn
+# CHECK-ALIAS: fmsub.h a4, a5, a6, a7
+fmsub.h x14, x15, x16, x17
+# CHECK-INST: fnmsub.h s2, s3, s4, s5, dyn
+# CHECK-ALIAS: fnmsub.h s2, s3, s4, s5
+fnmsub.h x18, x19, x20, x21
+# CHECK-INST: fnmadd.h s6, s7, s8, s9, dyn
+# CHECK-ALIAS: fnmadd.h s6, s7, s8, s9
+fnmadd.h x22, x23, x24, x25
+# CHECK-INST: fadd.h s10, s11, t3, dyn
+# CHECK-ALIAS: fadd.h s10, s11, t3
+fadd.h x26, x27, x28
+# CHECK-INST: fsub.h t4, t5, t6, dyn
+# CHECK-ALIAS: fsub.h t4, t5, t6
+fsub.h x29, x30, x31
+# CHECK-INST: fmul.h s0, s1, s2, dyn
+# CHECK-ALIAS: fmul.h s0, s1, s2
+fmul.h s0, s1, s2
+# CHECK-INST: fdiv.h s3, s4, s5, dyn
+# CHECK-ALIAS: fdiv.h s3, s4, s5
+fdiv.h s3, s4, s5
+# CHECK-INST: fsqrt.h s6, s7, dyn
+# CHECK-ALIAS: fsqrt.h s6, s7
+fsqrt.h s6, s7
+# CHECK-INST: fcvt.w.h a0, s5, dyn
+# CHECK-ALIAS: fcvt.w.h a0, s5
+fcvt.w.h a0, s5
+# CHECK-INST: fcvt.wu.h a1, s6, dyn
+# CHECK-ALIAS: fcvt.wu.h a1, s6
+fcvt.wu.h a1, s6
+# CHECK-INST: fcvt.h.w t6, a4, dyn
+# CHECK-ALIAS: fcvt.h.w t6, a4
+fcvt.h.w t6, a4
+# CHECK-INST: fcvt.h.wu s0, a5, dyn
+# CHECK-ALIAS: fcvt.h.wu s0, a5
+fcvt.h.wu s0, a5
Index: llvm/test/MC/RIS

[PATCH] D119420: [OpenCL] Add OpenCL 3.0 atomics to -fdeclare-opencl-builtins

2022-02-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! The rename can be made on commit.




Comment at: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl:84
 
+#if (__OPENCL_CPP_VERSION__ == 100 || __OPENCL_C_VERSION__ == 200)
+#define __opencl_c_atomic_order_seq_cst 1

Anastasia wrote:
> Why do we need to set those for `__OPENCL_CPP_VERSION__ == 100` since those 
> atomics are for OpenCL 2.0 onwards?
Sorry C++ for OpenCL is aligned with OpenCL 2, so this check makes sense.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119420

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


[PATCH] D119405: [Clang][Sema] Use C++ standard terminology in clang diagnostics.

2022-02-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D119405#3310711 , @junaire wrote:

> In D119405#3310695 , @aaron.ballman 
> wrote:
>
>> Thank you for the patch!
>>
>> I don't think this is an improvement; the diagnostic text goes from being 
>> correct in C but odd in C++ to being correct in C++ but odd in C (the two 
>> standards use different terminology). We're already inconsistent with which 
>> we prefer (we have diagnostics that use `literal` and others that use 
>> `constant`), and perhaps it'd make sense to start using 
>> `%select{constant|literal}N` in the individual diagnostics to switch the 
>> wording based on the current language mode. That said, I don't know that 
>> there's a ton of value in that change (it seems unlikely that anyone is 
>> actually confused what the diagnostic is saying today).
>
> Thanks for spending your valuable time reviewing this! I think your words 
> make sense. And I wonder if the patch is rejected, what should I do? I mean 
> does phabricator have something like close PR in github?

I'm very happy to help! I really appreciate the patch; I see it was marked as a 
good first issue patch, so I'm sorry for the back-and-forth.

If we decide not to go forward, Phabricator has an "Abandon Revision" option 
under the "Add Action" drop-down menu. I'd say let's leave the patch open until 
the discussion on GitHub concludes, just in case.

>> Also, this changes the text of a diagnostic but doesn't update any tests, so 
>> precommit CI is failing. :-)
>
> Well, I already run `ninja check-clang` locally to make sure it doesn't break 
> anything, and I didn't find any tests are falling in the CI, so I guess maybe 
> the CI is just not stable enough?

Oh no! I see now that the precommit CI pipeline never ran the Clang tests 
because the build failed for unrelated reasons. So yeah, our CI wasn't very 
stable. I took a deeper look and we are lacking any test coverage for these 
diagnostic in the test suite, which is unfortunate. If you are looking for a 
good first issue, that might actually be a great one to tackle -- you could add 
a new test case in `clang/test/Sema/` named `float-constants.c` (or something 
along those lines) to add new test cases for both of those diagnostics. Then 
we'd have test coverage for the diagnostic to help us catch regressions in 
behavior. (You get bonus points for covering the different kinds of 
floating-point literals, like hexadecimal floats, and testing edge cases vs 
extreme cases vs normal cases, etc.)

>> Before changing things in this review, I think we should go back to the bug 
>> report to find out why the request was made and what issues there are with 
>> the diagnostic. If it's a matter of "wrong terminology in a language mode", 
>> I'm of the opinion that's not really an issue in this particular case 
>> (unless there's other confusion that's caused by the terminology). I'll 
>> start the discussion there.
>
> Good point! thanks for telling me about how the community works, I'm still 
> learning :-)

Welcome to the community -- there's a lot to learn, but we're happy to help you 
learn it!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119405

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


[PATCH] D93298: [RISCV] add the MC layer support of Zfinx extension

2022-02-10 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence added inline comments.



Comment at: llvm/lib/Target/RISCV/RISCVRegisterInfo.td:555
+def GPRF64  : RegisterClass<"RISCV", [f64], 64, (add GPR)>;
+def GPRPF64 : RegisterClass<"RISCV", [f64], 64, (add
+X10_PD, X12_PD, X14_PD, X16_PD,

craig.topper wrote:
> Jim wrote:
> > Is XLenRI correct for GPRPF64? RV32 has size 32.
> I'm not sure the RegInfos are correct for the other classes either. The 
> RegInfos override the register size, the spill size, and spill alignment. I 
> think those should all be based on the FP type.
> 
> So I don't think any of these should have a RegInfos.
Without `RegInfo`, it would cause `spill size` to be changed for a large number 
of other tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93298

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


[clang-tools-extra] d038fae - [clang-tidy] add option performance-move-const-arg.CheckMoveToConstRef

2022-02-10 Thread Yitzhak Mandelbaum via cfe-commits

Author: Greg Miller
Date: 2022-02-10T13:31:07Z
New Revision: d038faea4608f8f39602fb557666281c49de5722

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

LOG: [clang-tidy] add option performance-move-const-arg.CheckMoveToConstRef

This option allows callers to disable the warning from
https://clang.llvm.org/extra/clang-tidy/checks/performance-move-const-arg.html
that would warn on the following

```
void f(const string &s);
string s;
f(std::move(s));  // ALLOWED if 
performance-move-const-arg.CheckMoveToConstRef=false
```

The reason people might want to disable this check, is because it allows
callers to use `std::move()` or not based on local reasoning about the
argument, and without having to care about how the function `f` accepts
the argument. Indeed, `f` might accept the argument by const-ref today,
but change to by-value tomorrow, and if the caller had moved the
argument that they were finished with, the code would work as
efficiently as possible regardless of how `f` accepted the parameter.

Reviewed By: ymandel

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

Added: 

clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg-const-ref.cpp

Modified: 
clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
index 6e7d28b2974f..9a9c915d0296 100644
--- a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
+++ b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
@@ -37,6 +37,7 @@ static void replaceCallWithArg(const CallExpr *Call, 
DiagnosticBuilder &Diag,
 
 void MoveConstArgCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
   Options.store(Opts, "CheckTriviallyCopyableMove", 
CheckTriviallyCopyableMove);
+  Options.store(Opts, "CheckMoveToConstRef", CheckMoveToConstRef);
 }
 
 void MoveConstArgCheck::registerMatchers(MatchFinder *Finder) {
@@ -193,7 +194,7 @@ void MoveConstArgCheck::check(const 
MatchFinder::MatchResult &Result) {
   << (InvocationParm->getFunctionScopeIndex() + 1) << FunctionName
   << *InvocationParmType << ExpectParmTypeName;
 }
-  } else if (ReceivingExpr) {
+  } else if (ReceivingExpr && CheckMoveToConstRef) {
 if ((*InvocationParmType)->isRValueReferenceType())
   return;
 

diff  --git a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h 
b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
index 4a93e4c306e3..e10284750272 100644
--- a/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
+++ b/clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
@@ -18,16 +18,18 @@ namespace performance {
 
 /// Find casts of calculation results to bigger type. Typically from int to
 ///
-/// There is one option:
+/// The options are
 ///
 ///   - `CheckTriviallyCopyableMove`: Whether to check for trivially-copyable
 //  types as their objects are not moved but copied. Enabled by default.
+//- `CheckMoveToConstRef`: Whether to check if a `std::move()` is passed
+//  as a const reference argument.
 class MoveConstArgCheck : public ClangTidyCheck {
 public:
   MoveConstArgCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context),
-CheckTriviallyCopyableMove(
-Options.get("CheckTriviallyCopyableMove", true)) {}
+  : ClangTidyCheck(Name, Context), CheckTriviallyCopyableMove(Options.get(
+   "CheckTriviallyCopyableMove", 
true)),
+CheckMoveToConstRef(Options.get("CheckMoveToConstRef", true)) {}
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
 return LangOpts.CPlusPlus;
   }
@@ -37,6 +39,7 @@ class MoveConstArgCheck : public ClangTidyCheck {
 
 private:
   const bool CheckTriviallyCopyableMove;
+  const bool CheckMoveToConstRef;
   llvm::DenseSet AlreadyCheckedMoves;
 };
 

diff  --git 
a/clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst 
b/clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst
index a8ec18d99c27..4bdd153a290d 100644
--- a/clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst
+++ b/clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst
@@ -35,3 +35,8 @@ Options
 
If `true`, enables detection of trivially copyable types that do not
have a move constructor. Default is `true`.
+
+.. option:: CheckMoveToConstRef
+
+   If `true`, enables detection of `std::move()` passed as a const
+   reference argument. Default is `t

[PATCH] D119370: [clang-tidy] add option performance-move-const-arg.CheckMoveToConstRef

2022-02-10 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd038faea4608: [clang-tidy] add option 
performance-move-const-arg.CheckMoveToConstRef (authored by devjgm, committed 
by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119370

Files:
  clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
  clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
  clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg-const-ref.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg-const-ref.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-move-const-arg-const-ref.cpp
@@ -0,0 +1,80 @@
+// RUN: %check_clang_tidy %s performance-move-const-arg %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: performance-move-const-arg.CheckMoveToConstRef, value: false}]}'
+
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &> {
+  typedef _Tp type;
+};
+
+template 
+struct remove_reference<_Tp &&> {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) {
+  return static_cast::type &&>(__t);
+}
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept {
+  return static_cast<_Tp &&>(__t);
+}
+
+} // namespace std
+
+struct TriviallyCopyable {
+  int i;
+};
+
+void f(TriviallyCopyable) {}
+
+void g() {
+  TriviallyCopyable obj;
+  // Some basic test to ensure that other warnings from
+  // performance-move-const-arg are still working and enabled.
+  f(std::move(obj));
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: std::move of the variable 'obj' of the trivially-copyable type 'TriviallyCopyable' has no effect; remove std::move() [performance-move-const-arg]
+  // CHECK-FIXES: f(obj);
+}
+
+class NoMoveSemantics {
+public:
+  NoMoveSemantics();
+  NoMoveSemantics(const NoMoveSemantics &);
+  NoMoveSemantics &operator=(const NoMoveSemantics &);
+};
+
+class MoveSemantics {
+public:
+  MoveSemantics();
+  MoveSemantics(MoveSemantics &&);
+
+  MoveSemantics &operator=(MoveSemantics &&);
+};
+
+void callByConstRef1(const NoMoveSemantics &);
+void callByConstRef2(const MoveSemantics &);
+
+void moveToConstReferencePositives() {
+  NoMoveSemantics a;
+
+  // This call is now allowed since CheckMoveToConstRef is false.
+  callByConstRef1(std::move(a));
+
+  MoveSemantics b;
+
+  // This call is now allowed since CheckMoveToConstRef is false.
+  callByConstRef2(std::move(b));
+}
Index: clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst
+++ clang-tools-extra/docs/clang-tidy/checks/performance-move-const-arg.rst
@@ -35,3 +35,8 @@
 
If `true`, enables detection of trivially copyable types that do not
have a move constructor. Default is `true`.
+
+.. option:: CheckMoveToConstRef
+
+   If `true`, enables detection of `std::move()` passed as a const
+   reference argument. Default is `true`.
Index: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
===
--- clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
+++ clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.h
@@ -18,16 +18,18 @@
 
 /// Find casts of calculation results to bigger type. Typically from int to
 ///
-/// There is one option:
+/// The options are
 ///
 ///   - `CheckTriviallyCopyableMove`: Whether to check for trivially-copyable
 //  types as their objects are not moved but copied. Enabled by default.
+//- `CheckMoveToConstRef`: Whether to check if a `std::move()` is passed
+//  as a const reference argument.
 class MoveConstArgCheck : public ClangTidyCheck {
 public:
   MoveConstArgCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context),
-CheckTriviallyCopyableMove(
-Options.get("CheckTriviallyCopyableMove", true)) {}
+  : ClangTidyCheck(Name, Context), CheckTriviallyCopyableMove(Options.get(
+   "CheckTriviallyCopyableMove", true)),
+CheckMoveToConstRef(Options.get("CheckMoveToConstRef", true)) {}
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
 return LangOpts.CPlusPlus;
   }
@@ -37,6 +39,7 @@
 
 private:
   const bool CheckTriviallyCopyableMove;
+  const bool CheckMoveToConstRef;
   llvm::DenseSet AlreadyCheckedMoves;
 };
 
Index: clang-tools-extra/clang-tidy/performance/MoveConstArgCheck.cpp
==

[PATCH] D119351: Update all LLVM documentation mentioning runtimes in LLVM_ENABLE_PROJECTS

2022-02-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne updated this revision to Diff 407500.
ldionne marked 3 inline comments as done.
ldionne added a comment.

Address review comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119351

Files:
  README.md
  bolt/docs/OptimizingClang.md
  clang/docs/DataFlowSanitizer.rst
  clang/docs/Toolchain.rst
  compiler-rt/www/index.html
  flang/README.md
  libcxx/docs/BuildingLibcxx.rst
  libunwind/docs/BuildingLibunwind.rst
  llvm/docs/BuildingADistribution.rst
  llvm/docs/CMake.rst
  llvm/docs/GettingStarted.rst

Index: llvm/docs/GettingStarted.rst
===
--- llvm/docs/GettingStarted.rst
+++ llvm/docs/GettingStarted.rst
@@ -623,10 +623,15 @@
 | | other LLVM subprojects to additionally build. (Only|
 | | effective when using a side-by-side project layout |
 | | e.g. via git). The default list is empty. Can  |
-| | include: clang, clang-tools-extra, compiler-rt,|
-| | cross-project-tests, flang, libc, libclc, libcxx,  |
-| | libcxxabi, libunwind, lld, lldb, mlir, openmp, |
-| | polly, or pstl.|
+| | include: clang, clang-tools-extra, |
+| | cross-project-tests, flang, libc, libclc, lld, |
+| | lldb, mlir, openmp, polly, or pstl.|
++-++
+| LLVM_ENABLE_RUNTIMES| A semicolon-delimited list selecting which of the  |
+| | runtimes to build. (Only effective when using the  |
+| | full monorepo layout). The default list is empty.  |
+| | Can include: libcxx, libcxxabi, libunwind, |
+| | compiler-rt, libc, or openmp.  |
 +-++
 | LLVM_ENABLE_SPHINX  | Build sphinx-based documentation from the source   |
 | | code. This is disabled by default because it is|
@@ -1217,6 +1222,11 @@
compiling more than one project, separate the items with a semicolon. Should
you run into issues with the semicolon, try surrounding it with single quotes.
 
+* -DLLVM_ENABLE_RUNTIMES
+   Set this equal to the runtimes you wish to compile (e.g. libcxx, libcxxabi, etc.)
+   If compiling more than one runtime, separate the items with a semicolon. Should
+   you run into issues with the semicolon, try surrounding it with single quotes.
+
  * -DCLANG_ENABLE_STATIC_ANALYZER
Set this option to OFF if you do not require the clang static analyzer. This
should improve your build time slightly.
Index: llvm/docs/CMake.rst
===
--- llvm/docs/CMake.rst
+++ llvm/docs/CMake.rst
@@ -221,6 +221,10 @@
   Control which projects are enabled. For example you may want to work on clang
   or lldb by specifying ``-DLLVM_ENABLE_PROJECTS="clang;lldb"``.
 
+**LLVM_ENABLE_RUNTIMES**:STRING
+  Control which runtimes are enabled. For example you may want to work on
+  libc++ or libc++abi by specifying ``-DLLVM_ENABLE_RUNTIMES="libcxx;libcxxabi"``.
+
 **LLVM_LIBDIR_SUFFIX**:STRING
   Extra suffix to append to the directory where libraries are to be
   installed. On a 64-bit architecture, one could use ``-DLLVM_LIBDIR_SUFFIX=64``
@@ -505,17 +509,17 @@
 
 **LLVM_ENABLE_PROJECTS**:STRING
   Semicolon-separated list of projects to build, or *all* for building all
-  (clang, lldb, compiler-rt, lld, polly, etc) projects. This flag assumes
-  that projects are checked out side-by-side and not nested, i.e. clang
-  needs to be in parallel of llvm instead of nested in `llvm/tools`.
-  This feature allows to have one build for only LLVM and another for clang+llvm
-  using the same source checkout.
+  (clang, lldb, lld, polly, etc) projects. This flag assumes that projects
+  are checked out side-by-side and not nested, i.e. clang needs to be in
+  parallel of llvm instead of nested in `llvm/tools`. This feature allows
+  to have one build for only LLVM and another for clang+llvm using the same
+  source checkout.
   The full list is:
-  ``clang;clang-tools-extra;compiler-rt;cross-project-tests;libc;libclc;lld;lldb;openmp;polly;pstl``
+  ``clang;clang-tools-extra;cross-project-tests;libc;libclc;lld;lldb;openmp;polly;pstl``
 
 **LLVM_ENABLE_RUNTIMES**:STRING
-  Build libc++, libc++abi or other projects using that a just-built compiler.
-  This is the correct way to build libc++ when putting together a toolchain.
+  Build libc++, libc++abi, libunwind or compiler-rt using the just-built compiler.
+  This is the correct way to build runtimes w

[PATCH] D119351: Update all LLVM documentation mentioning runtimes in LLVM_ENABLE_PROJECTS

2022-02-10 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: README.md:71
+  mlir, openmp, polly, or pstl. ``LLVM_ENABLE_RUNTIMES`` can include 
any of
+  libcxx, libcxxabi, libunwind, or compiler-rt.
 

tianshilei1992 wrote:
> FWIW, OpenMP can be put into either of them. In OpenMP doc 
> (https://openmp.llvm.org/SupportAndFAQ.html#q-how-to-build-an-openmp-gpu-offload-capable-compiler),
>  we recommend to use `LLVM_ENABLE_RUNTIMES` to build OpenMP if users would 
> like to use offloading features.
Thanks for the clarification, I tweaked the documentation a bit.



Comment at: bolt/docs/OptimizingClang.md:228-236
 $ CPATH=${TOPLEV}/stage1/install/bin/
-$ cmake -G Ninja ${TOPLEV}/llvm-project/llvm -DLLVM_TARGETS_TO_BUILD=X86 \
+$ cmake -G Ninja -S ${TOPLEV}/llvm-project/llvm -B ${TOPLEV}/stage2-prof-gen \
+-DLLVM_TARGETS_TO_BUILD=X86 \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_C_COMPILER=$CPATH/clang -DCMAKE_CXX_COMPILER=$CPATH/clang++ \
 -DLLVM_ENABLE_PROJECTS="clang;lld" \
 -DLLVM_USE_LINKER=lld -DLLVM_BUILD_INSTRUMENTED=ON \

Quuxplusone wrote:
> FWIW, I personally prefer to run cmake and ninja //from// the build 
> directory, i.e.
> ```
> $ mkdir ${TOPLEV}/llvm-project/llvm/stage2-prof-gen
> $ cd ${TOPLEV}/llvm-project/llvm/stage2-prof-gen
> $ CPATH=${TOPLEV}/stage1/install/bin
> $ cmake -G Ninja \
> -DLLVM_TARGETS_TO_BUILD=X86 \
> ~~~
> -DCMAKE_INSTALL_PREFIX=${TOPLEV}/stage2-prof-gen/install \
> ../llvm-project/llvm
> $ ninja install
> ```
> This is the style that was used in `DataFlowSanitizer.rst` below, which you 
> explicitly moved away from into `-B`/`-S`/`-C` land (where I find it harder 
> to keep straight all the different extra options that are needed).
> 
> Orthogonally, I'm worried that the advice on lines 73–74 of README.md doesn't 
> mention `CMAKE_INSTALL_PREFIX`. When I'm building libc++ locally as part of 
> my development workflow, I //absolutely do not// want to blow away my 
> computer's default standard library installation; but what //do// I want to 
> do? Should I use something like `-DCMAKE_INSTALL_PREFIX=$(pwd)/install` as 
> depicted here? Can I really not get away with "running it out of the 
> buildroot" the way I'm used to?— I //must// install it somewhere on my system 
> in order to test it at all?
> Re: `-C` `-B` `-S`

I really like using those flags because it makes the command relocatable, i.e. 
it works regardless of where it is being run. As such, it's way more 
copy-pasteable too. However, since that's orthogonal to this change, I'll 
revert to the old style just so we have fewer things to argue about. But in 
general, for libc++/libc++abi/libunwind instructions, you'll find that I want 
things documented this way for that reason.

> Re: `CMAKE_INSTALL_PREFIX`

You don't necessarily need to install it in order to test it -- we test libc++ 
all the time without running the `install-cxx` target. Furthermore, I would 
expect that most systems nowadays have some sort of integrity protection that 
prevents you from doing something bad like that. Apple platforms certainly do 
-- you simply can't overwrite your `libc++.1.dylib` anymore and render your 
system unusable. Still, I'll add a word of caution to `CMAKE_INSTALL_PREFIX` 
above even though it's orthogonal to this patch -- it's easy enough to do.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119351

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


[clang] ce07de2 - [clang][tests] Add test for C++ DR2406

2022-02-10 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-02-10T14:52:30+01:00
New Revision: ce07de234b77dc6cc263cdf4081eace5761d6b5a

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

LOG: [clang][tests] Add test for C++ DR2406

Clang already handles this fine, so add a test case to let the
make_cxx_dr_status script pick it up.

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

Added: 
clang/test/CXX/drs/dr2406.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CXX/drs/dr2406.cpp b/clang/test/CXX/drs/dr2406.cpp
new file mode 100644
index 0..7ea0870fb70b3
--- /dev/null
+++ b/clang/test/CXX/drs/dr2406.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -x c++ %s  -verify
+
+// dr2406: yes
+
+void fallthrough(int n) {
+  void g(), h(), i();
+  switch (n) {
+  case 1:
+  case 2:
+g();
+[[fallthrough]];
+  case 3: // warning on fallthrough discouraged
+do {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not 
directly precede switch label}}
+} while (false);
+  case 6:
+do {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not 
directly precede switch label}}
+} while (n);
+  case 7:
+while (false) {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not 
directly precede switch label}}
+}
+  case 5:
+h();
+  case 4: // implementation may warn on fallthrough
+i();
+[[fallthrough]]; // expected-error {{fallthrough annotation does not 
directly precede switch label}}
+  }
+}



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


[clang] ef2c827 - [clang] Add test for C++ DR2390

2022-02-10 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2022-02-10T14:52:30+01:00
New Revision: ef2c8274dfa216078436c6acfe0274a43a737242

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

LOG: [clang] Add test for C++ DR2390

DR2390 clarifies that the argument to __has_cpp_attribute() needs to be
macro-expanded. Clang already supports this and tests it explicitly in
clang/test/Preprocessor/has_attribute.cpp.

Copy the test over to clang/test/CXX/drs/ so the make_cxx_drs script
picks it up.

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

Added: 
clang/test/CXX/drs/dr2390.cpp

Modified: 


Removed: 




diff  --git a/clang/test/CXX/drs/dr2390.cpp b/clang/test/CXX/drs/dr2390.cpp
new file mode 100644
index 0..d8ab1e9a1b385
--- /dev/null
+++ b/clang/test/CXX/drs/dr2390.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
+
+// dr2390: yes
+
+namespace PR48462 {
+// Test that macro expansion of the builtin argument works.
+#define C clang
+#define F fallthrough
+#define CF clang::fallthrough
+
+#if __has_cpp_attribute(F)
+int has_fallthrough;
+#endif
+// CHECK: int has_fallthrough;
+
+#if __has_cpp_attribute(C::F)
+int has_clang_fallthrough_1;
+#endif
+// CHECK: int has_clang_fallthrough_1;
+
+#if __has_cpp_attribute(clang::F)
+int has_clang_fallthrough_2;
+#endif
+// CHECK: int has_clang_fallthrough_2;
+
+#if __has_cpp_attribute(C::fallthrough)
+int has_clang_fallthrough_3;
+#endif
+// CHECK: int has_clang_fallthrough_3;
+
+#if __has_cpp_attribute(CF)
+int has_clang_fallthrough_4;
+#endif
+// CHECK: int has_clang_fallthrough_4;
+
+#define FUNCLIKE1(x) clang::x
+#if __has_cpp_attribute(FUNCLIKE1(fallthrough))
+int funclike_1;
+#endif
+// CHECK: int funclike_1;
+
+#define FUNCLIKE2(x) _Clang::x
+#if __has_cpp_attribute(FUNCLIKE2(fallthrough))
+int funclike_2;
+#endif
+// CHECK: int funclike_2;
+} // namespace PR48462



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


[PATCH] D119224: [clang][tests] Add a testcase for C++ DR2406

2022-02-10 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGce07de234b77: [clang][tests] Add test for C++ DR2406 
(authored by tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119224

Files:
  clang/test/CXX/drs/dr2406.cpp


Index: clang/test/CXX/drs/dr2406.cpp
===
--- /dev/null
+++ clang/test/CXX/drs/dr2406.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -x c++ %s  -verify
+
+// dr2406: yes
+
+void fallthrough(int n) {
+  void g(), h(), i();
+  switch (n) {
+  case 1:
+  case 2:
+g();
+[[fallthrough]];
+  case 3: // warning on fallthrough discouraged
+do {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not 
directly precede switch label}}
+} while (false);
+  case 6:
+do {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not 
directly precede switch label}}
+} while (n);
+  case 7:
+while (false) {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not 
directly precede switch label}}
+}
+  case 5:
+h();
+  case 4: // implementation may warn on fallthrough
+i();
+[[fallthrough]]; // expected-error {{fallthrough annotation does not 
directly precede switch label}}
+  }
+}


Index: clang/test/CXX/drs/dr2406.cpp
===
--- /dev/null
+++ clang/test/CXX/drs/dr2406.cpp
@@ -0,0 +1,30 @@
+// RUN: %clang_cc1 -x c++ %s  -verify
+
+// dr2406: yes
+
+void fallthrough(int n) {
+  void g(), h(), i();
+  switch (n) {
+  case 1:
+  case 2:
+g();
+[[fallthrough]];
+  case 3: // warning on fallthrough discouraged
+do {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not directly precede switch label}}
+} while (false);
+  case 6:
+do {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not directly precede switch label}}
+} while (n);
+  case 7:
+while (false) {
+  [[fallthrough]]; // expected-error {{fallthrough annotation does not directly precede switch label}}
+}
+  case 5:
+h();
+  case 4: // implementation may warn on fallthrough
+i();
+[[fallthrough]]; // expected-error {{fallthrough annotation does not directly precede switch label}}
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119230: [clang] Add test for C++ DR2390

2022-02-10 Thread Timm Bäder via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGef2c8274dfa2: [clang] Add test for C++ DR2390 (authored by 
tbaeder).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119230

Files:
  clang/test/CXX/drs/dr2390.cpp


Index: clang/test/CXX/drs/dr2390.cpp
===
--- /dev/null
+++ clang/test/CXX/drs/dr2390.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
+
+// dr2390: yes
+
+namespace PR48462 {
+// Test that macro expansion of the builtin argument works.
+#define C clang
+#define F fallthrough
+#define CF clang::fallthrough
+
+#if __has_cpp_attribute(F)
+int has_fallthrough;
+#endif
+// CHECK: int has_fallthrough;
+
+#if __has_cpp_attribute(C::F)
+int has_clang_fallthrough_1;
+#endif
+// CHECK: int has_clang_fallthrough_1;
+
+#if __has_cpp_attribute(clang::F)
+int has_clang_fallthrough_2;
+#endif
+// CHECK: int has_clang_fallthrough_2;
+
+#if __has_cpp_attribute(C::fallthrough)
+int has_clang_fallthrough_3;
+#endif
+// CHECK: int has_clang_fallthrough_3;
+
+#if __has_cpp_attribute(CF)
+int has_clang_fallthrough_4;
+#endif
+// CHECK: int has_clang_fallthrough_4;
+
+#define FUNCLIKE1(x) clang::x
+#if __has_cpp_attribute(FUNCLIKE1(fallthrough))
+int funclike_1;
+#endif
+// CHECK: int funclike_1;
+
+#define FUNCLIKE2(x) _Clang::x
+#if __has_cpp_attribute(FUNCLIKE2(fallthrough))
+int funclike_2;
+#endif
+// CHECK: int funclike_2;
+} // namespace PR48462


Index: clang/test/CXX/drs/dr2390.cpp
===
--- /dev/null
+++ clang/test/CXX/drs/dr2390.cpp
@@ -0,0 +1,47 @@
+// RUN: %clang_cc1 -E -P %s -o - | FileCheck %s
+
+// dr2390: yes
+
+namespace PR48462 {
+// Test that macro expansion of the builtin argument works.
+#define C clang
+#define F fallthrough
+#define CF clang::fallthrough
+
+#if __has_cpp_attribute(F)
+int has_fallthrough;
+#endif
+// CHECK: int has_fallthrough;
+
+#if __has_cpp_attribute(C::F)
+int has_clang_fallthrough_1;
+#endif
+// CHECK: int has_clang_fallthrough_1;
+
+#if __has_cpp_attribute(clang::F)
+int has_clang_fallthrough_2;
+#endif
+// CHECK: int has_clang_fallthrough_2;
+
+#if __has_cpp_attribute(C::fallthrough)
+int has_clang_fallthrough_3;
+#endif
+// CHECK: int has_clang_fallthrough_3;
+
+#if __has_cpp_attribute(CF)
+int has_clang_fallthrough_4;
+#endif
+// CHECK: int has_clang_fallthrough_4;
+
+#define FUNCLIKE1(x) clang::x
+#if __has_cpp_attribute(FUNCLIKE1(fallthrough))
+int funclike_1;
+#endif
+// CHECK: int funclike_1;
+
+#define FUNCLIKE2(x) _Clang::x
+#if __has_cpp_attribute(FUNCLIKE2(fallthrough))
+int funclike_2;
+#endif
+// CHECK: int funclike_2;
+} // namespace PR48462
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D113393: [c++2b] Implement P0849R8 auto(x)

2022-02-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:2396
+def ext_decltype_auto_expr : ExtWarn<
+  "ISO C++23 DIS does not allow functional-style cast to 'decltype(auto)'">,
+  InGroup>;

Is there a reason this one should be `ExtWarn` instead of `Extension`? (I think 
we typically only issue this kind of diagnostic when `-pedantic` is specified.)



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1035
+  // the typename-specifier in a function-style cast expression may
+  // be 'auto' since C++2b
   Diag(Tok.getLocation(),





Comment at: 
clang/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.auto.deduct/p2.cpp:4
+// p2.3 allows only T = auto in T(x).
+// As a Clang extension, we also allow T = decltype(auto) to match p2.2 (new 
T(x)).
+

lichray wrote:
> rsmith wrote:
> > We should produce an `ExtWarn` for this case.
> Fixed. Now silenced in this file and produced somewhere else.
> We should produce an ExtWarn for this case.

Can you help me understand our rule for when to use `ExtWarn` vs `Extension` 
for this? I was under the impression we used `Extension` for this sort of 
thing, and only used `ExtWarn` in the cases where the use of the extension is 
wrong and the warning should be on by default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113393

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


[PATCH] D119398: [OpenCL] Guard atomic_double with cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics

2022-02-10 Thread Yang Haonan via Phabricator via cfe-commits
haonanya updated this revision to Diff 407506.
haonanya added a comment.

Remove the .td changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119398

Files:
  clang/lib/Headers/opencl-c.h


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13832,6 +13832,7 @@
 #endif // defined(__opencl_c_ext_fp32_global_atomic_min_max) &&
\
 defined(__opencl_c_ext_fp32_local_atomic_min_max)
 
+#if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #if defined(__opencl_c_ext_fp64_global_atomic_min_max)
 double __ovld atomic_fetch_min(volatile __global atomic_double *object,
double operand);
@@ -13882,6 +13883,8 @@
 memory_scope scope);
 #endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) &&
\
 defined(__opencl_c_ext_fp64_local_atomic_min_max)
+#endif // defined(cl_khr_int64_base_atomics) &&
+   // defined(cl_khr_int64_extended_atomics)
 
 #if defined(__opencl_c_ext_fp16_global_atomic_add)
 half __ovld atomic_fetch_add(volatile __global atomic_half *object,
@@ -13985,6 +13988,7 @@
 #endif // defined(__opencl_c_ext_fp32_global_atomic_add) &&
\
 defined(__opencl_c_ext_fp32_local_atomic_add)
 
+#if defined(cl_khr_int64_base_atomics) && 
defined(cl_khr_int64_extended_atomics)
 #if defined(__opencl_c_ext_fp64_global_atomic_add)
 double __ovld atomic_fetch_add(volatile __global atomic_double *object,
double operand);
@@ -14035,6 +14039,8 @@
 memory_scope scope);
 #endif // defined(__opencl_c_ext_fp64_global_atomic_add) &&
\
 defined(__opencl_c_ext_fp64_local_atomic_add)
+#endif // defined(cl_khr_int64_base_atomics) &&
+   // defined(cl_khr_int64_extended_atomics)
 
 #endif // cl_ext_float_atomics
 


Index: clang/lib/Headers/opencl-c.h
===
--- clang/lib/Headers/opencl-c.h
+++ clang/lib/Headers/opencl-c.h
@@ -13832,6 +13832,7 @@
 #endif // defined(__opencl_c_ext_fp32_global_atomic_min_max) &&\
 defined(__opencl_c_ext_fp32_local_atomic_min_max)
 
+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #if defined(__opencl_c_ext_fp64_global_atomic_min_max)
 double __ovld atomic_fetch_min(volatile __global atomic_double *object,
double operand);
@@ -13882,6 +13883,8 @@
 memory_scope scope);
 #endif // defined(__opencl_c_ext_fp64_global_atomic_min_max) &&\
 defined(__opencl_c_ext_fp64_local_atomic_min_max)
+#endif // defined(cl_khr_int64_base_atomics) &&
+   // defined(cl_khr_int64_extended_atomics)
 
 #if defined(__opencl_c_ext_fp16_global_atomic_add)
 half __ovld atomic_fetch_add(volatile __global atomic_half *object,
@@ -13985,6 +13988,7 @@
 #endif // defined(__opencl_c_ext_fp32_global_atomic_add) &&\
 defined(__opencl_c_ext_fp32_local_atomic_add)
 
+#if defined(cl_khr_int64_base_atomics) && defined(cl_khr_int64_extended_atomics)
 #if defined(__opencl_c_ext_fp64_global_atomic_add)
 double __ovld atomic_fetch_add(volatile __global atomic_double *object,
double operand);
@@ -14035,6 +14039,8 @@
 memory_scope scope);
 #endif // defined(__opencl_c_ext_fp64_global_atomic_add) &&\
 defined(__opencl_c_ext_fp64_local_atomic_add)
+#endif // defined(cl_khr_int64_base_atomics) &&
+   // defined(cl_khr_int64_extended_atomics)
 
 #endif // cl_ext_float_atomics
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119375: [Clang][Sema] Do not evaluate value-dependent immediate invocations

2022-02-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

1 nit, but otherwise I'm happy with this.




Comment at: clang/test/SemaCXX/cxx2a-consteval.cpp:616
 
+namespace value_dependent {
+

A quick comment on this test as to why it has no diagnostics would be nice.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119375

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


[PATCH] D119398: [OpenCL] Guard atomic_double with cl_khr_int64_base_atomics and cl_khr_int64_extended_atomics

2022-02-10 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh accepted this revision.
svenvh added a comment.

Thanks, LGTM!  I'll try to followup with the .td changes soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119398

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


[PATCH] D119162: [Pseudo] Token/TokenStream, PP directive parser.

2022-02-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 407512.
sammccall added a comment.

Add unit tests.
Clarify finalization is about the mutability of the *sequence*. Add assertions.
Include cooking & cleaning of tokens. (In our prototype this was after PP but I
don't think that makes much sense).
Drop fields/accessors that aren't used yet.
Fix a few bugs revealed by tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119162

Files:
  clang/include/clang/Tooling/Syntax/Pseudo/Preprocess.h
  clang/include/clang/Tooling/Syntax/Pseudo/Token.h
  clang/lib/Tooling/Syntax/Pseudo/CMakeLists.txt
  clang/lib/Tooling/Syntax/Pseudo/Lex.cpp
  clang/lib/Tooling/Syntax/Pseudo/Preprocess.cpp
  clang/lib/Tooling/Syntax/Pseudo/Token.cpp
  clang/test/Syntax/Inputs/example.c
  clang/test/Syntax/lex.test
  clang/tools/clang-pseudo/ClangPseudo.cpp
  clang/unittests/Tooling/Syntax/Pseudo/CMakeLists.txt
  clang/unittests/Tooling/Syntax/Pseudo/PreprocessTest.cpp
  clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp

Index: clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp
===
--- /dev/null
+++ clang/unittests/Tooling/Syntax/Pseudo/TokenTest.cpp
@@ -0,0 +1,175 @@
+//===--- TokenTest.cpp ===//
+//
+// 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/Tooling/Syntax/Pseudo/Token.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/TokenKinds.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace syntax {
+namespace pseudo {
+namespace {
+
+using testing::AllOf;
+using testing::ElementsAre;
+using testing::ElementsAreArray;
+using testing::Not;
+
+MATCHER_P2(token, Text, Kind, "") {
+  return arg.Kind == Kind && arg.text() == Text;
+}
+
+MATCHER_P(hasFlag, Flag, "") { return arg.flag(Flag); }
+
+MATCHER_P2(lineIndent, Line, Indent, "") {
+  return arg.Line == (unsigned)Line && arg.Indent == (unsigned)Indent;
+}
+
+TEST(TokenTest, Lex) {
+  LangOptions Opts;
+  std::string Code = R"cpp(
+#include 
+int main() {
+  return 42; // the answer
+}
+  )cpp";
+  TokenStream Raw = lex(Code, Opts);
+  ASSERT_TRUE(Raw.isFinalized());
+  EXPECT_THAT(Raw.tokens(),
+  ElementsAreArray({
+  // Lexing of directives is weird, especially  strings.
+  token("#", tok::hash),
+  token("include", tok::raw_identifier),
+  token("<", tok::less),
+  token("stdio", tok::raw_identifier),
+  token(".", tok::period),
+  token("h", tok::raw_identifier),
+  token(">", tok::greater),
+
+  token("int", tok::raw_identifier),
+  token("main", tok::raw_identifier),
+  token("(", tok::l_paren),
+  token(")", tok::r_paren),
+  token("{", tok::l_brace),
+  token("return", tok::raw_identifier),
+  token("42", tok::numeric_constant),
+  token(";", tok::semi),
+  token("// the answer", tok::comment),
+  token("}", tok::r_brace),
+  }));
+
+  TokenStream Cooked = cook(Raw, Opts);
+  ASSERT_TRUE(Cooked.isFinalized());
+  EXPECT_THAT(Cooked.tokens(),
+  ElementsAreArray({
+  // Cooked identifier types in directives are not meaningful.
+  token("#", tok::hash),
+  token("include", tok::identifier),
+  token("<", tok::less),
+  token("stdio", tok::identifier),
+  token(".", tok::period),
+  token("h", tok::identifier),
+  token(">", tok::greater),
+
+  token("int", tok::kw_int),
+  token("main", tok::identifier),
+  token("(", tok::l_paren),
+  token(")", tok::r_paren),
+  token("{", tok::l_brace),
+  token("return", tok::kw_return),
+  token("42", tok::numeric_constant),
+  token(";", tok::semi),
+  token("// the answer", tok::comment),
+  token("}", tok::r_brace),
+  }));
+  // Check raw tokens point back into original source code.
+  EXPECT_EQ(Raw.tokens().front().text().begin(), &Code[Code.find('#')]);
+}
+
+TEST(TokenTest, LineContinuation) {
+  LangOptions Opts;
+  std::string Code = R"cpp(
+one_\
+token
+two \
+tokens
+  )cpp";
+  TokenStream Raw = lex(Code, Opts);
+  EXPECT_THAT(Raw.tokens(),
+  ElementsAre(AllOf(token("one_\\\ntoken", tok::raw_iden

[PATCH] D113622: [analyzer] support ignoring use-after-free checking with reference_counted attribute

2022-02-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D113622#3193319 , @chrisdangelo 
wrote:

> Hi @aaron.ballman,
>
> It's nice to meet you, virtually.

Nice to meet you as well, and I'm very sorry that this review took so long for 
me to get to. It fell off my radar for a while. :-(

> I've been working with @NoQ on this change. I've now removed the [wip] 
> prefix. When you have some time, I'd appreciate your feedback.
>
> This change adds a new attribute "reference_counted". This attribute is 
> intended to annotate struct declarations that are known to use a reference 
> counting pattern before being freed.

One thing to consider: `analyzer_noreturn` currently exists under the GNU 
spelling only. We may want to think about adding a `[[]]` spelling for Clang 
static analyzer attributes. I'm not certain whether we'd want that to be 
spelled `[[clang::reference_counted]]` or 
`[[clang_analyzer::reference_counted]]`, etc. We've never really decided on a 
policy about analyzer-specific attributes before and we may want to consider 
what we'd like to do before/while adding this attribute.

> The long term intention is that "reference_counted" may grow additional 
> affordances for describing the expected retain and release conventions that 
> can be wired up to train the static analyzer RetainCountChecker.
>
> The short term intention, executed in these changes, is that 
> "reference_counted" will be used to silence static analyzer use-after-free 
> and double-free checks that are indicating false positives when the pointer 
> is being monitored by a reference counting system.

Another possibility to consider is whether we want to introduce a generic 
suppression attribute to suppress static analyzer diagnostics in general, 
rather than having a per-use case attribute.

> This change does not currently enable warnings when the "reference_counted" 
> attribute is written before the "struct" keyword. There may be other cases 
> where the programmer may incorrectly use "reference_counted".
>
> I've successfully run the tests locally via `ninja check-clang-analysis` and 
> `ninja check-clang`.
>
> I've successfully exercised these changes against a large C / C++ project and 
> studied the output with @NoQ.

That's great to hear! Can you speak to the results in more detail? (Did you 
have to use the attribute a large number of times? Did the false positive rate 
improve and if so, by how much? Were there any surprises you found? That sort 
of thing.)

I'd also be curious to know how this attribute interacts (if at all) with 
things like ARC (automatic reference counting) in ObjC and the NS 
retains-related attributes as those are also related to reference counting and 
also only impact the static analyzer. If we can avoid adding a new attribute 
(perhaps by adding a new attribute spelling to an existing attribute that 
covers the same needs), that'd be a really great thing.

> These changes are expected to be used in conjunction with additional work 
> with ownership compiler attributes (https://reviews.llvm.org/D113530).
>
> Thank you,
> Chris






Comment at: clang/include/clang/Basic/Attr.td:1735
+  let Spellings = [Clang<"reference_counted">];
+  let Subjects = SubjectList<[Record]>;
+  let Documentation = [Undocumented];

chrisdangelo wrote:
> I've discussed a bit with Devin Coughlin yesterday. Devin would like to be 
> sure that we have appropriate warnings showing if this attribute is misused.
> 
> Previously, when I have been testing the use of this attribute, I mistakenly 
> added the attribute annotation after "typedef" and before "struct". This was 
> causing the attribute to not be discovered when the analyzer attempts to 
> inspect the declaration. I don't recall if a compiler warning was being 
> emitted.
> 
> This note is being written as a reminder to be evaluate what warning support 
> is already included or adding support if necessary.
Agreed -- we're definitely missing test coverage for the attribute as it 
stands. We should have coverage testing applying it to the correct and 
incorrect subjects, diagnostics on being given arguments, tests that 
inheritance works, etc.



Comment at: clang/include/clang/Basic/Attr.td:1700
+  let Subjects = SubjectList<[Record]>;
+  let Documentation = [Undocumented];
+  let SimpleHandler = 1;

NoQ wrote:
> Hmm, I think it's a good idea to provide some documentation.
+1, no new undocumented attributes please. (The docs also help us reviewer to 
ensure the behavior of the patch matches the intent.)



Comment at: clang/test/Analysis/malloc-annotations.c:314
 
+struct AnnotatedRefCountedStruct 
*testAnnotatedRefCountedStructIgnoresUseAfterFree() {
+  struct AnnotatedRefCountedStruct *p = CreateAnnotatedRefCountedStruct();

Please give all of the new test case functions a prototype (e.g., `(void)` 
instead of `()`).



Comment a

[PATCH] D119351: Update all LLVM documentation mentioning runtimes in LLVM_ENABLE_PROJECTS

2022-02-10 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: bolt/docs/OptimizingClang.md:228-236
 $ CPATH=${TOPLEV}/stage1/install/bin/
-$ cmake -G Ninja ${TOPLEV}/llvm-project/llvm -DLLVM_TARGETS_TO_BUILD=X86 \
+$ cmake -G Ninja -S ${TOPLEV}/llvm-project/llvm -B ${TOPLEV}/stage2-prof-gen \
+-DLLVM_TARGETS_TO_BUILD=X86 \
 -DCMAKE_BUILD_TYPE=Release \
 -DCMAKE_C_COMPILER=$CPATH/clang -DCMAKE_CXX_COMPILER=$CPATH/clang++ \
 -DLLVM_ENABLE_PROJECTS="clang;lld" \
 -DLLVM_USE_LINKER=lld -DLLVM_BUILD_INSTRUMENTED=ON \

ldionne wrote:
> Quuxplusone wrote:
> > FWIW, I personally prefer to run cmake and ninja //from// the build 
> > directory, i.e.
> > ```
> > $ mkdir ${TOPLEV}/llvm-project/llvm/stage2-prof-gen
> > $ cd ${TOPLEV}/llvm-project/llvm/stage2-prof-gen
> > $ CPATH=${TOPLEV}/stage1/install/bin
> > $ cmake -G Ninja \
> > -DLLVM_TARGETS_TO_BUILD=X86 \
> > ~~~
> > -DCMAKE_INSTALL_PREFIX=${TOPLEV}/stage2-prof-gen/install \
> > ../llvm-project/llvm
> > $ ninja install
> > ```
> > This is the style that was used in `DataFlowSanitizer.rst` below, which you 
> > explicitly moved away from into `-B`/`-S`/`-C` land (where I find it harder 
> > to keep straight all the different extra options that are needed).
> > 
> > Orthogonally, I'm worried that the advice on lines 73–74 of README.md 
> > doesn't mention `CMAKE_INSTALL_PREFIX`. When I'm building libc++ locally as 
> > part of my development workflow, I //absolutely do not// want to blow away 
> > my computer's default standard library installation; but what //do// I want 
> > to do? Should I use something like `-DCMAKE_INSTALL_PREFIX=$(pwd)/install` 
> > as depicted here? Can I really not get away with "running it out of the 
> > buildroot" the way I'm used to?— I //must// install it somewhere on my 
> > system in order to test it at all?
> > Re: `-C` `-B` `-S`
> 
> I really like using those flags because it makes the command relocatable, 
> i.e. it works regardless of where it is being run. As such, it's way more 
> copy-pasteable too. However, since that's orthogonal to this change, I'll 
> revert to the old style just so we have fewer things to argue about. But in 
> general, for libc++/libc++abi/libunwind instructions, you'll find that I want 
> things documented this way for that reason.
> 
> > Re: `CMAKE_INSTALL_PREFIX`
> 
> You don't necessarily need to install it in order to test it -- we test 
> libc++ all the time without running the `install-cxx` target. Furthermore, I 
> would expect that most systems nowadays have some sort of integrity 
> protection that prevents you from doing something bad like that. Apple 
> platforms certainly do -- you simply can't overwrite your `libc++.1.dylib` 
> anymore and render your system unusable. Still, I'll add a word of caution to 
> `CMAKE_INSTALL_PREFIX` above even though it's orthogonal to this patch -- 
> it's easy enough to do.
FWIW, the `CMAKE_INSTALL_PREFIX` change is an improvement but only //slightly// 
more reassuring than before. ;) Part of my paranoia is that I happen to know 
that Homebrew stores things in `/usr/local/...` as well (although probably 
entirely under `/usr/local/Cellar/...`?) and I wouldn't want to blow those away 
//either//.
Apparently on my Apple system I have `/usr/lib/libc++.dylib`, 
`/System/DriverKit/usr/lib/libc++.dylib`, and 
`/usr/local/Cellar/llvm/12.0.1/lib/libc++.dylib`.

> we test libc++ all the time without running the `install-cxx` target

Well, I know I do, but I don't use ENABLE_RUNTIMES yet... and the how-to below 
//does// end with the line `ninja -C build install-cxx`. If there's a 
supported/expected-to-work way to build and test libc++ that doesn't use `ninja 
install-cxx`, it'd be cool to mention it.

Anyway, this is all just me fudding and shouldn't block this PR. :)



Comment at: llvm/docs/GettingStarted.rst:633-634
+| | full monorepo layout). The default list is empty.  
|
+| | Can include: libcxx, libcxxabi, libunwind, 
|
+| | compiler-rt, libc, or openmp.  
|
 
+-++

The other list is a-z order; this one could be too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119351

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


[PATCH] D113499: [clang-tidy] Reduce false positives for `bugprone-infinite-loop` with dependent expressions

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

Sorry about the delay in getting this reviewed, but it generally LGTM. Can you 
also add a release note about the fix? (I'm accepting the review and you can 
feel free to land with the requested changes made, but if you want another 
round of review before you land, just ask!)




Comment at: clang-tools-extra/clang-tidy/bugprone/InfiniteLoopCheck.cpp:120
 
-static bool isKnownFalse(const Expr &Cond, const ASTContext &Ctx) {
-  if (Cond.isValueDependent())
+static bool isKnown(const Expr &Cond, const ASTContext &Ctx, const bool Value) 
{
+  if (Cond.isValueDependent()) {

My renaming may not be the best improvement to make, but `Value` wasn't giving 
me much indication of what to pass to it as a caller. It may also help to 
rename the function from `isKnown()` to `isKnownToHaveValue()` or something 
along those lines.


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

https://reviews.llvm.org/D113499

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


[clang-tools-extra] bd6c697 - clangd: Set a diagnostic on a code action resulting from a tweak

2022-02-10 Thread Kadir Cetinkaya via cfe-commits

Author: Christian Kandeler
Date: 2022-02-10T15:58:12+01:00
New Revision: bd6c6974f5ea1626a6bb1b6adea59616d70ff3a8

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

LOG: clangd: Set a diagnostic on a code action resulting from a tweak

... if there is a match.
This is needed to that clients can can make a connection between a
diagnostic and an associated quickfix-tweak.
Ideally, quickfix-kind tweak code actions would be provided inline along
with the non-tweak fixes, but this doesn't seem easily achievable.

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/ClangdLSPServer.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdLSPServer.cpp 
b/clang-tools-extra/clangd/ClangdLSPServer.cpp
index 8bd95b075fb93..0ec2052d094de 100644
--- a/clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ b/clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -986,8 +986,8 @@ void ClangdLSPServer::onCodeAction(const CodeActionParams 
&Params,
 
   // Now enumerate the semantic code actions.
   auto ConsumeActions =
-  [Reply = std::move(Reply), File, Selection = Params.range,
-   FixIts = std::move(FixIts), this](
+  [Diags = Params.context.diagnostics, Reply = std::move(Reply), File,
+   Selection = Params.range, FixIts = std::move(FixIts), this](
   llvm::Expected> Tweaks) mutable {
 if (!Tweaks)
   return Reply(Tweaks.takeError());
@@ -1003,13 +1003,17 @@ void ClangdLSPServer::onCodeAction(const 
CodeActionParams &Params,
 for (auto &Action : Actions) {
   if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) {
 if (OnlyFix) {
-  OnlyFix->isPreferred = false;
+  OnlyFix = nullptr;
   break;
 }
-Action.isPreferred = true;
 OnlyFix = &Action;
   }
 }
+if (OnlyFix) {
+  OnlyFix->isPreferred = true;
+  if (Diags.size() == 1 && Diags.front().range == Selection)
+OnlyFix->diagnostics = {Diags.front()};
+}
 
 if (SupportsCodeAction)
   return Reply(llvm::json::Array(Actions));



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


[PATCH] D118976: clangd: Set a diagnostic on a code action resulting from a tweak

2022-02-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGbd6c6974f5ea: clangd: Set a diagnostic on a code action 
resulting from a tweak (authored by ckandeler, committed by kadircet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118976

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp


Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -986,8 +986,8 @@
 
   // Now enumerate the semantic code actions.
   auto ConsumeActions =
-  [Reply = std::move(Reply), File, Selection = Params.range,
-   FixIts = std::move(FixIts), this](
+  [Diags = Params.context.diagnostics, Reply = std::move(Reply), File,
+   Selection = Params.range, FixIts = std::move(FixIts), this](
   llvm::Expected> Tweaks) mutable {
 if (!Tweaks)
   return Reply(Tweaks.takeError());
@@ -1003,13 +1003,17 @@
 for (auto &Action : Actions) {
   if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) {
 if (OnlyFix) {
-  OnlyFix->isPreferred = false;
+  OnlyFix = nullptr;
   break;
 }
-Action.isPreferred = true;
 OnlyFix = &Action;
   }
 }
+if (OnlyFix) {
+  OnlyFix->isPreferred = true;
+  if (Diags.size() == 1 && Diags.front().range == Selection)
+OnlyFix->diagnostics = {Diags.front()};
+}
 
 if (SupportsCodeAction)
   return Reply(llvm::json::Array(Actions));


Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -986,8 +986,8 @@
 
   // Now enumerate the semantic code actions.
   auto ConsumeActions =
-  [Reply = std::move(Reply), File, Selection = Params.range,
-   FixIts = std::move(FixIts), this](
+  [Diags = Params.context.diagnostics, Reply = std::move(Reply), File,
+   Selection = Params.range, FixIts = std::move(FixIts), this](
   llvm::Expected> Tweaks) mutable {
 if (!Tweaks)
   return Reply(Tweaks.takeError());
@@ -1003,13 +1003,17 @@
 for (auto &Action : Actions) {
   if (Action.kind && *Action.kind == CodeAction::QUICKFIX_KIND) {
 if (OnlyFix) {
-  OnlyFix->isPreferred = false;
+  OnlyFix = nullptr;
   break;
 }
-Action.isPreferred = true;
 OnlyFix = &Action;
   }
 }
+if (OnlyFix) {
+  OnlyFix->isPreferred = true;
+  if (Diags.size() == 1 && Diags.front().range == Selection)
+OnlyFix->diagnostics = {Diags.front()};
+}
 
 if (SupportsCodeAction)
   return Reply(llvm::json::Array(Actions));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D117348: [Preprocessor] Reduce the memory overhead of `#define` directives

2022-02-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

Thanks, this LGTM as well! I don't think the precommit CI pipeline failures are 
related from what I can tell.


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

https://reviews.llvm.org/D117348

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


[PATCH] D119440: [OpenMP][NFC] update status for 5.1 'nothing' directive to 'worked on'

2022-02-10 Thread Deepak Eachempati via Phabricator via cfe-commits
dreachem created this revision.
dreachem added reviewers: cchen, jdoerfert, koops.
Herald added subscribers: guansong, yaxunl.
dreachem requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119440

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -339,7 +339,7 @@
 
+--+--+--+---+
 | misc extension   | assume and assumes directives 
   | :part:`worked on`| 
  |
 
+--+--+--+---+
-| misc extension   | nothing directive 
   | :none:`unclaimed`| 
  |
+| misc extension   | nothing directive 
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | misc extension   | masked construct and related combined 
constructs | :part:`worked on`| D5, D100514 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -339,7 +339,7 @@
 +--+--+--+---+
 | misc extension   | assume and assumes directives| :part:`worked on`|   |
 +--+--+--+---+
-| misc extension   | nothing directive| :none:`unclaimed`|   |
+| misc extension   | nothing directive| :part:`worked on`|   |
 +--+--+--+---+
 | misc extension   | masked construct and related combined constructs | :part:`worked on`| D5, D100514   |
 +--+--+--+---+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119440: [OpenMP][NFC] update status for 5.1 'nothing' directive to 'worked on'

2022-02-10 Thread Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG02a05097e700: [OpenMP][NFC] update status for 5.1 
'nothing' directive to 'worked on' (authored by dreachem, 
committed by Chi-Chun, Chen ).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119440

Files:
  clang/docs/OpenMPSupport.rst


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -339,7 +339,7 @@
 
+--+--+--+---+
 | misc extension   | assume and assumes directives 
   | :part:`worked on`| 
  |
 
+--+--+--+---+
-| misc extension   | nothing directive 
   | :none:`unclaimed`| 
  |
+| misc extension   | nothing directive 
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | misc extension   | masked construct and related combined 
constructs | :part:`worked on`| D5, D100514 
  |
 
+--+--+--+---+


Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -339,7 +339,7 @@
 +--+--+--+---+
 | misc extension   | assume and assumes directives| :part:`worked on`|   |
 +--+--+--+---+
-| misc extension   | nothing directive| :none:`unclaimed`|   |
+| misc extension   | nothing directive| :part:`worked on`|   |
 +--+--+--+---+
 | misc extension   | masked construct and related combined constructs | :part:`worked on`| D5, D100514   |
 +--+--+--+---+
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 02a0509 - [OpenMP][NFC] update status for 5.1 'nothing' directive to 'worked on'

2022-02-10 Thread via cfe-commits

Author: dreachem
Date: 2022-02-10T09:22:44-06:00
New Revision: 02a05097e7003bedafeac0decb5f914429b35523

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

LOG: [OpenMP][NFC] update status for 5.1 'nothing' directive to 'worked on'

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

Added: 


Modified: 
clang/docs/OpenMPSupport.rst

Removed: 




diff  --git a/clang/docs/OpenMPSupport.rst b/clang/docs/OpenMPSupport.rst
index 29ef8a5051cd4..54b31f5371334 100644
--- a/clang/docs/OpenMPSupport.rst
+++ b/clang/docs/OpenMPSupport.rst
@@ -339,7 +339,7 @@ want to help with the implementation.
 
+--+--+--+---+
 | misc extension   | assume and assumes directives 
   | :part:`worked on`| 
  |
 
+--+--+--+---+
-| misc extension   | nothing directive 
   | :none:`unclaimed`| 
  |
+| misc extension   | nothing directive 
   | :part:`worked on`| 
  |
 
+--+--+--+---+
 | misc extension   | masked construct and related combined 
constructs | :part:`worked on`| D5, D100514 
  |
 
+--+--+--+---+



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


[PATCH] D72404: [ThinLTO/FullLTO] Support Os and Oz

2022-02-10 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D72404#3310704 , @aykevl wrote:

> @mehdi_amini thanks for explaining! D119342 
>  moves slightly closer to removing 
> SizeLevel from the pass pipeline setup.

I left a comment on D119342  - I think that 
is the right way to go. As mentioned there, there is still some legacy handling 
of options passed down from the driver, but over time we've been trying to move 
things to use function attributes, for the reasons @mehdi_amini mentioned. To 
expand on one of the reasons Mehdi mentioned: using function attributes 
naturally handles LTO linking in the case where one file is compiled `-flto 
-Os` and another is compiled `-flto -O2` the same way as if you compiled the 
two files with those different flags all the way down to native code without 
LTO. Using the approach in this pass you would be forced to pick either `-Os` 
or `-O2` for both files at LTO link time.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72404

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


[PATCH] D99134: Lambdas are not necessarily locals. This resolves DR48250.

2022-02-10 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

From my look, this seems to fix the problem, and covers the case that Richard 
brought up, and I have no comments, so I think I'm happy with it.  Please give 
Richard/Aaron ~24 hrs to take a look before committing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99134

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


[PATCH] D119446: [clang-cl] Accept the "legacy'"-target flag spelling

2022-02-10 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.
hans added a reviewer: thakis.
Herald added a subscriber: dang.
hans requested review of this revision.
Herald added a project: clang.

we already accept "--target=". No reason to not accept "-target" too (that's 
the one I typically use for some reason).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119446

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -772,4 +772,9 @@
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}ucrt
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}um
 
+// Accept both the -target and --target= spellings.
+// RUN: %clang_cl --target=i686-pc-windows-msvc19.14.0 -### -- %s 2>&1 | 
FileCheck -check-prefix=TARGET %s
+// RUN: %clang_cl -target i686-pc-windows-msvc19.14.0  -### -- %s 2>&1 | 
FileCheck -check-prefix=TARGET %s
+// TARGET: "-triple" "i686-pc-windows-msvc19.14.0"
+
 void f() { }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4442,7 +4442,9 @@
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag
 // style of double-dash and equals-joined flags.
-def target_legacy_spelling : Separate<["-"], "target">, Alias;
+def target_legacy_spelling : Separate<["-"], "target">,
+ Alias,
+ Flags<[CoreOption]>;
 
 // Special internal option to handle -Xlinker --no-demangle.
 def Z_Xlinker__no_demangle : Flag<["-"], "Z-Xlinker-no-demangle">,


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -772,4 +772,9 @@
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}ucrt
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}um
 
+// Accept both the -target and --target= spellings.
+// RUN: %clang_cl --target=i686-pc-windows-msvc19.14.0 -### -- %s 2>&1 | FileCheck -check-prefix=TARGET %s
+// RUN: %clang_cl -target i686-pc-windows-msvc19.14.0  -### -- %s 2>&1 | FileCheck -check-prefix=TARGET %s
+// TARGET: "-triple" "i686-pc-windows-msvc19.14.0"
+
 void f() { }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4442,7 +4442,9 @@
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag
 // style of double-dash and equals-joined flags.
-def target_legacy_spelling : Separate<["-"], "target">, Alias;
+def target_legacy_spelling : Separate<["-"], "target">,
+ Alias,
+ Flags<[CoreOption]>;
 
 // Special internal option to handle -Xlinker --no-demangle.
 def Z_Xlinker__no_demangle : Flag<["-"], "Z-Xlinker-no-demangle">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119446: [clang-cl] Accept the "legacy'"-target flag spelling

2022-02-10 Thread Nico Weber via Phabricator via cfe-commits
thakis accepted this revision.
thakis added a comment.
This revision is now accepted and ready to land.

lg!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119446

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


[PATCH] D99134: Lambdas are not necessarily locals. This resolves DR48250.

2022-02-10 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

Would love to see this cherry-picked into the llvm 14 release branch if 
possible!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99134

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


[PATCH] D119447: [clang][dataflow] Include terminator statements in buildStmtToBasicBlockMap

2022-02-10 Thread Stanislav Gatev via Phabricator via cfe-commits
sgatev created this revision.
sgatev added reviewers: ymandel, xazax.hun, gribozavr2.
Herald added subscribers: tschuett, steakhal, rnkovacs.
sgatev requested review of this revision.
Herald added a project: clang.

This will be necessary later when we add support for evaluating logic
expressions such as && and ||.

This is part of the implementation of the dataflow analysis framework.
See "[RFC] A dataflow analysis framework for Clang AST" on cfe-dev.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119447

Files:
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp


Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -38,6 +38,8 @@
 
   StmtToBlock[Stmt.getValue().getStmt()] = Block;
 }
+if (const Stmt *TerminatorStmt = Block->getTerminatorStmt())
+  StmtToBlock[TerminatorStmt] = Block;
   }
   return StmtToBlock;
 }


Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -38,6 +38,8 @@
 
   StmtToBlock[Stmt.getValue().getStmt()] = Block;
 }
+if (const Stmt *TerminatorStmt = Block->getTerminatorStmt())
+  StmtToBlock[TerminatorStmt] = Block;
   }
   return StmtToBlock;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119375: [Clang][Sema] Do not evaluate value-dependent immediate invocations

2022-02-10 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron updated this revision to Diff 407564.
Izaron added a comment.

Add test comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119375

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx2a-consteval.cpp


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -613,6 +613,32 @@
 
 } // namespace unevaluated
 
+namespace value_dependent {
+
+consteval int foo(int x) {
+  return x;
+}
+
+template  constexpr int bar() {
+  // Previously this call was rejected as value-dependent constant expressions
+  // can't be immediately evaluated. Now we show that we don't immediately
+  // evaluate them until they are instantiated.
+  return foo(X);
+}
+
+template  constexpr int baz() {
+  constexpr int t = sizeof(T);
+  // Previously this call was rejected as `t` is value-dependent and its value
+  // is unknown until the function is instantiated. Now we show that we don't
+  // reject such calls.
+  return foo(t);
+}
+
+static_assert(bar<15>() == 15);
+static_assert(baz() == sizeof(int));
+
+} // namespace value_dependent
+
 namespace PR50779 {
 struct derp {
   int b = 0;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16747,7 +16747,10 @@
   ConstantExpr::getStorageKind(Decl->getReturnType().getTypePtr(),
getASTContext()),
   /*IsImmediateInvocation*/ true);
-  ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
+  /// Value-dependent constant expressions should not be immediately
+  /// evaluated until they are instantiated.
+  if (!Res->isValueDependent())
+ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
   return Res;
 }
 


Index: clang/test/SemaCXX/cxx2a-consteval.cpp
===
--- clang/test/SemaCXX/cxx2a-consteval.cpp
+++ clang/test/SemaCXX/cxx2a-consteval.cpp
@@ -613,6 +613,32 @@
 
 } // namespace unevaluated
 
+namespace value_dependent {
+
+consteval int foo(int x) {
+  return x;
+}
+
+template  constexpr int bar() {
+  // Previously this call was rejected as value-dependent constant expressions
+  // can't be immediately evaluated. Now we show that we don't immediately
+  // evaluate them until they are instantiated.
+  return foo(X);
+}
+
+template  constexpr int baz() {
+  constexpr int t = sizeof(T);
+  // Previously this call was rejected as `t` is value-dependent and its value
+  // is unknown until the function is instantiated. Now we show that we don't
+  // reject such calls.
+  return foo(t);
+}
+
+static_assert(bar<15>() == 15);
+static_assert(baz() == sizeof(int));
+
+} // namespace value_dependent
+
 namespace PR50779 {
 struct derp {
   int b = 0;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -16747,7 +16747,10 @@
   ConstantExpr::getStorageKind(Decl->getReturnType().getTypePtr(),
getASTContext()),
   /*IsImmediateInvocation*/ true);
-  ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
+  /// Value-dependent constant expressions should not be immediately
+  /// evaluated until they are instantiated.
+  if (!Res->isValueDependent())
+ExprEvalContexts.back().ImmediateInvocationCandidates.emplace_back(Res, 0);
   return Res;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D117355: [PowerPC] Fix the undef virtual register reading failure for PPC backend trap optimization

2022-02-10 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:432
   if (EnableTrapOptimization && TrapOpt) {
+bool IsVReg =
+(MI.getNumOperands() && MI.getOperand(0).isReg())

amyk wrote:
> Might be good to pull out `MI.getOperand(0).isReg()` into a separate variable 
> since you're using it three times here. 
I think you can disregard my comment. I realized later that there are both 
`isReg()` and `getReg()`, and the latter should be called only when `isReg()` 
is true. Sorry about that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D117355

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


[PATCH] D119271: CGCall: also emit LLVM `allocalign` attribute when handling AllocAlign

2022-02-10 Thread Augie Fackler via Phabricator via cfe-commits
durin42 added inline comments.



Comment at: clang/test/CodeGen/alloc-align-attr.c:14
 // CHECK-NEXT:[[CASTED_ALIGN:%.*]] = zext i32 [[TMP0]] to i64
 // CHECK-NEXT:call void @llvm.assume(i1 true) [ "align"(i32* [[CALL]], i64 
[[CASTED_ALIGN]]) ]
 // CHECK-NEXT:[[TMP1:%.*]] = load i32, i32* [[CALL]], align 4

xbolva00 wrote:
> now this llvm.assume is redudant and should be removed?
I don't think so? Right now allocalign doesn't mean a whole lot (it really just 
answers some questions that used to be inferred from function name by 
MemoryBuiltins.cpp) so I'd rather leave the llvm.assume given that I doubt it's 
hurting anyone?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119271

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


[PATCH] D119301: [AArch64][ARM] add -Wunaligned-access only for clang

2022-02-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 407571.
ychen added a comment.

- Remove `CmdArgs` from `arm::getARMTargetFeatures`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119301

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.h
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm-alignment.c

Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -86,8 +86,8 @@
 // RUN: %clang -target aarch64-unknown-openbsd -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 
-// CHECK-ALIGNED-ARM: "-target-feature" "+strict-align"
-// CHECK-ALIGNED-AARCH64: "-target-feature" "+strict-align"
+// CHECK-ALIGNED-ARM: "-target-feature" "+strict-align" {{.*}} "-Wunaligned-access"
+// CHECK-ALIGNED-AARCH64: "-target-feature" "+strict-align" {{.*}} "-Wunaligned-access"
 
 // Make sure that v6M cores and v8M Baseline always trigger the unsupported
 // aligned accesses error for all supported architecture triples.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -328,7 +328,7 @@
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
-arm::getARMTargetFeatures(D, Triple, Args, CmdArgs, Features, ForAS);
+arm::getARMTargetFeatures(D, Triple, Args, Features, ForAS);
 break;
 
   case llvm::Triple::ppc:
@@ -347,8 +347,7 @@
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
-aarch64::getAArch64TargetFeatures(D, Triple, Args, CmdArgs, Features,
-  ForAS);
+aarch64::getAArch64TargetFeatures(D, Triple, Args, Features, ForAS);
 break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
@@ -1625,6 +1624,16 @@
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName);
 }
+
+void AddUnalignedAccessWarning(ArgStringList &CmdArgs) {
+  auto StrictAlignIter =
+  std::find_if(CmdArgs.rbegin(), CmdArgs.rend(), [](StringRef Arg) {
+return Arg == "+strict-align" || Arg == "-strict-align";
+  });
+  if (StrictAlignIter != CmdArgs.rend() &&
+  StringRef(*StrictAlignIter) == "+strict-align")
+CmdArgs.push_back("-Wunaligned-access");
+}
 }
 
 static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
@@ -1720,6 +1729,8 @@
 
   // Enable/disable return address signing and indirect branch targets.
   CollectARMPACBTIOptions(getToolChain(), Args, CmdArgs, false /*isAArch64*/);
+
+  AddUnalignedAccessWarning(CmdArgs);
 }
 
 void Clang::RenderTargetOptions(const llvm::Triple &EffectiveTriple,
@@ -1893,6 +1904,8 @@
   CmdArgs.push_back(Args.MakeArgString(TuneCPU));
 }
   }
+
+  AddUnalignedAccessWarning(CmdArgs);
 }
 
 void Clang::AddMIPSTargetArgs(const ArgList &Args,
Index: clang/lib/Driver/ToolChains/Arch/ARM.h
===
--- clang/lib/Driver/ToolChains/Arch/ARM.h
+++ clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -66,7 +66,6 @@
bool FromAs = false);
 void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  llvm::opt::ArgStringList &CmdArgs,
   std::vector &Features, bool ForAS);
 int getARMSubArchVersionNumber(const llvm::Triple &Triple);
 bool isARMMProfile(const llvm::Triple &Triple);
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -434,7 +434,7 @@
 }
 
 void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
-   const ArgList &Args, ArgStringList &CmdArgs,
+   const ArgList &Args,
std::vector &Features, bool ForAS) {
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
@@ -772,8 +772,6 @@
   // Kernel code has more strict alignment requirements.
   if (KernelOrKext) {
 Features.push_back("+strict-align");
-if (!ForAS)
-  CmdArgs.push_back("-Wunaligned-access");
   } else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
   options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_munaligned_access)) {
@@ -784,11 +782,8 @@
   // access either.
   else if (Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v8m_baseline)
 

[clang] 8baa076 - [clang-cl] Accept the "legacy" -target flag spelling

2022-02-10 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2022-02-10T18:27:30+01:00
New Revision: 8baa076dffa381baa1f190356b4be5b0cc3bf13e

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

LOG: [clang-cl] Accept the "legacy" -target flag spelling

we already accept "--target=". No reason to not accept "-target" too
(that's the one I typically use for some reason).

Differential revision: https://reviews.llvm.org/D119446

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/cl-options.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a64a6766e1645..d668118e58a0b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4454,7 +4454,9 @@ def mno_vzeroupper : Flag<["-"], "mno-vzeroupper">, 
Group;
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag
 // style of double-dash and equals-joined flags.
-def target_legacy_spelling : Separate<["-"], "target">, Alias;
+def target_legacy_spelling : Separate<["-"], "target">,
+ Alias,
+ Flags<[CoreOption]>;
 
 // Special internal option to handle -Xlinker --no-demangle.
 def Z_Xlinker__no_demangle : Flag<["-"], "Z-Xlinker-no-demangle">,

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index 50c2443c21899..f152c9f69819d 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -772,4 +772,9 @@
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}ucrt
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}um
 
+// Accept both the -target and --target= spellings.
+// RUN: %clang_cl --target=i686-pc-windows-msvc19.14.0 -### -- %s 2>&1 | 
FileCheck -check-prefix=TARGET %s
+// RUN: %clang_cl -target i686-pc-windows-msvc19.14.0  -### -- %s 2>&1 | 
FileCheck -check-prefix=TARGET %s
+// TARGET: "-triple" "i686-pc-windows-msvc19.14.0"
+
 void f(void) { }



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


[PATCH] D119446: [clang-cl] Accept the "legacy'"-target flag spelling

2022-02-10 Thread Hans Wennborg 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 rG8baa076dffa3: [clang-cl] Accept the "legacy" 
-target flag spelling (authored by hans).

Changed prior to commit:
  https://reviews.llvm.org/D119446?vs=407545&id=407573#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119446

Files:
  clang/include/clang/Driver/Options.td
  clang/test/Driver/cl-options.c


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -772,4 +772,9 @@
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}ucrt
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}um
 
+// Accept both the -target and --target= spellings.
+// RUN: %clang_cl --target=i686-pc-windows-msvc19.14.0 -### -- %s 2>&1 | 
FileCheck -check-prefix=TARGET %s
+// RUN: %clang_cl -target i686-pc-windows-msvc19.14.0  -### -- %s 2>&1 | 
FileCheck -check-prefix=TARGET %s
+// TARGET: "-triple" "i686-pc-windows-msvc19.14.0"
+
 void f(void) { }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4454,7 +4454,9 @@
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag
 // style of double-dash and equals-joined flags.
-def target_legacy_spelling : Separate<["-"], "target">, Alias;
+def target_legacy_spelling : Separate<["-"], "target">,
+ Alias,
+ Flags<[CoreOption]>;
 
 // Special internal option to handle -Xlinker --no-demangle.
 def Z_Xlinker__no_demangle : Flag<["-"], "Z-Xlinker-no-demangle">,


Index: clang/test/Driver/cl-options.c
===
--- clang/test/Driver/cl-options.c
+++ clang/test/Driver/cl-options.c
@@ -772,4 +772,9 @@
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}ucrt
 // FAKEDIR: "-libpath:/foo{{/|}}Lib{{/|}}10.0.12345.0{{/|}}um
 
+// Accept both the -target and --target= spellings.
+// RUN: %clang_cl --target=i686-pc-windows-msvc19.14.0 -### -- %s 2>&1 | FileCheck -check-prefix=TARGET %s
+// RUN: %clang_cl -target i686-pc-windows-msvc19.14.0  -### -- %s 2>&1 | FileCheck -check-prefix=TARGET %s
+// TARGET: "-triple" "i686-pc-windows-msvc19.14.0"
+
 void f(void) { }
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4454,7 +4454,9 @@
 // These are legacy user-facing driver-level option spellings. They are always
 // aliases for options that are spelled using the more common Unix / GNU flag
 // style of double-dash and equals-joined flags.
-def target_legacy_spelling : Separate<["-"], "target">, Alias;
+def target_legacy_spelling : Separate<["-"], "target">,
+ Alias,
+ Flags<[CoreOption]>;
 
 // Special internal option to handle -Xlinker --no-demangle.
 def Z_Xlinker__no_demangle : Flag<["-"], "Z-Xlinker-no-demangle">,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 71d7c8d - [clangd] Crash in __memcmp_avx2_movbe

2022-02-10 Thread Ivan Murashko via cfe-commits

Author: Ivan Murashko
Date: 2022-02-10T09:40:44-08:00
New Revision: 71d7c8d870db3b2da1fe1b3f54be77163c55dcd2

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

LOG: [clangd] Crash in __memcmp_avx2_movbe

There is a clangd crash at `__memcmp_avx2_movbe`. Short problem description is 
below.

The method `HeaderIncludes::addExistingInclude` stores `Include` objects by 
reference at 2 places: `ExistingIncludes` (primary storage) and 
`IncludesByPriority` (pointer to the object's location at ExistingIncludes). 
`ExistingIncludes` is a map where value is a `SmallVector`. A new element is 
inserted by `push_back`. The operation might do resize. As result pointers 
stored at `IncludesByPriority` might become invalid.

Typical stack trace
```
frame #0: 0x7f11460dcd94 libc.so.6`__memcmp_avx2_movbe + 308
frame #1: 0x004782b8 clangd`llvm::StringRef::compareMemory(Lhs="
\"t2.h\"", Rhs="", Length=6) at StringRef.h:76:22
frame #2: 0x00701253 clangd`llvm::StringRef::compare(this=0x
7f10de7d8610, RHS=(Data = "", Length = 7166742329480737377)) const at String
Ref.h:206:34
  * frame #3: 0x007603ab clangd`llvm::operator<(llvm::StringRef, llv
m::StringRef)(LHS=(Data = "\"t2.h\"", Length = 6), RHS=(Data = "", Length =
7166742329480737377)) at StringRef.h:907:23
frame #4: 0x02d0ad9f clangd`clang::tooling::HeaderIncludes::inse
rt(this=0x7f10de7fb1a0, IncludeName=(Data = "t2.h\"", Length = 4), IsAng
led=false) const at HeaderIncludes.cpp:365:22
frame #5: 0x012ebfdd clangd`clang::clangd::IncludeInserter::inse
rt(this=0x7f10de7fb148, VerbatimHeader=(Data = "\"t2.h\"", Length = 6))
const at Headers.cpp:262:70
```

A unit test test for the crash was created 
(`HeaderIncludesTest.RepeatedIncludes`). The proposed solution is to use 
std::list instead of llvm::SmallVector

Test Plan
```
./tools/clang/unittests/Tooling/ToolingTests 
--gtest_filter=HeaderIncludesTest.RepeatedIncludes
```

Reviewed By: sammccall

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

Added: 


Modified: 
clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
clang/unittests/Tooling/HeaderIncludesTest.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h 
b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
index c1b7baec7ec51..ea8ad896be89f 100644
--- a/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ b/clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -14,6 +14,7 @@
 #include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
+#include 
 #include 
 
 namespace clang {
@@ -97,7 +98,8 @@ class HeaderIncludes {
   // Map from include name (quotation trimmed) to a list of existing includes
   // (in case there are more than one) with the name in the current file. 
   // and "x" will be treated as the same header when deleting #includes.
-  llvm::StringMap> ExistingIncludes;
+  // std::list is used for pointers stability (see IncludesByPriority)
+  llvm::StringMap> ExistingIncludes;
 
   /// Map from priorities of #include categories to all #includes in the same
   /// category. This is used to find #includes of the same category when

diff  --git a/clang/unittests/Tooling/HeaderIncludesTest.cpp 
b/clang/unittests/Tooling/HeaderIncludesTest.cpp
index 37007fbfb65e9..b7b958f0c914f 100644
--- a/clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ b/clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -51,6 +51,15 @@ TEST_F(HeaderIncludesTest, NoExistingIncludeWithoutDefine) {
   EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
 }
 
+TEST_F(HeaderIncludesTest, RepeatedIncludes) {
+  std::string Code;
+  for (int i = 0; i < 100; ++i) {
+Code += "#include \"a.h\"\n";
+  }
+  std::string Expected = Code + "#include \"a2.h\"\n";
+  EXPECT_EQ(Expected, insert(Code, "\"a2.h\""));
+}
+
 TEST_F(HeaderIncludesTest, NoExistingIncludeWithDefine) {
   std::string Code = "#ifndef A_H\n"
  "#define A_H\n"



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


[PATCH] D118755: [clangd] Crash in __memcmp_avx2_movbe

2022-02-10 Thread Ivan Murashko via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71d7c8d870db: [clangd] Crash in __memcmp_avx2_movbe 
(authored by ivanmurashko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118755

Files:
  clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
  clang/unittests/Tooling/HeaderIncludesTest.cpp


Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -51,6 +51,15 @@
   EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
 }
 
+TEST_F(HeaderIncludesTest, RepeatedIncludes) {
+  std::string Code;
+  for (int i = 0; i < 100; ++i) {
+Code += "#include \"a.h\"\n";
+  }
+  std::string Expected = Code + "#include \"a2.h\"\n";
+  EXPECT_EQ(Expected, insert(Code, "\"a2.h\""));
+}
+
 TEST_F(HeaderIncludesTest, NoExistingIncludeWithDefine) {
   std::string Code = "#ifndef A_H\n"
  "#define A_H\n"
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -14,6 +14,7 @@
 #include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
+#include 
 #include 
 
 namespace clang {
@@ -97,7 +98,8 @@
   // Map from include name (quotation trimmed) to a list of existing includes
   // (in case there are more than one) with the name in the current file. 
   // and "x" will be treated as the same header when deleting #includes.
-  llvm::StringMap> ExistingIncludes;
+  // std::list is used for pointers stability (see IncludesByPriority)
+  llvm::StringMap> ExistingIncludes;
 
   /// Map from priorities of #include categories to all #includes in the same
   /// category. This is used to find #includes of the same category when


Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -51,6 +51,15 @@
   EXPECT_EQ(Expected, insert(Code, "\"a.h\""));
 }
 
+TEST_F(HeaderIncludesTest, RepeatedIncludes) {
+  std::string Code;
+  for (int i = 0; i < 100; ++i) {
+Code += "#include \"a.h\"\n";
+  }
+  std::string Expected = Code + "#include \"a2.h\"\n";
+  EXPECT_EQ(Expected, insert(Code, "\"a2.h\""));
+}
+
 TEST_F(HeaderIncludesTest, NoExistingIncludeWithDefine) {
   std::string Code = "#ifndef A_H\n"
  "#define A_H\n"
Index: clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
===
--- clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
+++ clang/include/clang/Tooling/Inclusions/HeaderIncludes.h
@@ -14,6 +14,7 @@
 #include "clang/Tooling/Inclusions/IncludeStyle.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Regex.h"
+#include 
 #include 
 
 namespace clang {
@@ -97,7 +98,8 @@
   // Map from include name (quotation trimmed) to a list of existing includes
   // (in case there are more than one) with the name in the current file. 
   // and "x" will be treated as the same header when deleting #includes.
-  llvm::StringMap> ExistingIncludes;
+  // std::list is used for pointers stability (see IncludesByPriority)
+  llvm::StringMap> ExistingIncludes;
 
   /// Map from priorities of #include categories to all #includes in the same
   /// category. This is used to find #includes of the same category when
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119061: [Clang] noinline call site attribute

2022-02-10 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: clang/test/Sema/attr-noinline.cpp:14
+}
+
+[[clang::noinline]] static int i = bar(); // expected-error {{'noinline' 
attribute only applies to functions and statements}}

xbolva00 wrote:
> aaron.ballman wrote:
> > xbolva00 wrote:
> > > aaron.ballman wrote:
> > > > Should there be any diagnostic in a situation like this?
> > > > ```
> > > > [[gnu::always_inline]] int f() { return 0; }
> > > > 
> > > > void func() {
> > > >   [[clang::noinline]] int i = f(); // Should there be some way to know 
> > > > of the conflict?
> > > > }
> > > > ```
> > > Yeah, this is tricky. LLVM will currently prefer always_inline. 
> > > 
> > > I was wondering about a new warning as well, I think it is a good idea to 
> > > warn tor this scenario, I was just not sure where is a good place for 
> > > such check. Maybe collect all callexprs in CallExprFinder and detech this 
> > > colision?
> > Yeah, if always_inline wins, that'd be a pretty big surprise. Is that 
> > intentional, or expected to change? (I would have expected the call site 
> > attribute to "win" because it knows more about its inlining needs than the 
> > author of the declaration.)
> > 
> > As for the diagnostic, the call expression finder is where I'd expect the 
> > logic to start from. That'll find you all the call expressions involved, 
> > and for each one of those you can look to see if you can find a decl for 
> > the call, and if there is one, check to see if it has an `AlwaysInlineAttr` 
> > on it, then diagnose from there.
> > 
> > 
> Yes, I think that noinline should win as well :) but it is kinda edge case 
> scenario, so I am not too worried for now. 
> 
> But yeah, fix for inliner probably makes sense.
> 
> WDYT @aeubanks ? Would be such small change acceptable? I could send a patch.
favoring call-site attributes over callee attributes in the inliner seems 
reasonable


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

https://reviews.llvm.org/D119061

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


[PATCH] D119257: Revert "Re-land [LLD] Remove global state in lldCommon"

2022-02-10 Thread Krzysztof Drewniak via Phabricator via cfe-commits
krzysz00 abandoned this revision.
krzysz00 added a comment.

Worked around elsewhere, more permanent fix pending, abandoning


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119257

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


[PATCH] D116514: [clangd] Add code action to generate a constructor for a C++ class

2022-02-10 Thread Adrian Vogelsgesang via Phabricator via cfe-commits
avogelsgesang added a comment.

Can we add this tweak as the default "fix-it" action for

> Class '...' does not declare any constructor to initialize its non-modifiable 
> me

on structs like

  struct X {
 int& a;
  }

?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116514

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


[clang] 6c7e6fc - [clang-format] Do not remove required spaces when aligning tokens.

2022-02-10 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2022-02-10T19:15:27+01:00
New Revision: 6c7e6fc7b6654b7ecd364f352f8ffd6dfecbf77b

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

LOG: [clang-format] Do not remove required spaces when aligning tokens.

Fixes https://github.com/llvm/llvm-project/issues/44292.
Fixes https://github.com/llvm/llvm-project/issues/45874.

Reviewed By: HazardyKnusperkeks, owenpan

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

Added: 


Modified: 
clang/lib/Format/WhitespaceManager.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/WhitespaceManager.cpp 
b/clang/lib/Format/WhitespaceManager.cpp
index 1d639275b1d59..758dc5860888e 100644
--- a/clang/lib/Format/WhitespaceManager.cpp
+++ b/clang/lib/Format/WhitespaceManager.cpp
@@ -331,6 +331,12 @@ AlignTokenSequence(const FormatStyle &Style, unsigned 
Start, unsigned End,
   FoundMatchOnLine = true;
   Shift = Column - Changes[i].StartOfTokenColumn;
   Changes[i].Spaces += Shift;
+  // FIXME: This is a workaround that should be removed when we fix
+  // http://llvm.org/PR53699. An assertion later below verifies this.
+  if (Changes[i].NewlinesBefore == 0)
+Changes[i].Spaces =
+std::max(Changes[i].Spaces,
+ static_cast(Changes[i].Tok->SpacesRequiredBefore));
 }
 
 // This is for function parameters that are split across multiple lines,
@@ -399,6 +405,12 @@ AlignTokenSequence(const FormatStyle &Style, unsigned 
Start, unsigned End,
 if (ContinuedStringLiteral)
   Changes[i].Spaces += Shift;
 
+// We should not remove required spaces unless we break the line before.
+assert(Changes[i].NewlinesBefore > 0 ||
+   Changes[i].Spaces >=
+   static_cast(Changes[i].Tok->SpacesRequiredBefore) ||
+   Changes[i].Tok->is(tok::eof));
+
 Changes[i].StartOfTokenColumn += Shift;
 if (i + 1 != Changes.size())
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index c7516427c2f45..8639a72eceb12 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -17277,6 +17277,31 @@ TEST_F(FormatTest, AlignConsecutiveDeclarations) {
"const unsigned   g;\n"
"Const unsigned   h;",
Alignment);
+
+  // See PR46529
+  FormatStyle BracedAlign = getLLVMStyle();
+  BracedAlign.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("const auto result{[]() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "}};",
+   BracedAlign);
+  verifyFormat("int foo{[]() {\n"
+   "  int bar{0};\n"
+   "  return 0;\n"
+   "}()};",
+   BracedAlign);
+  BracedAlign.Cpp11BracedListStyle = false;
+  verifyFormat("const auto result{ []() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "} };",
+   BracedAlign);
+  verifyFormat("int foo{ []() {\n"
+   "  int bar{ 0 };\n"
+   "  return 0;\n"
+   "}() };",
+   BracedAlign);
 }
 
 TEST_F(FormatTest, AlignWithLineBreaks) {



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


[PATCH] D119419: [clang-format] Do not remove required spaces when aligning tokens.

2022-02-10 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6c7e6fc7b665: [clang-format] Do not remove required spaces 
when aligning tokens. (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119419

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17277,6 +17277,31 @@
"const unsigned   g;\n"
"Const unsigned   h;",
Alignment);
+
+  // See PR46529
+  FormatStyle BracedAlign = getLLVMStyle();
+  BracedAlign.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("const auto result{[]() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "}};",
+   BracedAlign);
+  verifyFormat("int foo{[]() {\n"
+   "  int bar{0};\n"
+   "  return 0;\n"
+   "}()};",
+   BracedAlign);
+  BracedAlign.Cpp11BracedListStyle = false;
+  verifyFormat("const auto result{ []() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "} };",
+   BracedAlign);
+  verifyFormat("int foo{ []() {\n"
+   "  int bar{ 0 };\n"
+   "  return 0;\n"
+   "}() };",
+   BracedAlign);
 }
 
 TEST_F(FormatTest, AlignWithLineBreaks) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -331,6 +331,12 @@
   FoundMatchOnLine = true;
   Shift = Column - Changes[i].StartOfTokenColumn;
   Changes[i].Spaces += Shift;
+  // FIXME: This is a workaround that should be removed when we fix
+  // http://llvm.org/PR53699. An assertion later below verifies this.
+  if (Changes[i].NewlinesBefore == 0)
+Changes[i].Spaces =
+std::max(Changes[i].Spaces,
+ static_cast(Changes[i].Tok->SpacesRequiredBefore));
 }
 
 // This is for function parameters that are split across multiple lines,
@@ -399,6 +405,12 @@
 if (ContinuedStringLiteral)
   Changes[i].Spaces += Shift;
 
+// We should not remove required spaces unless we break the line before.
+assert(Changes[i].NewlinesBefore > 0 ||
+   Changes[i].Spaces >=
+   static_cast(Changes[i].Tok->SpacesRequiredBefore) ||
+   Changes[i].Tok->is(tok::eof));
+
 Changes[i].StartOfTokenColumn += Shift;
 if (i + 1 != Changes.size())
   Changes[i + 1].PreviousEndOfTokenColumn += Shift;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -17277,6 +17277,31 @@
"const unsigned   g;\n"
"Const unsigned   h;",
Alignment);
+
+  // See PR46529
+  FormatStyle BracedAlign = getLLVMStyle();
+  BracedAlign.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
+  verifyFormat("const auto result{[]() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "}};",
+   BracedAlign);
+  verifyFormat("int foo{[]() {\n"
+   "  int bar{0};\n"
+   "  return 0;\n"
+   "}()};",
+   BracedAlign);
+  BracedAlign.Cpp11BracedListStyle = false;
+  verifyFormat("const auto result{ []() {\n"
+   "  const auto something = 1;\n"
+   "  return 2;\n"
+   "} };",
+   BracedAlign);
+  verifyFormat("int foo{ []() {\n"
+   "  int bar{ 0 };\n"
+   "  return 0;\n"
+   "}() };",
+   BracedAlign);
 }
 
 TEST_F(FormatTest, AlignWithLineBreaks) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -331,6 +331,12 @@
   FoundMatchOnLine = true;
   Shift = Column - Changes[i].StartOfTokenColumn;
   Changes[i].Spaces += Shift;
+  // FIXME: This is a workaround that should be removed when we fix
+  // http://llvm.org/PR53699. An assertion later below verifies this.
+  if (Changes[i].NewlinesBefore == 0)
+Changes[i].Spaces =
+std::max(Changes[i].Spaces,
+ static_cast(Changes[i].Tok->SpacesRequiredBefore));
 }
 
 // This is for function parameters that are split across multiple lines,
@@ -399,6 +405,12 @@
 if (ContinuedStringLiter

[clang] b96106a - [AArch64][ARM] add -Wunaligned-access only for clang

2022-02-10 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-02-10T10:26:30-08:00
New Revision: b96106af3f557da833b5e3b9ef9194c23ecd1596

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

LOG: [AArch64][ARM] add -Wunaligned-access only for clang

Reviewed By: lenary

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.h
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/lib/Driver/ToolChains/Arch/ARM.h
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/arm-alignment.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index ca0ca4bf4eeac..6e3e3d04bbe3a 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -222,7 +222,6 @@ getAArch64MicroArchFeaturesFromMcpu(const Driver &D, 
StringRef Mcpu,
 void aarch64::getAArch64TargetFeatures(const Driver &D,
const llvm::Triple &Triple,
const ArgList &Args,
-   llvm::opt::ArgStringList &CmdArgs,
std::vector &Features,
bool ForAS) {
   Arg *A;
@@ -466,16 +465,10 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
 
   if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
options::OPT_munaligned_access)) {
-if (A->getOption().matches(options::OPT_mno_unaligned_access)) {
+if (A->getOption().matches(options::OPT_mno_unaligned_access))
   Features.push_back("+strict-align");
-  if (!ForAS)
-CmdArgs.push_back("-Wunaligned-access");
-}
-  } else if (Triple.isOSOpenBSD()) {
+  } else if (Triple.isOSOpenBSD())
 Features.push_back("+strict-align");
-if (!ForAS)
-  CmdArgs.push_back("-Wunaligned-access");
-  }
 
   if (Args.hasArg(options::OPT_ffixed_x1))
 Features.push_back("+reserve-x1");

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.h 
b/clang/lib/Driver/ToolChains/Arch/AArch64.h
index 0cdc2ec725e02..d47c402d4a42d 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.h
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.h
@@ -22,7 +22,6 @@ namespace aarch64 {
 
 void getAArch64TargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  llvm::opt::ArgStringList &CmdArgs,
   std::vector &Features,
   bool ForAS);
 

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index 16af9f6d71295..2d961f6e836ff 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -434,7 +434,7 @@ static bool hasIntegerMVE(const std::vector &F) {
 }
 
 void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
-   const ArgList &Args, ArgStringList &CmdArgs,
+   const ArgList &Args,
std::vector &Features, bool ForAS) {
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
@@ -772,8 +772,6 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   // Kernel code has more strict alignment requirements.
   if (KernelOrKext) {
 Features.push_back("+strict-align");
-if (!ForAS)
-  CmdArgs.push_back("-Wunaligned-access");
   } else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
   options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_munaligned_access)) {
@@ -784,11 +782,8 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
   // access either.
   else if (Triple.getSubArch() == 
llvm::Triple::SubArchType::ARMSubArch_v8m_baseline)
 D.Diag(diag::err_target_unsupported_unaligned) << "v8m.base";
-} else {
+} else
   Features.push_back("+strict-align");
-  if (!ForAS)
-CmdArgs.push_back("-Wunaligned-access");
-}
   } else {
 // Assume pre-ARMv6 doesn't support unaligned accesses.
 //
@@ -807,23 +802,14 @@ void arm::getARMTargetFeatures(const Driver &D, const 
llvm::Triple &Triple,
 int VersionNum = getARMSubArchVersionNumber(Triple);
 if (Triple.isOSDarwin() || Triple.isOSNetBSD()) {
   if (VersionNum < 6 ||
-  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m) {
+  Triple.getSubArch() == llvm::Triple::SubArchType::ARMSubArch_v6m)
 Features.push_

[PATCH] D119301: [AArch64][ARM] add -Wunaligned-access only for clang

2022-02-10 Thread Yuanfang Chen 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 rGb96106af3f55: [AArch64][ARM] add -Wunaligned-access only for 
clang (authored by ychen).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119301

Files:
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.h
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/lib/Driver/ToolChains/Arch/ARM.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/arm-alignment.c

Index: clang/test/Driver/arm-alignment.c
===
--- clang/test/Driver/arm-alignment.c
+++ clang/test/Driver/arm-alignment.c
@@ -86,8 +86,8 @@
 // RUN: %clang -target aarch64-unknown-openbsd -### %s 2> %t
 // RUN: FileCheck --check-prefix=CHECK-ALIGNED-AARCH64 < %t %s
 
-// CHECK-ALIGNED-ARM: "-target-feature" "+strict-align"
-// CHECK-ALIGNED-AARCH64: "-target-feature" "+strict-align"
+// CHECK-ALIGNED-ARM: "-target-feature" "+strict-align" {{.*}} "-Wunaligned-access"
+// CHECK-ALIGNED-AARCH64: "-target-feature" "+strict-align" {{.*}} "-Wunaligned-access"
 
 // Make sure that v6M cores and v8M Baseline always trigger the unsupported
 // aligned accesses error for all supported architecture triples.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -328,7 +328,7 @@
   case llvm::Triple::armeb:
   case llvm::Triple::thumb:
   case llvm::Triple::thumbeb:
-arm::getARMTargetFeatures(D, Triple, Args, CmdArgs, Features, ForAS);
+arm::getARMTargetFeatures(D, Triple, Args, Features, ForAS);
 break;
 
   case llvm::Triple::ppc:
@@ -347,8 +347,7 @@
   case llvm::Triple::aarch64:
   case llvm::Triple::aarch64_32:
   case llvm::Triple::aarch64_be:
-aarch64::getAArch64TargetFeatures(D, Triple, Args, CmdArgs, Features,
-  ForAS);
+aarch64::getAArch64TargetFeatures(D, Triple, Args, Features, ForAS);
 break;
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
@@ -1631,6 +1630,16 @@
   CmdArgs.push_back("-target-abi");
   CmdArgs.push_back(ABIName);
 }
+
+void AddUnalignedAccessWarning(ArgStringList &CmdArgs) {
+  auto StrictAlignIter =
+  std::find_if(CmdArgs.rbegin(), CmdArgs.rend(), [](StringRef Arg) {
+return Arg == "+strict-align" || Arg == "-strict-align";
+  });
+  if (StrictAlignIter != CmdArgs.rend() &&
+  StringRef(*StrictAlignIter) == "+strict-align")
+CmdArgs.push_back("-Wunaligned-access");
+}
 }
 
 static void CollectARMPACBTIOptions(const ToolChain &TC, const ArgList &Args,
@@ -1726,6 +1735,8 @@
 
   // Enable/disable return address signing and indirect branch targets.
   CollectARMPACBTIOptions(getToolChain(), Args, CmdArgs, false /*isAArch64*/);
+
+  AddUnalignedAccessWarning(CmdArgs);
 }
 
 void Clang::RenderTargetOptions(const llvm::Triple &EffectiveTriple,
@@ -1899,6 +1910,8 @@
   CmdArgs.push_back(Args.MakeArgString(TuneCPU));
 }
   }
+
+  AddUnalignedAccessWarning(CmdArgs);
 }
 
 void Clang::AddMIPSTargetArgs(const ArgList &Args,
Index: clang/lib/Driver/ToolChains/Arch/ARM.h
===
--- clang/lib/Driver/ToolChains/Arch/ARM.h
+++ clang/lib/Driver/ToolChains/Arch/ARM.h
@@ -66,7 +66,6 @@
bool FromAs = false);
 void getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
   const llvm::opt::ArgList &Args,
-  llvm::opt::ArgStringList &CmdArgs,
   std::vector &Features, bool ForAS);
 int getARMSubArchVersionNumber(const llvm::Triple &Triple);
 bool isARMMProfile(const llvm::Triple &Triple);
Index: clang/lib/Driver/ToolChains/Arch/ARM.cpp
===
--- clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -434,7 +434,7 @@
 }
 
 void arm::getARMTargetFeatures(const Driver &D, const llvm::Triple &Triple,
-   const ArgList &Args, ArgStringList &CmdArgs,
+   const ArgList &Args,
std::vector &Features, bool ForAS) {
   bool KernelOrKext =
   Args.hasArg(options::OPT_mkernel, options::OPT_fapple_kext);
@@ -772,8 +772,6 @@
   // Kernel code has more strict alignment requirements.
   if (KernelOrKext) {
 Features.push_back("+strict-align");
-if (!ForAS)
-  CmdArgs.push_back("-Wunaligned-access");
   } else if (Arg *A = Args.getLastArg(options::OPT_mno_unaligned_access,
   options::OPT_munaligned_access)) {
 if (A->getOption().matches(options::OPT_munaligned_access)) {
@@ -784,11 +782,8 @@

[clang] bd3a1de - [clang-cl] Support the /JMC flag

2022-02-10 Thread Yuanfang Chen via cfe-commits

Author: Yuanfang Chen
Date: 2022-02-10T10:26:30-08:00
New Revision: bd3a1de683f80d174ea9c97000db3ec3276bc022

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

LOG: [clang-cl] Support the /JMC flag

The introduction and some examples are on this page:
https://devblogs.microsoft.com/cppblog/announcing-jmc-stepping-in-visual-studio/

The `/JMC` flag enables these instrumentations:
- Insert at the beginning of every function immediately after the prologue with
  a call to `void __fastcall __CheckForDebuggerJustMyCode(unsigned char 
*JMC_flag)`.
  The argument for `__CheckForDebuggerJustMyCode` is the address of a boolean
  global variable (the global variable is initialized to 1) with the name
  convention `___`. All such global variables are placed in
  the `.msvcjmc` section.
- The `` part of `___` has a one-to-one mapping
  with a directory path. MSVC uses some unknown hashing function. Here I
  used DJB.
- Add a dummy/empty COMDAT function `__JustMyCode_Default`.
- Add `/alternatename:__CheckForDebuggerJustMyCode=__JustMyCode_Default` link
  option via ".drectve" section. This is to prevent failure in
  case `__CheckForDebuggerJustMyCode` is not provided during linking.

Implementation:
All the instrumentations are implemented in an IR codegen pass. The pass is 
placed immediately before CodeGenPrepare pass. This is to not interfere with 
mid-end optimizations and make the instrumentation target-independent (I'm 
still working on an ELF port in a separate patch).

Reviewed By: hans

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

Added: 
llvm/lib/CodeGen/JMCInstrumenter.cpp
llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll

Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/CodeGenOptions.def
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Driver/Options.td
clang/lib/CodeGen/BackendUtil.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/cl-options.c
llvm/include/llvm/CodeGen/CommandFlags.h
llvm/include/llvm/CodeGen/Passes.h
llvm/include/llvm/InitializePasses.h
llvm/include/llvm/LinkAllPasses.h
llvm/include/llvm/Target/TargetOptions.h
llvm/lib/CodeGen/CMakeLists.txt
llvm/lib/CodeGen/CodeGen.cpp
llvm/lib/CodeGen/CommandFlags.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/ARM/ARMTargetMachine.cpp
llvm/lib/Target/X86/X86TargetMachine.cpp
llvm/tools/opt/opt.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 9055514d80293..ba8e028eb6aea 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -80,6 +80,12 @@ Attribute Changes in Clang
 Windows Support
 ---
 
+- Add support for MSVC-compatible ``/JMC``/``/JMC-`` flag in clang-cl (supports
+  X86/X64/ARM/ARM64). ``/JMC`` could only be used when ``/Zi`` or ``/Z7`` is
+  turned on. With this addition, clang-cl can be used in Visual Studio for the
+  JustMyCode feature. Note, you may need to manually add ``/JMC`` as additional
+  compile options in the Visual Studio since it currently assumes clang-cl 
does not support ``/JMC``.
+
 C Language Changes in Clang
 ---
 

diff  --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index ec1b13f40d453..1df5168c7d4ec 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -144,6 +144,7 @@ VALUE_CODEGENOPT(PatchableFunctionEntryOffset , 32, 0)
 CODEGENOPT(HotPatch, 1, 0) ///< Supports the Microsoft /HOTPATCH flag and
///< generates a 'patchable-function' attribute.
 
+CODEGENOPT(JMCInstrument, 1, 0) ///< Set when -fjmc is enabled.
 CODEGENOPT(InstrumentForProfiling , 1, 0) ///< Set when -pg is enabled.
 CODEGENOPT(CallFEntry , 1, 0) ///< Set when -mfentry is enabled.
 CODEGENOPT(MNopMCount , 1, 0) ///< Set when -mnop-mcount is enabled.

diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 51a10ab54953c..427cb788c3a4c 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -633,4 +633,8 @@ def err_drv_invalid_or_unsupported_offload_target : Error<
   "invalid or unsupported offload target: '%0'">;
 def err_drv_cuda_offload_only_emit_bc : Error<
   "CUDA offload target is supported only along with --emit-llvm">;
+
+def warn_drv_jmc_requires_debuginfo : Warning<
+  "/JMC requires debug info. Use '/Zi', '/Z7' or other debug options; option 
ignored">,
+  InGroup;
 }

diff  --git a/clang/include/clang/Driver/Options.t

[PATCH] D118428: [clang-cl] Support the /JMC flag

2022-02-10 Thread Yuanfang Chen via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
ychen marked an inline comment as done.
Closed by commit rGbd3a1de683f8: [clang-cl] Support the /JMC flag (authored by 
ychen).

Changed prior to commit:
  https://reviews.llvm.org/D118428?vs=407384&id=407600#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D118428

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-options.c
  llvm/include/llvm/CodeGen/CommandFlags.h
  llvm/include/llvm/CodeGen/Passes.h
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/LinkAllPasses.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/CodeGen.cpp
  llvm/lib/CodeGen/CommandFlags.cpp
  llvm/lib/CodeGen/JMCInstrumenter.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
  llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
  llvm/tools/opt/opt.cpp

Index: llvm/tools/opt/opt.cpp
===
--- llvm/tools/opt/opt.cpp
+++ llvm/tools/opt/opt.cpp
@@ -498,7 +498,8 @@
   "generic-to-nvvm",  "expandmemcmp",
   "loop-reduce",  "lower-amx-type",
   "pre-amx-config",   "lower-amx-intrinsics",
-  "polyhedral-info",  "replace-with-veclib"};
+  "polyhedral-info",  "replace-with-veclib",
+  "jmc-instrument"};
   for (const auto &P : PassNamePrefix)
 if (Pass.startswith(P))
   return true;
@@ -572,6 +573,7 @@
   initializeHardwareLoopsPass(Registry);
   initializeTypePromotionPass(Registry);
   initializeReplaceWithVeclibLegacyPass(Registry);
+  initializeJMCInstrumenterPass(Registry);
 
 #ifdef BUILD_EXAMPLES
   initializeExampleIRTransforms(Registry);
Index: llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
@@ -0,0 +1,120 @@
+; RUN: opt -jmc-instrument -mtriple=x86_64-pc-windows-msvc  -S < %s | FileCheck %s
+; RUN: opt -jmc-instrument -mtriple=aarch64-pc-windows-msvc -S < %s | FileCheck %s
+; RUN: opt -jmc-instrument -mtriple=arm-pc-windows-msvc -S < %s | FileCheck %s
+
+; CHECK: $__JustMyCode_Default = comdat any
+
+; CHECK: @"__7DF23CF5_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !0
+; CHECK: @"__A85D9D03_x@c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !5
+; CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (void (i8*)* @__JustMyCode_Default to i8*)], section "llvm.metadata"
+
+; CHECK: define void @l1() !dbg !13 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @l2() !dbg !17 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w1() !dbg !19 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w2() !dbg !20 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w3() !dbg !22 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: define void @w4() !dbg !24 {
+; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x@c")
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: declare void @__CheckForDebuggerJustMyCode(i8* noundef) unnamed_addr
+
+; CHECK: define void @__JustMyCode_Default(i8* noundef %0) unnamed_addr comdat {
+; CHECK:   ret void
+; CHECK: }
+
+; CHECK: !llvm.linker.options = !{!12}
+
+; CHECK: !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+; CHECK: !1 = distinct !DIGlobalVariable(name: "__7DF23CF5_x@c", scope: !2, file: !3, type: !8, isLocal: true, isDefinition: true)
+; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
+; CHECK: !3 = !DIFile(filename: "a/x.c", directory: "/tmp")
+; CHECK: !4 = !{!0, !5}
+; CHECK: !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
+; CHECK: !6 = distinct !DIGlobalVariable(name: "__A85D9D03_x@c", scope: !2, file: !7, type: !8, isLocal: true, isDefinition: true)
+; CHECK: !7 = !DIFile(filename: "./

[PATCH] D119461: [compiler-rt] Fix endianness in get_sock_peer_name test

2022-02-10 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added reviewers: tamird, vitalybuka.
Herald added a subscriber: dberris.
mgorny requested review of this revision.

Fix passing the port and IP address with the wrong endianness
in get_sock_peer_name() that causes the connect() to fail inside
without an outgoing network interface (it's trying to connect
to 1.0.0.127 instead of 127.0.0.1).


https://reviews.llvm.org/D119461

Files:
  compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
@@ -17,10 +17,10 @@
 
   const sockaddr_in sin = {
   .sin_family = AF_INET,
-  .sin_port = 1234,
+  .sin_port = htons(1234),
   .sin_addr =
   {
-  .s_addr = INADDR_LOOPBACK,
+  .s_addr = htonl(INADDR_LOOPBACK),
   },
   };
   assert(connect(fd, reinterpret_cast(&sin), sizeof(sin)) ==


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
@@ -17,10 +17,10 @@
 
   const sockaddr_in sin = {
   .sin_family = AF_INET,
-  .sin_port = 1234,
+  .sin_port = htons(1234),
   .sin_addr =
   {
-  .s_addr = INADDR_LOOPBACK,
+  .s_addr = htonl(INADDR_LOOPBACK),
   },
   };
   assert(connect(fd, reinterpret_cast(&sin), sizeof(sin)) ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119462: resolve the bugtype typo inside emitAdditionOverflowbug function

2022-02-10 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets created this revision.
Herald added a subscriber: martong.
phyBrackets requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D119462

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, 
N);
+auto Report = 
std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, N);
+auto Report = std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119461: [compiler-rt] Fix endianness in get_sock_peer_name test

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

@vitalybuka, I suspect this might also fix the test on Android but I don't have 
an environment to test it.


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

https://reviews.llvm.org/D119461

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


[PATCH] D119461: [compiler-rt] Fix endianness in get_sock_peer_name test

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

Thanks for the prompt review!


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

https://reviews.llvm.org/D119461

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


[PATCH] D119461: [compiler-rt] Fix endianness in get_sock_peer_name test

2022-02-10 Thread Michał Górny 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 rGc65fb0cdf262: [compiler-rt] Fix endianness in 
get_sock_peer_name test (authored by mgorny).
Herald added a project: Sanitizers.
Herald added a subscriber: Sanitizers.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119461

Files:
  compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
@@ -17,10 +17,10 @@
 
   const sockaddr_in sin = {
   .sin_family = AF_INET,
-  .sin_port = 1234,
+  .sin_port = htons(1234),
   .sin_addr =
   {
-  .s_addr = INADDR_LOOPBACK,
+  .s_addr = htonl(INADDR_LOOPBACK),
   },
   };
   assert(connect(fd, reinterpret_cast(&sin), sizeof(sin)) ==


Index: compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
===
--- compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
+++ compiler-rt/test/sanitizer_common/TestCases/Linux/get_sock_peer_name.cpp
@@ -17,10 +17,10 @@
 
   const sockaddr_in sin = {
   .sin_family = AF_INET,
-  .sin_port = 1234,
+  .sin_port = htons(1234),
   .sin_addr =
   {
-  .s_addr = INADDR_LOOPBACK,
+  .s_addr = htonl(INADDR_LOOPBACK),
   },
   };
   assert(connect(fd, reinterpret_cast(&sin), sizeof(sin)) ==
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119363: [clang] Add `ObjCProtocolLoc` to represent protocol references

2022-02-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a subscriber: akyrtzi.
sammccall added a comment.

Thanks @akyrtzi @egorzhdan I was going to suggest that I think someone at Apple 
should probably look at changes here first.

The goal here is to ensure that any tokens in the code that reference a decl 
have some AST node (which can be stored in DynTypedNode).
This is provides a nice simple model which clangd's go-to-definition etc rely 
on: token -> ast node -> target.
Clang almost follows this rule but references to protocols have no dedicated 
AST node.




Comment at: clang/include/clang/AST/RecursiveASTVisitor.h:331
+  /// \returns false if the visitation was terminated early, true otherwise.
+  bool TraverseObjCProtocolLoc(ObjCProtocolLoc ProtocolLoc);
+

RAV changes should have tests



Comment at: clang/include/clang/AST/TypeLoc.h:2612
+public:
+  const ObjCProtocolDecl *Protocol = nullptr;
+  SourceLocation Loc = SourceLocation();

These fields shouldn't be public in AST nodes, provide accessors instead (I 
think they can be read-only).



Comment at: clang/include/clang/AST/TypeLoc.h:2621
+  /// Evaluates true when this protocol loc is valid/non-empty.
+  explicit operator bool() const { return Protocol; }
+};

will we ever have invalid instances?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119363

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


[clang-tools-extra] 100ec80 - [clang-tidy] Add early exit for defaulted FunctionDecls

2022-02-10 Thread Kirill Bobyrev via cfe-commits

Author: Kirill Bobyrev
Date: 2022-02-10T20:29:26+01:00
New Revision: 100ec80ab5a6a01071771b67fc2141640d0984da

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

LOG: [clang-tidy] Add early exit for defaulted FunctionDecls

This prevents matching of defaulted comparison operators.

Resolves: https://github.com/llvm/llvm-project/issues/53355

Author: Febbe (Fabian Keßler)

Added: 


Modified: 
clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp

clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
index 60b80af35c7d8..8d6322563f794 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseTrailingReturnTypeCheck.cpp
@@ -404,14 +404,17 @@ void UseTrailingReturnTypeCheck::check(const 
MatchFinder::MatchResult &Result) {
   const auto *Fr = Result.Nodes.getNodeAs("Friend");
   assert(F && "Matcher is expected to find only FunctionDecls");
 
-  if (F->getLocation().isInvalid())
+  // Three-way comparison operator<=> is syntactic sugar and generates implicit
+  // nodes for all other operators.
+  if (F->getLocation().isInvalid() || F->isImplicit())
 return;
 
-  // Skip functions which return just 'auto'.
+  // Skip functions which return 'auto' and defaulted operators.
   const auto *AT = F->getDeclaredReturnType()->getAs();
-  if (AT != nullptr && !AT->isConstrained() &&
-  AT->getKeyword() == AutoTypeKeyword::Auto &&
-  !hasAnyNestedLocalQualifiers(F->getDeclaredReturnType()))
+  if (AT != nullptr &&
+  ((!AT->isConstrained() && AT->getKeyword() == AutoTypeKeyword::Auto &&
+!hasAnyNestedLocalQualifiers(F->getDeclaredReturnType())) ||
+   F->isDefaulted()))
 return;
 
   // TODO: implement those

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
index de2198437e101..63fe7a95fdc94 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize-use-trailing-return-type-cxx20.cpp
@@ -52,3 +52,49 @@ template 
 T req2(T t) requires requires { t + t; };
   // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: use a trailing return type for 
this function [modernize-use-trailing-return-type]
   // CHECK-FIXES: {{^}}auto req2(T t) -> T requires requires { t + t; };{{$}}
+
+//
+// Operator c++20 defaulted comparison operators
+//
+// Requires 
+
+namespace std {
+struct strong_ordering {
+  using value_type = signed char;
+  static strong_ordering const less;
+  static strong_ordering const equal;
+  static strong_ordering const equivalent;
+  static strong_ordering const greater;
+
+  constexpr strong_ordering(value_type v) : val(v) {}
+  template 
+  requires(T{0}) friend constexpr auto
+  operator==(strong_ordering v, T u) noexcept -> bool {
+return v.val == u;
+  }
+  friend constexpr auto operator==(strong_ordering v, strong_ordering w) 
noexcept -> bool = default;
+
+  value_type val{};
+};
+inline constexpr strong_ordering strong_ordering::less{-1};
+inline constexpr strong_ordering strong_ordering::equal{0};
+inline constexpr strong_ordering strong_ordering::equivalent{0};
+inline constexpr strong_ordering strong_ordering::greater{1};
+
+} // namespace std
+
+struct TestDefaultOperatorA {
+  int a{};
+  int b{};
+
+  friend auto operator<=>(const TestDefaultOperatorA &, const 
TestDefaultOperatorA &) noexcept = default;
+};
+
+struct TestDefaultOperatorB {
+  int a{};
+  int b{};
+  friend auto operator==(const TestDefaultOperatorB &, const 
TestDefaultOperatorB &) noexcept -> bool = default;
+  friend bool operator<(const TestDefaultOperatorB &, const 
TestDefaultOperatorB &) noexcept = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: use a trailing return type for 
this function [modernize-use-trailing-return-type]
+  // CHECK-FIXES: {{^}}  friend auto operator<(const TestDefaultOperatorB &, 
const TestDefaultOperatorB &) noexcept -> bool = default;{{$}}
+};



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


[PATCH] D119462: resolve the bugtype typo inside emitAdditionOverflowbug function in CStringChecker.cpp.

2022-02-10 Thread Shivam Rajput via Phabricator via cfe-commits
phyBrackets updated this revision to Diff 407623.
phyBrackets added a comment.

Use the git blame


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119462

Files:
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, 
N);
+auto Report = 
std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }


Index: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -257,7 +257,6 @@
   void emitNotCStringBug(CheckerContext &C, ProgramStateRef State,
  const Stmt *S, StringRef WarningMsg) const;
   void emitAdditionOverflowBug(CheckerContext &C, ProgramStateRef State) const;
-
   ProgramStateRef checkAdditionOverflow(CheckerContext &C,
 ProgramStateRef state,
 NonLoc left,
@@ -420,7 +419,6 @@
 
 SVal BufEnd =
 svalBuilder.evalBinOpLN(State, BO_Add, *BufLoc, LastOffset, PtrTy);
-
 State = CheckLocation(C, State, Buffer, BufEnd, Access);
 
 // If the buffer isn't large enough, abort.
@@ -622,8 +620,8 @@
 void CStringChecker::emitAdditionOverflowBug(CheckerContext &C,
  ProgramStateRef State) const {
   if (ExplodedNode *N = C.generateErrorNode(State)) {
-if (!BT_NotCString)
-  BT_NotCString.reset(
+if (!BT_AdditionOverflow)
+  BT_AdditionOverflow.reset(
   new BuiltinBug(Filter.CheckNameCStringOutOfBounds, "API",
  "Sum of expressions causes overflow."));
 
@@ -634,8 +632,8 @@
 "This expression will create a string whose length is too big to "
 "be represented as a size_t";
 
-auto Report =
-std::make_unique(*BT_NotCString, WarningMsg, N);
+auto Report = std::make_unique(*BT_AdditionOverflow,
+   WarningMsg, N);
 C.emitReport(std::move(Report));
   }
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D99134: Lambdas are not necessarily locals. This resolves DR48250.

2022-02-10 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.

LGTM.

Please also add something like this as a unit test:

In D99134#2643441 , @rsmith wrote:

>   template int x = [](auto){ return T(); }.operator()(T());
>   int y = x;


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99134

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


[PATCH] D119366: [clangd] Use `ObjCProtocolLoc` for generalized ObjC protocol support

2022-02-10 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

LG, thanks!
You might want to check out how hover behaves and add a test there.




Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:948
 
   Code = R"cpp(
+void test(id p);

This new test case looks interesting, but can we keep the old one too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119366

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


  1   2   >