[PATCH] D114064: [clang] [MinGW] Pass --no-demangle through to the mingw linker

2021-11-16 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added a reviewer: rnk.
mstorsjo requested review of this revision.
Herald added a project: clang.

Clang has custom handling of --no-demangle, where it is removed
from the input -Wl and -Xlinker options, and readded specifically
by the drivers where it's known to be supported.

Both ld.bfd and lld support the --no-demangle option.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114064

Files:
  clang/lib/Driver/ToolChains/MinGW.cpp
  clang/test/Driver/Xlinker-args.c


Index: clang/test/Driver/Xlinker-args.c
===
--- clang/test/Driver/Xlinker-args.c
+++ clang/test/Driver/Xlinker-args.c
@@ -12,6 +12,11 @@
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
 
+/// Check that --no-demangle gets forwarded to the mingw linker
+// RUN: %clang -target x86_64-w64-mingw32 -### \
+// RUN:   -Wl,--no-demangle %s 2> %t
+// RUN: FileCheck -check-prefix=MINGW < %t %s
+
 // RUN: %clang -target powerpc-unknown-aix -### \
 // RUN:   -b one -b two %s 2> %t
 // RUN: FileCheck -check-prefix=AIX < %t %s
@@ -23,6 +28,7 @@
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" 
"-r" {{.*}} "-T" "a.lds"
+// MINGW: "--no-demangle"
 // AIX: "-b" "one" "-b" "two"
 // NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
 
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -164,6 +164,9 @@
 CmdArgs.push_back("--enable-auto-image-base");
   }
 
+  if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
+CmdArgs.push_back("--no-demangle");
+
   CmdArgs.push_back("-o");
   const char *OutputFile = Output.getFilename();
   // GCC implicitly adds an .exe extension if it is given an output file name


Index: clang/test/Driver/Xlinker-args.c
===
--- clang/test/Driver/Xlinker-args.c
+++ clang/test/Driver/Xlinker-args.c
@@ -12,6 +12,11 @@
 // RUN:   -Wl,two,--no-demangle,three -Xlinker four -z five -r %s 2> %t
 // RUN: FileCheck -check-prefix=LINUX < %t %s
 
+/// Check that --no-demangle gets forwarded to the mingw linker
+// RUN: %clang -target x86_64-w64-mingw32 -### \
+// RUN:   -Wl,--no-demangle %s 2> %t
+// RUN: FileCheck -check-prefix=MINGW < %t %s
+
 // RUN: %clang -target powerpc-unknown-aix -### \
 // RUN:   -b one -b two %s 2> %t
 // RUN: FileCheck -check-prefix=AIX < %t %s
@@ -23,6 +28,7 @@
 // DARWIN-NOT: --no-demangle
 // DARWIN: "one" "two" "three" "four" "-z" "five" "-r"
 // LINUX: "--no-demangle" "-e" "_start" "one" "two" "three" "four" "-z" "five" "-r" {{.*}} "-T" "a.lds"
+// MINGW: "--no-demangle"
 // AIX: "-b" "one" "-b" "two"
 // NOT-AIX: error: unsupported option '-b' for target 'powerpc-unknown-linux'
 
Index: clang/lib/Driver/ToolChains/MinGW.cpp
===
--- clang/lib/Driver/ToolChains/MinGW.cpp
+++ clang/lib/Driver/ToolChains/MinGW.cpp
@@ -164,6 +164,9 @@
 CmdArgs.push_back("--enable-auto-image-base");
   }
 
+  if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
+CmdArgs.push_back("--no-demangle");
+
   CmdArgs.push_back("-o");
   const char *OutputFile = Output.getFilename();
   // GCC implicitly adds an .exe extension if it is given an output file name
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Gentle ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110622

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


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

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Gentle ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110618

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


[PATCH] D114059: [X86] add 3 missing intrinsics: _mm_(mask/maskz)_cvtpbh_ps

2021-11-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper 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/D114059/new/

https://reviews.llvm.org/D114059

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


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

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Ping?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110549

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


[PATCH] D114059: [X86] add 3 missing intrinsics: _mm_(mask/maskz)_cvtpbh_ps

2021-11-16 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 387845.
FreddyYe added a comment.

convertion -> conversion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114059

Files:
  clang/lib/Headers/avx512bf16intrin.h
  clang/lib/Headers/avx512vlbf16intrin.h
  clang/test/CodeGen/X86/avx512vlbf16-builtins.c

Index: clang/test/CodeGen/X86/avx512vlbf16-builtins.c
===
--- clang/test/CodeGen/X86/avx512vlbf16-builtins.c
+++ clang/test/CodeGen/X86/avx512vlbf16-builtins.c
@@ -169,6 +169,15 @@
   return _mm_cvtness_sbh(A);
 }
 
+__m128 test_mm_cvtpbh_ps(__m128bh A) {
+  // CHECK-LABEL: @test_mm_cvtpbh_ps
+  // CHECK: sext <4 x i16> %{{.*}} to <4 x i32>
+  // CHECK: @llvm.x86.sse2.pslli.d
+  // CHECK: bitcast <2 x i64> %{{.*}} to <4 x float>
+  // CHECK: ret <4 x float> %{{.*}}
+  return _mm_cvtpbh_ps(A);
+}
+
 __m256 test_mm256_cvtpbh_ps(__m128bh A) {
   // CHECK-LABEL: @test_mm256_cvtpbh_ps
   // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
@@ -178,6 +187,16 @@
   return _mm256_cvtpbh_ps(A);
 }
 
+__m128 test_mm_maskz_cvtpbh_ps(__mmask8 M, __m128bh A) {
+  // CHECK-LABEL: @test_mm_maskz_cvtpbh_ps
+  // CHECK: sext <4 x i16> %{{.*}} to <4 x i32>
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
+  // CHECK: @llvm.x86.sse2.pslli.d
+  // CHECK: bitcast <2 x i64> %{{.*}} to <4 x float>
+  // CHECK: ret <4 x float> %{{.*}}
+  return _mm_maskz_cvtpbh_ps(M, A);
+}
+
 __m256 test_mm256_maskz_cvtpbh_ps(__mmask8 M, __m128bh A) {
   // CHECK-LABEL: @test_mm256_maskz_cvtpbh_ps
   // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
@@ -188,6 +207,16 @@
   return _mm256_maskz_cvtpbh_ps(M, A);
 }
 
+__m128 test_mm_mask_cvtpbh_ps(__m128 S, __mmask8 M, __m128bh A) {
+  // CHECK-LABEL: @test_mm_mask_cvtpbh_ps
+  // CHECK: sext <4 x i16> %{{.*}} to <4 x i32>
+  // CHECK: @llvm.x86.sse2.pslli.d
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
+  // CHECK: bitcast <2 x i64> %{{.*}} to <4 x float>
+  // CHECK: ret <4 x float> %{{.*}}
+  return _mm_mask_cvtpbh_ps(S, M, A);
+}
+
 __m256 test_mm256_mask_cvtpbh_ps(__m256 S, __mmask8 M, __m128bh A) {
   // CHECK-LABEL: @test_mm256_mask_cvtpbh_ps
   // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
Index: clang/lib/Headers/avx512vlbf16intrin.h
===
--- clang/lib/Headers/avx512vlbf16intrin.h
+++ clang/lib/Headers/avx512vlbf16intrin.h
@@ -420,18 +420,46 @@
   return __R[0];
 }
 
+/// Convert Packed BF16 Data to Packed float Data.
+///
+/// \headerfile 
+///
+/// \param __A
+///A 128-bit vector of [4 x bfloat].
+/// \returns A 128-bit vector of [4 x float] come from conversion of __A
+static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtpbh_ps(__m128bh __A) {
+  return _mm_castsi128_ps(
+  (__m128i)_mm_slli_epi32((__m128i)_mm_cvtepi16_epi32((__m128i)__A), 16));
+}
+
 /// Convert Packed BF16 Data to Packed float Data.
 ///
 /// \headerfile 
 ///
 /// \param __A
 ///A 128-bit vector of [8 x bfloat].
-/// \returns A 256-bit vector of [8 x float] come from convertion of __A
+/// \returns A 256-bit vector of [8 x float] come from conversion of __A
 static __inline__ __m256 __DEFAULT_FN_ATTRS256 _mm256_cvtpbh_ps(__m128bh __A) {
   return _mm256_castsi256_ps((__m256i)_mm256_slli_epi32(
   (__m256i)_mm256_cvtepi16_epi32((__m128i)__A), 16));
 }
 
+/// Convert Packed BF16 Data to Packed float Data using zeroing mask.
+///
+/// \headerfile 
+///
+/// \param __U
+///A 4-bit mask. Elements are zeroed out when the corresponding mask
+///bit is not set.
+/// \param __A
+///A 128-bit vector of [4 x bfloat].
+/// \returns A 128-bit vector of [4 x float] come from conversion of __A
+static __inline__ __m128 __DEFAULT_FN_ATTRS128
+_mm_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) {
+  return _mm_castsi128_ps((__m128i)_mm_slli_epi32(
+  (__m128i)_mm_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16));
+}
+
 /// Convert Packed BF16 Data to Packed float Data using zeroing mask.
 ///
 /// \headerfile 
@@ -441,13 +469,33 @@
 ///bit is not set.
 /// \param __A
 ///A 128-bit vector of [8 x bfloat].
-/// \returns A 256-bit vector of [8 x float] come from convertion of __A
+/// \returns A 256-bit vector of [8 x float] come from conversion of __A
 static __inline__ __m256 __DEFAULT_FN_ATTRS256
 _mm256_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) {
   return _mm256_castsi256_ps((__m256i)_mm256_slli_epi32(
   (__m256i)_mm256_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16));
 }
 
+/// Convert Packed BF16 Data to Packed float Data using merging mask.
+///
+/// \headerfile 
+///
+/// \param __S
+///A 128-bit vector of [4 x float]. Elements are copied from __S when
+/// the corresponding mask bit is not set.
+/// \param __U
+///A 4-bit mask. Elements are zeroed out when the corresponding mask
+///bit is not set.
+/// \param __A

[PATCH] D112404: [SPIR-V] Add translator tool

2021-11-16 Thread Henry Linjamäki via Phabricator via cfe-commits
linjamaki added a comment.

Hi @Anastasia and @bader,

This patch should be ready to land, I think. Could you please push it to the 
LLVM for us? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112404

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


[PATCH] D114059: [X86] add 3 missing intrinsics: _mm_(mask/maskz)_cvtpbh_ps

2021-11-16 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/lib/Headers/avx512vlbf16intrin.h:429
+///A 128-bit vector of [4 x bfloat].
+/// \returns A 128-bit vector of [4 x float] come from convertion of __A
+static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtpbh_ps(__m128bh __A) {

convertion -> conversion


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114059

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


[PATCH] D114058: [clang] Add ObjC decls to Decl::isFunctionOrFunctionTemplate

2021-11-16 Thread Sheldon Neuberger via Phabricator via cfe-commits
sheldonneuberger-sc created this revision.
sheldonneuberger-sc added a reviewer: nridge.
Herald added subscribers: usaxena95, kadircet.
sheldonneuberger-sc added a reviewer: erichkeane.
sheldonneuberger-sc edited the summary of this revision.
sheldonneuberger-sc published this revision for review.
Herald added subscribers: cfe-commits, ilya-biryukov.
Herald added a project: clang.

This fixes "textDocument/prepareCallHierarchy" in clangd for ObjC methods. 
Details at https://github.com/clangd/vscode-clangd/issues/247.

clangd uses Decl::isFunctionOrFunctionTemplate to check if the decl given in a 
prepareCallHierarchy request is eligible for prepareCallHierarchy, so we want 
it to return true for ObjC methods too. I added Block, Captured, and ObjCMethod 
because that's what was also done in DeclContext::isFunctionOrMethod.

Need guidance on if the function should be renamed to 
isFunctionOrMethodOrFunctionTemplate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114058

Files:
  clang/include/clang/AST/DeclBase.h


Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1040,9 +1040,15 @@
 
   /// Whether this declaration is a function or function template.
   bool isFunctionOrFunctionTemplate() const {
-return (DeclKind >= Decl::firstFunction &&
-DeclKind <= Decl::lastFunction) ||
-   DeclKind == FunctionTemplate;
+switch (DeclKind) {
+case Decl::Block:
+case Decl::Captured:
+case Decl::ObjCMethod:
+case Decl::FunctionTemplate:
+  return true;
+default:
+  return DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction;
+}
   }
 
   /// If this is a declaration that describes some template, this


Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -1040,9 +1040,15 @@
 
   /// Whether this declaration is a function or function template.
   bool isFunctionOrFunctionTemplate() const {
-return (DeclKind >= Decl::firstFunction &&
-DeclKind <= Decl::lastFunction) ||
-   DeclKind == FunctionTemplate;
+switch (DeclKind) {
+case Decl::Block:
+case Decl::Captured:
+case Decl::ObjCMethod:
+case Decl::FunctionTemplate:
+  return true;
+default:
+  return DeclKind >= Decl::firstFunction && DeclKind <= Decl::lastFunction;
+}
   }
 
   /// If this is a declaration that describes some template, this
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114059: [X86] add 3 missing intrinsics: _mm_(mask/maskz)_cvtpbh_ps

2021-11-16 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe created this revision.
Herald added a subscriber: pengfei.
FreddyYe 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/D114059

Files:
  clang/lib/Headers/avx512vlbf16intrin.h
  clang/test/CodeGen/X86/avx512vlbf16-builtins.c

Index: clang/test/CodeGen/X86/avx512vlbf16-builtins.c
===
--- clang/test/CodeGen/X86/avx512vlbf16-builtins.c
+++ clang/test/CodeGen/X86/avx512vlbf16-builtins.c
@@ -169,6 +169,15 @@
   return _mm_cvtness_sbh(A);
 }
 
+__m128 test_mm_cvtpbh_ps(__m128bh A) {
+  // CHECK-LABEL: @test_mm_cvtpbh_ps
+  // CHECK: sext <4 x i16> %{{.*}} to <4 x i32>
+  // CHECK: @llvm.x86.sse2.pslli.d
+  // CHECK: bitcast <2 x i64> %{{.*}} to <4 x float>
+  // CHECK: ret <4 x float> %{{.*}}
+  return _mm_cvtpbh_ps(A);
+}
+
 __m256 test_mm256_cvtpbh_ps(__m128bh A) {
   // CHECK-LABEL: @test_mm256_cvtpbh_ps
   // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
@@ -178,6 +187,16 @@
   return _mm256_cvtpbh_ps(A);
 }
 
+__m128 test_mm_maskz_cvtpbh_ps(__mmask8 M, __m128bh A) {
+  // CHECK-LABEL: @test_mm_maskz_cvtpbh_ps
+  // CHECK: sext <4 x i16> %{{.*}} to <4 x i32>
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
+  // CHECK: @llvm.x86.sse2.pslli.d
+  // CHECK: bitcast <2 x i64> %{{.*}} to <4 x float>
+  // CHECK: ret <4 x float> %{{.*}}
+  return _mm_maskz_cvtpbh_ps(M, A);
+}
+
 __m256 test_mm256_maskz_cvtpbh_ps(__mmask8 M, __m128bh A) {
   // CHECK-LABEL: @test_mm256_maskz_cvtpbh_ps
   // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
@@ -188,6 +207,16 @@
   return _mm256_maskz_cvtpbh_ps(M, A);
 }
 
+__m128 test_mm_mask_cvtpbh_ps(__m128 S, __mmask8 M, __m128bh A) {
+  // CHECK-LABEL: @test_mm_mask_cvtpbh_ps
+  // CHECK: sext <4 x i16> %{{.*}} to <4 x i32>
+  // CHECK: @llvm.x86.sse2.pslli.d
+  // CHECK: select <4 x i1> %{{.*}}, <4 x i32> %{{.*}}, <4 x i32> %{{.*}}
+  // CHECK: bitcast <2 x i64> %{{.*}} to <4 x float>
+  // CHECK: ret <4 x float> %{{.*}}
+  return _mm_mask_cvtpbh_ps(S, M, A);
+}
+
 __m256 test_mm256_mask_cvtpbh_ps(__m256 S, __mmask8 M, __m128bh A) {
   // CHECK-LABEL: @test_mm256_mask_cvtpbh_ps
   // CHECK: sext <8 x i16> %{{.*}} to <8 x i32>
Index: clang/lib/Headers/avx512vlbf16intrin.h
===
--- clang/lib/Headers/avx512vlbf16intrin.h
+++ clang/lib/Headers/avx512vlbf16intrin.h
@@ -420,6 +420,18 @@
   return __R[0];
 }
 
+/// Convert Packed BF16 Data to Packed float Data.
+///
+/// \headerfile 
+///
+/// \param __A
+///A 128-bit vector of [4 x bfloat].
+/// \returns A 128-bit vector of [4 x float] come from convertion of __A
+static __inline__ __m128 __DEFAULT_FN_ATTRS128 _mm_cvtpbh_ps(__m128bh __A) {
+  return _mm_castsi128_ps(
+  (__m128i)_mm_slli_epi32((__m128i)_mm_cvtepi16_epi32((__m128i)__A), 16));
+}
+
 /// Convert Packed BF16 Data to Packed float Data.
 ///
 /// \headerfile 
@@ -432,6 +444,22 @@
   (__m256i)_mm256_cvtepi16_epi32((__m128i)__A), 16));
 }
 
+/// Convert Packed BF16 Data to Packed float Data using zeroing mask.
+///
+/// \headerfile 
+///
+/// \param __U
+///A 4-bit mask. Elements are zeroed out when the corresponding mask
+///bit is not set.
+/// \param __A
+///A 128-bit vector of [4 x bfloat].
+/// \returns A 128-bit vector of [4 x float] come from convertion of __A
+static __inline__ __m128 __DEFAULT_FN_ATTRS128
+_mm_maskz_cvtpbh_ps(__mmask8 __U, __m128bh __A) {
+  return _mm_castsi128_ps((__m128i)_mm_slli_epi32(
+  (__m128i)_mm_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16));
+}
+
 /// Convert Packed BF16 Data to Packed float Data using zeroing mask.
 ///
 /// \headerfile 
@@ -448,6 +476,26 @@
   (__m256i)_mm256_maskz_cvtepi16_epi32((__mmask8)__U, (__m128i)__A), 16));
 }
 
+/// Convert Packed BF16 Data to Packed float Data using merging mask.
+///
+/// \headerfile 
+///
+/// \param __S
+///A 128-bit vector of [4 x float]. Elements are copied from __S when
+/// the corresponding mask bit is not set.
+/// \param __U
+///A 4-bit mask. Elements are zeroed out when the corresponding mask
+///bit is not set.
+/// \param __A
+///A 128-bit vector of [4 x bfloat].
+/// \returns A 128-bit vector of [4 x float] come from convertion of __A
+static __inline__ __m128 __DEFAULT_FN_ATTRS128
+_mm_mask_cvtpbh_ps(__m128 __S, __mmask8 __U, __m128bh __A) {
+  return _mm_castsi128_ps((__m128i)_mm_mask_slli_epi32(
+  (__m128i)__S, (__mmask8)__U, (__m128i)_mm_cvtepi16_epi32((__m128i)__A),
+  16));
+}
+
 /// Convert Packed BF16 Data to Packed float Data using merging mask.
 ///
 /// \headerfile 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114051: Illustrate an alternative for tracking includes per submodule.

2021-11-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 387834.
vsapsai added a comment.

Handle `BuildingSubmoduleStack` not storing the top-level module.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114051

Files:
  clang/include/clang/Lex/ExternalPreprocessorSource.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -57,7 +57,6 @@
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessingRecord.h"
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/Token.h"
 #include "clang/Sema/IdentifierResolver.h"
@@ -2170,16 +2169,15 @@
   return false;
 }
 
-void ASTWriter::addIncludedFiles(
-const llvm::DenseMap ,
-RecordDataImpl ) {
+void ASTWriter::addIncludedFiles(const Preprocessor::IncludeInfoMap ,
+ RecordDataImpl ) {
   // Map the FileEntry map into an input file ID vector.
   llvm::SmallVector> FileIDs;
   for (const auto  : Files) {
 auto InputFileIt = InputFileIDs.find(E.first);
 assert(InputFileIt != InputFileIDs.end() &&
"Included file is an known input file");
-FileIDs.emplace_back(InputFileIt->second, E.second);
+FileIDs.emplace_back(InputFileIt->second, E.second.NumIncludes);
   }
 
   // Ensure the order is stable.
@@ -2414,10 +2412,6 @@
MacroOffsetsBase - ASTBlockStartOffset};
 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record, bytes(MacroOffsets));
   }
-
-  addIncludedFiles(PP.getNullSubmoduleIncludes(), Record);
-  Stream.EmitRecord(PP_NUM_INCLUDES, Record);
-  Record.clear();
 }
 
 void ASTWriter::WritePreprocessorDetail(PreprocessingRecord ,
@@ -2814,7 +2808,8 @@
   Stream.EmitRecordWithBlob(ExportAsAbbrev, Record, Mod->ExportAsModule);
 }
 
-if (const auto *Includes = PP->getLocalSubmoduleIncludes(Mod)) {
+if (const Preprocessor::IncludeInfoMap *Includes =
+PP->getLocalSubmoduleIncludes(Mod)) {
   RecordData Record;
   addIncludedFiles(*Includes, Record);
   Stream.EmitRecord(SUBMODULE_NUM_INCLUDES, Record);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -3702,7 +3702,8 @@
 break;
 
   for (const auto  : readIncludedFiles(F, Record))
-PP.incrementTransitiveIncludeCount(E.getFirst(), E.getSecond());
+PP.incrementTransitiveIncludeCount(E.getFirst(),
+   E.getSecond().NumIncludes);
   break;
 }
 
@@ -8605,8 +8606,8 @@
   return LocalID + I->second;
 }
 
-llvm::DenseMap
-ASTReader::readIncludedFiles(ModuleFile , RecordData ) {
+Preprocessor::IncludeInfoMap ASTReader::readIncludedFiles(ModuleFile ,
+  RecordData ) {
   unsigned Idx = 0;
   unsigned TotalCount = Record[Idx++];
   unsigned IncludedOnceCount = Record[Idx++];
@@ -8617,25 +8618,25 @@
 return FileMgr.getOptionalFileRef(InputFileInfo.Filename);
   };
 
-  llvm::DenseMap Result;
+  Preprocessor::IncludeInfoMap Result;
   for (unsigned I = 0; I < IncludedOnceCount; ++I)
 if (const FileEntry *File = ReadFile())
-  Result.insert({File, 1});
+  Result.insert({File, {1}});
   for (unsigned I = 0; I < TotalCount - IncludedOnceCount; ++I)
 if (const FileEntry *File = ReadFile())
-  Result.insert({File, 2}); // squash "more than one" include into exactly 2
+  Result.insert(
+  {File, {2}}); // squash "more than one" include into exactly 2
   return Result;
 }
 
-const llvm::DenseMap *
-ASTReader::getIncludedFiles(Module *M) {
+const Preprocessor::IncludeInfoMap *ASTReader::getIncludedFiles(Module *M) {
   ModuleFile *F = getModuleManager().lookup(M->getASTFile());
   if (!F)
 return nullptr;
 
-  auto ResultIt = SubmoduleIncludedFiles.insert(
-  {M, llvm::DenseMap{}});
-  auto  = ResultIt.first->second;
+  auto ResultIt =
+  SubmoduleIncludedFiles.insert({M, Preprocessor::IncludeInfoMap{}});
+  Preprocessor::IncludeInfoMap  = ResultIt.first->second;
   if (!ResultIt.second)
 return 
 
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ clang/lib/Lex/Preprocessor.cpp
@@ -91,8 +91,7 @@
   // deferred to Preprocessor::Initialize().
   Identifiers(IILookup), PragmaHandlers(new 

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

2021-11-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 387828.
ChuanqiXu marked 2 inline comments as done.
ChuanqiXu added a comment.

Use `-Wno-coroutine` instead of `-Wno-deprectated-experimental-coroutine` to 
keep CI stable.


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

https://reviews.llvm.org/D113977

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

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

[PATCH] D51650: Implement target_clones multiversioning

2021-11-16 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D51650#3127097 , @aaron.ballman 
wrote:

> In D51650#3126569 , @akuegel wrote:
>
>> Since it is not clear whether the semantic change was intended, I think it 
>> makes sense to revert the patch for now. If it is intended, it might be good 
>> to mention it in the change description, so that people are warned.
>
> That looks like an unintended change to me, likely due to the new mutual 
> exclusion checks. Thanks for letting us know!

It was SORTA intended, I was going for 'conservative fix' here, but the 
'target' change was more of a 'while I was there' bit. I'm away for the next 
two weeks, but can re-land this without that plus a test to validate a winner 
(as that wasn't really the case before IIRC).

That said, the above example gives me some willies with regards to setting up 
multiversioning The interaction of two declarations here, 1 which adds a 
'target' to the pragma-push seems fishy/confusing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D51650

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


[PATCH] D112777: [X86][FP16] add alias for f*mul_*ch intrinsics

2021-11-16 Thread Freddy, Ye via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG73c9cf820409: [X86][FP16] add alias for f*mul_*ch intrinsics 
(authored by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112777

Files:
  clang/lib/Headers/avx512fp16intrin.h
  clang/lib/Headers/avx512vlfp16intrin.h
  clang/test/CodeGen/X86/avx512fp16-builtins.c
  clang/test/CodeGen/X86/avx512vlfp16-builtins.c

Index: clang/test/CodeGen/X86/avx512vlfp16-builtins.c
===
--- clang/test/CodeGen/X86/avx512vlfp16-builtins.c
+++ clang/test/CodeGen/X86/avx512vlfp16-builtins.c
@@ -3114,3 +3114,76 @@
   // CHECK: call nnan half @llvm.vector.reduce.fmax.v8f16(<8 x half> %{{.*}})
   return _mm_reduce_max_ph(__W);
 }
+
+// tests below are for alias intrinsics.
+__m128h test_mm_mul_pch(__m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.128
+  return _mm_mul_pch(__A, __B);
+}
+
+__m128h test_mm_mask_mul_pch(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_mask_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.128
+  return _mm_mask_mul_pch(__W, __U, __A, __B);
+}
+
+__m128h test_mm_maskz_mul_pch(__mmask8 __U, __m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_maskz_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.128
+  return _mm_maskz_mul_pch(__U, __A, __B);
+}
+
+__m256h test_mm256_mul_pch(__m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.256
+  return _mm256_mul_pch(__A, __B);
+}
+
+__m256h test_mm256_mask_mul_pch(__m256h __W, __mmask8 __U, __m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_mask_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.256
+  return _mm256_mask_mul_pch(__W, __U, __A, __B);
+}
+
+__m256h test_mm256_maskz_mul_pch(__mmask8 __U, __m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_maskz_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.256
+  return _mm256_maskz_mul_pch(__U, __A, __B);
+}
+
+__m128h test_mm_cmul_pch(__m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.128
+  return _mm_cmul_pch(__A, __B);
+}
+
+__m128h test_mm_mask_cmul_pch(__m128h __W, __mmask8 __U, __m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_mask_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.128
+  return _mm_mask_fcmul_pch(__W, __U, __A, __B);
+}
+
+__m128h test_mm_maskz_cmul_pch(__mmask8 __U, __m128h __A, __m128h __B) {
+  // CHECK-LABEL: @test_mm_maskz_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.128
+  return _mm_maskz_cmul_pch(__U, __A, __B);
+}
+
+__m256h test_mm256_cmul_pch(__m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.256
+  return _mm256_cmul_pch(__A, __B);
+}
+
+__m256h test_mm256_mask_cmul_pch(__m256h __W, __mmask8 __U, __m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_mask_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.256
+  return _mm256_mask_cmul_pch(__W, __U, __A, __B);
+}
+
+__m256h test_mm256_maskz_cmul_pch(__mmask8 __U, __m256h __A, __m256h __B) {
+  // CHECK-LABEL: @test_mm256_maskz_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.256
+  return _mm256_maskz_cmul_pch(__U, __A, __B);
+}
Index: clang/test/CodeGen/X86/avx512fp16-builtins.c
===
--- clang/test/CodeGen/X86/avx512fp16-builtins.c
+++ clang/test/CodeGen/X86/avx512fp16-builtins.c
@@ -4482,3 +4482,147 @@
   // CHECK:  %{{.*}} = bitcast <32 x i16> %{{.*}} to <32 x half>
   return _mm512_permutexvar_ph(__A, __B);
 }
+
+// tests below are for alias intrinsics.
+__m512h test_mm512_mul_pch(__m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.512
+  return _mm512_mul_pch(__A, __B);
+}
+
+__m512h test_mm512_mask_mul_pch(__m512h __W, __mmask16 __U, __m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_mask_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.512
+  return _mm512_mask_mul_pch(__W, __U, __A, __B);
+}
+
+__m512h test_mm512_maskz_mul_pch(__mmask16 __U, __m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_maskz_mul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfmul.cph.512
+  return _mm512_maskz_mul_pch(__U, __A, __B);
+}
+
+__m512h test_mm512_cmul_pch(__m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.512
+  return _mm512_cmul_pch(__A, __B);
+}
+__m512h test_mm512_mask_cmul_pch(__m512h __W, __mmask16 __U, __m512h __A, __m512h __B) {
+  // CHECK-LABEL: @test_mm512_mask_cmul_pch
+  // CHECK: @llvm.x86.avx512fp16.mask.vfcmul.cph.512
+  return _mm512_mask_cmul_pch(__W, __U, __A, __B);
+}
+

[clang] 73c9cf8 - [X86][FP16] add alias for f*mul_*ch intrinsics

2021-11-16 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2021-11-17T13:26:11+08:00
New Revision: 73c9cf820409834b134a8c8c8039efe4113845d9

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

LOG: [X86][FP16] add alias for f*mul_*ch intrinsics

*_mul_*ch is to align with *_mul_*s, *_mul_*d and *_mul_*h.

Reviewed By: pengfei

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

Added: 


Modified: 
clang/lib/Headers/avx512fp16intrin.h
clang/lib/Headers/avx512vlfp16intrin.h
clang/test/CodeGen/X86/avx512fp16-builtins.c
clang/test/CodeGen/X86/avx512vlfp16-builtins.c

Removed: 




diff  --git a/clang/lib/Headers/avx512fp16intrin.h 
b/clang/lib/Headers/avx512fp16intrin.h
index 91f7195d88f02..99409a31b32bd 100644
--- a/clang/lib/Headers/avx512fp16intrin.h
+++ b/clang/lib/Headers/avx512fp16intrin.h
@@ -3306,6 +3306,42 @@ _mm512_permutexvar_ph(__m512i __A, __m512h __B) {
   return (__m512h)__builtin_ia32_permvarhi512((__v32hi)__B, (__v32hi)__A);
 }
 
+// intrinsics below are alias for f*mul_*ch
+#define _mm512_mul_pch(A, B) _mm512_fmul_pch(A, B)
+#define _mm512_mask_mul_pch(W, U, A, B) _mm512_mask_fmul_pch(W, U, A, B)
+#define _mm512_maskz_mul_pch(U, A, B) _mm512_maskz_fmul_pch(U, A, B)
+#define _mm512_mul_round_pch(A, B, R) _mm512_fmul_round_pch(A, B, R)
+#define _mm512_mask_mul_round_pch(W, U, A, B, R)   
\
+  _mm512_mask_fmul_round_pch(W, U, A, B, R)
+#define _mm512_maskz_mul_round_pch(U, A, B, R) 
\
+  _mm512_maskz_fmul_round_pch(U, A, B, R)
+
+#define _mm512_cmul_pch(A, B) _mm512_fcmul_pch(A, B)
+#define _mm512_mask_cmul_pch(W, U, A, B) _mm512_mask_fcmul_pch(W, U, A, B)
+#define _mm512_maskz_cmul_pch(U, A, B) _mm512_maskz_fcmul_pch(U, A, B)
+#define _mm512_cmul_round_pch(A, B, R) _mm512_fcmul_round_pch(A, B, R)
+#define _mm512_mask_cmul_round_pch(W, U, A, B, R)  
\
+  _mm512_mask_fcmul_round_pch(W, U, A, B, R)
+#define _mm512_maskz_cmul_round_pch(U, A, B, R)
\
+  _mm512_maskz_fcmul_round_pch(U, A, B, R)
+
+#define _mm_mul_sch(A, B) _mm_fmul_sch(A, B)
+#define _mm_mask_mul_sch(W, U, A, B) _mm_mask_fmul_sch(W, U, A, B)
+#define _mm_maskz_mul_sch(U, A, B) _mm_maskz_fmul_sch(U, A, B)
+#define _mm_mul_round_sch(A, B, R) _mm_fmul_round_sch(A, B, R)
+#define _mm_mask_mul_round_sch(W, U, A, B, R)  
\
+  _mm_mask_fmul_round_sch(W, U, A, B, R)
+#define _mm_maskz_mul_round_sch(U, A, B, R) _mm_maskz_fmul_round_sch(U, A, B, 
R)
+
+#define _mm_cmul_sch(A, B) _mm_fcmul_sch(A, B)
+#define _mm_mask_cmul_sch(W, U, A, B) _mm_mask_fcmul_sch(W, U, A, B)
+#define _mm_maskz_cmul_sch(U, A, B) _mm_maskz_fcmul_sch(U, A, B)
+#define _mm_cmul_round_sch(A, B, R) _mm_fcmul_round_sch(A, B, R)
+#define _mm_mask_cmul_round_sch(W, U, A, B, R) 
\
+  _mm_mask_fcmul_round_sch(W, U, A, B, R)
+#define _mm_maskz_cmul_round_sch(U, A, B, R)   
\
+  _mm_maskz_fcmul_round_sch(U, A, B, R)
+
 #undef __DEFAULT_FN_ATTRS128
 #undef __DEFAULT_FN_ATTRS256
 #undef __DEFAULT_FN_ATTRS512

diff  --git a/clang/lib/Headers/avx512vlfp16intrin.h 
b/clang/lib/Headers/avx512vlfp16intrin.h
index 5f596879bb2e1..3d27853ad9648 100644
--- a/clang/lib/Headers/avx512vlfp16intrin.h
+++ b/clang/lib/Headers/avx512vlfp16intrin.h
@@ -2047,6 +2047,21 @@ _mm_reduce_min_ph(__m128h __V) {
   return __builtin_ia32_reduce_fmin_ph128(__V);
 }
 
+// intrinsics below are alias for f*mul_*ch
+#define _mm_mul_pch(A, B) _mm_fmul_pch(A, B)
+#define _mm_mask_mul_pch(W, U, A, B) _mm_mask_fmul_pch(W, U, A, B)
+#define _mm_maskz_mul_pch(U, A, B) _mm_maskz_fmul_pch(U, A, B)
+#define _mm256_mul_pch(A, B) _mm256_fmul_pch(A, B)
+#define _mm256_mask_mul_pch(W, U, A, B) _mm256_mask_fmul_pch(W, U, A, B)
+#define _mm256_maskz_mul_pch(U, A, B) _mm256_maskz_fmul_pch(U, A, B)
+
+#define _mm_cmul_pch(A, B) _mm_fcmul_pch(A, B)
+#define _mm_mask_cmul_pch(W, U, A, B) _mm_mask_fcmul_pch(W, U, A, B)
+#define _mm_maskz_cmul_pch(U, A, B) _mm_maskz_fcmul_pch(U, A, B)
+#define _mm256_cmul_pch(A, B) _mm256_fcmul_pch(A, B)
+#define _mm256_mask_cmul_pch(W, U, A, B) _mm256_mask_fcmul_pch(W, U, A, B)
+#define _mm256_maskz_cmul_pch(U, A, B) _mm256_maskz_fcmul_pch(U, A, B)
+
 #undef __DEFAULT_FN_ATTRS128
 #undef __DEFAULT_FN_ATTRS256
 

diff  --git a/clang/test/CodeGen/X86/avx512fp16-builtins.c 
b/clang/test/CodeGen/X86/avx512fp16-builtins.c
index 024ff86e10e35..3faa153d0408c 100644
--- a/clang/test/CodeGen/X86/avx512fp16-builtins.c
+++ b/clang/test/CodeGen/X86/avx512fp16-builtins.c
@@ -4482,3 +4482,147 @@ __m512h test_mm512_permutexvar_epi16(__m512i __A, 
__m512h __B) {
   // CHECK:  %{{.*}} = bitcast <32 x i16> %{{.*}} to <32 x half>
   return _mm512_permutexvar_ph(__A, __B);
 }
+
+// tests below are 

[PATCH] D109751: [Clang] Support conversion between PPC double-double and IEEE float128

2021-11-16 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf updated this revision to Diff 387819.
qiucf added a comment.

Disallow conversion in compound and conditional


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

https://reviews.llvm.org/D109751

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/CodeGen/ibm128-cast.c
  clang/test/Sema/float128-ld-incompatibility.cpp

Index: clang/test/Sema/float128-ld-incompatibility.cpp
===
--- clang/test/Sema/float128-ld-incompatibility.cpp
+++ clang/test/Sema/float128-ld-incompatibility.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 \
 // RUN: -triple powerpc64le-unknown-linux-gnu -target-cpu pwr9 \
-// RUN: -target-feature +float128 %s
+// RUN: -Wno-unused-value -Wno-parentheses -target-feature +float128 %s
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -triple x86_64-unknown-linux-gnu -Wno-unused-value -Wno-parentheses %s
 
 __float128 qf();
@@ -35,5 +35,5 @@
   q / ld; // expected-error {{invalid operands to binary expression ('__float128' and 'long double')}}
   ld = q; // expected-error {{assigning to 'long double' from incompatible type '__float128'}}
   q = ld; // expected-error {{assigning to '__float128' from incompatible type 'long double'}}
-  q + b ? q : ld; // expected-error {{incompatible operand types ('__float128' and 'long double')}}
+  q + b ? q : ld; // expected-no-error
 }
Index: clang/test/CodeGen/ibm128-cast.c
===
--- clang/test/CodeGen/ibm128-cast.c
+++ clang/test/CodeGen/ibm128-cast.c
@@ -2,11 +2,18 @@
 // RUN:   -target-feature +float128 -mabi=ieeelongdouble -fsyntax-only -Wno-unused %s
 // RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown -verify \
 // RUN:   -target-feature +float128 -fsyntax-only -Wno-unused %s
+// RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown -DCODEGEN \
+// RUN:   -target-feature +float128 -mabi=ieeelongdouble %s -o - | FileCheck %s
 
-__float128 cast1(__ibm128 x) { return x; } // expected-error {{returning '__ibm128' from a function with incompatible result type '__float128'}}
+// CHECK: define dso_local fp128 @cast1(ppc_fp128 %{{.+}})
+// CHECK: %{{.+}} = call fp128 @llvm.ppc.convert.ppcf128.to.f128(ppc_fp128 %{{.+}})
+__float128 cast1(__ibm128 x) { return x; } // expected-no-error
 
-__ibm128 cast2(__float128 x) { return x; } // expected-error {{returning '__float128' from a function with incompatible result type '__ibm128'}}
+// IEEE: define dso_local ppc_fp128 @cast2(fp128 %{{.+}})
+// IEEE: %{{.+}} = call ppc_fp128 @llvm.ppc.convert.f128.to.ppcf128(fp128 %{{.+}})
+__ibm128 cast2(__float128 x) { return x; } // expected-no-error
 
+#ifndef CODEGEN
 __ibm128 gf;
 
 void narrow(double *d, float *f) {
@@ -17,9 +24,9 @@
 }
 
 #ifdef __LONG_DOUBLE_IEEE128__
-long double cast3(__ibm128 x) { return x; } // expected-error {{returning '__ibm128' from a function with incompatible result type 'long double'}}
+long double cast3(__ibm128 x) { return x; } // expected-no-error
 
-__ibm128 cast4(long double x) { return x; } // expected-error {{returning 'long double' from a function with incompatible result type '__ibm128'}}
+__ibm128 cast4(long double x) { return x; } // expected-no-error
 
 void imp_cast(__ibm128 w, __float128 q, long double l, _Bool b) {
   w + q;  // expected-error {{invalid operands to binary expression ('__ibm128' and '__float128')}}
@@ -30,12 +37,12 @@
   q *w;   // expected-error {{invalid operands to binary expression ('__float128' and '__ibm128')}}
   q / w;  // expected-error {{invalid operands to binary expression ('__float128' and '__ibm128')}}
   w / l;  // expected-error {{invalid operands to binary expression ('__ibm128' and 'long double')}}
-  w = q;  // expected-error {{assigning to '__ibm128' from incompatible type '__float128'}}
-  q = w;  // expected-error {{assigning to '__float128' from incompatible type '__ibm128'}}
-  l = w;  // expected-error {{assigning to 'long double' from incompatible type '__ibm128'}}
-  w = l;  // expected-error {{assigning to '__ibm128' from incompatible type 'long double'}}
-  b ? q : w;  // expected-error {{incompatible operand types ('__float128' and '__ibm128')}}
-  !b ? w : l; // expected-error {{incompatible operand types ('__ibm128' and 'long double')}}
+  w = q;  // expected-no-error {{assigning to '__ibm128' from incompatible type '__float128'}}
+  q = w;  // expected-no-error {{assigning to '__float128' from incompatible type '__ibm128'}}
+  l = w;  // expected-no-error {{assigning to 'long double' from incompatible type '__ibm128'}}
+  w = l;  // expected-no-error {{assigning to '__ibm128' from incompatible type 'long double'}}
+  b ? q : w;  // expected-no-error {{incompatible operand types ('__float128' and '__ibm128')}}
+  !b ? w : l; // expected-no-error {{incompatible operand types ('__ibm128' and 'long double')}}
 }
 

[PATCH] D109751: [Clang] Support conversion between PPC double-double and IEEE float128

2021-11-16 Thread Qiu Chaofan via Phabricator via cfe-commits
qiucf added a comment.

In D109751#3131169 , @nemanjai wrote:

> Please provide a description for this patch which includes justification for 
> why we want to allow conversion between the two types.
> I am of the impression that allowing the two types to coexist in completely 
> disjoint code should be fine, but I really don't see a compelling reason to 
> allow conversions between the two types.

The motivating case is failure after D92815 : 
`clang compiler-rt/test/builtins/Unit/multc3_test.c -I 
compiler-rt/lib/builtins/ -mfloat128 -mcpu=power9 -lm`

  compiler-rt/test/builtins/Unit/multc3_test.c:24:15: error: passing 'long 
double' to parameter of incompatible type '_Float128' (aka '__float128')

Because the piece of code will be expanded to:

  if ((__builtin_types_compatible_p(__typeof(creall(x)), _Float128)
   ? __isinff128(creall(x))
   : __builtin_isinf_sign(creall(x))) ||
  (__builtin_types_compatible_p(__typeof(cimagl(x)), _Float128)
   ? __isinff128(cimagl(x))
   : __builtin_isinf_sign(cimagl(x
return inf;

which requires 'long double' (the same semantics to `__ibm128` by default) and 
'_Float128' are compatible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109751

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


[PATCH] D112915: [clang][modules] Track number of includes per submodule

2021-11-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Didn't go in-depth for serialization/deserialization. When we add tracking 
`isImport` on per-submodule basis, do you think AST reading/writing would 
change significantly?




Comment at: clang/include/clang/Lex/ExternalPreprocessorSource.h:45
+  /// Return the files directly included in the given (sub)module.
+  virtual const llvm::DenseMap *
+  getIncludedFiles(Module *M) = 0;

I think it is better for understanding and more convenient to use some `using` 
instead of duplicating `llvm::DenseMap` in 
multiple places.



Comment at: clang/include/clang/Lex/Preprocessor.h:775-781
+  struct SubmoduleIncludeState {
+/// For each included file, we track the number of includes.
+llvm::DenseMap IncludedFiles;
+
+/// The set of modules that are visible within the submodule.
+VisibleModuleSet VisibleModules;
+  };

I think the interplay between `CurSubmoduleIncludeState`, `IncludedFiles`, and 
`CurSubmoduleState` is pretty complicated. Recently I've realized that it can 
be beneficial to distinguish include tracking for the purpose of serializing 
per submodule and for the purpose of deciding if should enter a file. In 
D114051 I've tried to illustrate this approach. There are some tests failing 
but hope the main idea is still understandable.

One of my big concerns is tracking `VisibleModules` in multiple places. D114051 
demonstrates one of the ways to deal with it but I think it is more important 
for you to know the problem I was trying to solve, not the solution I came up 
with.



Comment at: clang/lib/Basic/Module.cpp:653
 ImportLocs[ID] = Loc;
-Vis(M);
+Vis(V.M);
 

Was meaning to make this fix for a long time but couldn't test it. Thanks for 
finally fixing it!



Comment at: clang/lib/Lex/Preprocessor.cpp:1336
+  [&](Module *M) {
+const auto *Includes = getLocalSubmoduleIncludes(M);
+if (!Includes)

If I drop checking `getLocalSubmoduleIncludes`, no tests are failing. But it 
seems like this call is required. How can we test it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112915

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


[PATCH] D114051: Illustrate an alternative for tracking includes per submodule.

2021-11-16 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
Herald added a subscriber: ributzka.
vsapsai requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Aggregated transitive includes are stored in SubmoduleState, includes
per submodule for subsequent serialization are stored in
IncludedFilesPerSubmodule.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114051

Files:
  clang/include/clang/Lex/ExternalPreprocessorSource.h
  clang/include/clang/Lex/Preprocessor.h
  clang/include/clang/Serialization/ASTReader.h
  clang/include/clang/Serialization/ASTWriter.h
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Lex/Preprocessor.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp

Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -57,7 +57,6 @@
 #include "clang/Lex/MacroInfo.h"
 #include "clang/Lex/ModuleMap.h"
 #include "clang/Lex/PreprocessingRecord.h"
-#include "clang/Lex/Preprocessor.h"
 #include "clang/Lex/PreprocessorOptions.h"
 #include "clang/Lex/Token.h"
 #include "clang/Sema/IdentifierResolver.h"
@@ -2170,16 +2169,15 @@
   return false;
 }
 
-void ASTWriter::addIncludedFiles(
-const llvm::DenseMap ,
-RecordDataImpl ) {
+void ASTWriter::addIncludedFiles(const Preprocessor::IncludeInfoMap ,
+ RecordDataImpl ) {
   // Map the FileEntry map into an input file ID vector.
   llvm::SmallVector> FileIDs;
   for (const auto  : Files) {
 auto InputFileIt = InputFileIDs.find(E.first);
 assert(InputFileIt != InputFileIDs.end() &&
"Included file is an known input file");
-FileIDs.emplace_back(InputFileIt->second, E.second);
+FileIDs.emplace_back(InputFileIt->second, E.second.NumIncludes);
   }
 
   // Ensure the order is stable.
@@ -2414,10 +2412,6 @@
MacroOffsetsBase - ASTBlockStartOffset};
 Stream.EmitRecordWithBlob(MacroOffsetAbbrev, Record, bytes(MacroOffsets));
   }
-
-  addIncludedFiles(PP.getNullSubmoduleIncludes(), Record);
-  Stream.EmitRecord(PP_NUM_INCLUDES, Record);
-  Record.clear();
 }
 
 void ASTWriter::WritePreprocessorDetail(PreprocessingRecord ,
@@ -2814,7 +2808,8 @@
   Stream.EmitRecordWithBlob(ExportAsAbbrev, Record, Mod->ExportAsModule);
 }
 
-if (const auto *Includes = PP->getLocalSubmoduleIncludes(Mod)) {
+if (const Preprocessor::IncludeInfoMap *Includes =
+PP->getLocalSubmoduleIncludes(Mod)) {
   RecordData Record;
   addIncludedFiles(*Includes, Record);
   Stream.EmitRecord(SUBMODULE_NUM_INCLUDES, Record);
Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -3702,7 +3702,8 @@
 break;
 
   for (const auto  : readIncludedFiles(F, Record))
-PP.incrementTransitiveIncludeCount(E.getFirst(), E.getSecond());
+PP.incrementTransitiveIncludeCount(E.getFirst(),
+   E.getSecond().NumIncludes);
   break;
 }
 
@@ -8605,8 +8606,8 @@
   return LocalID + I->second;
 }
 
-llvm::DenseMap
-ASTReader::readIncludedFiles(ModuleFile , RecordData ) {
+Preprocessor::IncludeInfoMap ASTReader::readIncludedFiles(ModuleFile ,
+  RecordData ) {
   unsigned Idx = 0;
   unsigned TotalCount = Record[Idx++];
   unsigned IncludedOnceCount = Record[Idx++];
@@ -8617,25 +8618,25 @@
 return FileMgr.getOptionalFileRef(InputFileInfo.Filename);
   };
 
-  llvm::DenseMap Result;
+  Preprocessor::IncludeInfoMap Result;
   for (unsigned I = 0; I < IncludedOnceCount; ++I)
 if (const FileEntry *File = ReadFile())
-  Result.insert({File, 1});
+  Result.insert({File, {1}});
   for (unsigned I = 0; I < TotalCount - IncludedOnceCount; ++I)
 if (const FileEntry *File = ReadFile())
-  Result.insert({File, 2}); // squash "more than one" include into exactly 2
+  Result.insert(
+  {File, {2}}); // squash "more than one" include into exactly 2
   return Result;
 }
 
-const llvm::DenseMap *
-ASTReader::getIncludedFiles(Module *M) {
+const Preprocessor::IncludeInfoMap *ASTReader::getIncludedFiles(Module *M) {
   ModuleFile *F = getModuleManager().lookup(M->getASTFile());
   if (!F)
 return nullptr;
 
-  auto ResultIt = SubmoduleIncludedFiles.insert(
-  {M, llvm::DenseMap{}});
-  auto  = ResultIt.first->second;
+  auto ResultIt =
+  SubmoduleIncludedFiles.insert({M, Preprocessor::IncludeInfoMap{}});
+  Preprocessor::IncludeInfoMap  = ResultIt.first->second;
   if (!ResultIt.second)
 return 
 
Index: clang/lib/Lex/Preprocessor.cpp
===
--- clang/lib/Lex/Preprocessor.cpp
+++ 

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

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



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

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

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

2021-11-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu marked 5 inline comments as done.
ChuanqiXu added inline comments.



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

Quuxplusone wrote:
> I'd like to see the next word in this diagnostic. (Ditto throughout. I'd also 
> like to make sure that the diagnostic is not being printed with single-quotes 
> in the wrong place, e.g. `Found deprecated 
> std::experimental::'coroutine_handle'`; if it is, please fix that.)
> 
> This code is also misindented; please fix it up, as long as you're touching 
> it. Should be
> ```
> for co_await (auto i : arr) {}
> ```
Oh, clang-format couldn't recognize the new grammar. I need to be careful to 
use it to format codes.



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

ldionne wrote:
> 
Since the option is new added, I wonder if the CI would break if it didn't 
update compiler in time. (Or if it would run CI for previous compiler). Let's 
see if the CI would be green.


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

https://reviews.llvm.org/D113977

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


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

2021-11-16 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 387811.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D113977

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

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

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

2021-11-16 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Does GCC actually change the formal types of expressions to `float`, or is it 
doing this "no intermediate casts thing" as some sort of fp_contract-style 
custom emission of trees of expressions that involve `_Float16`?

In any case, doing operation-by-operation emulation seems like the right first 
approach rather than starting by doing the less conformant thing.


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

https://reviews.llvm.org/D113107

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


[PATCH] D110927: [analyzer] Access stored value of a constant array through a pointer to another type

2021-11-16 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Taking advantage of strict aliasing is good as long as it produces strictly 
smaller analysis space (less paths, more constrained states). I.e., we can use 
it for eliminating possibilities, but not for discovering possibilities.

If we ever prove that strict aliasing is violated on a given execution path 
(while being enabled), the ideal thing to do is to terminate the analysis 
immediately by generating a sink. We can then optionally develop a checker that 
emits a warning in such cases.

For the cases where you eliminate possibilities through recognizing strict 
aliasing, I wonder if a note can be added to the bug report to notify the user 
that the strict aliasing rule was invoked to add a certain assumption.


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

https://reviews.llvm.org/D110927

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


[PATCH] D106756: Added l16/l32 length modifiers for char16_t/char32_t

2021-11-16 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 387788.
MarcusJohnson91 added a comment.

Clang-FormatDiff.py; Still waiting for the UTFConvert patch to land first.


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

https://reviews.llvm.org/D106756

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/FormatString.h
  clang/lib/AST/FormatString.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/ScanfFormatString.cpp
  clang/test/Sema/format-strings-int-typedefs.c
  clang/test/SemaCXX/format-strings.cpp

Index: clang/test/SemaCXX/format-strings.cpp
===
--- clang/test/SemaCXX/format-strings.cpp
+++ clang/test/SemaCXX/format-strings.cpp
@@ -24,6 +24,8 @@
 
 void g() {
   printf("%ls", "foo"); // expected-warning{{format specifies type 'wchar_t *' but the argument has type 'const char *'}}
+  printf("%l16s", "foo"); // expected-warning{{format specifies type 'char16_t *' but the argument has type 'const char *'}}
+  printf("%l32s", "foo"); // expected-warning{{format specifies type 'char32_t *' but the argument has type 'const char *'}}
 }
 
 // Test that we properly handle format_idx on C++ members.
Index: clang/test/Sema/format-strings-int-typedefs.c
===
--- clang/test/Sema/format-strings-int-typedefs.c
+++ clang/test/Sema/format-strings-int-typedefs.c
@@ -10,18 +10,35 @@
   printf("%td", 42.0); // expected-warning {{format specifies type 'ptrdiff_t' (aka 'int')}}
   printf("%lc", 42.0); // expected-warning {{format specifies type 'wint_t' (aka 'int')}}
   printf("%ls", 42.0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+  printf("%l16c", 42.0); // expected-warning {{format specifies type 'char16_t' (aka 'int')}}
+  printf("%l16s", 42.0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  printf("%l32c", 42.0); // expected-warning {{format specifies type 'char32_t' (aka 'int')}}
+  printf("%l32s", 42.0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
   printf("%S", 42.0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   printf("%C", 42.0);  // expected-warning {{format specifies type 'wchar_t' (aka 'int')}}
 
+  wprintf(L"%l16c", 42.0); // expected-warning {{format specifies type 'char16_t' (aka 'short')}}
+  wprintf(L"%l16s", 42.0); // expected-warning {{format specifies type 'char16_t *' (aka 'short *')}}
+  wprintf(L"%l32c", 42.0); // expected-warning {{format specifies type 'char32_t' (aka 'int')}}
+  wprintf(L"%l32s", 42.0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
+
   scanf("%jd", 0); // expected-warning {{format specifies type 'intmax_t *' (aka 'long long *')}}
   scanf("%ju", 0); // expected-warning {{format specifies type 'uintmax_t *' (aka 'unsigned long long *')}}
   scanf("%zu", 0); // expected-warning {{format specifies type 'size_t *' (aka 'unsigned long *')}}
   scanf("%td", 0); // expected-warning {{format specifies type 'ptrdiff_t *' (aka 'int *')}}
   scanf("%lc", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   scanf("%ls", 0); // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
+  scanf("%l16c", 0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  scanf("%l16s", 0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  scanf("%l32c", 0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
+  scanf("%l32s", 0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
   scanf("%S",  0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
   scanf("%C",  0);  // expected-warning {{format specifies type 'wchar_t *' (aka 'int *')}}
 
+  wscanf("%l16c", 0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  wscanf("%l16s", 0); // expected-warning {{format specifies type 'char16_t *' (aka 'int *')}}
+  wscanf("%l32c", 0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
+  wscanf("%l32s", 0); // expected-warning {{format specifies type 'char32_t *' (aka 'int *')}}
 
   // typedef size_t et al. to something crazy.
   typedef void *size_t;
Index: clang/lib/AST/ScanfFormatString.cpp
===
--- clang/lib/AST/ScanfFormatString.cpp
+++ clang/lib/AST/ScanfFormatString.cpp
@@ -261,6 +261,8 @@
 case LengthModifier::AsInt32:
 case LengthModifier::AsInt3264:
 case LengthModifier::AsWide:
+case LengthModifier::AsUTF16:
+case LengthModifier::AsUTF32:
 case LengthModifier::AsShortLong:
   return ArgType::Invalid();
   }
@@ -302,6 +304,8 @@
 case LengthModifier::AsInt32:
 case LengthModifier::AsInt3264:
 case LengthModifier::AsWide:
+case 

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

2021-11-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov added a comment.

In D114006#3135456 , @steakhal wrote:

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

Thanks! That depends on the mood at the particular moment :) But seriously, 
it's an automatic typo. I do it every other time :) Fixed.


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

https://reviews.llvm.org/D114006

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


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

2021-11-16 Thread Denys Petrov via Phabricator via cfe-commits
ASDenysPetrov updated this revision to Diff 387773.
ASDenysPetrov added a comment.

Fixed failed unittest.


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

https://reviews.llvm.org/D114006

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

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

[PATCH] D114036: Add Android test case for -Wpartial-availability. Also update Android availability tests to match on the whole string, so we can distinguish between "Android 16" and "Android 16.0.0"

2021-11-16 Thread Stephen Hines via Phabricator via cfe-commits
srhines accepted this revision.
srhines added a comment.

Thanks for the expanded (and more specific) tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114036

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


[PATCH] D113943: Add `withTag` matcher.

2021-11-16 Thread James King via Phabricator via cfe-commits
jcking1034 updated this revision to Diff 387769.
jcking1034 added a comment.

Improve wrapping of PolymorphicMatchers


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113943

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.h

Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -43,6 +43,7 @@
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
 #include "clang/AST/NestedNameSpecifier.h"
+#include "clang/AST/PrettyPrinter.h"
 #include "clang/AST/Stmt.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -1042,6 +1043,44 @@
   std::vector Names;
 };
 
+template  class WithTagMatcher : public MatcherInterface {
+public:
+  explicit WithTagMatcher(std::string _BeforeTag, std::string _AfterTag,
+  internal::Matcher _InnerMatcher)
+  : BeforeTag(std::move(_BeforeTag)), AfterTag(std::move(_AfterTag)),
+InnerMatcher(_InnerMatcher) {}
+  explicit WithTagMatcher(internal::Matcher _InnerMatcher)
+  : BeforeTag("⭐ Attempting new match"),
+AfterTag("✔️ Concluding attempt"), InnerMatcher(_InnerMatcher) {}
+  bool matches(const T , ASTMatchFinder *Finder,
+   BoundNodesTreeBuilder *Builder) const override {
+DynTypedNode DTN = DynTypedNode::create(Node);
+
+llvm::errs() << BeforeTag << "\n";
+
+llvm::errs() << "Matcher Name: " << InnerMatcher.getMatcherName() << "\n";
+
+llvm::errs() << "Node Kind: " << DTN.getNodeKind().asStringRef() << "\n"
+ << "Node Value:\n```\n";
+DTN.print(llvm::errs(), PrintingPolicy(LangOptions()));
+llvm::errs() << "\n```\n"
+ << "Node AST:\n";
+DTN.dump(llvm::errs(), Finder->getASTContext());
+
+bool result = InnerMatcher.matches(Node, Finder, Builder);
+llvm::errs() << "Result: " << (result ? "Successful\n" : "Unsuccessful\n");
+
+llvm::errs() << AfterTag << "\n\n";
+
+return result;
+  }
+
+private:
+  std::string BeforeTag;
+  std::string AfterTag;
+  internal::Matcher InnerMatcher;
+};
+
 /// Matches named declarations with a specific name.
 ///
 /// See \c hasName() and \c hasAnyName() in ASTMatchers.h for details.
@@ -1718,6 +1757,38 @@
   std::tuple Params;
 };
 
+template  class MatcherT,
+  typename ReturnTypesF, typename... ParamTypes>
+class PolymorphicWithTagMatcher {
+public:
+  PolymorphicWithTagMatcher(
+  internal::PolymorphicMatcher
+  _InnerMatcher)
+  : InnerMatcher(_InnerMatcher) {}
+
+  using ReturnTypes = typename ExtractFunctionArgMeta::type;
+
+  template  operator Matcher() const LLVM_LVALUE_FUNCTION {
+static_assert(TypeListContainsSuperOf::value,
+  "right polymorphic conversion");
+return internal::Matcher(
+new internal::WithTagMatcher(internal::Matcher(InnerMatcher)));
+  }
+
+#if LLVM_HAS_RVALUE_REFERENCE_THIS
+  template  operator Matcher() && {
+static_assert(TypeListContainsSuperOf::value,
+  "right polymorphic conversion");
+return internal::Matcher(new internal::WithTagMatcher(
+internal::Matcher(std::move(InnerMatcher;
+  }
+#endif
+
+private:
+  internal::PolymorphicMatcher
+  InnerMatcher;
+};
+
 /// Matches nodes of type T that have child nodes of type ChildT for
 /// which a specified child matcher matches.
 ///
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -2993,6 +2993,40 @@
   new internal::HasNameMatcher({std::string(Name)}));
 }
 
+template 
+inline internal::Matcher withTag(std::string BeforeTag, std::string AfterTag,
+const internal::Matcher ) {
+  return internal::Matcher(
+  new internal::WithTagMatcher(BeforeTag, AfterTag, InnerMatcher));
+}
+
+template  class MatcherT,
+  typename ReturnTypesF, typename... ParamTypes>
+inline internal::PolymorphicWithTagMatcher
+withTag(std::string BeforeTag, std::string AfterTag,
+const internal::PolymorphicMatcher ) {
+  return internal::PolymorphicWithTagMatcher(BeforeTag, AfterTag,
+InnerMatcher);
+}
+
+template 
+inline internal::Matcher withTag(const internal::Matcher ) {
+  return internal::Matcher(new internal::WithTagMatcher(InnerMatcher));
+}
+
+template  class MatcherT,
+  typename ReturnTypesF, typename... ParamTypes>
+inline internal::PolymorphicWithTagMatcher
+withTag(const internal::PolymorphicMatcher ) {
+  return internal::PolymorphicWithTagMatcher(InnerMatcher);
+}
+
 /// Matches NamedDecl 

[PATCH] D114036: Add Android test case for -Wpartial-availability. Also update Android availability tests to match on the whole string, so we can distinguish between "Android 16" and "Android 16.0.0"

2021-11-16 Thread James Farrell via Phabricator via cfe-commits
jamesfarrell created this revision.
Herald added a subscriber: danielkiss.
jamesfarrell 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/D114036

Files:
  clang/test/Sema/attr-availability-android.c


Index: clang/test/Sema/attr-availability-android.c
===
--- clang/test/Sema/attr-availability-android.c
+++ clang/test/Sema/attr-availability-android.c
@@ -1,8 +1,12 @@
 // RUN: %clang_cc1 "-triple" "arm-linux-androideabi16" -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D WARN_PARTIAL -Wpartial-availability "-triple" 
"arm-linux-androideabi16" -fsyntax-only -verify %s
 
 void f0(int) 
__attribute__((availability(android,introduced=14,deprecated=19)));
 void f1(int) __attribute__((availability(android,introduced=16)));
 void f2(int) 
__attribute__((availability(android,introduced=14,deprecated=16))); // 
expected-note {{'f2' has been explicitly marked deprecated here}}
+#ifdef WARN_PARTIAL
+// expected-note-re@+2 {{'f3' has been marked as being introduced in Android 
19 here, but the deployment target is Android 16.0.0{{$
+#endif
 void f3(int) __attribute__((availability(android,introduced=19)));
 void f4(int) 
__attribute__((availability(android,introduced=9,deprecated=11,obsoleted=16), 
availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly 
marked unavailable}}
 void f5(int) __attribute__((availability(ios,introduced=3.2), 
availability(android,unavailable))); // expected-note{{'f5' has been explicitly 
marked unavailable here}}
@@ -10,9 +14,12 @@
 void test() {
   f0(0);
   f1(0);
-  f2(0); // expected-warning{{'f2' is deprecated: first deprecated in Android 
16}}
+  f2(0); // expected-warning-re{{'f2' is deprecated: first deprecated in 
Android 16{{$
+#ifdef WARN_PARTIAL
+// expected-warning@+2{{'f3' is only available on Android 19 or newer}} 
expected-note@+2{{enclose 'f3' in a __builtin_available check to silence this 
warning}}
+#endif
   f3(0);
-  f4(0); // expected-error{{f4' is unavailable: obsoleted in Android 16}}
+  f4(0); // expected-error-re{{'f4' is unavailable: obsoleted in Android 
16{{$
   f5(0); // expected-error{{'f5' is unavailable: not available on Android}}
 }
 


Index: clang/test/Sema/attr-availability-android.c
===
--- clang/test/Sema/attr-availability-android.c
+++ clang/test/Sema/attr-availability-android.c
@@ -1,8 +1,12 @@
 // RUN: %clang_cc1 "-triple" "arm-linux-androideabi16" -fsyntax-only -verify %s
+// RUN: %clang_cc1 -D WARN_PARTIAL -Wpartial-availability "-triple" "arm-linux-androideabi16" -fsyntax-only -verify %s
 
 void f0(int) __attribute__((availability(android,introduced=14,deprecated=19)));
 void f1(int) __attribute__((availability(android,introduced=16)));
 void f2(int) __attribute__((availability(android,introduced=14,deprecated=16))); // expected-note {{'f2' has been explicitly marked deprecated here}}
+#ifdef WARN_PARTIAL
+// expected-note-re@+2 {{'f3' has been marked as being introduced in Android 19 here, but the deployment target is Android 16.0.0{{$
+#endif
 void f3(int) __attribute__((availability(android,introduced=19)));
 void f4(int) __attribute__((availability(android,introduced=9,deprecated=11,obsoleted=16), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}}
 void f5(int) __attribute__((availability(ios,introduced=3.2), availability(android,unavailable))); // expected-note{{'f5' has been explicitly marked unavailable here}}
@@ -10,9 +14,12 @@
 void test() {
   f0(0);
   f1(0);
-  f2(0); // expected-warning{{'f2' is deprecated: first deprecated in Android 16}}
+  f2(0); // expected-warning-re{{'f2' is deprecated: first deprecated in Android 16{{$
+#ifdef WARN_PARTIAL
+// expected-warning@+2{{'f3' is only available on Android 19 or newer}} expected-note@+2{{enclose 'f3' in a __builtin_available check to silence this warning}}
+#endif
   f3(0);
-  f4(0); // expected-error{{f4' is unavailable: obsoleted in Android 16}}
+  f4(0); // expected-error-re{{'f4' is unavailable: obsoleted in Android 16{{$
   f5(0); // expected-error{{'f5' is unavailable: not available on Android}}
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112481: [Sema] fix nondeterminism in ASTContext::getDeducedTemplateSpecializationType

2021-11-16 Thread Igor Sugak via Phabricator via cfe-commits
sugak added a comment.

ping @rsmith


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112481

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


[PATCH] D114034: [clang-tidy] fix debug-only test failure

2021-11-16 Thread Matt Beardsley via Phabricator via cfe-commits
mattbeardsley added a subscriber: dstenb.
mattbeardsley added a comment.

@dstenb - wanted to check with you too to make sure that this change to 
pr37091.cpp seems like it won't interfere with the original intent of the test 
(https://reviews.llvm.org/D45686 )

The lingering file issue you'd fixed seemed to be independent of any particular 
clang-tidy check, but if not, hopefully it can at least get away with not 
relying on the top-level .clang-tidy anymore!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114034

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


[PATCH] D114034: [clang-tidy] fix debug-only test failure

2021-11-16 Thread Matt Beardsley via Phabricator via cfe-commits
mattbeardsley created this revision.
mattbeardsley added a reviewer: kbobyrev.
Herald added a subscriber: xazax.hun.
mattbeardsley requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang-tools-extra.

The clang-tidy/infrastructure/pr37091.cpp test inherits the top-level 
.clang-tidy configuration because it doesn't specify its own checks, which ends 
up including misc-RenameFcn. This results in an assert when built with 
"-DCMAKE_BUILD_TYPE=Debug" because fQualifiedName is an empty string in 
"hasName(fQualifiedName)" in RenamefcnCheck.cpp (because none of the config 
options for misc-RenameFcn are provided - not that they should be). The 
HasNameMatcher::HasNameMatcher implementation behind hasName(...) asserts on 
empty strings.

Fixed in 2 ways:

- make the clang-tidy/infrastructure/pr37091.cpp test independent of the 
top-level .clang-tidy (picked an arbitrary check that I saw another 
clang-tidy/infrastructure test was also using: 
clang-tidy/infrastructure/temporaries.cpp)
- It's not useful for the top-level .clang-tidy to have misc-RenameFcn enabled 
anyway, so disabled that

(each of those changes fixes the debug-only assert in 
clang-tidy/infrastructure/pr37091.cpp on its own, but I thought each change had 
its own merits)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114034

Files:
  .clang-tidy
  clang-tools-extra/test/clang-tidy/infrastructure/pr37091.cpp


Index: clang-tools-extra/test/clang-tidy/infrastructure/pr37091.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/pr37091.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/pr37091.cpp
@@ -6,5 +6,5 @@
 //
 // Verify that no temporary files are left behind by the clang-tidy invocation.
 
-// RUN: env TMPDIR=%t TEMP=%t TMP=%t clang-tidy %s -- --target=mips64
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t clang-tidy 
-checks='-*,clang-analyzer-core.NullDereference' %s -- --target=mips64
 // RUN: rmdir %t
Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -1,4 +1,4 @@
-Checks: 
'-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
+Checks: 
'-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-RenameFcn,readability-identifier-naming'
 CheckOptions:
   - key: readability-identifier-naming.ClassCase
 value:   CamelCase


Index: clang-tools-extra/test/clang-tidy/infrastructure/pr37091.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/pr37091.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/pr37091.cpp
@@ -6,5 +6,5 @@
 //
 // Verify that no temporary files are left behind by the clang-tidy invocation.
 
-// RUN: env TMPDIR=%t TEMP=%t TMP=%t clang-tidy %s -- --target=mips64
+// RUN: env TMPDIR=%t TEMP=%t TMP=%t clang-tidy -checks='-*,clang-analyzer-core.NullDereference' %s -- --target=mips64
 // RUN: rmdir %t
Index: .clang-tidy
===
--- .clang-tidy
+++ .clang-tidy
@@ -1,4 +1,4 @@
-Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,readability-identifier-naming'
+Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,-misc-non-private-member-variables-in-classes,-misc-no-recursion,-misc-RenameFcn,readability-identifier-naming'
 CheckOptions:
   - key: readability-identifier-naming.ClassCase
 value:   CamelCase
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

update the set type


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

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

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

[PATCH] D112773: Allow __attribute__((swift_attr)) in attribute push pragmas

2021-11-16 Thread Becca Royal-Gordon via Phabricator via cfe-commits
beccadax added a comment.

> My reading of 
> https://clang.llvm.org/docs/LanguageExtensions.html#specifying-an-attribute-for-multiple-declarations-pragma-clang-attribute
>  suggests that any() /could/ apply to everything. (`The any rule applies 
> attributes to all declarations that are matched by at least one of the rules 
> in the any.`)

My reading of that rule suggest that an `any()` with no subrules would not 
match anything because, if you fed in a declaration, none of the (nonexistent) 
subrules of the `any()` would match it.

> My recollection of the discussions when we adopted #pragma clang attribute is 
> that we tried our best to limit the damage from the pragma over-applying 
> attributes, but I don't recall if we explicitly talked about any() with no 
> subjects. What would make me comfortable with this patch is 1) doing some 
> archeology to find the original reviews for pragma clang attribute to see if 
> we made any sort of explicit decision here but forgot to document it. If we 
> didn't make an explicit decision in this area, we should make one now. We can 
> either decide "any() with no subjects applies to everything", "any() with no 
> subjects is dangerous and will apply to nothing", or "any() with no subjects 
> is dangerous and we will diagnose if the user tries this" (probably other 
> ideas we could consider). Ultimately, I would like to see the pragma clang 
> attribute documentation updated before/when we land this bit so that our 
> documentation clearly sets user expectations.

Looking at https://reviews.llvm.org/D30009, I don't see any relevant discussion 
of how `any()` (without subrules) should behave. What I do see is that they 
started with "match everything always" behavior, but concerns about users not 
knowing which declarations it would be applied to (and how that behavior might 
change as the compiler evolved) led them to the idea of requiring users to list 
the declarations they expected the compiler to match and having a way to allow 
a subset ; then they realized that only 
the subset version was actually useful 
. What I take from this is that there 
was clearly concern about users not being able to tell what the pragma would 
affect and they changed the design so that users would need to specify it 
clearly, which suggests that a way to leave it unspecified was seen as an 
anti-goal.

Looking at the implementation of 
`Parser::ParsePragmaAttributeSubjectMatchRuleSet()`, it looks like `any` or 
`any()` would cause a parse error—we return `true` (as in the error branches) 
if we do not parse an open parenthesis or do not parse an identifier after the 
open parenthesis—which again makes me think that the design intentionally left 
out any mechanism to match all subjects.

We don't have a statement that there is and should be no way to apply 
`attribute push` to everything, but I think we can conclude that having such a 
capability wasn't a goal of the final design.

What would you like me to do from here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112773

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


[PATCH] D114031: Full matching for version numbers.

2021-11-16 Thread James Farrell via Phabricator via cfe-commits
jamesfarrell created this revision.
jamesfarrell 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/D114031

Files:
  clang/test/Sema/attr-availability-android.c


Index: clang/test/Sema/attr-availability-android.c
===
--- clang/test/Sema/attr-availability-android.c
+++ clang/test/Sema/attr-availability-android.c
@@ -11,7 +11,7 @@
 void f4(int) 
__attribute__((availability(android,introduced=9,deprecated=11,obsoleted=16), 
availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly 
marked unavailable}}
 void f5(int) __attribute__((availability(ios,introduced=3.2), 
availability(android,unavailable))); // expected-note{{'f5' has been explicitly 
marked unavailable here}}
 #ifdef WARN_PARTIAL
-// expected-note@+2 {{'f6' has been marked as being introduced in Android 31 
here, but the deployment target is Android 21}}
+// expected-note-re@+2 {{'f6' has been marked as being introduced in Android 
31 here, but the deployment target is Android 21{{$
 #endif
 void f6(int) __attribute__((availability(android,introduced=31)));
 


Index: clang/test/Sema/attr-availability-android.c
===
--- clang/test/Sema/attr-availability-android.c
+++ clang/test/Sema/attr-availability-android.c
@@ -11,7 +11,7 @@
 void f4(int) __attribute__((availability(android,introduced=9,deprecated=11,obsoleted=16), availability(ios,introduced=2.0,deprecated=3.0))); // expected-note{{explicitly marked unavailable}}
 void f5(int) __attribute__((availability(ios,introduced=3.2), availability(android,unavailable))); // expected-note{{'f5' has been explicitly marked unavailable here}}
 #ifdef WARN_PARTIAL
-// expected-note@+2 {{'f6' has been marked as being introduced in Android 31 here, but the deployment target is Android 21}}
+// expected-note-re@+2 {{'f6' has been marked as being introduced in Android 31 here, but the deployment target is Android 21{{$
 #endif
 void f6(int) __attribute__((availability(android,introduced=31)));
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D114029: [clang][NFC] Inclusive terms: rename AccessDeclContextSanity to AccessDeclContextCheck

2021-11-16 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: klimek, akyrtzi, quinnp.
ZarkoCA added a project: clang.
ZarkoCA requested review of this revision.
Herald added subscribers: lldb-commits, cfe-commits.
Herald added a project: LLDB.

Rename function to more inclusive name.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114029

Files:
  clang/include/clang/AST/DeclBase.h
  clang/lib/AST/DeclBase.cpp
  lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -91,7 +91,7 @@
   assert(decl && "VerifyDecl called with nullptr?");
 #ifndef NDEBUG
   // We don't care about the actual access value here but only want to trigger
-  // that Clang calls its internal Decl::AccessDeclContextSanity check.
+  // that Clang calls its internal Decl::AccessDeclContextCheck validation.
   decl->getAccess();
 #endif
 }
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -964,7 +964,7 @@
   return {};
 }
 
-bool Decl::AccessDeclContextSanity() const {
+bool Decl::AccessDeclContextCheck() const {
 #ifndef NDEBUG
   // Suppress this check if any of the following hold:
   // 1. this is the translation unit (and thus has no parent)
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -352,7 +352,7 @@
  DeclContext *Parent, std::size_t Extra = 0);
 
 private:
-  bool AccessDeclContextSanity() const;
+  bool AccessDeclContextCheck() const;
 
   /// Get the module ownership kind to use for a local lexical child of \p DC,
   /// which may be either a local or (rarely) an imported declaration.
@@ -472,11 +472,11 @@
 
   void setAccess(AccessSpecifier AS) {
 Access = AS;
-assert(AccessDeclContextSanity());
+assert(AccessDeclContextCheck());
   }
 
   AccessSpecifier getAccess() const {
-assert(AccessDeclContextSanity());
+assert(AccessDeclContextCheck());
 return AccessSpecifier(Access);
   }
 


Index: lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
===
--- lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
+++ lldb/source/Plugins/TypeSystem/Clang/TypeSystemClang.cpp
@@ -91,7 +91,7 @@
   assert(decl && "VerifyDecl called with nullptr?");
 #ifndef NDEBUG
   // We don't care about the actual access value here but only want to trigger
-  // that Clang calls its internal Decl::AccessDeclContextSanity check.
+  // that Clang calls its internal Decl::AccessDeclContextCheck validation.
   decl->getAccess();
 #endif
 }
Index: clang/lib/AST/DeclBase.cpp
===
--- clang/lib/AST/DeclBase.cpp
+++ clang/lib/AST/DeclBase.cpp
@@ -964,7 +964,7 @@
   return {};
 }
 
-bool Decl::AccessDeclContextSanity() const {
+bool Decl::AccessDeclContextCheck() const {
 #ifndef NDEBUG
   // Suppress this check if any of the following hold:
   // 1. this is the translation unit (and thus has no parent)
Index: clang/include/clang/AST/DeclBase.h
===
--- clang/include/clang/AST/DeclBase.h
+++ clang/include/clang/AST/DeclBase.h
@@ -352,7 +352,7 @@
  DeclContext *Parent, std::size_t Extra = 0);
 
 private:
-  bool AccessDeclContextSanity() const;
+  bool AccessDeclContextCheck() const;
 
   /// Get the module ownership kind to use for a local lexical child of \p DC,
   /// which may be either a local or (rarely) an imported declaration.
@@ -472,11 +472,11 @@
 
   void setAccess(AccessSpecifier AS) {
 Access = AS;
-assert(AccessDeclContextSanity());
+assert(AccessDeclContextCheck());
   }
 
   AccessSpecifier getAccess() const {
-assert(AccessDeclContextSanity());
+assert(AccessDeclContextCheck());
 return AccessSpecifier(Access);
   }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112413: [X86] Add -mskip-rax-setup support to align with GCC

2021-11-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added inline comments.



Comment at: llvm/test/CodeGen/X86/pr23258.ll:22
+
+declare dso_local void @bar(i32, ...)
+

nickdesaulniers wrote:
> Is there anything one the callee side that we should check? I assume the 
> callee does some check of `%al` normally?
s/one/on/


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112413

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


[PATCH] D112413: [X86] Add -mskip-rax-setup support to align with GCC

2021-11-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers added a comment.

It might be nice to add an `llvm-link` test that produces an error when this 
module metadata doesn't match.  Basically, it would be nice to error if during 
LTO we link together two modules that differ in their use of `-mskip-rax-setup` 
since that has ABI implications between the two modules. 
https://llvm.org/docs/LangRef.html#module-flags-metadata




Comment at: clang/include/clang/Basic/CodeGenOptions.def:455
 
+/// Whether to skip RAX setup when passing variable arguments.
+CODEGENOPT(SkipRaxSetup, 1, 0)

Maybe note that this is x86 specific?



Comment at: clang/include/clang/Driver/Options.td:3193
+def mskip_rax_setup : Flag<["-"], "mskip-rax-setup">, Group, 
Flags<[NoXarchOption]>,
+  HelpText<"Skip setting up RAX register when passing variable arguments (x86 
only)">;
 def mstackrealign : Flag<["-"], "mstackrealign">, Group, 
Flags<[CC1Option]>,

pengfei wrote:
> MaskRay wrote:
> > nickdesaulniers wrote:
> > > I think GCC support `-mno-skip-rax-setup` as well. Can you please add 
> > > that (and tests for it) as well?  We don't need to actually handle it, I 
> > > think, but we shouldn't warn about the flag being unsupported, for 
> > > example.
> > Consider `SimpleMFlag`
> Thanks for the suggestion. I think adding a `-mno-skip-rax-setup` is simply 
> here.
Via @MaskRay 's suggestion, can we do something like:

```
def skip_rax_setup : SimpleMFlag<"skip-rax-setup", "Skip", "Do not skip", 
"setting up RAX register when passing variable arguments (x86 only)">;
```

Do we test that this flag is warned about being unused for non-x86 targets? (Is 
it worth adding such a test to clang)?



Comment at: llvm/test/CodeGen/X86/pr23258.ll:4
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=+sse | FileCheck %s 
--check-prefix=HAS-RAX
+; RUN: llc < %s -mtriple=x86_64-unknown-linux-gnu -mattr=-sse | FileCheck %s 
--check-prefix=NO-RAX
+

Might be worth testing the fourth case: +sse, SkipRaxSetup == 0. Though I think 
that exposes that `X86TargetLowering::X86TargetLowering` is only checking 
whether the Metadata exists, not whether it has a particular value.



Comment at: llvm/test/CodeGen/X86/pr23258.ll:17
+; NO-RAX-NEXT:jmp bar # TAILCALL
+entry:
+  tail call void (i32, ...) @bar(i32 1)

might be able to remove `entry:`, `dso_local`, and `nounwind`?



Comment at: llvm/test/CodeGen/X86/pr23258.ll:22
+
+declare dso_local void @bar(i32, ...)
+

Is there anything one the callee side that we should check? I assume the callee 
does some check of `%al` normally?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112413

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


[PATCH] D114025: [clang][NFC] Inclusive terms: replace some uses of sanity in clang

2021-11-16 Thread Zarko Todorovski via Phabricator via cfe-commits
ZarkoCA created this revision.
ZarkoCA added reviewers: aaron.ballman, dcoughlin, quinnp.
ZarkoCA added a project: clang.
Herald added subscribers: dexonsmith, martong.
ZarkoCA requested review of this revision.
Herald added a subscriber: cfe-commits.

Rewording of comments to avoid using `sanity test, sanity check`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114025

Files:
  clang/include/clang/AST/Redeclarable.h
  clang/include/clang/Analysis/CFG.h
  clang/include/clang/CodeGen/CGFunctionInfo.h
  clang/include/clang/Sema/Lookup.h
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/Analysis/RetainSummaryManager.cpp
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Frontend/FrontendActions.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
  clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/Store.cpp
  clang/lib/Tooling/Syntax/Tree.cpp

Index: clang/lib/Tooling/Syntax/Tree.cpp
===
--- clang/lib/Tooling/Syntax/Tree.cpp
+++ clang/lib/Tooling/Syntax/Tree.cpp
@@ -126,7 +126,7 @@
   for (auto *N = New; N; N = N->NextSibling) {
 assert(N->Parent == nullptr);
 assert(N->getRole() != NodeRole::Detached && "Roles must be set");
-// FIXME: sanity-check the role.
+// FIXME: validate the role.
   }
 
   auto Reachable = [](Node *From, Node *N) {
Index: clang/lib/StaticAnalyzer/Core/Store.cpp
===
--- clang/lib/StaticAnalyzer/Core/Store.cpp
+++ clang/lib/StaticAnalyzer/Core/Store.cpp
@@ -249,7 +249,7 @@
 }
 
 SVal StoreManager::evalDerivedToBase(SVal Derived, const CastExpr *Cast) {
-  // Sanity check to avoid doing the wrong thing in the face of
+  // Verify that we avoid doing the wrong thing in the face of
   // reinterpret_cast.
   if (!regionMatchesCXXRecordType(Derived, Cast->getSubExpr()->getType()))
 return UnknownVal();
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -326,8 +326,8 @@
 }
 Result = InitWithAdjustments;
   } else {
-// We need to create a region no matter what. For sanity, make sure we don't
-// try to stuff a Loc into a non-pointer temporary region.
+// We need to create a region no matter what. Make sure we don't try to
+// stuff a Loc into a non-pointer temporary region.
 assert(!InitValWithAdjustments.getAs() ||
Loc::isLocType(Result->getType()) ||
Result->getType()->isMemberPointerType());
Index: clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
===
--- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -1670,7 +1670,7 @@
   if (isUnderconstrained(PrevN)) {
 IsSatisfied = true;
 
-// As a sanity check, make sure that the negation of the constraint
+// As a validation check, make sure that the negation of the constraint
 // was infeasible in the current state.  If it is feasible, we somehow
 // missed the transition point.
 assert(!isUnderconstrained(N));
Index: clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/UnixAPIChecker.cpp
@@ -182,8 +182,7 @@
   ProgramStateRef state = C.getState();
 
   if (CE->getNumArgs() < MinArgCount) {
-// The frontend should issue a warning for this case, so this is a sanity
-// check.
+// The frontend should issue a warning for this case, check for that here.
 return;
   } else if (CE->getNumArgs() == MaxArgCount) {
 const Expr *Arg = CE->getArg(CreateModeArgIndex);
@@ -366,7 +365,7 @@
  const unsigned numArgs,
  const unsigned sizeArg,
  const char *fn) const {
-  // Sanity check for the correct number of arguments
+  // Check for the correct number of arguments.
   if (CE->getNumArgs() != numArgs)
 return;
 
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- 

[PATCH] D114023: [Driver] Pass --fix-cortex-a53-843419 automatically on Fuchsia

2021-11-16 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added inline comments.



Comment at: clang/lib/Driver/ToolChains/Fuchsia.cpp:91
+std::string CPU = getCPUName(D, Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");

How does this relate to -march, -mtune, and/or -mcpu?
It's not at all clear to me how we discern automatically when a A53 might be 
included in the supported target CPU set.  I'm not entirely sure we should have 
automatic injection in some cases where A53 is a valid target but not all.  
That is, if some compiler option combinations that produce code meant to be 
compatible with an A53 won't automatically get the --fix option, then perhaps 
it's better to require the explicit --fix option when supporting A53 is the 
explicit intent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114023

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


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

2021-11-16 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D110216#3135461 , @hans wrote:

> We're seeing a diagnostic change in Chromium which looks funny. For the 
> following code (span<> is our own class):
> 
> the diagnostic changes from:
>
>   fatal error: no viable conversion from 'span' to 
> 'span
>
> to
>
>   fatal error: no viable conversion from 'span' to 'span
>
> This looks very strange.

Hi! thanks for the report.

I am not sure how to reproduce this.

I tried mocking this situation:

  template  struct vector {};
  template  struct span {};
  
  template  auto make_span(const vector &) { return span(); }
  
  void WontCompile() {
const vector v;
  
span s1 = make_span(v);
  }

Which I get:

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

Looking at the `dump` of that type:

  AutoType 0x246b83676c0 'span' sugar
  `-ElaboratedType 0x246b8366d60 'span' sugar
`-TemplateSpecializationType 0x246b8366d20 'span' sugar span
  |-TemplateArgument type 'const int':'const int'
  | `-QualType 0x246b8366751 'const int' const
  |   `-SubstTemplateTypeParmType 0x246b8366750 'int' sugar
  | |-TemplateTypeParmType 0x246b835c790 'T' dependent depth 0 index 0
  | | `-TemplateTypeParm 0x246b835c740 'T'
  | `-BuiltinType 0x246b82e81e0 'int'
  `-RecordType 0x246b8366d00 'struct span'
`-ClassTemplateSpecialization 0x246b8366be8 'span'

In particular, the `SubstTemplateTypeParmType` desugars to int, not `T`, and I 
am not sure how you managed to get that ellipsis (from the type diff) on the 
template specialization arguments.

I am looking though at a clang built from `D112374`, which is main with what I 
believe are other patches that have no effect here besides the addition of the 
`ElaboratedType` node on that dump.

To be sure, it's going to take me a while to get a main built here, so 
hopefully this is not a big problem for you right now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

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


[PATCH] D114023: [Driver] Pass --fix-cortex-a53-843419 automatically on Fuchsia

2021-11-16 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: mcgrathr, leonardchan.
Herald added a subscriber: abrachet.
phosek requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When targeting cortex-a53, set this linker flag rather than relying
on the toolchain users to do it in their build.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114023

Files:
  clang/lib/Driver/ToolChains/Fuchsia.cpp
  clang/test/Driver/fuchsia.c


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -40,6 +40,7 @@
 // CHECK: "-pie"
 // CHECK: "--build-id"
 // CHECK: "--hash-style=gnu"
+// CHECK-AARCH64: "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
 // CHECK: Scrt1.o
 // CHECK-NOT: crti.o
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -37,6 +37,8 @@
   static_cast(getToolChain());
   const Driver  = ToolChain.getDriver();
 
+  const llvm::Triple  = ToolChain.getEffectiveTriple();
+
   ArgStringList CmdArgs;
 
   // Silence warning for "clang -g foo.o -o foo"
@@ -84,6 +86,12 @@
 CmdArgs.push_back("--hash-style=gnu");
   }
 
+  if (ToolChain.getArch() == llvm::Triple::aarch64) {
+std::string CPU = getCPUName(D, Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   CmdArgs.push_back("--eh-frame-hdr");
 
   if (Args.hasArg(options::OPT_static))


Index: clang/test/Driver/fuchsia.c
===
--- clang/test/Driver/fuchsia.c
+++ clang/test/Driver/fuchsia.c
@@ -40,6 +40,7 @@
 // CHECK: "-pie"
 // CHECK: "--build-id"
 // CHECK: "--hash-style=gnu"
+// CHECK-AARCH64: "--fix-cortex-a53-843419"
 // CHECK: "-dynamic-linker" "ld.so.1"
 // CHECK: Scrt1.o
 // CHECK-NOT: crti.o
Index: clang/lib/Driver/ToolChains/Fuchsia.cpp
===
--- clang/lib/Driver/ToolChains/Fuchsia.cpp
+++ clang/lib/Driver/ToolChains/Fuchsia.cpp
@@ -37,6 +37,8 @@
   static_cast(getToolChain());
   const Driver  = ToolChain.getDriver();
 
+  const llvm::Triple  = ToolChain.getEffectiveTriple();
+
   ArgStringList CmdArgs;
 
   // Silence warning for "clang -g foo.o -o foo"
@@ -84,6 +86,12 @@
 CmdArgs.push_back("--hash-style=gnu");
   }
 
+  if (ToolChain.getArch() == llvm::Triple::aarch64) {
+std::string CPU = getCPUName(D, Args, Triple);
+if (CPU.empty() || CPU == "generic" || CPU == "cortex-a53")
+  CmdArgs.push_back("--fix-cortex-a53-843419");
+  }
+
   CmdArgs.push_back("--eh-frame-hdr");
 
   if (Args.hasArg(options::OPT_static))
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D112143: [X86][ABI] Do not return float/double from x87 registers when x87 is disabled

2021-11-16 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.
This revision is now accepted and ready to land.

Just a comment on the ECX bit, otherwise this patch looks fine to me. Someone 
with more x86 knowledge may want to take a look though. Thanks for the patch!




Comment at: llvm/lib/Target/X86/X86CallingConv.td:279
+  CCIfNotSubtarget<"hasX87()",
+CCIfType<[f32], CCAssignToReg<[EAX, EDX, ECX]>>>,
   CCIfType<[f16], CCAssignToReg<[XMM0,XMM1,XMM2]>>,

Is there a test case that exercises the assignment to %ecx?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112143

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113840

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


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

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

In D113889#3134857 , @kuhnel wrote:

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113889

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


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

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

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




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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

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


[PATCH] D114011: Add a clang-transformer tutorial

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

tweaks


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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114011

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114003

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


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


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

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

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

add test for the new lint behavior:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

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

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

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

2021-11-16 Thread Victor Huang via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGae27ca9a6783: [PowerPC] PPC backend optimization on 
conditional trap intrustions (authored by NeHuang).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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

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

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

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

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

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

the diagnostic changes from:

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

to

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

This looks very strange.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110216

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


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

2021-11-16 Thread River Riddle via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4c484f11d355: [llvm] Add a SFINAE template parameter to 
DenseMapInfo (authored by rriddle).

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113641

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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114006

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


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

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



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

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

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

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



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

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



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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

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


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

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

clean up the code and remove debug statements


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113946

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

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

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

2021-11-16 Thread River Riddle via cfe-commits

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

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

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

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

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

Added: 


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

Removed: 




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

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

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

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

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

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

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



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

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

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



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

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



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

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

Agree. Thanks for catching this!



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

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

How do I actually do that?



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

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

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

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

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

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

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




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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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


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

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

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112374

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

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

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

Address review comments by @whisperity:

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

Also:

- use `hasUnqualifiedDesugaredType` -> handle typedefs better


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D112646

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

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

[PATCH] D111100: enable plugins for clang-tidy

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

Yes, this header does everything


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D00

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


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

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

.


mizvekov added a comment.

.


mizvekov added a comment.

..


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

.


mizvekov added a comment.

..


mizvekov added a comment.

- Run libcxx CI.




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

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



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

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



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

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



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





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

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



Comment at: 

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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113776

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


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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113776

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


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

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



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

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





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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113776

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


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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114003

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


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

2021-11-16 Thread Quinn Pham via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ed404a4abd3: [NFC][clang] Inclusive language: Rename 
myMaster in testcase (authored by quinnp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113433

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


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


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

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

2021-11-16 Thread Quinn Pham via cfe-commits

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

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

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

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

Reviewed By: ZarkoCA

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

Added: 


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

Removed: 




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

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



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


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

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

In D110257#3134001 , @JonChesterfield 
wrote:

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113925

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

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

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

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

clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114003

Files:
  clang/lib/Lex/LiteralSupport.cpp


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


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


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

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

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

NOTE: The half of the changes is just formatting.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114006

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

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

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

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

LGTM, thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113433

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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


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

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

Addressed review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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

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

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

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

enabled DEFAULT_LINKER_BUILD_ID_STYLE in linux


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113993

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


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

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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113942

Files:
  clang/utils/convert_arm_neon.py


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


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


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

2021-11-16 Thread Quinn Pham via cfe-commits

Author: Quinn Pham
Date: 2021-11-16T10:11:06-06:00
New Revision: d4b28a0fe6857e0404d07b0989eeced05eaa45e7

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

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

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

Reviewed By: kristof.beyls

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

Added: 


Modified: 
clang/utils/convert_arm_neon.py

Removed: 




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



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


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

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



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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111434

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


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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114003

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


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

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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D114003

Files:
  clang/lib/Lex/LiteralSupport.cpp


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


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


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

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



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

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



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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113977

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113977

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


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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113889

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


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

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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113889

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


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


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


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

2021-11-16 Thread Christian Kühnel via cfe-commits

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

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

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

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

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

Added: 


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

Removed: 




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



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


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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113306

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


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


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

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

2021-11-16 Thread Ahsan Saghir via cfe-commits

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

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

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

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

Reviewed By: nemanjai

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

Added: 


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

Removed: 




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

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

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



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


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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113895

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


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


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


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

2021-11-16 Thread Christian Kühnel via cfe-commits

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

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

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

Fixing the clang-tidy finding.

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

Added: 


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

Removed: 




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



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


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

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

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

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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113999

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


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


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

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

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

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


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

https://reviews.llvm.org/D113538

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


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

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

ping


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

https://reviews.llvm.org/D113538

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


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

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

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

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


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D110257

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


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

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

Add a small comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113995

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


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


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

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

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

These are the trigrams for queries right now:

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

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D113995

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


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

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

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

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113993

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


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

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

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

LGTM with some suggestions, thanks for adding this notice!




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





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

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

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



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




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113977

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


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

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

Use correct CMake variable type: BOOLEAN -> BOOL


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113993

Files:
  clang/CMakeLists.txt


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

  1   2   >