[PATCH] D128952: [AMDGPU] Add WMMA clang builtins

2022-06-30 Thread Piotr Sobczak 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 rG4a7822521277: [AMDGPU] Add WMMA clang builtins (authored by 
piotr).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128952

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w32.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl

Index: clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl
@@ -0,0 +1,84 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -DWMMA_GFX1100_TESTS -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-GFX1100
+
+typedef float  v4f   __attribute__((ext_vector_type(4)));
+typedef float  v8f   __attribute__((ext_vector_type(8)));
+typedef half   v8h   __attribute__((ext_vector_type(8)));
+typedef half   v16h  __attribute__((ext_vector_type(16)));
+typedef intv2i   __attribute__((ext_vector_type(2)));
+typedef intv4i   __attribute__((ext_vector_type(4)));
+typedef intv8i   __attribute__((ext_vector_type(8)));
+typedef short  v8s   __attribute__((ext_vector_type(8)));
+typedef short  v16s  __attribute__((ext_vector_type(16)));
+
+#ifdef WMMA_GFX1100_TESTS
+
+// Wave64
+
+//
+// amdgcn_wmma_f32_16x16x16_f16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_f32_16x16x16_f16_w64
+// CHECK-GFX1100: call <4 x float> @llvm.amdgcn.wmma.f32.16x16x16.f16.v4f32(<16 x half> %a, <16 x half> %b, <4 x float> %c)
+void test_amdgcn_wmma_f32_16x16x16_f16_w64(global v4f* out, v16h a, v16h b, v4f c)
+{
+  *out = __builtin_amdgcn_wmma_f32_16x16x16_f16_w64(a, b, c);
+}
+
+//
+// amdgcn_wmma_f32_16x16x16_bf16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_f32_16x16x16_bf16_w64
+// CHECK-GFX1100: call <4 x float> @llvm.amdgcn.wmma.f32.16x16x16.bf16.v4f32(<16 x i16> %a, <16 x i16> %b, <4 x float> %c)
+void test_amdgcn_wmma_f32_16x16x16_bf16_w64(global v4f* out, v16s a, v16s b, v4f c)
+{
+  *out = __builtin_amdgcn_wmma_f32_16x16x16_bf16_w64(a, b, c);
+}
+
+//
+// amdgcn_wmma_f16_16x16x16_f16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_f16_16x16x16_f16_w64
+// CHECK-GFX1100: call <8 x half> @llvm.amdgcn.wmma.f16.16x16x16.f16.v8f16(<16 x half> %a, <16 x half> %b, <8 x half> %c, i1 true)
+void test_amdgcn_wmma_f16_16x16x16_f16_w64(global v8h* out, v16h a, v16h b, v8h c)
+{
+  *out = __builtin_amdgcn_wmma_f16_16x16x16_f16_w64(a, b, c, true);
+}
+
+//
+// amdgcn_wmma_bf16_16x16x16_bf16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_bf16_16x16x16_bf16_w64
+// CHECK-GFX1100: call <8 x i16> @llvm.amdgcn.wmma.bf16.16x16x16.bf16.v8i16(<16 x i16> %a, <16 x i16> %b, <8 x i16> %c, i1 true)
+void test_amdgcn_wmma_bf16_16x16x16_bf16_w64(global v8s* out, v16s a, v16s b, v8s c)
+{
+  *out = __builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64(a, b, c, true);
+}
+
+//
+// amdgcn_wmma_i32_16x16x16_iu8
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_i32_16x16x16_iu8_w64
+// CHECK-GFX1100: call <4 x i32> @llvm.amdgcn.wmma.i32.16x16x16.iu8.v4i32(i1 true, <4 x i32> %a, i1 true, <4 x i32> %b, <4 x i32> %c, i1 false)
+void test_amdgcn_wmma_i32_16x16x16_iu8_w64(global v4i* out, v4i a, v4i b, v4i c)
+{
+  *out = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w64(true, a, true, b, c, false);
+}
+
+//
+// amdgcn_wmma_i32_16x16x16_iu4
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_i32_16x16x16_iu4_w64
+// CHECK-GFX1100: call <4 x i32> @llvm.amdgcn.wmma.i32.16x16x16.iu4.v4i32(i1 true, <2 x i32> %a, i1 true, <2 x i32> %b, <4 x i32> %c, i1 false)
+void test_amdgcn_wmma_i32_16x16x16_iu4_w64(global v4i* out, v2i a, v2i b, v4i c)
+{
+  *out = __builtin_amdgcn_wmma_i32_16x16x16_iu4_w64(true, a, true, b, c, false);
+}
+
+#endif
Index: clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w32.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w32.cl
@@ -0,0 +1,82 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -DWMMA_GFX1100_TESTS -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-GFX1100
+
+typedef float  v4f   __attribute__((ext_vector_type(4)));
+typedef float  v8f   __attribute__((ext_vector_type(8)));
+typedef half   v16h  __attribute__((ext_vector_type(16)));
+typedef intv2i   __attribute__((ext_vector_type(2)));
+typedef intv4i   __attribute__((ext_vector_type(4)));
+typedef intv8i   __attribute__((ext_vector_type(8)));
+typedef short  v16s  __attribute__((ext_vector_type(16)));
+
+#ifdef WMMA_GFX1100_TESTS
+
+// Wave32
+
+//
+// amdgcn_wmma_f32_16x16x16_f16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_f32_16x16x16_f16_w32
+// CHECK-GFX1100: call <8 x 

[clang] 4a78225 - [AMDGPU] Add WMMA clang builtins

2022-06-30 Thread Piotr Sobczak via cfe-commits

Author: Piotr Sobczak
Date: 2022-07-01T08:55:25+02:00
New Revision: 4a782252127761b60d33e74f9d9acb0aad6f742f

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

LOG: [AMDGPU] Add WMMA clang builtins

Add WMMA clang builtins and tests. Extra changes in code
are needed to handle function overloads.

WavefrontSize 32:
__builtin_amdgcn_wmma_f32_16x16x16_f16_w32
__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32
__builtin_amdgcn_wmma_f16_16x16x16_f16_w32
__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32
__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32
__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32

WavefrontSize 64:
__builtin_amdgcn_wmma_f32_16x16x16_f16_w64
__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64
__builtin_amdgcn_wmma_f16_16x16x16_f16_w64
__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64
__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64
__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64

Reviewed By: rampitec

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

Added: 
clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w32.cl
clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl

Modified: 
clang/include/clang/Basic/BuiltinsAMDGPU.def
clang/lib/CodeGen/CGBuiltin.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsAMDGPU.def 
b/clang/include/clang/Basic/BuiltinsAMDGPU.def
index bd188c7f34371..68bcf546d177c 100644
--- a/clang/include/clang/Basic/BuiltinsAMDGPU.def
+++ b/clang/include/clang/Basic/BuiltinsAMDGPU.def
@@ -252,6 +252,30 @@ TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_h, 
"V4UiUifV4fV4hV4hV4Ui
 TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_l, 
"V4UiWUifV4fV4fV4fV4Ui", "nc", "gfx10-insts")
 TARGET_BUILTIN(__builtin_amdgcn_image_bvh_intersect_ray_lh, 
"V4UiWUifV4fV4hV4hV4Ui", "nc", "gfx10-insts")
 
+
+//===--===//
+// GFX11+ only builtins.
+//===--===//
+
+//===--===//
+// WMMA builtins.
+// Postfix w32 indicates the builtin requires wavefront size of 32.
+// Postfix w64 indicates the builtin requires wavefront size of 64.
+//===--===//
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_f16_w32, "V8fV16hV16hV8f", 
"nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32, "V8fV16sV16sV8f", 
"nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_w32, 
"V16hV16hV16hV16hIb", "nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32, 
"V16sV16sV16sV16sIb", "nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32, 
"V8iIbV4iIbV4iV8iIb", "nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32, 
"V8iIbV2iIbV2iV8iIb", "nc", "gfx11-insts")
+
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_f16_w64, "V4fV16hV16hV4f", 
"nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64, "V4fV16sV16sV4f", 
"nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_f16_16x16x16_f16_w64, "V8hV16hV16hV8hIb", 
"nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64, 
"V8sV16sV16sV8sIb", "nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64, 
"V4iIbV4iIbV4iV4iIb", "nc", "gfx11-insts")
+TARGET_BUILTIN(__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64, 
"V4iIbV2iIbV2iV4iIb", "nc", "gfx11-insts")
+
 
//===--===//
 // Special builtins.
 
//===--===//

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index b22d1f76c1a1d..8c7ee6b078f2e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -16861,6 +16861,69 @@ Value *CodeGenFunction::EmitAMDGPUBuiltinExpr(unsigned 
BuiltinID,
   RayInverseDir, TextureDescr});
   }
 
+  case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32:
+  case AMDGPU::BI__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64:
+  case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w32:
+  case AMDGPU::BI__builtin_amdgcn_wmma_f16_16x16x16_f16_w64:
+  case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32:
+  case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64:
+  case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w32:
+  case AMDGPU::BI__builtin_amdgcn_wmma_f32_16x16x16_f16_w64:
+  case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32:
+  case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64:
+  case AMDGPU::BI__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32:
+  case AMDGPU::BI__builtin_amdgcn_wmma

[PATCH] D128953: [NFC] refactor compression namespaces making way for a possible introduction of alternatives to zlib compression in the llvm toolchain.

2022-06-30 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: llvm/include/llvm/Support/Compression.h:49-51
+namespace profile = llvm::compression::zlib;
+
+namespace serialize = llvm::compression::zlib;

I think we will need to support dynamically selecting (de)compression algorithm 
for both profile and serialization. For example, we should be able to use read 
profiles generated by an older version of LLVM that only supported zlib, even 
if the new one also supports zstd. Given that, I'd omit these and instead use 
`compression::zlib` everywhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[PATCH] D128679: [pseudo] Define a clangPseudoCLI library.

2022-06-30 Thread Haojian Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfe66aebd7551: [pseudo] Define a clangPseudoCLI library. 
(authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D128679?vs=440929&id=441605#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128679

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/benchmarks/CMakeLists.txt
  clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/Language.h
  clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h
  clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
  clang-tools-extra/pseudo/lib/CMakeLists.txt
  clang-tools-extra/pseudo/lib/cli/CLI.cpp
  clang-tools-extra/pseudo/lib/cli/CMakeLists.txt
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/tool/CMakeLists.txt
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -8,6 +8,7 @@
 
 #include "clang-pseudo/GLR.h"
 #include "clang-pseudo/Token.h"
+#include "clang-pseudo/Language.h"
 #include "clang-pseudo/grammar/Grammar.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/TokenKinds.h"
@@ -48,9 +49,15 @@
 public:
   void build(llvm::StringRef GrammarBNF) {
 std::vector Diags;
-G = Grammar::parseBNF(GrammarBNF, Diags);
+TestLang.G = Grammar::parseBNF(GrammarBNF, Diags);
   }
 
+  TokenStream emptyTokenStream() {
+TokenStream Empty;
+Empty.finalize();
+return Empty;
+  }
+ 
   void buildGrammar(std::vector Nonterminals,
 std::vector Rules) {
 Nonterminals.push_back("_");
@@ -66,19 +73,22 @@
 
   SymbolID id(llvm::StringRef Name) const {
 for (unsigned I = 0; I < NumTerminals; ++I)
-  if (G.table().Terminals[I] == Name)
+  if (TestLang.G.table().Terminals[I] == Name)
 return tokenSymbol(static_cast(I));
-for (SymbolID ID = 0; ID < G.table().Nonterminals.size(); ++ID)
-  if (G.table().Nonterminals[ID].Name == Name)
+for (SymbolID ID = 0; ID < TestLang.G.table().Nonterminals.size(); ++ID)
+  if (TestLang.G.table().Nonterminals[ID].Name == Name)
 return ID;
 ADD_FAILURE() << "No such symbol found: " << Name;
 return 0;
   }
 
   RuleID ruleFor(llvm::StringRef NonterminalName) const {
-auto RuleRange = G.table().Nonterminals[id(NonterminalName)].RuleRange;
+auto RuleRange =
+TestLang.G.table().Nonterminals[id(NonterminalName)].RuleRange;
 if (RuleRange.End - RuleRange.Start == 1)
-  return G.table().Nonterminals[id(NonterminalName)].RuleRange.Start;
+  return TestLang.G.table()
+  .Nonterminals[id(NonterminalName)]
+  .RuleRange.Start;
 ADD_FAILURE() << "Expected a single rule for " << NonterminalName
   << ", but it has " << RuleRange.End - RuleRange.Start
   << " rule!\n";
@@ -86,7 +96,7 @@
   }
 
 protected:
-  Grammar G;
+  Language TestLang;
   ForestArena Arena;
   GSS GSStack;
 };
@@ -112,9 +122,8 @@
/*Parents=*/{GSSNode0});
 
   buildGrammar({}, {}); // Create a fake empty grammar.
-  LRTable T =
-  LRTable::buildForTests(G, /*Entries=*/
- {
+  TestLang.Table =
+  LRTable::buildForTests(TestLang.G, /*Entries=*/{
  {1, tokenSymbol(tok::semi), Action::shift(4)},
  {2, tokenSymbol(tok::semi), Action::shift(4)},
  {3, tokenSymbol(tok::semi), Action::shift(5)},
@@ -123,8 +132,8 @@
 
   ForestNode &SemiTerminal = Arena.createTerminal(tok::semi, 0);
   std::vector NewHeads;
-  glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal, {G, T, Arena, GSStack},
-   NewHeads);
+  glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal,
+   {TestLang.G, TestLang.Table, Arena, GSStack}, NewHeads);
 
   EXPECT_THAT(NewHeads,
   UnorderedElementsAre(AllOf(state(4), parsedSymbol(&SemiTerminal),
@@ -144,8 +153,8 @@
   buildGrammar({"class-name", "enum-name"},
{"class-name := IDENTIFIER", "enum-name := IDENTIFIER"});
 
-  LRTable Table = LRTable::buildForTests(
-  G,
+  TestLang.Table = LRTable::buildForTests(
+  TestLang.G,
   {
   {/*State=*/0, id("class-name"), Action::goTo(2)},
   {/*State=*/0, id("enum-name"), Action::goTo(3)}

[clang-tools-extra] fe66aeb - [pseudo] Define a clangPseudoCLI library.

2022-06-30 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2022-07-01T08:31:34+02:00
New Revision: fe66aebd755191fac66a73b50d94c29f60be9a88

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

LOG: [pseudo] Define a clangPseudoCLI library.

- define a common data structure Language which is a compiled result of the
  bnf grammar. It is defined in Language.h;
- creates a clangPseudoCLI lib which defines a grammar commandline flag and
  expose a function to get the Language. It supports --grammar=cxx,
  --grammmar=/path/to/file.bnf;
- use the clangPseudoCLI in clang-pseudo, fuzzer, and benchmark tools (
  simplify the code and use the prebuilt cxx grammar);

Split out from https://reviews.llvm.org/D127448.

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

Added: 
clang-tools-extra/pseudo/include/clang-pseudo/Language.h
clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h
clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h
clang-tools-extra/pseudo/lib/cli/CLI.cpp
clang-tools-extra/pseudo/lib/cli/CMakeLists.txt

Modified: 
clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
clang-tools-extra/pseudo/benchmarks/CMakeLists.txt
clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
clang-tools-extra/pseudo/lib/CMakeLists.txt
clang-tools-extra/pseudo/lib/cxx/CXX.cpp
clang-tools-extra/pseudo/tool/CMakeLists.txt
clang-tools-extra/pseudo/tool/ClangPseudo.cpp
clang-tools-extra/pseudo/unittests/GLRTest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp 
b/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
index a06fde7d7149c..5bf6ff2c08f32 100644
--- a/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
+++ b/clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
@@ -25,6 +25,7 @@
 #include "clang-pseudo/Forest.h"
 #include "clang-pseudo/GLR.h"
 #include "clang-pseudo/Token.h"
+#include "clang-pseudo/cli/CLI.h"
 #include "clang-pseudo/grammar/Grammar.h"
 #include "clang-pseudo/grammar/LRTable.h"
 #include "clang/Basic/LangOptions.h"
@@ -39,9 +40,6 @@ using llvm::cl::desc;
 using llvm::cl::opt;
 using llvm::cl::Required;
 
-static opt GrammarFile("grammar",
-desc("Parse and check a BNF grammar 
file."),
-Required);
 static opt Source("source", desc("Source file"), Required);
 
 namespace clang {
@@ -49,11 +47,10 @@ namespace pseudo {
 namespace bench {
 namespace {
 
-const std::string *GrammarText = nullptr;
 const std::string *SourceText = nullptr;
-const Grammar *G = nullptr;
+const Language *Lang = nullptr;
 
-void setupGrammarAndSource() {
+void setup() {
   auto ReadFile = [](llvm::StringRef FilePath) -> std::string {
 llvm::ErrorOr> GrammarText =
 llvm::MemoryBuffer::getFile(FilePath);
@@ -64,22 +61,13 @@ void setupGrammarAndSource() {
 }
 return GrammarText.get()->getBuffer().str();
   };
-  GrammarText = new std::string(ReadFile(GrammarFile));
   SourceText = new std::string(ReadFile(Source));
-  std::vector Diags;
-  G = new Grammar(Grammar::parseBNF(*GrammarText, Diags));
+  Lang = &getLanguageFromFlags();
 }
 
-static void parseBNF(benchmark::State &State) {
-  std::vector Diags;
-  for (auto _ : State)
-Grammar::parseBNF(*GrammarText, Diags);
-}
-BENCHMARK(parseBNF);
-
 static void buildSLR(benchmark::State &State) {
   for (auto _ : State)
-LRTable::buildSLR(*G);
+LRTable::buildSLR(Lang->G);
 }
 BENCHMARK(buildSLR);
 
@@ -129,13 +117,13 @@ static void preprocess(benchmark::State &State) {
 BENCHMARK(preprocess);
 
 static void glrParse(benchmark::State &State) {
-  LRTable Table = clang::pseudo::LRTable::buildSLR(*G);
-  SymbolID StartSymbol = *G->findNonterminal("translation-unit");
+  SymbolID StartSymbol = *Lang->G->findNonterminal("translation-unit");
   TokenStream Stream = lexAndPreprocess();
   for (auto _ : State) {
 pseudo::ForestArena Forest;
 pseudo::GSS GSS;
-pseudo::glrParse(Stream, ParseParams{*G, Table, Forest, GSS}, StartSymbol);
+pseudo::glrParse(Stream, ParseParams{*Lang->G, Lang->Table, Forest, GSS},
+ StartSymbol);
   }
   State.SetBytesProcessed(static_cast(State.iterations()) *
   SourceText->size());
@@ -143,13 +131,13 @@ static void glrParse(benchmark::State &State) {
 BENCHMARK(glrParse);
 
 static void full(benchmark::State &State) {
-  LRTable Table = clang::pseudo::LRTable::buildSLR(*G);
-  SymbolID StartSymbol = *G->findNonterminal("translation-unit");
+  SymbolID StartSymbol = *Lang->G.findNonterminal("translation-unit");
  

[PATCH] D118034: [C++20] [Modules] Don't complain about duplicated default template argument across modules

2022-06-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a reviewer: ilya-biryukov.
ChuanqiXu added a subscriber: ilya-biryukov.
ChuanqiXu added a comment.

Add @ilya-biryukov since he did similar things in 
https://reviews.llvm.org/D128921


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

https://reviews.llvm.org/D118034

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


[PATCH] D123952: [FPEnv] Allow CompoundStmt to keep FP options

2022-06-30 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.
Herald added a reviewer: NoQ.

Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123952

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


[PATCH] D126189: [C++20][Modules] Build module static initializers per P1874R1.

2022-06-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D126189#3617896 , @iains wrote:

> In D126189#3617850 , @ChuanqiXu 
> wrote:
>
>> @iains may I ask what's the issue to not land this? It looks like you're 
>> waiting for the behavior to be consistency with GCC?
>>
>> Since this patch could fix 
>> https://github.com/llvm/llvm-project/issues/51873, which breaks the users to 
>> compile a hello world example.
>
> I need to make some typo corrections; there is no issue (I'm not waiting for 
> anything) just prioritising posting patches to complete C++20 support .. will 
> land this soon.

Thanks! The reason why I am a little bit hurry is that I'm trying to implement 
std modules: https://github.com/ChuanqiXu9/stdmodules

Now it runs good for libcxx. But it would meet segfault in 
https://github.com/ChuanqiXu9/stdmodules/blob/master/test/HelloWorld/HelloWorld.cpp
 if we don't land this revision.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126189

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


[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-06-30 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi updated this revision to Diff 441587.
akyrtzi added a comment.
Herald added a project: clang-tools-extra.

Update `clang-tools-extra/test/pp-trace/pp-trace-include.cpp` to accomodate for 
`PrevFID` getting a value and
preserve using `getFileEntryForID()` for the `SourceManager::getFilename()` 
implementation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

Files:
  clang-tools-extra/test/pp-trace/pp-trace-include.cpp
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Lex/PPLexerChange.cpp

Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -111,6 +111,7 @@
 ///  and start lexing tokens from it instead of the current buffer.
 void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
 ConstSearchDirIterator CurDir) {
+  PreprocessorLexer *PrevPPLexer = CurPPLexer;
 
   // Add the current lexer to the include stack.
   if (CurPPLexer || CurTokenLexer)
@@ -130,8 +131,17 @@
 SrcMgr::CharacteristicKind FileType =
SourceMgr.getFileCharacteristic(CurLexer->getFileLoc());
 
-Callbacks->FileChanged(CurLexer->getFileLoc(),
-   PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;
+if (PrevPPLexer) {
+  PrevFID = PrevPPLexer->getFileID();
+  EnterLoc = PrevPPLexer->getSourceLocation();
+}
+Callbacks->FileChanged(CurLexer->getFileLoc(), PPCallbacks::EnterFile,
+   FileType, PrevFID);
+Callbacks->LexedFileChanged(CurLexer->getFileID(),
+PPCallbacks::LexedFileChangeReason::EnterFile,
+FileType, PrevFID, EnterLoc);
   }
 }
 
@@ -486,10 +496,13 @@
 
 // Notify the client, if desired, that we are in a new source file.
 if (Callbacks && !isEndOfMacro && CurPPLexer) {
+  SourceLocation Loc = CurPPLexer->getSourceLocation();
   SrcMgr::CharacteristicKind FileType =
-SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation());
-  Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
- PPCallbacks::ExitFile, FileType, ExitedFID);
+  SourceMgr.getFileCharacteristic(Loc);
+  Callbacks->FileChanged(Loc, PPCallbacks::ExitFile, FileType, ExitedFID);
+  Callbacks->LexedFileChanged(CurPPLexer->getFileID(),
+  PPCallbacks::LexedFileChangeReason::ExitFile,
+  FileType, ExitedFID, Loc);
 }
 
 // Restore conditional stack as well as the recorded
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -31,23 +31,22 @@
 namespace {
 struct DepCollectorPPCallbacks : public PPCallbacks {
   DependencyCollector &DepCollector;
-  SourceManager &SM;
-  DiagnosticsEngine &Diags;
-  DepCollectorPPCallbacks(DependencyCollector &L, SourceManager &SM,
-  DiagnosticsEngine &Diags)
-  : DepCollector(L), SM(SM), Diags(Diags) {}
-
-  void FileChanged(SourceLocation Loc, FileChangeReason Reason,
-   SrcMgr::CharacteristicKind FileType,
-   FileID PrevFID) override {
-if (Reason != PPCallbacks::EnterFile)
+  Preprocessor &PP;
+  DepCollectorPPCallbacks(DependencyCollector &L, Preprocessor &PP)
+  : DepCollector(L), PP(PP) {}
+
+  void LexedFileChanged(FileID FID, LexedFileChangeReason Reason,
+SrcMgr::CharacteristicKind FileType, FileID PrevFID,
+SourceLocation Loc) override {
+if (Reason != PPCallbacks::LexedFileChangeReason::EnterFile)
+  return;
+if (PP.getPredefinesFileID() == FID)
   return;
 
 // Dependency generation really does want to go all the way to the
 // file entry for a source location to find out what is depended on.
 // We do not want #line markers to affect dependency generation!
-if (Optional Filename = SM.getNonBuiltinFilenameForID(
-SM.getFileID(SM.getExpansionLoc(Loc
+if (Optional Filename = PP.getSourceManager().getFilename(FID))
   DepCollector.maybeAddDependency(
   llvm::sys::path::remove_leading_dotslash(*Filename),
   /*FromModule*/ false, isSystem(FileType), /*IsModuleFile*/ false,
@@ -90,7 +89,9 @@
 /*IsMissing=*/false);
   }
 
-  void EndOfMainFile() override { DepCollector.finishedMainFile(Diags); }
+  void EndOfMainFile() override {
+DepCollector.finishedMainFile(PP.getDiagnostics());
+  }
 };
 
 struct DepCollectorMMCallbacks : public M

[clang] 6bd53df - [clang][NFC][tests] dr208.c optional signext handling

2022-06-30 Thread Hubert Tong via cfe-commits

Author: Hubert Tong
Date: 2022-07-01T00:03:58-04:00
New Revision: 6bd53df9b6e9fffb440ee2f9020f15b61f8b39e7

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

LOG: [clang][NFC][tests] dr208.c optional signext handling

Fixes llvm/llvm-project#56325.

Added: 


Modified: 
clang/test/C/drs/dr208.c

Removed: 




diff  --git a/clang/test/C/drs/dr208.c b/clang/test/C/drs/dr208.c
index aac27e7c1ad31..67c6bc1a5b4e4 100644
--- a/clang/test/C/drs/dr208.c
+++ b/clang/test/C/drs/dr208.c
@@ -15,10 +15,10 @@ void dr208(void) {
 [0] = dr208_init(2) /* expected-warning {{initializer overrides prior 
initialization of this subobject}} */
   };
 
-  /* CHECK-NOT: call i32 @dr208_init(i32 noundef 0)
- CHECK-DAG: call i32 @dr208_init(i32 noundef 1)
- CHECK-DAG: call i32 @dr208_init(i32 noundef 2)
- CHECK-NOT: call i32 @dr208_init(i32 noundef 0)
+  /* CHECK-NOT: call {{signext i32|i32}} @dr208_init(i32 noundef {{(signext 
)?}}0)
+ CHECK-DAG: call {{signext i32|i32}} @dr208_init(i32 noundef {{(signext 
)?}}1)
+ CHECK-DAG: call {{signext i32|i32}} @dr208_init(i32 noundef {{(signext 
)?}}2)
+ CHECK-NOT: call {{signext i32|i32}} @dr208_init(i32 noundef {{(signext 
)?}}0)
*/
 }
 



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


[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-30 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a subscriber: usama54321.
NoQ added a comment.

Thanks, very nice!

@usama54321 you recently fixed a similar problem in a clang-tidy check, do you 
know if it also requires a similar clause for polymorphic expressions inside 
`typeid`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

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


[PATCH] D128489: [ODRHash diagnostics] Move common code for calculating diag locations in `DiagnoseODRMismatch` into a lambda. NFC.

2022-06-30 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ceb9c347f14: [ODRHash diagnostics] Move common code for 
calculating diag locations in… (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128489

Files:
  clang/lib/Serialization/ASTReader.cpp


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -10012,34 +10012,35 @@
 }
   };
 
-  auto DiagnoseODRMismatch =
-  [this](DiffResult &DR, NamedDecl *FirstRecord, StringRef FirstModule,
- NamedDecl *SecondRecord, StringRef SecondModule) {
-SourceLocation FirstLoc;
-SourceRange FirstRange;
-auto *FirstTag = dyn_cast(FirstRecord);
-if (DR.FirstDiffType == EndOfClass && FirstTag) {
-  FirstLoc = FirstTag->getBraceRange().getEnd();
-} else {
-  FirstLoc = DR.FirstDecl->getLocation();
-  FirstRange = DR.FirstDecl->getSourceRange();
-}
-Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
-<< FirstRecord << FirstModule.empty() << FirstModule << FirstRange
-<< DR.FirstDiffType;
-
-SourceLocation SecondLoc;
-SourceRange SecondRange;
-auto *SecondTag = dyn_cast(SecondRecord);
-if (DR.SecondDiffType == EndOfClass && SecondTag) {
-  SecondLoc = SecondTag->getBraceRange().getEnd();
-} else {
-  SecondLoc = DR.SecondDecl->getLocation();
-  SecondRange = DR.SecondDecl->getSourceRange();
-}
-Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
-<< SecondModule << SecondRange << DR.SecondDiffType;
-  };
+  auto DiagnoseODRMismatch = [this](DiffResult &DR, NamedDecl *FirstRecord,
+StringRef FirstModule,
+NamedDecl *SecondRecord,
+StringRef SecondModule) {
+auto GetMismatchedDeclLoc = [](const NamedDecl *Container,
+   ODRMismatchDecl DiffType, const Decl *D) {
+  SourceLocation Loc;
+  SourceRange Range;
+  auto *Tag = dyn_cast(Container);
+  if (DiffType == EndOfClass && Tag) {
+Loc = Tag->getBraceRange().getEnd();
+  } else {
+Loc = D->getLocation();
+Range = D->getSourceRange();
+  }
+  return std::make_pair(Loc, Range);
+};
+
+auto FirstDiagInfo =
+GetMismatchedDeclLoc(FirstRecord, DR.FirstDiffType, DR.FirstDecl);
+Diag(FirstDiagInfo.first, diag::err_module_odr_violation_mismatch_decl)
+<< FirstRecord << FirstModule.empty() << FirstModule
+<< FirstDiagInfo.second << DR.FirstDiffType;
+
+auto SecondDiagInfo =
+GetMismatchedDeclLoc(SecondRecord, DR.SecondDiffType, DR.SecondDecl);
+Diag(SecondDiagInfo.first, diag::note_module_odr_violation_mismatch_decl)
+<< SecondModule << SecondDiagInfo.second << DR.SecondDiffType;
+  };
 
   // Issue any pending ODR-failure diagnostics.
   for (auto &Merge : OdrMergeFailures) {


Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -10012,34 +10012,35 @@
 }
   };
 
-  auto DiagnoseODRMismatch =
-  [this](DiffResult &DR, NamedDecl *FirstRecord, StringRef FirstModule,
- NamedDecl *SecondRecord, StringRef SecondModule) {
-SourceLocation FirstLoc;
-SourceRange FirstRange;
-auto *FirstTag = dyn_cast(FirstRecord);
-if (DR.FirstDiffType == EndOfClass && FirstTag) {
-  FirstLoc = FirstTag->getBraceRange().getEnd();
-} else {
-  FirstLoc = DR.FirstDecl->getLocation();
-  FirstRange = DR.FirstDecl->getSourceRange();
-}
-Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
-<< FirstRecord << FirstModule.empty() << FirstModule << FirstRange
-<< DR.FirstDiffType;
-
-SourceLocation SecondLoc;
-SourceRange SecondRange;
-auto *SecondTag = dyn_cast(SecondRecord);
-if (DR.SecondDiffType == EndOfClass && SecondTag) {
-  SecondLoc = SecondTag->getBraceRange().getEnd();
-} else {
-  SecondLoc = DR.SecondDecl->getLocation();
-  SecondRange = DR.SecondDecl->getSourceRange();
-}
-Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
-<< SecondModule << SecondRange << DR.SecondDiffType;
-  };
+  auto DiagnoseODRMismatch = [this](DiffResult &DR, NamedDecl *FirstRecord,
+StringRef FirstModule,
+NamedDecl *SecondRecord,
+ 

[clang] 2ceb9c3 - [ODRHash diagnostics] Move common code for calculating diag locations in `DiagnoseODRMismatch` into a lambda. NFC.

2022-06-30 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-06-30T19:39:22-07:00
New Revision: 2ceb9c347f14e81a8c71d644724cefd10fce6eaf

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

LOG: [ODRHash diagnostics] Move common code for calculating diag locations in 
`DiagnoseODRMismatch` into a lambda. NFC.

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

Added: 


Modified: 
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 37371eff28ef..d853805bf97e 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -10012,34 +10012,35 @@ void ASTReader::diagnoseOdrViolations() {
 }
   };
 
-  auto DiagnoseODRMismatch =
-  [this](DiffResult &DR, NamedDecl *FirstRecord, StringRef FirstModule,
- NamedDecl *SecondRecord, StringRef SecondModule) {
-SourceLocation FirstLoc;
-SourceRange FirstRange;
-auto *FirstTag = dyn_cast(FirstRecord);
-if (DR.FirstDiffType == EndOfClass && FirstTag) {
-  FirstLoc = FirstTag->getBraceRange().getEnd();
-} else {
-  FirstLoc = DR.FirstDecl->getLocation();
-  FirstRange = DR.FirstDecl->getSourceRange();
-}
-Diag(FirstLoc, diag::err_module_odr_violation_mismatch_decl)
-<< FirstRecord << FirstModule.empty() << FirstModule << FirstRange
-<< DR.FirstDiffType;
-
-SourceLocation SecondLoc;
-SourceRange SecondRange;
-auto *SecondTag = dyn_cast(SecondRecord);
-if (DR.SecondDiffType == EndOfClass && SecondTag) {
-  SecondLoc = SecondTag->getBraceRange().getEnd();
-} else {
-  SecondLoc = DR.SecondDecl->getLocation();
-  SecondRange = DR.SecondDecl->getSourceRange();
-}
-Diag(SecondLoc, diag::note_module_odr_violation_mismatch_decl)
-<< SecondModule << SecondRange << DR.SecondDiffType;
-  };
+  auto DiagnoseODRMismatch = [this](DiffResult &DR, NamedDecl *FirstRecord,
+StringRef FirstModule,
+NamedDecl *SecondRecord,
+StringRef SecondModule) {
+auto GetMismatchedDeclLoc = [](const NamedDecl *Container,
+   ODRMismatchDecl DiffType, const Decl *D) {
+  SourceLocation Loc;
+  SourceRange Range;
+  auto *Tag = dyn_cast(Container);
+  if (DiffType == EndOfClass && Tag) {
+Loc = Tag->getBraceRange().getEnd();
+  } else {
+Loc = D->getLocation();
+Range = D->getSourceRange();
+  }
+  return std::make_pair(Loc, Range);
+};
+
+auto FirstDiagInfo =
+GetMismatchedDeclLoc(FirstRecord, DR.FirstDiffType, DR.FirstDecl);
+Diag(FirstDiagInfo.first, diag::err_module_odr_violation_mismatch_decl)
+<< FirstRecord << FirstModule.empty() << FirstModule
+<< FirstDiagInfo.second << DR.FirstDiffType;
+
+auto SecondDiagInfo =
+GetMismatchedDeclLoc(SecondRecord, DR.SecondDiffType, DR.SecondDecl);
+Diag(SecondDiagInfo.first, diag::note_module_odr_violation_mismatch_decl)
+<< SecondModule << SecondDiagInfo.second << DR.SecondDiffType;
+  };
 
   // Issue any pending ODR-failure diagnostics.
   for (auto &Merge : OdrMergeFailures) {



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


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-06-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a reviewer: ChuanqiXu.
ChuanqiXu added a comment.

Thanks for filing that issue. I wanted to add that myself before. It should be 
better to change `isVisible` and `hasVisibleDefinition` to `isReachable` and 
`hasReachableDefinition`. The definition of reachability comes from C++20 
Modules and it shouldn't affect Clang Modules.

And would you like to add an example for C++20 Modules? It should be something 
like:

  // RUN: rm -rf %t
  // RUN: mkdir %t
  // RUN: split-file %s %t
  //
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/same_as.cppm -o 
%t/same_as.pcm
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface 
-fprebuilt-module-path=%t %t/concepts.cppm -o %t/concepts.pcm
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface 
-fprebuilt-module-path=%t %t/format.cppm -o %t/format.pcm
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/conflicting.cppm -o 
%t/conflicting.pcm
  // RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cppm 
-fsyntax-only -verify
  
  //--- same_as.cppm
  export module same_as;
  export template 
  concept same_as = __is_same(T, U);
  
  //--- concepts.cppm
  export module concepts;
  export import same_as;
  
  export template 
  concept ConflictingConcept = true;
  
  //--- format.cppm
  
  export module format;
  export import concepts;
  export import same_as;
  
  export template  void foo()
requires same_as
  {}
  
  //--- conflicting.cppm
  export module conflicting;
  export template 
  concept ConflictingConcept = true;
  
  //--- Use.cppm
  import format;
  import conflicting;
  
  template  void foo()
requires same_as
  {}
  ConflictingConcept auto x = 10; // expected-error {{reference to 
'ConflictingConcept' is ambiguous}}
  // expected-note@* 2 {{candidate}}

Also I feel it would be better to rewrite the current tests into the above 
style by `split-file`.




Comment at: clang/lib/Sema/SemaTemplate.cpp:8679
+  Previous.isSingleResult() ? Previous.getAsSingle() : 
nullptr;
+  if (PrevDef && !hasVisibleDefinition(PrevDef) &&
+  Context.isSameEntity(NewDecl, PrevDef)) {





Comment at: clang/lib/Sema/SemaTemplate.cpp:8689
+  while (F.hasNext()) {
+if (!isVisible(F.next())) {
+  F.erase();




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D128489: [ODRHash diagnostics] Move common code for calculating diag locations in `DiagnoseODRMismatch` into a lambda. NFC.

2022-06-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/lib/Serialization/ASTReader.cpp:10020
+auto GetMismatchedDeclLoc = [](const NamedDecl *Container,
+   ODRMismatchDecl DiffType, const Decl *D) {
+  SourceLocation Loc;

vsapsai wrote:
> ChuanqiXu wrote:
> > DiffType is not necessary here, right?
> Unfortunately, it is necessary. A little bit later we have
> ```
> if (DiffType == EndOfClass && Tag)
> ```
> where we use `DiffType`.
> 
> By the way, the implementation isn't really correct for `EndOfClass` and 
> non-TagDecl as `Loc` remains invalid. But that's a separate issue, I've 
> decided to keep the current change to NFC.
Oh, sorry for I missed that. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128489

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


[PATCH] D128048: Add a new clang option "-ftime-trace="

2022-06-30 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo updated this revision to Diff 441574.
dongjunduo added a comment.

[Clang] format the source file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp

Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -212,7 +212,9 @@
   bool Success = CompilerInvocation::CreateFromArgs(Clang->getInvocation(),
 Argv, Diags, Argv0);
 
-  if (Clang->getFrontendOpts().TimeTrace) {
+  if (Clang->getFrontendOpts().TimeTrace ||
+  !Clang->getFrontendOpts().TimeTracePath.empty()) {
+Clang->getFrontendOpts().TimeTrace = 1;
 llvm::timeTraceProfilerInitialize(
 Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
@@ -256,6 +258,14 @@
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
 llvm::sys::path::replace_extension(Path, "json");
+if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
+  // replace the suffix to '.json' directly
+  SmallString<128> FileName(llvm::sys::path::filename(Path));
+  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
+  if (llvm::sys::fs::is_directory(TracePath))
+llvm::sys::path::append(TracePath, FileName);
+  Path.assign(TracePath);
+}
 if (auto profilerOutput = Clang->createOutputFile(
 Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -2,6 +2,20 @@
 // RUN: cat %T/check-time-trace.json \
 // RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN:   | FileCheck %s
+// RUN: %clangxx -S -ftime-trace=%T/new-name.json -ftime-trace-granularity=0 -o %T/check-time-trace %s
+// RUN: cat %T/new-name.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
+// RUN: mkdir %T/output1
+// RUN: %clangxx -S -ftime-trace=%T/output1 -ftime-trace-granularity=0 -o %T/check-time-trace %s
+// RUN: cat %T/output1/check-time-trace.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
+// RUN: mkdir %T/output2
+// RUN: %clangxx -S -ftime-trace=%T/output2/ -ftime-trace-granularity=0 -o %T/check-time-trace %s
+// RUN: cat %T/output2/check-time-trace.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
 
 // CHECK:  "beginningOfTime": {{[0-9]{16},}}
 // CHECK-NEXT: "traceEvents": [
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6183,6 +6183,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_path);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
   Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -499,6 +499,9 @@
   /// Minimum time granularity (in microseconds) traced by time profiler.
   unsigned TimeTraceGranularity;
 
+  /// Path which stores the output files for -ftime-trace
+  std::string TimeTracePath;
+
 public:
   FrontendOptions()
   : DisableFree(false), RelocatablePCH(false), ShowHelp(false),
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2828,6 +2828,15 @@
   HelpText<"Minimum time granularity (in microseconds) traced by time profiler">,
   Flags<[CC1Option, CoreOption]>,
   MarshallingInfoInt, "500u">;
+def ftime_trace_path : Joined<["-"], "ftime-trace=">, Group,
+  HelpText<"Turn on time profiler. Generates JSON file based on output filename. "
+   "Specify th

[PATCH] D128048: Add a new clang option "-ftime-trace="

2022-06-30 Thread Whitney Tsang via Phabricator via cfe-commits
Whitney accepted this revision.
Whitney added inline comments.



Comment at: clang/tools/driver/cc1_main.cpp:265
+  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
+  if (llvm::sys::fs::is_directory(TracePath)) {
+llvm::sys::path::append(TracePath, FileName);

No need braces for single instruction block. 
https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

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


[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-30 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo marked an inline comment as done.
dongjunduo added inline comments.



Comment at: clang/test/Driver/check-time-trace.cpp:9
+// RUN:   | FileCheck %s
+// RUN: %clangxx -S -ftime-trace=%T -ftime-trace-granularity=0 -o 
%T/check-time-trace %s
+// RUN: cat %T/check-time-trace.json \

Whitney wrote:
> By default, the JSON file is stored in %T, as it is the directory for the 
> output object file. Can you make a different directory, to ensure it is not 
> just the default behavior?
Done. I have moved them to new directories for the next tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

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


[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-30 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo updated this revision to Diff 441572.
dongjunduo added a comment.

[Clang] change test cases to different directory


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/check-time-trace.cpp
  clang/tools/driver/cc1_main.cpp

Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -212,7 +212,9 @@
   bool Success = CompilerInvocation::CreateFromArgs(Clang->getInvocation(),
 Argv, Diags, Argv0);
 
-  if (Clang->getFrontendOpts().TimeTrace) {
+  if (Clang->getFrontendOpts().TimeTrace ||
+  !Clang->getFrontendOpts().TimeTracePath.empty()) {
+Clang->getFrontendOpts().TimeTrace = 1;
 llvm::timeTraceProfilerInitialize(
 Clang->getFrontendOpts().TimeTraceGranularity, Argv0);
   }
@@ -256,6 +258,15 @@
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
 llvm::sys::path::replace_extension(Path, "json");
+if (!Clang->getFrontendOpts().TimeTracePath.empty()) {
+  // replace the suffix to '.json' directly
+  SmallString<128> FileName(llvm::sys::path::filename(Path));
+  SmallString<128> TracePath(Clang->getFrontendOpts().TimeTracePath);
+  if (llvm::sys::fs::is_directory(TracePath)) {
+llvm::sys::path::append(TracePath, FileName);
+  }
+  Path.assign(TracePath);
+}
 if (auto profilerOutput = Clang->createOutputFile(
 Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
Index: clang/test/Driver/check-time-trace.cpp
===
--- clang/test/Driver/check-time-trace.cpp
+++ clang/test/Driver/check-time-trace.cpp
@@ -2,6 +2,20 @@
 // RUN: cat %T/check-time-trace.json \
 // RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
 // RUN:   | FileCheck %s
+// RUN: %clangxx -S -ftime-trace=%T/new-name.json -ftime-trace-granularity=0 -o %T/check-time-trace %s
+// RUN: cat %T/new-name.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
+// RUN: mkdir %T/output1
+// RUN: %clangxx -S -ftime-trace=%T/output1 -ftime-trace-granularity=0 -o %T/check-time-trace %s
+// RUN: cat %T/output1/check-time-trace.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
+// RUN: mkdir %T/output2
+// RUN: %clangxx -S -ftime-trace=%T/output2/ -ftime-trace-granularity=0 -o %T/check-time-trace %s
+// RUN: cat %T/output2/check-time-trace.json \
+// RUN:   | %python -c 'import json, sys; json.dump(json.loads(sys.stdin.read()), sys.stdout, sort_keys=True, indent=2)' \
+// RUN:   | FileCheck %s
 
 // CHECK:  "beginningOfTime": {{[0-9]{16},}}
 // CHECK-NEXT: "traceEvents": [
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6183,6 +6183,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_path);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
   Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -499,6 +499,9 @@
   /// Minimum time granularity (in microseconds) traced by time profiler.
   unsigned TimeTraceGranularity;
 
+  /// Path which stores the output files for -ftime-trace
+  std::string TimeTracePath;
+
 public:
   FrontendOptions()
   : DisableFree(false), RelocatablePCH(false), ShowHelp(false),
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2828,6 +2828,15 @@
   HelpText<"Minimum time granularity (in microseconds) traced by time profiler">,
   Flags<[CC1Option, CoreOption]>,
   MarshallingInfoInt, "500u">;
+def ftime_trace_path : Joined<["-"], "ftime-trace=">, Group,
+  HelpText<"Turn on time profiler. Generates JSON file based on output filena

[PATCH] D128488: [ODRHash diagnostics] Split `err_module_odr_violation_mismatch_decl_diff` into per-entity diagnostics. NFC.

2022-06-30 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG15cb180dcbf8: [ODRHash diagnostics] Split 
`err_module_odr_violation_mismatch_decl_diff` into… (authored by vsapsai).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128488

Files:
  clang/include/clang/Basic/DiagnosticSerializationKinds.td
  clang/lib/Serialization/ASTReader.cpp

Index: clang/lib/Serialization/ASTReader.cpp
===
--- clang/lib/Serialization/ASTReader.cpp
+++ clang/lib/Serialization/ASTReader.cpp
@@ -9637,19 +9637,12 @@
 Other
   };
 
-  // Used with err_module_odr_violation_mismatch_decl_diff and
-  // note_module_odr_violation_mismatch_decl_diff
-  enum ODRMismatchDeclDifference {
+  // Used with err_module_odr_violation_record and
+  // note_module_odr_violation_record
+  enum ODRCXXRecordDifference {
 StaticAssertCondition,
 StaticAssertMessage,
 StaticAssertOnlyMessage,
-FieldName,
-FieldTypeName,
-FieldSingleBitField,
-FieldDifferentWidthBitField,
-FieldSingleMutable,
-FieldSingleInitializer,
-FieldDifferentInitializers,
 MethodName,
 MethodDeleted,
 MethodDefaulted,
@@ -9668,13 +9661,6 @@
 MethodDifferentTemplateArgument,
 MethodSingleBody,
 MethodDifferentBody,
-TypedefName,
-TypedefType,
-VarName,
-VarType,
-VarSingleInitializer,
-VarDifferentInitializer,
-VarConstexpr,
 FriendTypeFunction,
 FriendType,
 FriendFunction,
@@ -9694,17 +9680,27 @@
   NamedDecl *FirstRecord, StringRef FirstModule,
   StringRef SecondModule, FieldDecl *FirstField,
   FieldDecl *SecondField) {
+enum ODRFieldDifference {
+  FieldName,
+  FieldTypeName,
+  FieldSingleBitField,
+  FieldDifferentWidthBitField,
+  FieldSingleMutable,
+  FieldSingleInitializer,
+  FieldDifferentInitializers,
+};
+
 auto DiagError = [FirstRecord, FirstField, FirstModule,
-  this](ODRMismatchDeclDifference DiffType) {
+  this](ODRFieldDifference DiffType) {
   return Diag(FirstField->getLocation(),
-  diag::err_module_odr_violation_mismatch_decl_diff)
+  diag::err_module_odr_violation_field)
  << FirstRecord << FirstModule.empty() << FirstModule
  << FirstField->getSourceRange() << DiffType;
 };
 auto DiagNote = [SecondField, SecondModule,
- this](ODRMismatchDeclDifference DiffType) {
+ this](ODRFieldDifference DiffType) {
   return Diag(SecondField->getLocation(),
-  diag::note_module_odr_violation_mismatch_decl_diff)
+  diag::note_module_odr_violation_field)
  << SecondModule << SecondField->getSourceRange() << DiffType;
 };
 
@@ -9792,17 +9788,22 @@
   NamedDecl *FirstRecord, StringRef FirstModule, StringRef SecondModule,
   TypedefNameDecl *FirstTD, TypedefNameDecl *SecondTD,
   bool IsTypeAlias) {
+enum ODRTypedefDifference {
+  TypedefName,
+  TypedefType,
+};
+
 auto DiagError = [FirstRecord, FirstTD, FirstModule,
-  this](ODRMismatchDeclDifference DiffType) {
+  this](ODRTypedefDifference DiffType) {
   return Diag(FirstTD->getLocation(),
-  diag::err_module_odr_violation_mismatch_decl_diff)
+  diag::err_module_odr_violation_typedef)
  << FirstRecord << FirstModule.empty() << FirstModule
  << FirstTD->getSourceRange() << DiffType;
 };
 auto DiagNote = [SecondTD, SecondModule,
- this](ODRMismatchDeclDifference DiffType) {
+ this](ODRTypedefDifference DiffType) {
   return Diag(SecondTD->getLocation(),
-  diag::note_module_odr_violation_mismatch_decl_diff)
+  diag::note_module_odr_violation_typedef)
  << SecondModule << SecondTD->getSourceRange() << DiffType;
 };
 
@@ -9830,17 +9831,24 @@
  this](NamedDecl *FirstRecord, StringRef FirstModule,
StringRef SecondModule, VarDecl *FirstVD,
VarDecl *SecondVD) {
+enum ODRVarDifference {
+  VarName,
+  VarType,
+  VarSingleInitializer,
+  VarDifferentInitializer,
+  VarConstexpr,
+};
+
 auto DiagError = [FirstRecord, FirstVD, FirstModule,
-  this](ODRMismatchDeclDifference DiffType) {
+  this](ODRVarDifference DiffType) {
   return Diag(FirstVD->getLocation(),
-  diag::err_module_odr_violation_mismatch_decl_diff)
+  diag::err_module

[clang] 15cb180 - [ODRHash diagnostics] Split `err_module_odr_violation_mismatch_decl_diff` into per-entity diagnostics. NFC.

2022-06-30 Thread Volodymyr Sapsai via cfe-commits

Author: Volodymyr Sapsai
Date: 2022-06-30T18:40:46-07:00
New Revision: 15cb180dcbf84701f3af47983e223d0beaac3c9b

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

LOG: [ODRHash diagnostics] Split `err_module_odr_violation_mismatch_decl_diff` 
into per-entity diagnostics. NFC.

We'll need to add more cases for Objective-C entities and adding
everything to `err_module_odr_violation_mismatch_decl_diff` makes it
harder to work with over time.

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSerializationKinds.td
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSerializationKinds.td 
b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
index 251242e46fe5..0bd3734a4a04 100644
--- a/clang/include/clang/Basic/DiagnosticSerializationKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSerializationKinds.td
@@ -177,20 +177,13 @@ def note_module_odr_violation_mismatch_decl : Note<"but 
in '%0' found "
   "protected access specifier|static assert|field|method|type alias|typedef|"
   "data member|friend declaration|function template}1">;
 
-def err_module_odr_violation_mismatch_decl_
diff  : Error<
+def err_module_odr_violation_record : Error<
   "%q0 has 
diff erent definitions in 
diff erent modules; first 
diff erence is "
   "%select{definition in module '%2'|defined here}1 found "
   "%select{"
   "static assert with condition|"
   "static assert with message|"
   "static assert with %select{|no }4message|"
-  "field %4|"
-  "field %4 with type %5|"
-  "%select{non-|}5bitfield %4|"
-  "bitfield %4 with one width expression|"
-  "%select{non-|}5mutable field %4|"
-  "field %4 with %select{no|an}5 initalizer|"
-  "field %4 with an initializer|"
   "%select{method %5|constructor|destructor}4|"
   "%select{method %5|constructor|destructor}4 "
 "is %select{not deleted|deleted}6|"
@@ -226,13 +219,6 @@ def err_module_odr_violation_mismatch_decl_
diff  : Error<
 "with %select{no body|body}6|"
   "%select{method %5|constructor|destructor}4 "
 "with body|"
-  "%select{typedef|type alias}4 name %5|"
-  "%select{typedef|type alias}4 %5 with underlying type %6|"
-  "data member with name %4|"
-  "data member %4 with type %5|"
-  "data member %4 with%select{out|}5 an initializer|"
-  "data member %4 with an initializer|"
-  "data member %4 %select{is constexpr|is not constexpr}5|"
   "friend %select{class|function}4|"
   "friend %4|"
   "friend function %4|"
@@ -250,18 +236,11 @@ def err_module_odr_violation_mismatch_decl_
diff  : Error<
 "being a template parameter pack|"
   "}3">;
 
-def note_module_odr_violation_mismatch_decl_
diff  : Note<"but in '%0' found "
+def note_module_odr_violation_record : Note<"but in '%0' found "
   "%select{"
   "static assert with 
diff erent condition|"
   "static assert with 
diff erent message|"
   "static assert with %select{|no }2message|"
-  "field %2|"
-  "field %2 with type %3|"
-  "%select{non-|}3bitfield %2|"
-  "bitfield %2 with 
diff erent width expression|"
-  "%select{non-|}3mutable field %2|"
-  "field %2 with %select{no|an}3 initializer|"
-  "field %2 with a 
diff erent initializer|"
   "%select{method %3|constructor|destructor}2|"
   "%select{method %3|constructor|destructor}2 "
 "is %select{not deleted|deleted}4|"
@@ -297,13 +276,6 @@ def note_module_odr_violation_mismatch_decl_
diff  : Note<"but in '%0' found "
 "with %select{no body|body}4|"
   "%select{method %3|constructor|destructor}2 "
 "with 
diff erent body|"
-  "%select{typedef|type alias}2 name %3|"
-  "%select{typedef|type alias}2 %3 with 
diff erent underlying type %4|"
-  "data member with name %2|"
-  "data member %2 with 
diff erent type %3|"
-  "data member %2 with%select{out|}3 an initializer|"
-  "data member %2 with a 
diff erent initializer|"
-  "data member %2 %select{is constexpr|is not constexpr}3|"
   "friend %select{class|function}2|"
   "friend %2|"
   "friend function %2|"
@@ -321,6 +293,61 @@ def note_module_odr_violation_mismatch_decl_
diff  : Note<"but in '%0' found "
 "being a template parameter pack|"
   "}1">;
 
+def err_module_odr_violation_field : Error<
+  "%q0 has 
diff erent definitions in 
diff erent modules; first 
diff erence is "
+  "%select{definition in module '%2'|defined here}1 found "
+  "%select{"
+  "field %4|"
+  "field %4 with type %5|"
+  "%select{non-|}5bitfield %4|"
+  "bitfield %4 with one width expression|"
+  "%select{non-|}5mutable field %4|"
+  "field %4 with %select{no|an}5 initalizer|"
+  "field %4 with an initializer"
+  "}3">;
+def note_module_odr_violation_field : Note<"but in '%0' found "
+  "%select{"
+  "field %2|"
+  "field %2 with type %3|"
+  "%select{non-|}3bitfield %2|"

[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-06-30 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:212
+};
+/// List of captuer fields
+llvm::SmallVector

ABataev wrote:
> Captured?
Fixed.  Thanks.



Comment at: clang/lib/Sema/TreeTransform.h:122
+  /// the RebuildME uses to set if member expression needs to be rebuilt.
+  bool RebuildME = false;
+

ABataev wrote:
> jyu2 wrote:
> > ABataev wrote:
> > > I think we don't need to add a new field here. Can instead we have a 
> > > check for regions with default clauses, if possible?
> > It seems during the TransformMemberExpr, I can not get Directives info for 
> > omp regions to check.  Could you give me hand? 
> > Thanks.  
> > 
> Yes, we do not rebuild the DSA stack at the time of the instantiation. Can 
> you just check that we're inside OpenMPCapturedRegion? Something like 
> getCurCapturedRegion()->CapRegionKind == CR_OpenMP? Or walk the stack of 
> regions to find the outer OpenMP region, if any.
Thank you so much for the help.  I add new function in Sema to do this.  Hope 
that is okay with you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

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


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-06-30 Thread Jennifer Yu via Phabricator via cfe-commits
jyu2 updated this revision to Diff 441565.
jyu2 added a comment.

Thanks Alexey for the review.  This patch to address his comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127803

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/OpenMP/default_firstprivate_ast_print.cpp
  clang/test/OpenMP/default_private_ast_print.cpp

Index: clang/test/OpenMP/default_private_ast_print.cpp
===
--- clang/test/OpenMP/default_private_ast_print.cpp
+++ clang/test/OpenMP/default_private_ast_print.cpp
@@ -96,4 +96,57 @@
   // DUMP-NEXT:  -DeclRefExpr {{.*}} 'a'
   // DUMP-NEXT:  -DeclRefExpr {{.*}} 'yy'
 }
+
+void zoo(int);
+struct A {
+  int z;
+  int f;
+  A();
+  ~A();
+  void foo() {
+#pragma omp parallel private(z) default(private)
+{
+  z++;
+  f++;
+  zoo(z + f);
+  f++;
+}
+  }
+  // PRINT:#pragma omp parallel private(this->z) default(private)
+  // DUMP: -OMPParallelDirective
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:  -OMPDefaultClause
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'f'
+  // DUMP: -CXXThisExpr {{.*}} 'A *' implicit this
+  void bar() {
+#pragma omp parallel private(z) default(private)
+{
+#pragma omp parallel private(z) default(private)
+  {
+z++;
+f++;
+zoo(z + f);
+f++;
+  }
+}
+  }
+  // PRINT:#pragma omp parallel private(this->z) default(private)
+  // PRINT:  #pragma omp parallel private(this->z) default(private)
+  // DUMP: -OMPParallelDirective
+  // DUMP-NEXT:  -OMPPrivateClause
+  // DUMP-NEXT:-DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:  -OMPDefaultClause
+  // DUMP:   -OMPParallelDirective
+  // DUMP-NEXT:-OMPPrivateClause
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:-OMPDefaultClause
+  // DUMP-NEXT:-OMPPrivateClause {{.*}} 
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'f'
+  // DUMP: -CXXThisExpr
+  // DUMP: -MemberExpr
+  // DUMP-NEXT:   -CXXThisExpr
+  // DUMP: -CXXThisExpr
+};
 #endif // HEADER
Index: clang/test/OpenMP/default_firstprivate_ast_print.cpp
===
--- clang/test/OpenMP/default_firstprivate_ast_print.cpp
+++ clang/test/OpenMP/default_firstprivate_ast_print.cpp
@@ -45,7 +45,8 @@
 // PRINT-NEXT:  this->targetDev++;
 // CHECK-NEXT: }
 // DUMP: -OMPParallelDirective
-// DUMP->NEXT: -OMPDefaultClause
+// DUMP-NEXT: -OMPDefaultClause
+// DUMP-NOT:   -OMPFirstprivateClause
   }
   // PRINT: template<> void apply<32U>()
   // PRINT: #pragma omp parallel default(firstprivate)
@@ -54,6 +55,8 @@
   // CHECK-NEXT: }
   // DUMP: -OMPParallelDirective
   // DUMP-NEXT: -OMPDefaultClause
+  // DUMP-NEXT: -OMPFirstprivateClause
+  // DUMP-NEXT:   -DeclRefExpr {{.*}} 'targetDev'
 };
 
 void use_template() {
@@ -99,4 +102,60 @@
   // DUMP-NEXT: -DeclRefExpr {{.*}} 'yy'
   // DUMP-NEXT: -DeclRefExpr {{.*}} 'y'
 }
+void zoo(int);
+struct A {
+  int z;
+  int f;
+  A();
+  ~A();
+  void foo() {
+#pragma omp parallel firstprivate(z) default(firstprivate)
+{
+  z++;
+  f++;
+  zoo(z + f);
+  f++;
+}
+  }
+  // PRINT:  #pragma omp parallel firstprivate(this->z) default(firstprivate)
+  // DUMP:   -OMPParallelDirective
+  // DUMP-NEXT: -OMPFirstprivateClause
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT: -OMPDefaultClause
+  // DUMP-NEXT: -OMPFirstprivateClause {{.*}} 
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
+  // DUMP:  -CXXThisExpr {{.*}} 'A *' implicit this
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'f'
+  void bar() {
+#pragma omp parallel firstprivate(z) default(firstprivate)
+{
+#pragma omp parallel private(z) default(firstprivate)
+  {
+z++;
+f++;
+zoo(z + f);
+f++;
+  }
+}
+  }
+  // PRINT:  #pragma omp parallel firstprivate(this->z) default(firstprivate)
+  // PRINT:#pragma omp parallel private(this->z) default(firstprivate)
+  // DUMP: -OMPParallelDirective
+  // DUMP-NEXT: -OMPFirstprivateClause
+  // DUMP-NEXT:  -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT:  -OMPDefaultClause
+  // DUMP:-OMPParallelDirective
+  // DUMP-NEXT:-OMPPrivateClaus
+  // DUMP-NEXT: -DeclRefExpr {{.*}} 'z'
+  // DUMP-NEXT: -OMPDefaultClause
+  // DUMP-NEXT: -OMPFirstprivateClause {{.*}} 
+  // DUMP-NEXT:  -DeclRefExpr {{.*}} 'f'
+  // DUMP:   -CXXThisExpr {{.*}} 'A *' implicit this
+  // DUMP-NEXT:  -DeclRefExpr {{.*}} 'f'
+  // DUMP: -MemberExpr {{.*}}
+  // DUMP-NEXT:  -CXXThisExpr
+  // DUMP:   -CXXThisExpr {{.*}} 'A *' implicit this
+  // DUMP-NEXT:  -De

[PATCH] D128488: [ODRHash diagnostics] Split `err_module_odr_violation_mismatch_decl_diff` into per-entity diagnostics. NFC.

2022-06-30 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review, Chuanqi!




Comment at: clang/lib/Serialization/ASTReader.cpp:9642
+  // note_module_odr_violation_record
+  enum ODRCXXRecordDifference {
 StaticAssertCondition,

ChuanqiXu wrote:
> Is this specific to C++?
That is supposed to be for C++ only. In D128490 I'm moving it to 
```lang=c++
bool ODRDiagsEmitter::diagnoseMismatch(
const CXXRecordDecl *, const CXXRecordDecl *,
const struct CXXRecordDecl::DefinitionData *) const
```

so it will be even harder to use for non-C++ decls. And for pure C `RecordDecl` 
the plan is to move common checks there and call them from C++-specific code. 
So this enum should remain C++-specific. At most I might move some constants to 
`ODRRecordDifference` or something like that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128488

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


[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-06-30 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi updated this revision to Diff 441556.
akyrtzi added a comment.

Pass a value for `PrevFID` for `FileChanged()` callback as well, for 
`PPCallbacks::EnterFile` reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Lex/PPLexerChange.cpp

Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -111,6 +111,7 @@
 ///  and start lexing tokens from it instead of the current buffer.
 void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
 ConstSearchDirIterator CurDir) {
+  PreprocessorLexer *PrevPPLexer = CurPPLexer;
 
   // Add the current lexer to the include stack.
   if (CurPPLexer || CurTokenLexer)
@@ -130,8 +131,17 @@
 SrcMgr::CharacteristicKind FileType =
SourceMgr.getFileCharacteristic(CurLexer->getFileLoc());
 
-Callbacks->FileChanged(CurLexer->getFileLoc(),
-   PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;
+if (PrevPPLexer) {
+  PrevFID = PrevPPLexer->getFileID();
+  EnterLoc = PrevPPLexer->getSourceLocation();
+}
+Callbacks->FileChanged(CurLexer->getFileLoc(), PPCallbacks::EnterFile,
+   FileType, PrevFID);
+Callbacks->LexedFileChanged(CurLexer->getFileID(),
+PPCallbacks::LexedFileChangeReason::EnterFile,
+FileType, PrevFID, EnterLoc);
   }
 }
 
@@ -486,10 +496,13 @@
 
 // Notify the client, if desired, that we are in a new source file.
 if (Callbacks && !isEndOfMacro && CurPPLexer) {
+  SourceLocation Loc = CurPPLexer->getSourceLocation();
   SrcMgr::CharacteristicKind FileType =
-SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation());
-  Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
- PPCallbacks::ExitFile, FileType, ExitedFID);
+  SourceMgr.getFileCharacteristic(Loc);
+  Callbacks->FileChanged(Loc, PPCallbacks::ExitFile, FileType, ExitedFID);
+  Callbacks->LexedFileChanged(CurPPLexer->getFileID(),
+  PPCallbacks::LexedFileChangeReason::ExitFile,
+  FileType, ExitedFID, Loc);
 }
 
 // Restore conditional stack as well as the recorded
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -31,23 +31,22 @@
 namespace {
 struct DepCollectorPPCallbacks : public PPCallbacks {
   DependencyCollector &DepCollector;
-  SourceManager &SM;
-  DiagnosticsEngine &Diags;
-  DepCollectorPPCallbacks(DependencyCollector &L, SourceManager &SM,
-  DiagnosticsEngine &Diags)
-  : DepCollector(L), SM(SM), Diags(Diags) {}
-
-  void FileChanged(SourceLocation Loc, FileChangeReason Reason,
-   SrcMgr::CharacteristicKind FileType,
-   FileID PrevFID) override {
-if (Reason != PPCallbacks::EnterFile)
+  Preprocessor &PP;
+  DepCollectorPPCallbacks(DependencyCollector &L, Preprocessor &PP)
+  : DepCollector(L), PP(PP) {}
+
+  void LexedFileChanged(FileID FID, LexedFileChangeReason Reason,
+SrcMgr::CharacteristicKind FileType, FileID PrevFID,
+SourceLocation Loc) override {
+if (Reason != PPCallbacks::LexedFileChangeReason::EnterFile)
+  return;
+if (PP.getPredefinesFileID() == FID)
   return;
 
 // Dependency generation really does want to go all the way to the
 // file entry for a source location to find out what is depended on.
 // We do not want #line markers to affect dependency generation!
-if (Optional Filename = SM.getNonBuiltinFilenameForID(
-SM.getFileID(SM.getExpansionLoc(Loc
+if (Optional Filename = PP.getSourceManager().getFilename(FID))
   DepCollector.maybeAddDependency(
   llvm::sys::path::remove_leading_dotslash(*Filename),
   /*FromModule*/ false, isSystem(FileType), /*IsModuleFile*/ false,
@@ -90,7 +89,9 @@
 /*IsMissing=*/false);
   }
 
-  void EndOfMainFile() override { DepCollector.finishedMainFile(Diags); }
+  void EndOfMainFile() override {
+DepCollector.finishedMainFile(PP.getDiagnostics());
+  }
 };
 
 struct DepCollectorMMCallbacks : public ModuleMapCallbacks {
@@ -175,8 +176,7 @@
 
 DependencyCollector::~DependencyCollector() { }
 void DependencyCollector::attachToPreprocessor(Preprocessor &PP) {
-  PP.addPPCallbacks(std::make_unique(
-

[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-06-30 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi updated this revision to Diff 441551.
akyrtzi added a comment.

Use `Optional::value_or()`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Lex/PPLexerChange.cpp

Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -111,6 +111,7 @@
 ///  and start lexing tokens from it instead of the current buffer.
 void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
 ConstSearchDirIterator CurDir) {
+  PreprocessorLexer *PrevPPLexer = CurPPLexer;
 
   // Add the current lexer to the include stack.
   if (CurPPLexer || CurTokenLexer)
@@ -132,6 +133,15 @@
 
 Callbacks->FileChanged(CurLexer->getFileLoc(),
PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;
+if (PrevPPLexer) {
+  PrevFID = PrevPPLexer->getFileID();
+  EnterLoc = PrevPPLexer->getSourceLocation();
+}
+Callbacks->LexedFileChanged(CurLexer->getFileID(),
+PPCallbacks::LexedFileChangeReason::EnterFile,
+FileType, PrevFID, EnterLoc);
   }
 }
 
@@ -486,10 +496,13 @@
 
 // Notify the client, if desired, that we are in a new source file.
 if (Callbacks && !isEndOfMacro && CurPPLexer) {
+  SourceLocation Loc = CurPPLexer->getSourceLocation();
   SrcMgr::CharacteristicKind FileType =
-SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation());
-  Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
- PPCallbacks::ExitFile, FileType, ExitedFID);
+  SourceMgr.getFileCharacteristic(Loc);
+  Callbacks->FileChanged(Loc, PPCallbacks::ExitFile, FileType, ExitedFID);
+  Callbacks->LexedFileChanged(CurPPLexer->getFileID(),
+  PPCallbacks::LexedFileChangeReason::ExitFile,
+  FileType, ExitedFID, Loc);
 }
 
 // Restore conditional stack as well as the recorded
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -31,23 +31,22 @@
 namespace {
 struct DepCollectorPPCallbacks : public PPCallbacks {
   DependencyCollector &DepCollector;
-  SourceManager &SM;
-  DiagnosticsEngine &Diags;
-  DepCollectorPPCallbacks(DependencyCollector &L, SourceManager &SM,
-  DiagnosticsEngine &Diags)
-  : DepCollector(L), SM(SM), Diags(Diags) {}
-
-  void FileChanged(SourceLocation Loc, FileChangeReason Reason,
-   SrcMgr::CharacteristicKind FileType,
-   FileID PrevFID) override {
-if (Reason != PPCallbacks::EnterFile)
+  Preprocessor &PP;
+  DepCollectorPPCallbacks(DependencyCollector &L, Preprocessor &PP)
+  : DepCollector(L), PP(PP) {}
+
+  void LexedFileChanged(FileID FID, LexedFileChangeReason Reason,
+SrcMgr::CharacteristicKind FileType, FileID PrevFID,
+SourceLocation Loc) override {
+if (Reason != PPCallbacks::LexedFileChangeReason::EnterFile)
+  return;
+if (PP.getPredefinesFileID() == FID)
   return;
 
 // Dependency generation really does want to go all the way to the
 // file entry for a source location to find out what is depended on.
 // We do not want #line markers to affect dependency generation!
-if (Optional Filename = SM.getNonBuiltinFilenameForID(
-SM.getFileID(SM.getExpansionLoc(Loc
+if (Optional Filename = PP.getSourceManager().getFilename(FID))
   DepCollector.maybeAddDependency(
   llvm::sys::path::remove_leading_dotslash(*Filename),
   /*FromModule*/ false, isSystem(FileType), /*IsModuleFile*/ false,
@@ -90,7 +89,9 @@
 /*IsMissing=*/false);
   }
 
-  void EndOfMainFile() override { DepCollector.finishedMainFile(Diags); }
+  void EndOfMainFile() override {
+DepCollector.finishedMainFile(PP.getDiagnostics());
+  }
 };
 
 struct DepCollectorMMCallbacks : public ModuleMapCallbacks {
@@ -175,8 +176,7 @@
 
 DependencyCollector::~DependencyCollector() { }
 void DependencyCollector::attachToPreprocessor(Preprocessor &PP) {
-  PP.addPPCallbacks(std::make_unique(
-  *this, PP.getSourceManager(), PP.getDiagnostics()));
+  PP.addPPCallbacks(std::make_unique(*this, PP));
   PP.getHeaderSearchInfo().getModuleMap().addModuleMapCallbacks(
   std::make_unique(*this));
 }
Index: clang/lib/Basic/SourceManager.cpp
===

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.
Herald added a reviewer: ributzka.

I tried the ninja stage2-check-all on my local build with this patch applied 
and don't reproduce the issue.  Is there any way someone could get me the 
preprocessed source that this crashed on off the servers or something?  
@JDevlieghere or @vitalybuka  ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-06-30 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi added inline comments.



Comment at: clang/lib/Basic/SourceManager.cpp:1016
+return *Name;
   return StringRef();
 }

benlangmuir wrote:
> Just a suggestion: `value_or` can be a nice way to express simple cases like 
> this:
> 
> ```
> getFilename(getFileID(SpellingLoc)).value_or(StringRef());
> ```
Thank you for the tip!



Comment at: clang/lib/Lex/PPLexerChange.cpp:136
PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;

benlangmuir wrote:
> Why does `LexedFileChanged` have `PrevFID` set, but `FileChanged` does not 
> (it has a default argument of `FileID()`?  I would have expected that when 
> you call both `FileChanged` and `LexedFileChanged` for the same event this 
> would match.
I didn't want to change the "contract" of `FileChanged()` as part of these 
changes but it's probably unlikely that someone depends on `FileID` being 
invalid, I'll give it a try.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

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


[PATCH] D119296: KCFI sanitizer

2022-06-30 Thread Sami Tolvanen via Phabricator via cfe-commits
samitolvanen added a comment.

In D119296#3623059 , @nickdesaulniers 
wrote:

> I see you modified the mir parser & printer; consider adding a .mir test.

I added a .mir test for parsing the cfi-type. The machine instructions 
generated for the various call types are covered in the .ll tests.

> Might be nice to document the generated asm more for other compiler vendors 
> to better understand the implementation, rather than having to read the tests 
> added here.

The exact instruction sequence is also documented in the kernel patches in case 
other compiler vendors want to implement this, but sure, that makes sense. I 
assume comments in the various `AsmPrinter` functions would be sufficient?




Comment at: clang/lib/CodeGen/CodeGenFunction.h:4604
+  void EmitKCFIOperandBundle(const CGCallee &Callee,
+ SmallVectorImpl &Bundles);
+

nickdesaulniers wrote:
> Should this parameter be an `ArrayRef`? This might be a more precise type, 
> but seeing an impl type kind of breaks the whole pImpl idiom; I'm pretty sure 
> that's what `ArrayRef` is for.
> https://llvm.org/docs/ProgrammersManual.html#llvm-adt-arrayref-h
> That said, this header is pretty inconsistent in the use of `SmallVectorImp` 
> vs `ArrayRef`, but I *think* `ArrayRef` is strongly preferred.
I don't believe I can use `ArrayRef` when I need to append to the list, it 
appears to be read-only.



Comment at: llvm/lib/CodeGen/MachineInstr.cpp:1770-1771
+  if (uint32_t CFIType = getCFIType()) {
+if (!FirstOp) {
+  FirstOp = false;
+  OS << ',';

nickdesaulniers wrote:
> If `FirstOp` is `false`, reassign it `false`? Is that right?  I see that's 
> what's done on L1763, but..."what?"
Ah yes, it looks like this has been copied a few times earlier already. I'll 
stop the cycle.



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:7822-7840
+  ConstantInt *CFIType = nullptr;
+  auto Bundle = CB.getOperandBundle(LLVMContext::OB_kcfi);
+  if (Bundle && CB.isIndirectCall()) {
+if (!TLI.supportKCFIBundles())
+  report_fatal_error(
+  "Target doesn't support calls with kcfi operand bundles.");
+CFIType = cast(Bundle->Inputs[0]);

nickdesaulniers wrote:
> Are we able to reorder these?
> 
> ```
> CLI.setDebugLoc ...
>   ...
> if (Bundle && CB.isIndirectCall) {
>   ...
>   CLI.setCFIType ...
> ```
We can reorder these, but this does follow the same convention as the rest of 
the function. I assume `CallLoweringInfo` was specifically designed so that the 
arguments can all be initialized in one statement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D128952: [AMDGPU] Add WMMA clang builtins

2022-06-30 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec accepted this revision.
rampitec 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/D128952/new/

https://reviews.llvm.org/D128952

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


[PATCH] D128489: [ODRHash diagnostics] Move common code for calculating diag locations in `DiagnoseODRMismatch` into a lambda. NFC.

2022-06-30 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review!




Comment at: clang/lib/Serialization/ASTReader.cpp:10020
+auto GetMismatchedDeclLoc = [](const NamedDecl *Container,
+   ODRMismatchDecl DiffType, const Decl *D) {
+  SourceLocation Loc;

ChuanqiXu wrote:
> DiffType is not necessary here, right?
Unfortunately, it is necessary. A little bit later we have
```
if (DiffType == EndOfClass && Tag)
```
where we use `DiffType`.

By the way, the implementation isn't really correct for `EndOfClass` and 
non-TagDecl as `Loc` remains invalid. But that's a separate issue, I've decided 
to keep the current change to NFC.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128489

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


[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-06-30 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added inline comments.



Comment at: clang/lib/Basic/SourceManager.cpp:1016
+return *Name;
   return StringRef();
 }

Just a suggestion: `value_or` can be a nice way to express simple cases like 
this:

```
getFilename(getFileID(SpellingLoc)).value_or(StringRef());
```



Comment at: clang/lib/Lex/PPLexerChange.cpp:136
PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;

Why does `LexedFileChanged` have `PrevFID` set, but `FileChanged` does not (it 
has a default argument of `FileID()`?  I would have expected that when you call 
both `FileChanged` and `LexedFileChanged` for the same event this would match.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128947

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


[PATCH] D128754: Refactor LLVM compression namespaces (Part 1: remove crc32)

2022-06-30 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

LGTM. Should probably add `[llvm]` to the subject also. Generally it's helpful 
for immediately knowing which subrepo you're touching.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128754

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


[PATCH] D128103: Adds AST Matcher for ObjCStringLiteral

2022-06-30 Thread Rashmi Mudduluru 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 rGeb1d908e5cf7: Adds AST matcher for ObjCStringLiteral 
(authored by t-rasmud).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128103

Files:
  clang/docs/LibASTMatchersReference.html
  clang/docs/ReleaseNotes.rst
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -2352,6 +2352,26 @@
argumentCountIs(0;
 }
 
+TEST(ASTMatchersTestObjC, ObjCStringLiteral) {
+
+  StringRef Objc1String = "@interface NSObject "
+  "@end "
+  "@interface NSString "
+  "@end "
+  "@interface Test : NSObject "
+  "+ (void)someFunction:(NSString *)Desc; "
+  "@end "
+  "@implementation Test "
+  "+ (void)someFunction:(NSString *)Desc { "
+  "return; "
+  "} "
+  "- (void) foo { "
+  "[Test someFunction:@\"Ola!\"]; "
+  "}\n"
+  "@end ";
+EXPECT_TRUE(matchesObjC(Objc1String, objcStringLiteral()));
+}
+
 TEST(ASTMatchersTestObjC, ObjCDecls) {
   StringRef ObjCString = "@protocol Proto "
  "- (void)protoDidThing; "
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -505,6 +505,7 @@
   REGISTER_MATCHER(objcObjectPointerType);
   REGISTER_MATCHER(objcPropertyDecl);
   REGISTER_MATCHER(objcProtocolDecl);
+  REGISTER_MATCHER(objcStringLiteral);
   REGISTER_MATCHER(objcThrowStmt);
   REGISTER_MATCHER(objcTryStmt);
   REGISTER_MATCHER(ofClass);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -917,6 +917,7 @@
 const internal::VariadicDynCastAllOfMatcher
 cxxBoolLiteral;
 const internal::VariadicDynCastAllOfMatcher stringLiteral;
+const internal::VariadicDynCastAllOfMatcher objcStringLiteral;
 const internal::VariadicDynCastAllOfMatcher
 characterLiteral;
 const internal::VariadicDynCastAllOfMatcher
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -1515,6 +1515,15 @@
 extern const internal::VariadicDynCastAllOfMatcher
 objcMessageExpr;
 
+/// Matches ObjectiveC String literal expressions.
+///
+/// Example matches @"abcd"
+/// \code
+///   NSString *s = @"abcd";
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+objcStringLiteral;
+
 /// Matches Objective-C interface declarations.
 ///
 /// Example matches Foo
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -565,6 +565,9 @@
 
 - Added ``forEachTemplateArgument`` matcher which creates a match every
   time a ``templateArgument`` matches the matcher supplied to it.
+  
+- Added ``objcStringLiteral`` matcher which matches ObjectiveC String
+  literal expressions.
 
 clang-format
 
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -1236,7 +1236,7 @@
   #pragma omp parallel
 
 ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
-``default(private)`` and ``default(firstprivate)``
+`` default(private)`` and ``default(firstprivate)``
 
 
 
@@ -2036,6 +2036,14 @@
 
 
 
+MatcherStmt>objcStringLiteralMatcherObjCStringLiteral>...
+Matches ObjectiveC String literal expressions.
+
+Example matches @"abcd"
+  NSString *s = @"abcd";
+
+
+
 MatcherStmt>objcThrowStmtMatcherObjCAtThrowStmt>...
 Mat

[PATCH] D128754: Refactor LLVM compression namespaces (Part 1: remove crc32)

2022-06-30 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 441541.
ckissane added a comment.

- Merge branch 'ckissane.refactor-compression.part-0' into 
ckissane.refactor-compression.part-1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128754

Files:
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/Support/Compression.cpp
  llvm/unittests/Support/CompressionTest.cpp


Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -64,12 +64,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -84,10 +84,6 @@
   return E;
 }
 
-uint32_t zlib::crc32(StringRef Buffer) {
-  return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
-}
-
 #else
 bool zlib::isAvailable() { return false; }
 void zlib::compress(StringRef InputBuffer,
@@ -103,7 +99,4 @@
size_t UncompressedSize) {
   llvm_unreachable("zlib::uncompress is unavailable");
 }
-uint32_t zlib::crc32(StringRef Buffer) {
-  llvm_unreachable("zlib::crc32 is unavailable");
-}
 #endif
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -42,8 +42,6 @@
  SmallVectorImpl &UncompressedBuffer,
  size_t UncompressedSize);
 
-uint32_t crc32(StringRef Buffer);
-
 } // End of namespace zlib
 
 namespace profile = llvm::compression::zlib;
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -187,6 +187,7 @@
   * Code that explictly needs ``zlib`` compression (IE zlib elf debug 
sections) should use ``llvm::compression::zlib``.
   * Code interfacing with compressed profile data should use 
``llvm::compression::profile``.
   * Code interfacing with compressed serialized data should use 
``llvm::compression::serialize``.
+  * Remove crc32 from zlib compression namespace, people should use the 
``llvm::crc32`` instead.
 
 Changes to the Go bindings
 --


Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -64,12 +64,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -84,10 +84,6 @@
   return E;
 }
 
-uint32_t zlib::crc32(StringRef Buffer) {
-  return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
-}
-
 #else
 bool zlib::isAvailable() { return false; }
 void zlib::compress(StringRef InputBuffer,
@@ -103,7 +99,4 @@
size_t UncompressedSize) {
   llvm_unreachable("zlib::uncompress is unavailable");
 }
-uint32_t zlib::crc32(StringRef Buffer) {
-  llvm_unreachable("zlib::crc32 is unavailable");
-}
 #endif
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -42,8 +42,6 @@
  SmallVectorImpl &UncompressedBuffer,
  size_t UncompressedSize);
 
-uint32_t crc32(StringRef Buffer);
-
 } // End of namespace zlib
 
 namespace profile = llvm::compression::zlib;
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -187,6 +187,7 @@
   * Code that explictly needs ``zlib`` compression (IE zlib elf debug sections) should use ``llvm::compression::zlib``.
   * Code interfacing with compressed profile data should use ``llvm::compression::profile``.
   * Code interfacing with compressed serialized data should use ``llvm::compression::serialize``.
+  * Remove crc32 from zlib compression namespace, people should use the ``llvm::crc32`` instead.
 
 Changes to the Go bindings
 --
___
cfe-commits mailing list
cfe-commits

[clang] eb1d908 - Adds AST matcher for ObjCStringLiteral

2022-06-30 Thread Rashmi Mudduluru via cfe-commits

Author: Rashmi Mudduluru
Date: 2022-06-30T15:20:10-07:00
New Revision: eb1d908e5cf7279b98b84d1587d4665d3cdecbe9

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

LOG: Adds AST matcher for ObjCStringLiteral

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

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/docs/ReleaseNotes.rst
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index c206c63e84acb..03ca48cc1a9b3 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -1236,7 +1236,7 @@ Node Matchers
   #pragma omp parallel
 
 ``ompDefaultClause()`` matches ``default(none)``, ``default(shared)``,
-``default(private)`` and ``default(firstprivate)``
+`` default(private)`` and ``default(firstprivate)``
 
 
 
@@ -2036,6 +2036,14 @@ Node Matchers
 
 
 
+MatcherStmt>objcStringLiteralMatcherObjCStringLiteral>...
+Matches 
ObjectiveC String literal expressions.
+
+Example matches @"abcd"
+  NSString *s = @"abcd";
+
+
+
 MatcherStmt>objcThrowStmtMatcherObjCAtThrowStmt>...
 Matches Objective-C 
statements.
 
@@ -4716,8 +4724,8 @@ Narrowing Matchers
 
 
 
-MatcherOMPDefaultClause>isFirstPrivateKind
-Matches if the OpenMP 
``default`` clause has ``private`` kind
+MatcherOMPDefaultClause>isFirstPrivateKind
+Matches if the 
OpenMP ``default`` clause has ``firstprivate`` kind
 specified.
 
 Given
@@ -4729,12 +4737,12 @@ Narrowing Matchers
   #pragma omp parallel default(firstprivate)
 
 ``ompDefaultClause(isFirstPrivateKind())`` matches only
-``default(private)``.
+``default(firstprivate)``.
 
 
-MatcherOMPDefaultClause>isFirstPrivateKind
-Matches if the 
OpenMP ``default`` clause has ``firstprivate`` kind
-specified.
+
+MatcherOMPDefaultClause>isNoneKind
+Matches if the OpenMP 
``default`` clause has ``none`` kind specified.
 
 Given
 
@@ -4744,13 +4752,13 @@ Narrowing Matchers
   #pragma omp parallel default(private)
   #pragma omp parallel default(firstprivate)
 
-``ompDefaultClause(isFirstPrivateKind())`` matches only
-``default(firstprivate)``.
+``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
 
 
 
-MatcherOMPDefaultClause>isNoneKind
-Matches if the OpenMP 
``default`` clause has ``none`` kind specified.
+MatcherOMPDefaultClause>isPrivateKind
+Matches if the OpenMP 
``default`` clause has ``private`` kind
+specified.
 
 Given
 
@@ -4760,7 +4768,8 @@ Narrowing Matchers
   #pragma omp parallel default(private)
   #pragma omp parallel default(firstprivate)
 
-``ompDefaultClause(isNoneKind())`` matches only ``default(none)``.
+``ompDefaultClause(isPrivateKind())`` matches only
+``default(private)``.
 
 
 
@@ -7411,8 +7420,9 @@ AST Traversal Matchers
 
 
 
-MatcherClassTemplateSpecializationDecl>forEachTemplateArgumentMatcherTemplateArgument>
 InnerMatcher
-Matches 
classTemplateSpecialization, templateSpecializationType and functionDecl nodes 
where the template argument matches the inner matcher.
+MatcherClassTemplateSpecializationDecl>forEachTemplateArgumentclang::ast_matchers::MatcherTemplateArgument>
 InnerMatcher
+Matches 
classTemplateSpecialization, templateSpecializationType and
+functionDecl nodes where the template argument matches the inner matcher.
 This matcher may produce multiple matches.
 
 Given
@@ -7427,10 +7437,8 @@ AST Traversal Matchers
 
   bool B = false;
   f(R, B);
-
 templateSpecializationType(forEachTemplateArgument(isExpr(expr(
   matches twice, with expr() matching 'R * 2' and 'R * 4'
-
 functionDecl(forEachTemplateArgument(refersToType(builtin

[PATCH] D128953: [NFC] refactor compression namespaces making way for a possible introduction of alternatives to zlib compression in the llvm toolchain.

2022-06-30 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 441540.
ckissane added a comment.

- Merge branch 'ckissane.refactor-compression.part-0' of 
github.com:ckissane/llvm-project into ckissane.refactor-compression.part-0
- Merge branch 'main' into ckissane.refactor-compression.part-0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/Compression.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -19,6 +19,8 @@
 
 using namespace llvm;
 
+using namespace llvm::compression;
+
 namespace {
 
 #if LLVM_ENABLE_ZLIB
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1146,17 +1146,19 @@
   for (bool DoCompression : {false, true}) {
 // Compressing:
 std::string FuncNameStrings1;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings1),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames1, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings1),
+Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings2),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames2, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings2),
+Succeeded());
 
 for (int Padding = 0; Padding < 2; Padding++) {
   // Join with paddings :
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -739,7 +739,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -998,7 +998,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
 errc::invalid_argument,
 "LLVM was not compiled with LLVM_ENABLE_ZLIB: cannot decompress");
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -403,7 +403,7 @@
   MAI->setRelaxELFRelocations(RelaxELFRel);
 
   if (CompressDebugSections != DebugCompressionType::None) {
-if (!zlib::isAvailable()) {
+if (!compression::zlib::isAvailable()) {
   WithColor::error(errs(), ProgName)
   << "build tools with zlib to enable -compress-debug-sections";
   return 1;
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -23,10 +23,9 @@
 
 using namespace llvm;
 
+using namespace llvm::compression;
+
 #if LLVM_ENABLE_ZLIB
-static Error createError(StringRef Err) {
-  return make_error(Err, inconvertibleErrorCode());
-}
 
 static StringRef convertZlibCodeToString(int Code) {
   switch (Code) {
@@ -70,15 +69,17 @@
   // Tell MemorySanitizer that zlib output buffer is fully initialized.
   // This avoids a false report when running LLVM with uninstrumented ZLib.
   __msan_unpoison(UncompressedBu

[PATCH] D128955: [WPD] Use new llvm.public.type.test intrinsic for publicly visible classes

2022-06-30 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: ormris, steven_wu, hiraditya.
Herald added a project: All.
aeubanks requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, jdoerfert.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128955

Files:
  clang/lib/CodeGen/CGClass.cpp
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
  llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
  llvm/lib/Analysis/TypeMetadataUtils.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp

Index: llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
===
--- llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
+++ llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
@@ -860,7 +860,7 @@
 const DenseSet &DynamicExportSymbols) {
   if (!hasWholeProgramVisibility(WholeProgramVisibilityEnabledInLTO))
 return;
-  for (GlobalVariable &GV : M.globals())
+  for (GlobalVariable &GV : M.globals()) {
 // Add linkage unit visibility to any variable with type metadata, which are
 // the vtable definitions. We won't have an existing vcall_visibility
 // metadata on vtable definitions with public visibility.
@@ -870,6 +870,34 @@
 // linker, as we have no information on their eventual use.
 !DynamicExportSymbols.count(GV.getGUID()))
   GV.setVCallVisibilityMetadata(GlobalObject::VCallVisibilityLinkageUnit);
+  }
+}
+
+void updatePublicTypeTestCalls(Module &M,
+   bool WholeProgramVisibilityEnabledInLTO) {
+  Function *PublicTypeTestFunc =
+  M.getFunction(Intrinsic::getName(Intrinsic::public_type_test));
+  if (!PublicTypeTestFunc)
+return;
+  if (hasWholeProgramVisibility(WholeProgramVisibilityEnabledInLTO)) {
+Function *TypeTestFunc =
+Intrinsic::getDeclaration(&M, Intrinsic::type_test);
+for (Use &U : make_early_inc_range(PublicTypeTestFunc->uses())) {
+  auto *CI = cast(U.getUser());
+  auto *NewCI = CallInst::Create(
+  TypeTestFunc, {CI->getArgOperand(0), CI->getArgOperand(1)}, None, "",
+  CI);
+  CI->replaceAllUsesWith(NewCI);
+  CI->eraseFromParent();
+}
+  } else {
+auto *True = ConstantInt::getTrue(M.getContext());
+for (Use &U : make_early_inc_range(PublicTypeTestFunc->uses())) {
+  auto *CI = cast(U.getUser());
+  CI->replaceAllUsesWith(True);
+  CI->eraseFromParent();
+}
+  }
 }
 
 /// If whole program visibility asserted, then upgrade all public vcall
Index: llvm/lib/LTO/LTOBackend.cpp
===
--- llvm/lib/LTO/LTOBackend.cpp
+++ llvm/lib/LTO/LTOBackend.cpp
@@ -40,6 +40,7 @@
 #include "llvm/Support/ToolOutputFile.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Target/TargetMachine.h"
+#include "llvm/Transforms/IPO/WholeProgramDevirt.h"
 #include "llvm/Transforms/Scalar/LoopPassManager.h"
 #include "llvm/Transforms/Utils/FunctionImportUtils.h"
 #include "llvm/Transforms/Utils/SplitModule.h"
@@ -330,6 +331,7 @@
/*EmbedBitcode*/ true, /*EmbedCmdline*/ true,
/*Cmdline*/ CmdArgs);
   }
+  updatePublicTypeTestCalls(Mod, Conf.HasWholeProgramVisibility);
   // FIXME: Plumb the combined index into the new pass manager.
   runNewPMPasses(Conf, Mod, TM, Conf.OptLevel, IsThinLTO, ExportSummary,
  ImportSummary);
Index: llvm/lib/Analysis/TypeMetadataUtils.cpp
===
--- llvm/lib/Analysis/TypeMetadataUtils.cpp
+++ llvm/lib/Analysis/TypeMetadataUtils.cpp
@@ -75,7 +75,9 @@
 SmallVectorImpl &DevirtCalls,
 SmallVectorImpl &Assumes, const CallInst *CI,
 DominatorTree &DT) {
-  assert(CI->getCalledFunction()->getIntrinsicID() == Intrinsic::type_test);
+  assert(CI->getCalledFunction()->getIntrinsicID() == Intrinsic::type_test ||
+ CI->getCalledFunction()->getIntrinsicID() ==
+ Intrinsic::public_type_test);
 
   const Module *M = CI->getParent()->getParent()->getParent();
 
Index: llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
===
--- llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
+++ llvm/lib/Analysis/ModuleSummaryAnalysis.cpp
@@ -164,7 +164,8 @@
 SetVector &TypeCheckedLoadConstVCalls,
 DominatorTree &DT) {
   switch (CI->getCalledFunction()->getIntrinsicID()) {
-  case Intrinsic::type_test: {
+  case Intrinsic::type_test:
+  case Intrinsic::public_type_test: {
 auto *TypeMDVal = cast(CI->getArgOperand(1));
 auto *TypeId = dyn_cast(TypeMDVal->getMetadata());
 if (!TypeId)
Index: llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
===
--- llvm/include/llvm/Transforms/IPO/WholeProgramDevirt.h
+++ llvm/include/llvm/Transfo

[PATCH] D128953: refactor compression namespaces making way for a possible introduction of alternatives to zlib compression in the llvm toolchain.

2022-06-30 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan accepted this revision.
leonardchan added a comment.
This revision is now accepted and ready to land.

LGTM. Should also probably add `[NFC]` to the start of the subject




Comment at: lld/ELF/InputSection.cpp:77
+if (!compression::zlib::isAvailable())
+  error(toString(file) + ": contains a compressed section, " + "but " +
+compression::zlib::AlgorithmName + " is not available");

`": contains a compressed section, " + "but "` -> `": contains a compressed 
section, but "`



Comment at: llvm/lib/ProfileData/InstrProf.cpp:154
+OS << ("profile uses " + compression::profile::AlgorithmName +
+   " compression but the profile reader was built " + "without " +
+   compression::profile::AlgorithmName + " support");

`" compression but the profile reader was built " + "without "` -> `" 
compression but the profile reader was built without "`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128953

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


[PATCH] D128754: Refactor LLVM compression namespaces

2022-06-30 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 441537.
ckissane added a comment.

make part 1 after part 0 of refactor


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128754

Files:
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/Support/Compression.cpp
  llvm/unittests/Support/CompressionTest.cpp


Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -64,12 +64,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -84,10 +84,6 @@
   return E;
 }
 
-uint32_t zlib::crc32(StringRef Buffer) {
-  return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
-}
-
 #else
 bool zlib::isAvailable() { return false; }
 void zlib::compress(StringRef InputBuffer,
@@ -103,7 +99,4 @@
size_t UncompressedSize) {
   llvm_unreachable("zlib::uncompress is unavailable");
 }
-uint32_t zlib::crc32(StringRef Buffer) {
-  llvm_unreachable("zlib::crc32 is unavailable");
-}
 #endif
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -42,8 +42,6 @@
  SmallVectorImpl &UncompressedBuffer,
  size_t UncompressedSize);
 
-uint32_t crc32(StringRef Buffer);
-
 } // End of namespace zlib
 
 namespace profile = llvm::compression::zlib;
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -187,6 +187,7 @@
   * Code that explictly needs ``zlib`` compression (IE zlib elf debug 
sections) should use ``llvm::compression::zlib``.
   * Code interfacing with compressed profile data should use 
``llvm::compression::profile``.
   * Code interfacing with compressed serialized data should use 
``llvm::compression::serialize``.
+  * Remove crc32 from zlib compression namespace, people should use the 
``llvm::crc32`` instead.
 
 Changes to the Go bindings
 --


Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -64,12 +64,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -84,10 +84,6 @@
   return E;
 }
 
-uint32_t zlib::crc32(StringRef Buffer) {
-  return ::crc32(0, (const Bytef *)Buffer.data(), Buffer.size());
-}
-
 #else
 bool zlib::isAvailable() { return false; }
 void zlib::compress(StringRef InputBuffer,
@@ -103,7 +99,4 @@
size_t UncompressedSize) {
   llvm_unreachable("zlib::uncompress is unavailable");
 }
-uint32_t zlib::crc32(StringRef Buffer) {
-  llvm_unreachable("zlib::crc32 is unavailable");
-}
 #endif
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -42,8 +42,6 @@
  SmallVectorImpl &UncompressedBuffer,
  size_t UncompressedSize);
 
-uint32_t crc32(StringRef Buffer);
-
 } // End of namespace zlib
 
 namespace profile = llvm::compression::zlib;
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -187,6 +187,7 @@
   * Code that explictly needs ``zlib`` compression (IE zlib elf debug sections) should use ``llvm::compression::zlib``.
   * Code interfacing with compressed profile data should use ``llvm::compression::profile``.
   * Code interfacing with compressed serialized data should use ``llvm::compression::serialize``.
+  * Remove crc32 from zlib compression namespace, people should use the ``llvm::crc32`` instead.
 
 Changes to the Go bindings
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listi

[PATCH] D128953: chore: refactor compression namespaces making way for a possible introduction of alternatives to zlib compression in the llvm toolchain. Changes are as follows: * Relocate the `ll

2022-06-30 Thread Cole Kissane via Phabricator via cfe-commits
ckissane created this revision.
Herald added subscribers: wenlei, usaxena95, kadircet, arphaman, hiraditya, 
arichardson, emaste.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: All.
ckissane requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, StephenFan.
Herald added projects: clang, LLVM, clang-tools-extra.

...that explictly needs `zlib` compression (IE zlib elf debug sections) should 
use `llvm::compression::zlib`.   * Code interfacing with compressed profile 
data should use `llvm::compression::profile`.   * Code interfacing with 
compressed serialized data should use `llvm::compression::serialize`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128953

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/Compression.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -19,6 +19,8 @@
 
 using namespace llvm;
 
+using namespace llvm::compression;
+
 namespace {
 
 #if LLVM_ENABLE_ZLIB
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1146,17 +1146,19 @@
   for (bool DoCompression : {false, true}) {
 // Compressing:
 std::string FuncNameStrings1;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings1),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames1, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings1),
+Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings2),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames2, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings2),
+Succeeded());
 
 for (int Padding = 0; Padding < 2; Padding++) {
   // Join with paddings :
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -739,7 +739,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -998,7 +998,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
 errc::invalid_argument,
 "LLVM was not compiled with LLVM_ENABLE_ZLIB: cannot decompress");
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -403,7 +403,7 @@
   MAI->setRelaxELFRelocations(RelaxELFRel);
 
   if (CompressDebugSections != DebugCompressionType::None) {
-if (!zlib::isAvailable()) {
+if (!compression::zlib::isAvailable()) {
   WithColor::error(errs(), ProgName)
   << "build tools with zlib to enable -compress-debug-sections";
   return 1;
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -23,10 +23,9 @@
 
 using namespace llvm

[PATCH] D128952: [AMDGPU] Add WMMA clang builtins

2022-06-30 Thread Piotr Sobczak via Phabricator via cfe-commits
piotr created this revision.
Herald added subscribers: kosarev, kerbowa, t-tye, tpr, dstuttard, yaxunl, 
jvesely, kzhuravl.
Herald added a project: All.
piotr requested review of this revision.
Herald added subscribers: cfe-commits, wdng.
Herald added a project: clang.

Add WMMA clang builtins and tests. Extra changes in code
are needed to handle function overloads.

WavefrontSize 32:
__builtin_amdgcn_wmma_f32_16x16x16_f16_w32
__builtin_amdgcn_wmma_f32_16x16x16_bf16_w32
__builtin_amdgcn_wmma_f16_16x16x16_f16_w32
__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w32
__builtin_amdgcn_wmma_i32_16x16x16_iu8_w32
__builtin_amdgcn_wmma_i32_16x16x16_iu4_w32

WavefrontSize 64:
__builtin_amdgcn_wmma_f32_16x16x16_f16_w64
__builtin_amdgcn_wmma_f32_16x16x16_bf16_w64
__builtin_amdgcn_wmma_f16_16x16x16_f16_w64
__builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64
__builtin_amdgcn_wmma_i32_16x16x16_iu8_w64
__builtin_amdgcn_wmma_i32_16x16x16_iu4_w64


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128952

Files:
  clang/include/clang/Basic/BuiltinsAMDGPU.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w32.cl
  clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl

Index: clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w64.cl
@@ -0,0 +1,84 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -DWMMA_GFX1100_TESTS -S -emit-llvm -o - %s | FileCheck %s --check-prefix=CHECK-GFX1100
+
+typedef float  v4f   __attribute__((ext_vector_type(4)));
+typedef float  v8f   __attribute__((ext_vector_type(8)));
+typedef half   v8h   __attribute__((ext_vector_type(8)));
+typedef half   v16h  __attribute__((ext_vector_type(16)));
+typedef intv2i   __attribute__((ext_vector_type(2)));
+typedef intv4i   __attribute__((ext_vector_type(4)));
+typedef intv8i   __attribute__((ext_vector_type(8)));
+typedef short  v8s   __attribute__((ext_vector_type(8)));
+typedef short  v16s  __attribute__((ext_vector_type(16)));
+
+#ifdef WMMA_GFX1100_TESTS
+
+// Wave64
+
+//
+// amdgcn_wmma_f32_16x16x16_f16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_f32_16x16x16_f16_w64
+// CHECK-GFX1100: call <4 x float> @llvm.amdgcn.wmma.f32.16x16x16.f16.v4f32(<16 x half> %a, <16 x half> %b, <4 x float> %c)
+void test_amdgcn_wmma_f32_16x16x16_f16_w64(global v4f* out, v16h a, v16h b, v4f c)
+{
+  *out = __builtin_amdgcn_wmma_f32_16x16x16_f16_w64(a, b, c);
+}
+
+//
+// amdgcn_wmma_f32_16x16x16_bf16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_f32_16x16x16_bf16_w64
+// CHECK-GFX1100: call <4 x float> @llvm.amdgcn.wmma.f32.16x16x16.bf16.v4f32(<16 x i16> %a, <16 x i16> %b, <4 x float> %c)
+void test_amdgcn_wmma_f32_16x16x16_bf16_w64(global v4f* out, v16s a, v16s b, v4f c)
+{
+  *out = __builtin_amdgcn_wmma_f32_16x16x16_bf16_w64(a, b, c);
+}
+
+//
+// amdgcn_wmma_f16_16x16x16_f16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_f16_16x16x16_f16_w64
+// CHECK-GFX1100: call <8 x half> @llvm.amdgcn.wmma.f16.16x16x16.f16.v8f16(<16 x half> %a, <16 x half> %b, <8 x half> %c, i1 true)
+void test_amdgcn_wmma_f16_16x16x16_f16_w64(global v8h* out, v16h a, v16h b, v8h c)
+{
+  *out = __builtin_amdgcn_wmma_f16_16x16x16_f16_w64(a, b, c, true);
+}
+
+//
+// amdgcn_wmma_bf16_16x16x16_bf16
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_bf16_16x16x16_bf16_w64
+// CHECK-GFX1100: call <8 x i16> @llvm.amdgcn.wmma.bf16.16x16x16.bf16.v8i16(<16 x i16> %a, <16 x i16> %b, <8 x i16> %c, i1 true)
+void test_amdgcn_wmma_bf16_16x16x16_bf16_w64(global v8s* out, v16s a, v16s b, v8s c)
+{
+  *out = __builtin_amdgcn_wmma_bf16_16x16x16_bf16_w64(a, b, c, true);
+}
+
+//
+// amdgcn_wmma_i32_16x16x16_iu8
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_i32_16x16x16_iu8_w64
+// CHECK-GFX1100: call <4 x i32> @llvm.amdgcn.wmma.i32.16x16x16.iu8.v4i32(i1 true, <4 x i32> %a, i1 true, <4 x i32> %b, <4 x i32> %c, i1 false)
+void test_amdgcn_wmma_i32_16x16x16_iu8_w64(global v4i* out, v4i a, v4i b, v4i c)
+{
+  *out = __builtin_amdgcn_wmma_i32_16x16x16_iu8_w64(true, a, true, b, c, false);
+}
+
+//
+// amdgcn_wmma_i32_16x16x16_iu4
+//
+
+// CHECK-GFX1100-LABEL: @test_amdgcn_wmma_i32_16x16x16_iu4_w64
+// CHECK-GFX1100: call <4 x i32> @llvm.amdgcn.wmma.i32.16x16x16.iu4.v4i32(i1 true, <2 x i32> %a, i1 true, <2 x i32> %b, <4 x i32> %c, i1 false)
+void test_amdgcn_wmma_i32_16x16x16_iu4_w64(global v4i* out, v2i a, v2i b, v4i c)
+{
+  *out = __builtin_amdgcn_wmma_i32_16x16x16_iu4_w64(true, a, true, b, c, false);
+}
+
+#endif
Index: clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w32.cl
===
--- /dev/null
+++ clang/test/CodeGenOpenCL/builtins-amdgcn-wmma-w32.cl
@@ -0,0 +1,82 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx1100 -DWMMA_GFX1100_TESTS -S -emit-llvm -o -

[PATCH] D128844: Improve the formatting of static_assert messages

2022-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

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


[clang] da1609a - Improve the formatting of static_assert messages

2022-06-30 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-06-30T23:59:21+02:00
New Revision: da1609ad73540978f66111e96ea500b97ca9b39a

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

LOG: Improve the formatting of static_assert messages

Display 'static_assert failed: message' instead of
'static_assert failed "message"' to be consistent
with other implementations and be slightly more
readable.

Reviewed By: #libc, aaron.ballman, philnik, Mordante

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/C/drs/dr0xx.c
clang/test/CXX/dcl.dcl/p4-0x.cpp
clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
clang/test/PCH/cxx-static_assert.cpp
clang/test/Sema/static-assert.c
clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
clang/test/SemaCXX/static-assert.cpp

libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp

libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp

libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp

libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp

libcxx/test/libcxx/input.output/file.streams/fstreams/filebuf/traits_mismatch.fail.cpp

libcxx/test/libcxx/input.output/file.streams/fstreams/traits_mismatch.fail.cpp

libcxx/test/libcxx/input.output/iostream.format/input.streams/traits_mismatch.fail.cpp

libcxx/test/libcxx/input.output/iostream.format/output.streams/traits_mismatch.fail.cpp
libcxx/test/libcxx/input.output/string.streams/traits_mismatch.fail.cpp

libcxx/test/libcxx/iterators/predef.iterators/reverse.iterators/bad_template_argument.verify.cpp

libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp

libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp

libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/pair.tuple_element.fail.cpp

libcxx/test/libcxx/utilities/variant/variant.variant/variant.helper/variant_alternative.fail.cpp

libcxx/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.fail.cpp

libcxx/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp
libcxx/test/std/containers/associative/map/map.cons/deduct.fail.cpp

libcxx/test/std/containers/associative/multimap/multimap.cons/deduct.fail.cpp
libcxx/test/std/containers/sequences/array/array.fill/fill.fail.cpp
libcxx/test/std/containers/sequences/array/array.swap/swap.fail.cpp
libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp

libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp

libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp

libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp

libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
libcxx/test/std/numerics/numbers/illformed.verify.cpp
libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/params.fail.cpp
libcxx/test/std/strings/basic.string/char.bad.verify.cpp
libcxx/test/std/strings/string.view/char.bad.fail.cpp
libcxx/test/std/time/time.hms/hhmmss.fail.cpp

libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp

libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.verify.cpp

libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.verify.cpp

libcxx/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp
libcxx/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp

libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ctor.fail.cpp

libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.fail.cpp

libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp
libcxx/test/std/utilities/optional/optional.syn/optional_in_place_t.fail.cpp
libcxx/test/std/utilities/utility/forward/forward.fail.cpp
libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 880fe0d18a02e..bc7aec3803e82 10

[PATCH] D128844: Improve the formatting of static_assert messages

2022-06-30 Thread Corentin Jabot 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 rGda1609ad7354: Improve the formatting of static_assert 
messages (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp
  
libcxx/test/libcxx/input.output/file.streams/fstreams/filebuf/traits_mismatch.fail.cpp
  libcxx/test/libcxx/input.output/file.streams/fstreams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/input.output/iostream.format/input.streams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/input.output/iostream.format/output.streams/traits_mismatch.fail.cpp
  libcxx/test/libcxx/input.output/string.streams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/iterators/predef.iterators/reverse.iterators/bad_template_argument.verify.cpp
  
libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp
  
libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/pair.tuple_element.fail.cpp
  
libcxx/test/libcxx/utilities/variant/variant.variant/variant.helper/variant_alternative.fail.cpp
  
libcxx/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.fail.cpp
  
libcxx/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp
  libcxx/test/std/containers/associative/map/map.cons/deduct.fail.cpp
  libcxx/test/std/containers/associative/multimap/multimap.cons/deduct.fail.cpp
  libcxx/test/std/containers/sequences/array/array.fill/fill.fail.cpp
  libcxx/test/std/containers/sequences/array/array.swap/swap.fail.cpp
  libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
  libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp
  
libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
  libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
  
libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp
  
libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
  libcxx/test/std/numerics/numbers/illformed.verify.cpp
  libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/params.fail.cpp
  libcxx/test/std/strings/basic.string/char.bad.verify.cpp
  libcxx/test/std/strings/string.view/char.bad.fail.cpp
  libcxx/test/std/time/time.hms/hhmmss.fail.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.verify.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.verify.cpp
  libcxx/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp
  libcxx/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ctor.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp
  libcxx/test/std/utilities/optional/optional.syn/optional_in_place_t.fail.cpp
  libcxx/test/std/utilities/utility/forward/forward.fail.cpp
  libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp

Index: libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
===
--- libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
+++ libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
@@ -75,7 +75,7 @@
   using V = std::variant;
   V v1(42);
   V v2(101);
-  // expected-error-re@variant:* 6 {{static_assert failed {{.*}}"the relational operator does not return a type which is implicitly convertible to bool"}}
+  // expected-error-re@variant:* 6 {{static_assert failed{{.*}}the relational operator

[PATCH] D128449: [clang] Introduce -Warray-parameter

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

Extra test


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

https://reviews.llvm.org/D128449

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Misc/warning-wall.c
  clang/test/Sema/array-parameter.c
  clang/test/Sema/array-parameter.cpp

Index: clang/test/Sema/array-parameter.cpp
===
--- /dev/null
+++ clang/test/Sema/array-parameter.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -Warray-parameter -verify %s
+
+template 
+void func(int i[10]); // expected-note {{previously declared as 'int[10]' here}}
+
+template 
+void func(int i[N]); // expected-warning {{argument 'i' of type 'int[N]' with mismatched bound}}
+
+static constexpr int Extent = 10;
+void funk(int i[10]);
+void funk(int i[Extent]); // no-warning
Index: clang/test/Sema/array-parameter.c
===
--- /dev/null
+++ clang/test/Sema/array-parameter.c
@@ -0,0 +1,35 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -fsyntax-only -Warray-parameter -verify %s
+void f0(int a[]);
+void f0(int *a); // no warning
+
+void f1(int a[]);  // expected-note {{previously declared as 'int[]' here}}
+void f1(int a[2]); // expected-warning {{argument 'a' of type 'int[2]' with mismatched bound}}
+
+void f2(int a[3]); // expected-note {{previously declared as 'int[3]' here}}
+void f2(int a[2]); // expected-warning {{argument 'a' of type 'int[2]' with mismatched bound}}
+
+void f3(int a[const 2]);
+void f3(int a[2]); // no warning
+
+void f4(int a[static 2]);
+void f4(int a[2]); // no warning
+
+void f5(int a[restrict 2]);
+void f5(int a[2]); // no warning
+
+void f6(int a[volatile 2]);
+void f6(int a[2]); // no warning
+
+void f7(int a[*]);
+void f7(int a[]); // no warning
+
+void f8(int n, int a[*]); // expected-note {{previously declared as 'int[*]' here}}
+void f8(int n, int a[n]); // expected-warning {{argument 'a' of type 'int[n]' with mismatched bound}}
+
+void f9(int *a);
+void f9(int a[2]);
+void f9(int a[]); // expected-warning {{argument 'a' of type 'int[]' with mismatched bound}}
+  // expected-note@-2 {{previously declared as 'int[2]' here}}
+void f9(int a[2]) // expected-warning {{argument 'a' of type 'int[2]' with mismatched bound}}
+  // expected-note@-3 {{previously declared as 'int[]' here}}
+{}
Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -3,6 +3,7 @@
 
  CHECK:-Wall
 CHECK-NEXT:  -Wmost
+CHECK-NEXT:-Warray-parameter
 CHECK-NEXT:-Wbool-operation
 CHECK-NEXT:-Wbitwise-instead-of-logical
 CHECK-NEXT:-Wchar-subscripts
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -3209,6 +3209,36 @@
   if (!foundAny) newDecl->dropAttrs();
 }
 
+static bool EquivalentArrayTypes(QualType Old, QualType New) {
+  auto NoSizeInfo = [](QualType Ty) {
+return Ty->isIncompleteArrayType() || Ty->isPointerType() ||
+   (Ty->isVariableArrayType() &&
+cast(Ty)->getSizeModifier() ==
+ArrayType::ArraySizeModifier::Star);
+  };
+
+  // `type[]` is equivalent to `type *` and `type[*]`.
+  if (NoSizeInfo(Old) && NoSizeInfo(New))
+return true;
+
+  // Don't try to compare VLA sizes, unless one of them has the star modifier.
+  if (Old->isVariableArrayType() && New->isVariableArrayType()) {
+const auto *OldVAT = cast(Old);
+const auto *NewVAT = cast(New);
+if ((OldVAT->getSizeModifier() == ArrayType::ArraySizeModifier::Star) ^
+(NewVAT->getSizeModifier() == ArrayType::ArraySizeModifier::Star))
+  return false;
+return true;
+  }
+
+  // Only compare size, ignore Size modifiers and CVR.
+  if (Old->isConstantArrayType() && New->isConstantArrayType())
+return cast(Old)->getSize() ==
+   cast(New)->getSize();
+
+  return Old == New;
+}
+
 static void mergeParamDeclTypes(ParmVarDecl *NewParam,
 const ParmVarDecl *OldParam,
 Sema &S) {
@@ -3234,6 +3264,19 @@
   NewParam->setType(NewT);
 }
   }
+  const auto *OldParamDT = dyn_cast(OldParam->getType());
+  const auto *NewParamDT = dyn_cast(NewParam->getType());
+  if (OldParamDT && NewParamDT &&
+  OldParamDT->getPointeeType() == NewParamDT->getPointeeType()) {
+QualType OldParamOT = OldParamDT->getOriginalType();
+QualType NewParamOT = NewParamDT->getOriginalType();
+if (!EquivalentArrayTypes(OldParamOT, NewParamOT)) {
+  S.Diag(NewParam->getLocation(), diag::warn_inconsist

[PATCH] D128142: [MemProf] Memprof profile matching and annotation

2022-06-30 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 441529.
tejohnson marked 3 inline comments as done.
tejohnson added a comment.

Rebase on top of D128854  which now includes 
the extracted Analysis utilities.
I have not yet addressed the other comments on this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128142

Files:
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/Inputs/memprof.exe
  clang/test/CodeGen/Inputs/memprof.memprofraw
  clang/test/CodeGen/memprof.cpp
  llvm/include/llvm/Analysis/MemoryBuiltins.h
  llvm/include/llvm/ProfileData/InstrProfReader.h
  llvm/lib/Analysis/MemoryBuiltins.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/test/Transforms/PGOProfile/Inputs/memprof.exe
  llvm/test/Transforms/PGOProfile/Inputs/memprof.memprofraw
  llvm/test/Transforms/PGOProfile/Inputs/memprof_pgo.profraw
  llvm/test/Transforms/PGOProfile/memprof.ll
  llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll

Index: llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/memprofmissingfunc.ll
@@ -0,0 +1,25 @@
+;; Tests that we get a missing memprof error for a function not in profile when
+;; using -pgo-warn-missing-function.
+
+;; TODO: Use text profile inputs once that is available for memprof.
+
+;; The raw profiles have been generated from the source used for the memprof.ll
+;; test (see comments at the top of that file).
+
+; RUN: llvm-profdata merge %S/Inputs/memprof.memprofraw --profiled-binary %S/Inputs/memprof.exe -o %t.memprofdata
+
+; RUN: opt < %s -passes=pgo-instr-use -pgo-test-profile-file=%t.memprofdata -pgo-warn-missing-function -S 2>&1 | FileCheck %s
+
+; CHECK: memprof record not found for function hash 10477964663628735180 _Z16funcnotinprofilev
+
+; ModuleID = 'memprofmissingfunc.cc'
+source_filename = "memprofmissingfunc.cc"
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; Function Attrs: mustprogress noinline nounwind optnone uwtable
+define dso_local void @_Z16funcnotinprofilev() {
+entry:
+  ret void
+}
+
Index: llvm/test/Transforms/PGOProfile/memprof.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/memprof.ll
@@ -0,0 +1,493 @@
+;; Tests memprof profile matching (with and without instrumentation profiles).
+
+;; TODO: Use text profile inputs once that is available for memprof.
+
+;; The input IR and raw profiles have been generated from the following source:
+;;
+;; #include 
+;; #include 
+;; #include 
+;; char *foo() {
+;;   return new char[10];
+;; }
+;; char *foo2() {
+;;   return foo();
+;; }
+;; char *bar() {
+;;   return foo2();
+;; }
+;; char *baz() {
+;;   return foo2();
+;; }
+;; char *recurse(unsigned n) {
+;;   if (!n)
+;; return foo();
+;;   return recurse(n-1);
+;; }
+;; int main(int argc, char **argv) {
+;;   // Test allocations with different combinations of stack contexts and
+;;   // coldness (based on lifetime, since they are all accessed a single time
+;;   // per byte via the memset).
+;;   char *a = new char[10];
+;;   char *b = new char[10];
+;;   char *c = foo();
+;;   char *d = foo();
+;;   char *e = bar();
+;;   char *f = baz();
+;;   memset(a, 0, 10);
+;;   memset(b, 0, 10);
+;;   memset(c, 0, 10);
+;;   memset(d, 0, 10);
+;;   memset(e, 0, 10);
+;;   memset(f, 0, 10);
+;;   // a and c have short lifetimes
+;;   delete[] a;
+;;   delete[] c;
+;;   // b, d, e, and f have long lifetimes and will be detected as cold by default.
+;;   sleep(200);
+;;   delete[] b;
+;;   delete[] d;
+;;   delete[] e;
+;;   delete[] f;
+;;   // Loop ensures the two calls to recurse have stack contexts that only differ
+;;   // in one level of recursion. Tests recursion collapsing during matching, and
+;;   // subsequent handling of identical stack contexts but differing allocation
+;;   // behavior (since the first has a very long lifetime and the second has a
+;;   // short lifetime).
+;;   for (unsigned i = 0; i < 2; i++) {
+;; char *g = recurse(i + 3);
+;; memset(g, 0, 10);
+;; if (!i)
+;;   sleep(200);
+;; delete[] g;
+;;   }
+;;   return 0;
+;; }
+;;
+;; The following commands were used to compile the source to instrumented
+;; executables and collect raw binary format profiles:
+;;
+;; # Collect memory profile:
+;; $ clang++ -fuse-ld=lld -Wl,-no-pie -Wl,--no-rosegment -gmlt \
+;; 	-fdebug-info-for-profiling -mno-omit-leaf-frame-pointer \
+;;	-fno-omit-frame-pointer -fno-optimize-sibling-calls -m64 -Wl,-build-id \
+;; 	memprof.cc -o memprof.exe -fmemory-profile
+;; $ env MEMPROF_OPTIONS=log_path=stdout ./memprof.exe > memprof.memprofraw
+;;
+;; # Collect IR PGO profile:
+;; $ clang++ -fuse-ld=lld -Wl,-no-pie -Wl,--no-roseg

[PATCH] D128844: Improve the formatting of static_assert messages

2022-06-30 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik accepted this revision.
philnik added a comment.
This revision is now accepted and ready to land.

LGTM. (The clang-format if more of a suggestion than anything else currently)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

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


[PATCH] D128844: Improve the formatting of static_assert messages

2022-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

@philnik There seems to be an unrelated clang-format issue but otherwise the 
build looks fine now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

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


[PATCH] D128947: [Lex] Introduce `PPCallbacks::LexedFileChanged()` preprocessor callback

2022-06-30 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi created this revision.
Herald added subscribers: shchenz, kbarton, nemanjai.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is a preprocessor callback focused on the lexed file changing, without 
conflating effects of line number directives and other pragmas.
A client that only cares about what files the lexer processes, like dependency 
generation, can use this more straightforward
callback instead of `PPCallbacks::FileChanged()`. Clients that want the pragma 
directive effects as well can keep using `FileChanged()`.

A use case where `PPCallbacks::LexedFileChanged()` is particularly simpler to 
use than `FileChanged()` is in a situation
where a client wants to keep track of lexed file changes that include changes 
from/to the predefines buffer, where it becomes
unnecessary complicated trying to use `FileChanged()` while filtering out the 
pragma directives effects callbacks.

For `LexedFileChanged()` take the opportunity to also provide information about 
the prior `FileID` the `Lexer` moved from, even when
entering a new file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128947

Files:
  clang/include/clang/Basic/SourceManager.h
  clang/include/clang/Lex/PPCallbacks.h
  clang/lib/Basic/SourceManager.cpp
  clang/lib/Frontend/DependencyFile.cpp
  clang/lib/Lex/PPLexerChange.cpp

Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -111,6 +111,7 @@
 ///  and start lexing tokens from it instead of the current buffer.
 void Preprocessor::EnterSourceFileWithLexer(Lexer *TheLexer,
 ConstSearchDirIterator CurDir) {
+  PreprocessorLexer *PrevPPLexer = CurPPLexer;
 
   // Add the current lexer to the include stack.
   if (CurPPLexer || CurTokenLexer)
@@ -132,6 +133,15 @@
 
 Callbacks->FileChanged(CurLexer->getFileLoc(),
PPCallbacks::EnterFile, FileType);
+FileID PrevFID;
+SourceLocation EnterLoc;
+if (PrevPPLexer) {
+  PrevFID = PrevPPLexer->getFileID();
+  EnterLoc = PrevPPLexer->getSourceLocation();
+}
+Callbacks->LexedFileChanged(CurLexer->getFileID(),
+PPCallbacks::LexedFileChangeReason::EnterFile,
+FileType, PrevFID, EnterLoc);
   }
 }
 
@@ -486,10 +496,13 @@
 
 // Notify the client, if desired, that we are in a new source file.
 if (Callbacks && !isEndOfMacro && CurPPLexer) {
+  SourceLocation Loc = CurPPLexer->getSourceLocation();
   SrcMgr::CharacteristicKind FileType =
-SourceMgr.getFileCharacteristic(CurPPLexer->getSourceLocation());
-  Callbacks->FileChanged(CurPPLexer->getSourceLocation(),
- PPCallbacks::ExitFile, FileType, ExitedFID);
+  SourceMgr.getFileCharacteristic(Loc);
+  Callbacks->FileChanged(Loc, PPCallbacks::ExitFile, FileType, ExitedFID);
+  Callbacks->LexedFileChanged(CurPPLexer->getFileID(),
+  PPCallbacks::LexedFileChangeReason::ExitFile,
+  FileType, ExitedFID, Loc);
 }
 
 // Restore conditional stack as well as the recorded
Index: clang/lib/Frontend/DependencyFile.cpp
===
--- clang/lib/Frontend/DependencyFile.cpp
+++ clang/lib/Frontend/DependencyFile.cpp
@@ -31,23 +31,22 @@
 namespace {
 struct DepCollectorPPCallbacks : public PPCallbacks {
   DependencyCollector &DepCollector;
-  SourceManager &SM;
-  DiagnosticsEngine &Diags;
-  DepCollectorPPCallbacks(DependencyCollector &L, SourceManager &SM,
-  DiagnosticsEngine &Diags)
-  : DepCollector(L), SM(SM), Diags(Diags) {}
-
-  void FileChanged(SourceLocation Loc, FileChangeReason Reason,
-   SrcMgr::CharacteristicKind FileType,
-   FileID PrevFID) override {
-if (Reason != PPCallbacks::EnterFile)
+  Preprocessor &PP;
+  DepCollectorPPCallbacks(DependencyCollector &L, Preprocessor &PP)
+  : DepCollector(L), PP(PP) {}
+
+  void LexedFileChanged(FileID FID, LexedFileChangeReason Reason,
+SrcMgr::CharacteristicKind FileType, FileID PrevFID,
+SourceLocation Loc) override {
+if (Reason != PPCallbacks::LexedFileChangeReason::EnterFile)
+  return;
+if (PP.getPredefinesFileID() == FID)
   return;
 
 // Dependency generation really does want to go all the way to the
 // file entry for a source location to find out what is depended on.
 // We do not want #line markers to affect dependency generation!
-if (Optional Filename = SM.getNonBuiltinFilenameForID(
-SM.getFileID(SM.getExpansionLoc(Loc
+if (Optional Filename = PP.getSourceManager().getFilename(FID))
  

[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-06-30 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:483
+   !Type.getNonReferenceType().isConstQualified() &&
+   !isExpandedParameterPack(Param);
   }

sammccall wrote:
> upsj wrote:
> > sammccall wrote:
> > > upsj wrote:
> > > > sammccall wrote:
> > > > > sammccall wrote:
> > > > > > nridge wrote:
> > > > > > > sammccall wrote:
> > > > > > > > why is this check needed if we already decline to provide a 
> > > > > > > > name for the parameter on line 534 in chooseParameterNames?
> > > > > > > `shouldHintName` and `shouldHintReference` are [two independent 
> > > > > > > conditions](https://searchfox.org/llvm/rev/508eb41d82ca956c30950d9a16b522a29aeeb333/clang-tools-extra/clangd/InlayHints.cpp#411-418)
> > > > > > >  governing whether we show the parameter name and/or a `&` 
> > > > > > > indicating pass-by-mutable-ref, respectively
> > > > > > > 
> > > > > > > (I did approve the [patch](https://reviews.llvm.org/D124359) that 
> > > > > > > introduced `shouldHintReference` myself, hope that's ok)
> > > > > > Thanks, that makes sense! I just hadn't understood that change.
> > > > > What exactly *is* the motivation for suppressing reference hints in 
> > > > > the pack case?
> > > > > 
> > > > > (I can imagine there are cases where they're annoying, but it's hard 
> > > > > to know if the condition is right without knowing what those are)
> > > > I added an explanation. Basically, if we are unable to figure out which 
> > > > parameter the arguments are being forwarded to, the type of the 
> > > > ParmVarDecl for `Args&&...` gets deduced as `T&` or `T&&`, so that 
> > > > would mean even though we don't know whether the argument will 
> > > > eventually be forwarded to a reference parameter, we still claim all 
> > > > mutable lvalue arguments will be mutated, which IMO introduces more 
> > > > noise than necessary. But I think there are also good arguments for 
> > > > adding them to be safe.
> > > > 
> > > > There is another detail here, which is that we don't record whether we 
> > > > used std::forward, so the corresponding rvalue-to-lvalue conversions 
> > > > may lead to some unnecessary & annotations for rvalue arguments.
> > > This makes sense, the comment explains well, thank you!
> > > I have a couple of quibbles, up to you whether to change the logic.
> > > 
> > > #1: There's an unstated assumption that pack arguments *will* be 
> > > forwarded (there are other things we can do with them, like use them in 
> > > fold-expressions). It's a pretty good assumption but if the comment talks 
> > > about forwarding, it should probably mention explicitly ("it's likely the 
> > > params will be somehow forwarded, and...")
> > > 
> > > #2: the idea is that if the reference-ness is deduced from the callsite, 
> > > then it's not meaningful as an "is the param modified" signal, it's just 
> > > "is this arg modifiable". Fair enough, but this is a property of 
> > > universal/forwarding references (T&& where T is a template param), not of 
> > > packs. So I *think* this check should rather be 
> > > !isInstantiatedFromForwardingReference(Param).
> > > But maybe that's more complexity and what you have is a good heuristic - 
> > > I think at least we should call out that it's a heuristic for the true 
> > > condition.
> > > 
> > > 
> > #1: I agree, I'll make that more clear before committing.
> > 
> > #2: Now that I think about it, there are actually two things we don't keep 
> > track of: parameters could lose their reference-ness via `Args...` instead 
> > of `Args&&...` and their rvalue-ness by not using `std::forward`. We only 
> > look at whether the innermost call takes a reference parameter, but as I 
> > said, we may lose some of that information on the way, claiming the 
> > function may modify the argument when it actually creates a copy on the way 
> > (losing reference-ness). I think the case of an rvalue being mistaken for 
> > an lvalue should not be much of an issue, since the reference annotation 
> > almost makes sense.
> > 
> > To visualize the situation: These three snippets all add &: hints to the 
> > parameter of bar
> > ```
> > void foo(int&);
> > template 
> > void bar(Args... args) { return foo(args...); }
> > void baz() {
> >   bar(1);
> > }
> > ```
> > ```
> > void foo(int&);
> > template 
> > void bar(Args&&... args) { return foo(args...); }
> > void baz() {
> >   bar(1);
> > }
> > ```
> > ```
> > void foo(int&);
> > template 
> > void bar(Args&&... args) { return foo(std::forward(args)...); }
> > void baz() {
> >   int a;
> >   bar(a);
> > }
> > ```
> > Two of these three cases probably shouldn't have this annotation?
> > parameters could lose their reference-ness via Args... instead of Args&&...
> (I'm not quite following what you mean here: if we deduce as `Args` rather 
> than `Args&&` then the parameters are not references in the first place, 
> we're passing by value)
> 
> > and their rvalue-ness by n

[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-06-30 Thread Tobias Ribizel via Phabricator via cfe-commits
upsj updated this revision to Diff 441520.
upsj marked 3 inline comments as done.
upsj added a comment.

detect whether forwarding functions preserve reference-ness and value 
categories of their arguments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/InlayHints.cpp
  clang-tools-extra/clangd/unittests/InlayHintTests.cpp

Index: clang-tools-extra/clangd/unittests/InlayHintTests.cpp
===
--- clang-tools-extra/clangd/unittests/InlayHintTests.cpp
+++ clang-tools-extra/clangd/unittests/InlayHintTests.cpp
@@ -174,6 +174,43 @@
   )cpp");
 }
 
+TEST(ParameterHints, NoNameVariadicDeclaration) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+template 
+void foo(Args&& ...);
+void bar() {
+  foo(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicForwarded) {
+  // No hint for anonymous variadic parameter
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(std::forward(args)...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
+TEST(ParameterHints, NoNameVariadicPlain) {
+  // No hint for anonymous variadic parameter
+  assertParameterHints(R"cpp(
+void foo(int);
+template 
+void bar(Args&&... args) { return foo(args...); }
+void baz() {
+  bar(42);
+}
+  )cpp");
+}
+
 TEST(ParameterHints, NameInDefinition) {
   // Parameter name picked up from definition if necessary.
   assertParameterHints(R"cpp(
@@ -186,6 +223,36 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, NamePartiallyInDefinition) {
+  // Parameter name picked up from definition if necessary.
+  assertParameterHints(R"cpp(
+void foo(int, int b);
+void bar() {
+  foo($param1[[42]], $param2[[42]]);
+}
+void foo(int a, int) {};
+  )cpp",
+   ExpectedHint{"a: ", "param1"},
+   ExpectedHint{"b: ", "param2"});
+}
+
+TEST(ParameterHints, NameInDefinitionVariadic) {
+  // Parameter name picked up from definition in a resolved forwarded parameter.
+  assertParameterHints(R"cpp(
+void foo(int, int);
+template 
+void bar(Args... args) {
+  foo(args...);
+}
+void baz() {
+  bar($param1[[42]], $param2[[42]]);
+}
+void foo(int a, int b) {};
+  )cpp",
+   ExpectedHint{"a: ", "param1"},
+   ExpectedHint{"b: ", "param2"});
+}
+
 TEST(ParameterHints, NameMismatch) {
   // Prefer name from declaration.
   assertParameterHints(R"cpp(
@@ -258,6 +325,444 @@
ExpectedHint{"param: ", "param"});
 }
 
+TEST(ParameterHints, VariadicForwardedConstructor) {
+  // Name hint for variadic parameter using std::forward in a constructor call
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainConstructor) {
+  // Name hint for variadic parameter in a constructor call
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T bar(Args&&... args) { return T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwardedNewConstructor) {
+  // Name hint for variadic parameter using std::forward in a new expression
+  // This prototype of std::forward is sufficient for clang to recognize it
+  assertParameterHints(R"cpp(
+namespace std { template  T&& forward(T&); }
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{std::forward(args)...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicPlainNewConstructor) {
+  // Name hint for variadic parameter in a new expression
+  assertParameterHints(R"cpp(
+struct S { S(int a); };
+template 
+T* bar(Args&&... args) { return new T{args...}; }
+void baz() {
+  int b;
+  bar($param[[b]]);
+}
+  )cpp",
+   ExpectedHint{"a: ", "param"});
+}
+
+TEST(ParameterHints, VariadicForwarded) {
+  // Name for variadic parameter using std::forward
+  // This prototype of std::forward is sufficient for clang to recognize it

Re: [clang] cce06da - Test and document some C99 DRs

2022-06-30 Thread Aaron Ballman via cfe-commits
Thanks! I'm looking into it and will fix or revert shortly

~Aaron

On Thu, Jun 30, 2022 at 5:02 PM Nico Weber  wrote:
>
> Looks like this might break tests: http://45.33.8.238/linux/80043/step_7.txt
>
> On Thu, Jun 30, 2022, 9:47 PM Aaron Ballman via cfe-commits 
>  wrote:
>>
>>
>> Author: Aaron Ballman
>> Date: 2022-06-30T15:46:47-04:00
>> New Revision: cce06da1ecf789658551ca5f3b255c361f063abf
>>
>> URL: 
>> https://github.com/llvm/llvm-project/commit/cce06da1ecf789658551ca5f3b255c361f063abf
>> DIFF: 
>> https://github.com/llvm/llvm-project/commit/cce06da1ecf789658551ca5f3b255c361f063abf.diff
>>
>> LOG: Test and document some C99 DRs
>>
>> This captures the first 15 or so DRs in C99
>>
>> Added:
>> clang/test/C/drs/dr206.c
>> clang/test/C/drs/dr208.c
>> clang/test/C/drs/dr209.c
>> clang/test/C/drs/dr2xx.c
>>
>> Modified:
>> clang/www/c_dr_status.html
>>
>> Removed:
>>
>>
>>
>> 
>> diff  --git a/clang/test/C/drs/dr206.c b/clang/test/C/drs/dr206.c
>> new file mode 100644
>> index 0..d5686a43b3304
>> --- /dev/null
>> +++ b/clang/test/C/drs/dr206.c
>> @@ -0,0 +1,23 @@
>> +/* RUN: %clang_cc1 -std=c89 -Wno-deprecated-non-prototype -ast-dump -o -  
>> %s | FileCheck %s
>> +   RUN: %clang_cc1 -std=c99 -Wno-deprecated-non-prototype -ast-dump -o -  
>> %s | FileCheck %s
>> +   RUN: %clang_cc1 -std=c11 -Wno-deprecated-non-prototype -ast-dump -o -  
>> %s | FileCheck %s
>> +   RUN: %clang_cc1 -std=c17 -Wno-deprecated-non-prototype -ast-dump -o -  
>> %s | FileCheck %s
>> + */
>> +
>> +/* WG14 DR206: yes
>> + * Default argument conversion of float _Complex
>> + */
>> +void dr206_unprototyped();
>> +void dr206(void) {
>> +  /* Ensure that _Complex float is not promoted to _Complex double but is
>> +   * instead passed directly without a type conversion.
>> +   */
>> +  _Complex float f = 1.2f;
>> +  dr206_unprototyped(f);
>> +  // CHECK: CallExpr 0x{{.*}}  'void'
>> +  // CHECK-NEXT: ImplicitCastExpr 0x{{.*}}  'void (*)()' 
>> 
>> +  // CHECK-NEXT: DeclRefExpr 0x{{.*}}  'void ()' Function 0x{{.*}} 
>> 'dr206_unprototyped' 'void ()'
>> +  // CHECK-NEXT: ImplicitCastExpr 0x{{.*}}  '_Complex float' 
>> 
>> +  // CHECK-NEXT: DeclRefExpr 0x{{.*}}  '_Complex float' lvalue Var 
>> 0x{{.*}} 'f' '_Complex float'
>> +}
>> +
>>
>> diff  --git a/clang/test/C/drs/dr208.c b/clang/test/C/drs/dr208.c
>> new file mode 100644
>> index 0..aac27e7c1ad31
>> --- /dev/null
>> +++ b/clang/test/C/drs/dr208.c
>> @@ -0,0 +1,24 @@
>> +/* RUN: %clang_cc1 -std=c99 -verify -emit-llvm -o -  %s | FileCheck %s
>> +   RUN: %clang_cc1 -std=c11 -verify -emit-llvm -o -  %s | FileCheck %s
>> +   RUN: %clang_cc1 -std=c17 -verify -emit-llvm -o -  %s | FileCheck %s
>> +   RUN: %clang_cc1 -std=c2x -verify -emit-llvm -o -  %s | FileCheck %s
>> + */
>> +
>> +/* WG14 DR208: yes
>> + * Ambiguity in initialization
>> + */
>> +int dr208_init(int);
>> +void dr208(void) {
>> +  int a[2] = {
>> +dr208_init(0),  /* expected-note {{previous initialization with 
>> side effects is here (side effects will not occur at run time)}} */
>> +dr208_init(1),
>> +[0] = dr208_init(2) /* expected-warning {{initializer overrides prior 
>> initialization of this subobject}} */
>> +  };
>> +
>> +  /* CHECK-NOT: call i32 @dr208_init(i32 noundef 0)
>> + CHECK-DAG: call i32 @dr208_init(i32 noundef 1)
>> + CHECK-DAG: call i32 @dr208_init(i32 noundef 2)
>> + CHECK-NOT: call i32 @dr208_init(i32 noundef 0)
>> +   */
>> +}
>> +
>>
>> diff  --git a/clang/test/C/drs/dr209.c b/clang/test/C/drs/dr209.c
>> new file mode 100644
>> index 0..6cd6093a4b918
>> --- /dev/null
>> +++ b/clang/test/C/drs/dr209.c
>> @@ -0,0 +1,61 @@
>> +/* RUN: %clang_cc1 -std=c99 -ffreestanding -triple x86_64-unknown-linux 
>> -fsyntax-only -verify -pedantic -Wno-c11-extensions %s
>> +   RUN: %clang_cc1 -std=c99 -ffreestanding -triple x86_64-unknown-win32 
>> -fms-compatibility -fsyntax-only -verify -pedantic -Wno-c11-extensions %s
>> +   RUN: %clang_cc1 -std=c11 -ffreestanding -fsyntax-only -verify -pedantic 
>> %s
>> +   RUN: %clang_cc1 -std=c17 -ffreestanding -fsyntax-only -verify -pedantic 
>> %s
>> +   RUN: %clang_cc1 -std=c2x -ffreestanding -fsyntax-only -verify -pedantic 
>> %s
>> + */
>> +
>> +/* WG14 DR209: partial
>> + * Problem implementing INTN_C macros
>> + */
>> +#include 
>> +
>> +#if INT8_C(0) != 0
>> +#error "uh oh"
>> +#elif INT16_C(0) != 0
>> +#error "uh oh"
>> +#elif INT32_C(0) != 0
>> +#error "uh oh"
>> +#elif INT64_C(0) != 0LL
>> +#error "uh oh"
>> +#elif UINT8_C(0) != 0U
>> +#error "uh oh"
>> +#elif UINT16_C(0) != 0U
>> +#error "uh oh"
>> +#elif UINT32_C(0) != 0U
>> +#error "uh oh"
>> +#elif UINT64_C(0) != 0ULL
>> +#error "uh oh"
>> +#endif
>> +
>> +void dr209(void) {
>> +  (void)_Generic(INT8_C(0), __typeof__(+(int_least8_t){0}) : 1);
>> +  (void)_Generic(INT16_C(0), __typeof__(+(int_least16_t){0}) : 1);
>> +  (void)_Generic(INT32_C(0), __t

[clang] 56dc4db - Fix test expectation positioning relative to FIXME comment

2022-06-30 Thread Reid Kleckner via cfe-commits

Author: Reid Kleckner
Date: 2022-06-30T14:08:25-07:00
New Revision: 56dc4dbe45e2b1a3e33ab69323ae9d885ab34899

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

LOG: Fix test expectation positioning relative to FIXME comment

This new test was failing because the line number delta wasn't right.

Added: 


Modified: 
clang/test/C/drs/dr209.c

Removed: 




diff  --git a/clang/test/C/drs/dr209.c b/clang/test/C/drs/dr209.c
index 6cd6093a4b91..d8613669f327 100644
--- a/clang/test/C/drs/dr209.c
+++ b/clang/test/C/drs/dr209.c
@@ -33,8 +33,6 @@ void dr209(void) {
   (void)_Generic(INT16_C(0), __typeof__(+(int_least16_t){0}) : 1);
   (void)_Generic(INT32_C(0), __typeof__(+(int_least32_t){0}) : 1);
   (void)_Generic(INT64_C(0), __typeof__(+(int_least64_t){0}) : 1);
-  (void)_Generic(UINT8_C(0), __typeof__(+(uint_least8_t){0}) : 1);
-  (void)_Generic(UINT16_C(0), __typeof__(+(uint_least16_t){0}) : 1);
   // FIXME: This is not the expected behavior; the type of the expanded value
   // in both of these cases should be 'int',
   //
@@ -53,6 +51,8 @@ void dr209(void) {
   // but then the value undergoes integer promotions which would convert both
   // of those types to int.
   //
+  (void)_Generic(UINT8_C(0), __typeof__(+(uint_least8_t){0}) : 1);
+  (void)_Generic(UINT16_C(0), __typeof__(+(uint_least16_t){0}) : 1);
   // expected-error@-2 {{controlling expression type 'unsigned int' not 
compatible with any generic association type}}
   // expected-error@-2 {{controlling expression type 'unsigned int' not 
compatible with any generic association type}}
   (void)_Generic(UINT32_C(0), __typeof__(+(uint_least32_t){0}) : 1);



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


Re: [clang] cce06da - Test and document some C99 DRs

2022-06-30 Thread Nico Weber via cfe-commits
Looks like this might break tests: http://45.33.8.238/linux/80043/step_7.txt

On Thu, Jun 30, 2022, 9:47 PM Aaron Ballman via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

>
> Author: Aaron Ballman
> Date: 2022-06-30T15:46:47-04:00
> New Revision: cce06da1ecf789658551ca5f3b255c361f063abf
>
> URL:
> https://github.com/llvm/llvm-project/commit/cce06da1ecf789658551ca5f3b255c361f063abf
> DIFF:
> https://github.com/llvm/llvm-project/commit/cce06da1ecf789658551ca5f3b255c361f063abf.diff
>
> LOG: Test and document some C99 DRs
>
> This captures the first 15 or so DRs in C99
>
> Added:
> clang/test/C/drs/dr206.c
> clang/test/C/drs/dr208.c
> clang/test/C/drs/dr209.c
> clang/test/C/drs/dr2xx.c
>
> Modified:
> clang/www/c_dr_status.html
>
> Removed:
>
>
>
>
> 
> diff  --git a/clang/test/C/drs/dr206.c b/clang/test/C/drs/dr206.c
> new file mode 100644
> index 0..d5686a43b3304
> --- /dev/null
> +++ b/clang/test/C/drs/dr206.c
> @@ -0,0 +1,23 @@
> +/* RUN: %clang_cc1 -std=c89 -Wno-deprecated-non-prototype -ast-dump -o -
> %s | FileCheck %s
> +   RUN: %clang_cc1 -std=c99 -Wno-deprecated-non-prototype -ast-dump -o -
> %s | FileCheck %s
> +   RUN: %clang_cc1 -std=c11 -Wno-deprecated-non-prototype -ast-dump -o -
> %s | FileCheck %s
> +   RUN: %clang_cc1 -std=c17 -Wno-deprecated-non-prototype -ast-dump -o -
> %s | FileCheck %s
> + */
> +
> +/* WG14 DR206: yes
> + * Default argument conversion of float _Complex
> + */
> +void dr206_unprototyped();
> +void dr206(void) {
> +  /* Ensure that _Complex float is not promoted to _Complex double but is
> +   * instead passed directly without a type conversion.
> +   */
> +  _Complex float f = 1.2f;
> +  dr206_unprototyped(f);
> +  // CHECK: CallExpr 0x{{.*}}  'void'
> +  // CHECK-NEXT: ImplicitCastExpr 0x{{.*}}  'void (*)()'
> 
> +  // CHECK-NEXT: DeclRefExpr 0x{{.*}}  'void ()' Function 0x{{.*}}
> 'dr206_unprototyped' 'void ()'
> +  // CHECK-NEXT: ImplicitCastExpr 0x{{.*}}  '_Complex float'
> 
> +  // CHECK-NEXT: DeclRefExpr 0x{{.*}}  '_Complex float' lvalue
> Var 0x{{.*}} 'f' '_Complex float'
> +}
> +
>
> diff  --git a/clang/test/C/drs/dr208.c b/clang/test/C/drs/dr208.c
> new file mode 100644
> index 0..aac27e7c1ad31
> --- /dev/null
> +++ b/clang/test/C/drs/dr208.c
> @@ -0,0 +1,24 @@
> +/* RUN: %clang_cc1 -std=c99 -verify -emit-llvm -o -  %s | FileCheck %s
> +   RUN: %clang_cc1 -std=c11 -verify -emit-llvm -o -  %s | FileCheck %s
> +   RUN: %clang_cc1 -std=c17 -verify -emit-llvm -o -  %s | FileCheck %s
> +   RUN: %clang_cc1 -std=c2x -verify -emit-llvm -o -  %s | FileCheck %s
> + */
> +
> +/* WG14 DR208: yes
> + * Ambiguity in initialization
> + */
> +int dr208_init(int);
> +void dr208(void) {
> +  int a[2] = {
> +dr208_init(0),  /* expected-note {{previous initialization with
> side effects is here (side effects will not occur at run time)}} */
> +dr208_init(1),
> +[0] = dr208_init(2) /* expected-warning {{initializer overrides prior
> initialization of this subobject}} */
> +  };
> +
> +  /* CHECK-NOT: call i32 @dr208_init(i32 noundef 0)
> + CHECK-DAG: call i32 @dr208_init(i32 noundef 1)
> + CHECK-DAG: call i32 @dr208_init(i32 noundef 2)
> + CHECK-NOT: call i32 @dr208_init(i32 noundef 0)
> +   */
> +}
> +
>
> diff  --git a/clang/test/C/drs/dr209.c b/clang/test/C/drs/dr209.c
> new file mode 100644
> index 0..6cd6093a4b918
> --- /dev/null
> +++ b/clang/test/C/drs/dr209.c
> @@ -0,0 +1,61 @@
> +/* RUN: %clang_cc1 -std=c99 -ffreestanding -triple x86_64-unknown-linux
> -fsyntax-only -verify -pedantic -Wno-c11-extensions %s
> +   RUN: %clang_cc1 -std=c99 -ffreestanding -triple x86_64-unknown-win32
> -fms-compatibility -fsyntax-only -verify -pedantic -Wno-c11-extensions %s
> +   RUN: %clang_cc1 -std=c11 -ffreestanding -fsyntax-only -verify
> -pedantic %s
> +   RUN: %clang_cc1 -std=c17 -ffreestanding -fsyntax-only -verify
> -pedantic %s
> +   RUN: %clang_cc1 -std=c2x -ffreestanding -fsyntax-only -verify
> -pedantic %s
> + */
> +
> +/* WG14 DR209: partial
> + * Problem implementing INTN_C macros
> + */
> +#include 
> +
> +#if INT8_C(0) != 0
> +#error "uh oh"
> +#elif INT16_C(0) != 0
> +#error "uh oh"
> +#elif INT32_C(0) != 0
> +#error "uh oh"
> +#elif INT64_C(0) != 0LL
> +#error "uh oh"
> +#elif UINT8_C(0) != 0U
> +#error "uh oh"
> +#elif UINT16_C(0) != 0U
> +#error "uh oh"
> +#elif UINT32_C(0) != 0U
> +#error "uh oh"
> +#elif UINT64_C(0) != 0ULL
> +#error "uh oh"
> +#endif
> +
> +void dr209(void) {
> +  (void)_Generic(INT8_C(0), __typeof__(+(int_least8_t){0}) : 1);
> +  (void)_Generic(INT16_C(0), __typeof__(+(int_least16_t){0}) : 1);
> +  (void)_Generic(INT32_C(0), __typeof__(+(int_least32_t){0}) : 1);
> +  (void)_Generic(INT64_C(0), __typeof__(+(int_least64_t){0}) : 1);
> +  (void)_Generic(UINT8_C(0), __typeof__(+(uint_least8_t){0}) : 1);
> +  (void)_Generic(UINT16_C(0), __typeof__(+(uint_least16_t){0}) : 1);
> +  // FIXME: Thi

[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical

2022-06-30 Thread Ishaan Gandhi via Phabricator via cfe-commits
ishaangandhi updated this revision to Diff 441509.

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

https://reviews.llvm.org/D128402

Files:
  clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
===
--- /dev/null
+++ 
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s bugprone-branch-clone %t
+
+int test_unknown_expression() {
+  if (unknown_expression_1) {// CHECK-MESSAGES: :[[@LINE]]:7: error: 
use of undeclared identifier 'unknown_expression_1' [clang-diagnostic-error]
+function1(unknown_expression_2); // CHECK-MESSAGES: :[[@LINE]]:15: error: 
use of undeclared identifier 'unknown_expression_2' [clang-diagnostic-error]
+  } else {
+function2(unknown_expression_3); // CHECK-MESSAGES: :[[@LINE]]:15: error: 
use of undeclared identifier 'unknown_expression_3' [clang-diagnostic-error]
+  }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -158,6 +158,10 @@
 - Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
   ` check for empty structs.
 
+- Fixed a false positive in :doc:`bugprone-branch-clone
+  ` when the branches
+  involve unknown expressions.
+
 - Fixed some false positives in :doc:`bugprone-infinite-loop
   ` involving dependent expressions.
 
Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -19,6 +19,17 @@
 /// Returns true when the statements are Type I clones of each other.
 static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
const ASTContext &Context) {
+  if (isa(LHS) && isa(RHS)) {
+// If we have errors in expressions, we will be unable
+// to accurately profile and compute hashes for each
+// of the left and right statements.
+const auto *LHSExpr = llvm::cast(LHS);
+const auto *RHSExpr = llvm::cast(RHS);
+if (LHSExpr->containsErrors() && RHSExpr->containsErrors()) {
+  return false;
+}
+  }
+
   llvm::FoldingSetNodeID DataLHS, DataRHS;
   LHS->Profile(DataLHS, Context, false);
   RHS->Profile(DataRHS, Context, false);


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp
@@ -0,0 +1,9 @@
+// RUN: %check_clang_tidy -expect-clang-tidy-error %s bugprone-branch-clone %t
+
+int test_unknown_expression() {
+  if (unknown_expression_1) {// CHECK-MESSAGES: :[[@LINE]]:7: error: use of undeclared identifier 'unknown_expression_1' [clang-diagnostic-error]
+function1(unknown_expression_2); // CHECK-MESSAGES: :[[@LINE]]:15: error: use of undeclared identifier 'unknown_expression_2' [clang-diagnostic-error]
+  } else {
+function2(unknown_expression_3); // CHECK-MESSAGES: :[[@LINE]]:15: error: use of undeclared identifier 'unknown_expression_3' [clang-diagnostic-error]
+  }
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -158,6 +158,10 @@
 - Fixed nonsensical suggestion of :doc:`altera-struct-pack-align
   ` check for empty structs.
 
+- Fixed a false positive in :doc:`bugprone-branch-clone
+  ` when the branches
+  involve unknown expressions.
+
 - Fixed some false positives in :doc:`bugprone-infinite-loop
   ` involving dependent expressions.
 
Index: clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -19,6 +19,17 @@
 /// Returns true when the statements are Type I clones of each other.
 static bool areStatementsIdentical(const Stmt *LHS, const Stmt *RHS,
const ASTContext &Context) {
+  if (isa(LHS) && isa(RHS)) {
+// If we have errors in expressions, we will be unable
+// to accurately profile and compute hashes for each
+// of the left and right statements.
+const auto *LHSExpr = llvm::cast(LHS);
+const auto *RHSExpr = llvm::cast(RHS);
+if (LHSExpr->containsErrors() && RHSExpr->containsErr

[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-30 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added a comment.

I'm not sure how to check the no-op case without constructing at least a queue. 
Even assuming only 2 commutative operands, if they look the same `depth=1`, 
then the comparison has to iterate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D128715: [clang-tidy] Fix confusable identifiers interaction with DeclContext

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

Update test case to take into accounts  reviewers suggestions.

As a consequence use a more complex approach to detect whether two `NamedDecl` 
may interfere.


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

https://reviews.llvm.org/D128715

Files:
  clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/confusable-identifiers.cpp
@@ -1,9 +1,9 @@
 // RUN: %check_clang_tidy %s misc-confusable-identifiers %t
 
 int fo;
-// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: fo is confusable with 𝐟o [misc-confusable-identifiers]
 int 𝐟o;
-// CHECK-MESSAGES: :[[#@LINE-1]]:5: note: other declaration found here
+// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: '𝐟o' is confusable with 'fo' [misc-confusable-identifiers]
+// CHECK-MESSAGES: :[[#@LINE-3]]:5: note: other declaration found here
 
 void no() {
   int 𝐟oo;
@@ -12,14 +12,102 @@
 void worry() {
   int foo;
 }
-
 int 𝐟i;
-// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 𝐟i is confusable with fi [misc-confusable-identifiers]
 int fi;
-// CHECK-MESSAGES: :[[#@LINE-1]]:5: note: other declaration found here
+// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 'fi' is confusable with '𝐟i' [misc-confusable-identifiers]
+// CHECK-MESSAGES: :[[#@LINE-3]]:5: note: other declaration found here
+
+bool f0(const char *q1, const char *ql) {
+  // CHECK-MESSAGES: :[[#@LINE-1]]:37: warning: 'ql' is confusable with 'q1' [misc-confusable-identifiers]
+  // CHECK-MESSAGES: :[[#@LINE-2]]:21: note: other declaration found here
+  return q1 < ql;
+}
 
 // should not print anything
 namespace ns {
 struct Foo {};
 } // namespace ns
 auto f = ns::Foo();
+
+struct Test {
+  void f1(const char *pl);
+};
+
+bool f2(const char *p1, const char *ql) {
+  return p1 < ql;
+}
+
+bool f3(const char *q0, const char *q1) {
+  return q0 < q1;
+}
+
+template 
+struct S {
+  template 
+  void f4() {}
+  // CHECK-MESSAGES: :[[#@LINE-2]]:22: warning: 'il' is confusable with 'i1' [misc-confusable-identifiers]
+  // CHECK-MESSAGES: :[[#@LINE-5]]:20: note: other declaration found here
+};
+
+template 
+void f5(int il) {
+  // CHECK-MESSAGES: :[[#@LINE-1]]:13: warning: 'il' is confusable with 'i1' [misc-confusable-identifiers]
+  // CHECK-MESSAGES: :[[#@LINE-3]]:20: note: other declaration found here
+}
+
+template 
+void f6() {
+  int OO = 0;
+  // CHECK-MESSAGES: :[[#@LINE-1]]:7: warning: 'OO' is confusable with 'O0' [misc-confusable-identifiers]
+  // CHECK-MESSAGES: :[[#@LINE-4]]:20: note: other declaration found here
+}
+int OO = 0; // no warning, not same scope as f6
+
+namespace f7 {
+int i1;
+}
+
+namespace f8 {
+int il; // no warning, different namespace
+}
+
+namespace f7 {
+int il;
+// CHECK-MESSAGES: :[[#@LINE-1]]:5: warning: 'il' is confusable with 'i1' [misc-confusable-identifiers]
+// CHECK-MESSAGES: :[[#@LINE-10]]:5: note: other declaration found here
+} // namespace f7
+
+template 
+// CHECK-MESSAGES: :[[#@LINE-1]]:33: warning: 'tl' is confusable with 't1' [misc-confusable-identifiers]
+// CHECK-MESSAGES: :[[#@LINE-2]]:20: note: other declaration found here
+void f9();
+
+struct Base0 {
+  virtual void mO0();
+
+private:
+  void mII();
+};
+
+struct Derived0 : Base0 {
+  void mOO();
+  // CHECK-MESSAGES: :[[#@LINE-1]]:8: warning: 'mOO' is confusable with 'mO0' [misc-confusable-identifiers]
+  // CHECK-MESSAGES: :[[#@LINE-9]]:16: note: other declaration found here
+
+  void mI1(); // no warning: mII is private
+};
+
+struct Base1 {
+  long mO0;
+
+private:
+  long mII;
+};
+
+struct Derived1 : Base1 {
+  long mOO;
+  // CHECK-MESSAGES: :[[#@LINE-1]]:8: warning: 'mOO' is confusable with 'mO0' [misc-confusable-identifiers]
+  // CHECK-MESSAGES: :[[#@LINE-9]]:8: note: other declaration found here
+
+  long mI1(); // no warning: mII is private
+};
Index: clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
@@ -93,22 +93,73 @@
   return Skeleton;
 }
 
+static bool mayShadowImpl(const NamedDecl *ND0, const NamedDecl *ND1) {
+  const DeclContext *DC0 = ND0->getDeclContext()->getPrimaryContext();
+  const DeclContext *DC1 = ND1->getDeclContext()->getPrimaryContext();
+
+  if (isa(ND0) || isa(ND0))
+return true;
+
+  while (DC0->isTransparentContext())
+DC0 = DC0->getParent();
+  while (DC1->isTransparentContext())
+DC1 = DC1->getParent();
+
+  if (DC0->Equals(DC1))
+return true;
+
+  return false;

[PATCH] D128861: [clang-tidy] add cppcoreguidelines-symmetric-binary-operator

2022-06-30 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti added a comment.

Question: Should this check be extended to also include C.86 
:
 "Flag an operator==() for which the argument types differ; same for other 
comparison operators: !=, <, <=, >, and >=."? With a warning along the lines 
of: "comparison operators should be symmetric with respect to the parameters 
types" or "parameters of comparison operators should be of the same type" (or 
some other warning). Or should that be a new check? I think it fits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128861

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


[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-06-30 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

Thanks for the comments.




Comment at: clang/test/Driver/linker-wrapper.c:109
 
 // RUN: clang-offload-packager -o %t-lib.out \
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \

tra wrote:
> Nit: This test case does not have any CHECK lines and could use a comment 
> describing what it's supposed to test. AFAICT it's intended to make sure that 
> no temporary files are left around, but I'm not 100% sure.
Yes, it ensures that the files extracted from the static library are not 
leftover as temp files, this was a problem previously that I fixed. I'll add a 
comment explaining that.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:620-622
+  CmdArgs.push_back("-bundle-align=4096");
+
+  SmallVector Targets = {"-targets=host-x86_64-unknown-linux"};

tra wrote:
> We probably do not want to hardcode the assumption that the host is x86_64 
> linux. 
> 
> Bundle alignment should probably also be target-dependent, but 4K is common 
> enough and is probably fine in practice.
This is exactly the way it is in the Clang source for HIP. HIP uses the 
`clang-offload-bundler` which expects a host file and host triple, ergo the 
dummy triple and input from `/dev/null`. This obviously isn't great, maybe in 
the future I'll be able to convince the AMD folks to use my format instead.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:1205
+bundleHIP(ArrayRef Images) {
+  SmallVector> Buffers;
+

tra wrote:
> I'd move it to the end where the buffer is actually used. 
Sure, I'll do that for the others as well.



Comment at: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp:393
+ /*Initializer*/ nullptr,
+ IsHIP ? "__start_hip_offloading_entries"
+   : "__start_cuda_offloading_entries");

tra wrote:
> We should probably have a helper function returning properly prefixed name, 
> similar to what we do in clang:
> https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGCUDANV.cpp#L184
I had that thought, but unless I wanted to use regular expressions it would be 
a little weird since there's many different types here, e.g. `__cuda`, `.cuda` 
and `_cuda`. I figured it was easier to just make two strings rather than carry 
around three  different functions to handle these cases, or introduce some 
weird regex.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D128379: [clangd] Change the url for clang-tidy check documentation

2022-06-30 Thread Nathan James via Phabricator via cfe-commits
njames93 updated this revision to Diff 441499.
njames93 added a comment.

Changed to only use the major version.
If this still seems too flaky, happy to go back to just linking to the in 
progress release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128379

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/Diagnostics.cpp
  clang-tools-extra/clangd/Features.inc.in
  clang-tools-extra/clangd/test/diagnostics-tidy.test
  clang-tools-extra/clangd/test/lit.cfg.py
  clang-tools-extra/clangd/test/lit.site.cfg.py.in

Index: clang-tools-extra/clangd/test/lit.site.cfg.py.in
===
--- clang-tools-extra/clangd/test/lit.site.cfg.py.in
+++ clang-tools-extra/clangd/test/lit.site.cfg.py.in
@@ -16,6 +16,7 @@
 config.clangd_build_xpc = @CLANGD_BUILD_XPC@
 config.clangd_enable_remote = @CLANGD_ENABLE_REMOTE@
 config.clangd_tidy_checks = @CLANGD_TIDY_CHECKS@
+config.clangd_pre_release = @CLANGD_PRE_RELEASE@
 config.have_zlib = @LLVM_ENABLE_ZLIB@
 
 # Delegate logic to lit.cfg.py.
Index: clang-tools-extra/clangd/test/lit.cfg.py
===
--- clang-tools-extra/clangd/test/lit.cfg.py
+++ clang-tools-extra/clangd/test/lit.cfg.py
@@ -34,5 +34,8 @@
 if config.clangd_tidy_checks:
   config.available_features.add('clangd-tidy-checks')
 
+if config.clangd_pre_release:
+  config.available_features.add('clangd-pre-release')
+
 if config.have_zlib:
   config.available_features.add('zlib')
Index: clang-tools-extra/clangd/test/diagnostics-tidy.test
===
--- clang-tools-extra/clangd/test/diagnostics-tidy.test
+++ clang-tools-extra/clangd/test/diagnostics-tidy.test
@@ -1,4 +1,5 @@
 # REQUIRES: clangd-tidy-checks
+# REQUIRES: clangd-pre-release
 # RUN: clangd -lit-test -clang-tidy-checks=bugprone-sizeof-expression < %s | FileCheck -strict-whitespace %s
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
 ---
@@ -9,7 +10,7 @@
 # CHECK-NEXT:  {
 # CHECK-NEXT:"code": "bugprone-sizeof-expression",
 # CHECK-NEXT:"codeDescription": {
-# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone-sizeof-expression.html";
+# CHECK-NEXT:  "href": "https://clang.llvm.org/extra/clang-tidy/checks/bugprone/sizeof-expression.html";
 # CHECK-NEXT:},
 # CHECK-NEXT:"message": "Suspicious usage of 'sizeof(K)'; did you mean 'K'?",
 # CHECK-NEXT:"range": {
Index: clang-tools-extra/clangd/Features.inc.in
===
--- clang-tools-extra/clangd/Features.inc.in
+++ clang-tools-extra/clangd/Features.inc.in
@@ -4,3 +4,4 @@
 #define ENABLE_GRPC_REFLECTION @ENABLE_GRPC_REFLECTION@
 #define CLANGD_MALLOC_TRIM @CLANGD_MALLOC_TRIM@
 #define CLANGD_TIDY_CHECKS @CLANGD_TIDY_CHECKS@
+#define CLANGD_PRE_RELEASE @CLANGD_PRE_RELEASE@
Index: clang-tools-extra/clangd/Diagnostics.cpp
===
--- clang-tools-extra/clangd/Diagnostics.cpp
+++ clang-tools-extra/clangd/Diagnostics.cpp
@@ -9,6 +9,7 @@
 #include "Diagnostics.h"
 #include "../clang-tidy/ClangTidyDiagnosticConsumer.h"
 #include "Compiler.h"
+#include "Feature.h"
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "support/Logger.h"
@@ -17,6 +18,7 @@
 #include "clang/Basic/DiagnosticIDs.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/Version.h"
 #include "clang/Lex/Lexer.h"
 #include "clang/Lex/Token.h"
 #include "llvm/ADT/ArrayRef.h"
@@ -918,9 +920,31 @@
 // information to be worth linking.
 // https://clang.llvm.org/docs/DiagnosticsReference.html
 break;
-  case Diag::ClangTidy:
-return {("https://clang.llvm.org/extra/clang-tidy/checks/"; + Name + ".html")
-.str()};
+  case Diag::ClangTidy: {
+StringRef Module, Check;
+// This won't correctly get the module for clang-analyzer checks, but as we
+// don't link in the analyzer that shouldn't be an issue.
+// This would also need updating if anyone decides to create a module with a
+// '-' in the name.
+std::tie(Module, Check) = Name.split('-');
+if (Module.empty() || Check.empty())
+  return llvm::None;
+#if CLANGD_PRE_RELEASE
+return ("https://clang.llvm.org/extra/clang-tidy/checks/"; + Module + "/" +
+Check + ".html")
+.str();
+#else
+#define XSTRINGIFY(X) STRINGIFY(X)
+#define STRINGIFY(X) #X
+return ("https://releases.llvm.org/"; XSTRINGIFY(
+CLANG_VERSION_MAJOR) ".0.0/tools/clang/tools/extra/docs/"
+ "clang-tidy/checks/" +
+Module + "/" + Check + ".html")
+.str();
+#undef STRINGIF

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-30 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

> Yikes!  Thanks for the revert.  I didn't see the email from the bot until 
> just about 2 minutes before you reverted.  I'll see if I can reproduce.

FYI. The same on a different bot 
https://lab.llvm.org/buildbot/#/builders/5/builds/25486/steps/19/logs/stdio


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126907

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


[PATCH] D127803: Generate the capture for field when the field is used in openmp region with implicit default in the member function.

2022-06-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/TreeTransform.h:122
+  /// the RebuildME uses to set if member expression needs to be rebuilt.
+  bool RebuildME = false;
+

jyu2 wrote:
> ABataev wrote:
> > I think we don't need to add a new field here. Can instead we have a check 
> > for regions with default clauses, if possible?
> It seems during the TransformMemberExpr, I can not get Directives info for 
> omp regions to check.  Could you give me hand? 
> Thanks.  
> 
Yes, we do not rebuild the DSA stack at the time of the instantiation. Can you 
just check that we're inside OpenMPCapturedRegion? Something like 
getCurCapturedRegion()->CapRegionKind == CR_OpenMP? Or walk the stack of 
regions to find the outer OpenMP region, if any.


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

https://reviews.llvm.org/D127803

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


[clang] cce06da - Test and document some C99 DRs

2022-06-30 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-06-30T15:46:47-04:00
New Revision: cce06da1ecf789658551ca5f3b255c361f063abf

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

LOG: Test and document some C99 DRs

This captures the first 15 or so DRs in C99

Added: 
clang/test/C/drs/dr206.c
clang/test/C/drs/dr208.c
clang/test/C/drs/dr209.c
clang/test/C/drs/dr2xx.c

Modified: 
clang/www/c_dr_status.html

Removed: 




diff  --git a/clang/test/C/drs/dr206.c b/clang/test/C/drs/dr206.c
new file mode 100644
index 0..d5686a43b3304
--- /dev/null
+++ b/clang/test/C/drs/dr206.c
@@ -0,0 +1,23 @@
+/* RUN: %clang_cc1 -std=c89 -Wno-deprecated-non-prototype -ast-dump -o -  %s | 
FileCheck %s
+   RUN: %clang_cc1 -std=c99 -Wno-deprecated-non-prototype -ast-dump -o -  %s | 
FileCheck %s
+   RUN: %clang_cc1 -std=c11 -Wno-deprecated-non-prototype -ast-dump -o -  %s | 
FileCheck %s
+   RUN: %clang_cc1 -std=c17 -Wno-deprecated-non-prototype -ast-dump -o -  %s | 
FileCheck %s
+ */
+
+/* WG14 DR206: yes
+ * Default argument conversion of float _Complex
+ */
+void dr206_unprototyped();
+void dr206(void) {
+  /* Ensure that _Complex float is not promoted to _Complex double but is
+   * instead passed directly without a type conversion.
+   */
+  _Complex float f = 1.2f;
+  dr206_unprototyped(f);
+  // CHECK: CallExpr 0x{{.*}}  'void'
+  // CHECK-NEXT: ImplicitCastExpr 0x{{.*}}  'void (*)()' 

+  // CHECK-NEXT: DeclRefExpr 0x{{.*}}  'void ()' Function 0x{{.*}} 
'dr206_unprototyped' 'void ()'
+  // CHECK-NEXT: ImplicitCastExpr 0x{{.*}}  '_Complex float' 

+  // CHECK-NEXT: DeclRefExpr 0x{{.*}}  '_Complex float' lvalue Var 
0x{{.*}} 'f' '_Complex float'
+}
+

diff  --git a/clang/test/C/drs/dr208.c b/clang/test/C/drs/dr208.c
new file mode 100644
index 0..aac27e7c1ad31
--- /dev/null
+++ b/clang/test/C/drs/dr208.c
@@ -0,0 +1,24 @@
+/* RUN: %clang_cc1 -std=c99 -verify -emit-llvm -o -  %s | FileCheck %s
+   RUN: %clang_cc1 -std=c11 -verify -emit-llvm -o -  %s | FileCheck %s
+   RUN: %clang_cc1 -std=c17 -verify -emit-llvm -o -  %s | FileCheck %s
+   RUN: %clang_cc1 -std=c2x -verify -emit-llvm -o -  %s | FileCheck %s
+ */
+
+/* WG14 DR208: yes
+ * Ambiguity in initialization
+ */
+int dr208_init(int);
+void dr208(void) {
+  int a[2] = {
+dr208_init(0),  /* expected-note {{previous initialization with side 
effects is here (side effects will not occur at run time)}} */
+dr208_init(1),
+[0] = dr208_init(2) /* expected-warning {{initializer overrides prior 
initialization of this subobject}} */
+  };
+
+  /* CHECK-NOT: call i32 @dr208_init(i32 noundef 0)
+ CHECK-DAG: call i32 @dr208_init(i32 noundef 1)
+ CHECK-DAG: call i32 @dr208_init(i32 noundef 2)
+ CHECK-NOT: call i32 @dr208_init(i32 noundef 0)
+   */
+}
+

diff  --git a/clang/test/C/drs/dr209.c b/clang/test/C/drs/dr209.c
new file mode 100644
index 0..6cd6093a4b918
--- /dev/null
+++ b/clang/test/C/drs/dr209.c
@@ -0,0 +1,61 @@
+/* RUN: %clang_cc1 -std=c99 -ffreestanding -triple x86_64-unknown-linux 
-fsyntax-only -verify -pedantic -Wno-c11-extensions %s
+   RUN: %clang_cc1 -std=c99 -ffreestanding -triple x86_64-unknown-win32 
-fms-compatibility -fsyntax-only -verify -pedantic -Wno-c11-extensions %s
+   RUN: %clang_cc1 -std=c11 -ffreestanding -fsyntax-only -verify -pedantic %s
+   RUN: %clang_cc1 -std=c17 -ffreestanding -fsyntax-only -verify -pedantic %s
+   RUN: %clang_cc1 -std=c2x -ffreestanding -fsyntax-only -verify -pedantic %s
+ */
+
+/* WG14 DR209: partial
+ * Problem implementing INTN_C macros
+ */
+#include 
+
+#if INT8_C(0) != 0
+#error "uh oh"
+#elif INT16_C(0) != 0
+#error "uh oh"
+#elif INT32_C(0) != 0
+#error "uh oh"
+#elif INT64_C(0) != 0LL
+#error "uh oh"
+#elif UINT8_C(0) != 0U
+#error "uh oh"
+#elif UINT16_C(0) != 0U
+#error "uh oh"
+#elif UINT32_C(0) != 0U
+#error "uh oh"
+#elif UINT64_C(0) != 0ULL
+#error "uh oh"
+#endif
+
+void dr209(void) {
+  (void)_Generic(INT8_C(0), __typeof__(+(int_least8_t){0}) : 1);
+  (void)_Generic(INT16_C(0), __typeof__(+(int_least16_t){0}) : 1);
+  (void)_Generic(INT32_C(0), __typeof__(+(int_least32_t){0}) : 1);
+  (void)_Generic(INT64_C(0), __typeof__(+(int_least64_t){0}) : 1);
+  (void)_Generic(UINT8_C(0), __typeof__(+(uint_least8_t){0}) : 1);
+  (void)_Generic(UINT16_C(0), __typeof__(+(uint_least16_t){0}) : 1);
+  // FIXME: This is not the expected behavior; the type of the expanded value
+  // in both of these cases should be 'int',
+  //
+  // C99 7.18.4p3: The type of the expression shall have the same type as would
+  // an expression of the corresponding type converted according to the integer
+  // promotions.
+  //
+  // C99 7.18.4.1p1: The macro UINTN_C(value) shall expand to an integer
+  // constant expression corresponding to the type uint_least

[PATCH] D128914: [HIP] Add support for handling HIP in the linker wrapper

2022-06-30 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Syntax/style looks OK to me with a few nits.




Comment at: clang/test/Driver/linker-wrapper.c:109
 
 // RUN: clang-offload-packager -o %t-lib.out \
 // RUN:   
--image=file=%S/Inputs/dummy-elf.o,kind=openmp,triple=nvptx64-nvidia-cuda,arch=sm_70
 \

Nit: This test case does not have any CHECK lines and could use a comment 
describing what it's supposed to test. AFAICT it's intended to make sure that 
no temporary files are left around, but I'm not 100% sure.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:620-622
+  CmdArgs.push_back("-bundle-align=4096");
+
+  SmallVector Targets = {"-targets=host-x86_64-unknown-linux"};

We probably do not want to hardcode the assumption that the host is x86_64 
linux. 

Bundle alignment should probably also be target-dependent, but 4K is common 
enough and is probably fine in practice.



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:1205
+bundleHIP(ArrayRef Images) {
+  SmallVector> Buffers;
+

I'd move it to the end where the buffer is actually used. 



Comment at: clang/tools/clang-linker-wrapper/OffloadWrapper.cpp:393
+ /*Initializer*/ nullptr,
+ IsHIP ? "__start_hip_offloading_entries"
+   : "__start_cuda_offloading_entries");

We should probably have a helper function returning properly prefixed name, 
similar to what we do in clang:
https://github.com/llvm/llvm-project/blob/main/clang/lib/CodeGen/CGCUDANV.cpp#L184


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128914

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


[PATCH] D128853: [Interpreter] Pass target features to JIT

2022-06-30 Thread Jonas Hahnfeld 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 rGf22795de683d: [Interpreter] Pass target features to JIT 
(authored by Hahnfeld).

Changed prior to commit:
  https://reviews.llvm.org/D128853?vs=441151&id=441483#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128853

Files:
  clang/lib/Interpreter/IncrementalExecutor.cpp
  clang/lib/Interpreter/IncrementalExecutor.h
  clang/lib/Interpreter/Interpreter.cpp


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -213,10 +213,10 @@
 llvm::Error Interpreter::Execute(PartialTranslationUnit &T) {
   assert(T.TheModule);
   if (!IncrExecutor) {
-const llvm::Triple &Triple =
-getCompilerInstance()->getASTContext().getTargetInfo().getTriple();
+const clang::TargetInfo &TI =
+getCompilerInstance()->getASTContext().getTargetInfo();
 llvm::Error Err = llvm::Error::success();
-IncrExecutor = std::make_unique(*TSCtx, Err, Triple);
+IncrExecutor = std::make_unique(*TSCtx, Err, TI);
 
 if (Err)
   return Err;
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -15,7 +15,6 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
 
 #include 
@@ -32,6 +31,7 @@
 namespace clang {
 
 struct PartialTranslationUnit;
+class TargetInfo;
 
 class IncrementalExecutor {
   using CtorDtorIterator = llvm::orc::CtorDtorIterator;
@@ -45,7 +45,7 @@
   enum SymbolNameKind { IRName, LinkerName };
 
   IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, llvm::Error &Err,
-  const llvm::Triple &Triple);
+  const clang::TargetInfo &TI);
   ~IncrementalExecutor();
 
   llvm::Error addModule(PartialTranslationUnit &PTU);
Index: clang/lib/Interpreter/IncrementalExecutor.cpp
===
--- clang/lib/Interpreter/IncrementalExecutor.cpp
+++ clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -12,6 +12,8 @@
 
 #include "IncrementalExecutor.h"
 
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
@@ -28,12 +30,13 @@
 
 IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
  llvm::Error &Err,
- const llvm::Triple &Triple)
+ const clang::TargetInfo &TI)
 : TSCtx(TSC) {
   using namespace llvm::orc;
   llvm::ErrorAsOutParameter EAO(&Err);
 
-  auto JTMB = JITTargetMachineBuilder(Triple);
+  auto JTMB = JITTargetMachineBuilder(TI.getTriple());
+  JTMB.addFeatures(TI.getTargetOpts().Features);
   if (auto JitOrErr = LLJITBuilder().setJITTargetMachineBuilder(JTMB).create())
 Jit = std::move(*JitOrErr);
   else {


Index: clang/lib/Interpreter/Interpreter.cpp
===
--- clang/lib/Interpreter/Interpreter.cpp
+++ clang/lib/Interpreter/Interpreter.cpp
@@ -213,10 +213,10 @@
 llvm::Error Interpreter::Execute(PartialTranslationUnit &T) {
   assert(T.TheModule);
   if (!IncrExecutor) {
-const llvm::Triple &Triple =
-getCompilerInstance()->getASTContext().getTargetInfo().getTriple();
+const clang::TargetInfo &TI =
+getCompilerInstance()->getASTContext().getTargetInfo();
 llvm::Error Err = llvm::Error::success();
-IncrExecutor = std::make_unique(*TSCtx, Err, Triple);
+IncrExecutor = std::make_unique(*TSCtx, Err, TI);
 
 if (Err)
   return Err;
Index: clang/lib/Interpreter/IncrementalExecutor.h
===
--- clang/lib/Interpreter/IncrementalExecutor.h
+++ clang/lib/Interpreter/IncrementalExecutor.h
@@ -15,7 +15,6 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
 
 #include 
@@ -32,6 +31,7 @@
 namespace clang {
 
 struct PartialTranslationUnit;
+class TargetInfo;
 
 class IncrementalExecutor {
   using CtorDtorIterator = llvm::orc::CtorDtorIterator;
@@ -45,7 +45,7 @@
   enum SymbolNameKind { IRName, LinkerName };
 
   IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, llvm::Error &Err,
-  const llvm::Triple &Triple);
+  const clang::TargetInfo &TI);
   ~Incremen

[clang] f22795d - [Interpreter] Pass target features to JIT

2022-06-30 Thread Jonas Hahnfeld via cfe-commits

Author: Jonas Hahnfeld
Date: 2022-06-30T21:25:14+02:00
New Revision: f22795de683d571bbf7e655a7b4ed5ccda186e66

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

LOG: [Interpreter] Pass target features to JIT

This is required to support RISC-V where the '+d' target feature
indicates the presence of the D instruction set extension, which
changes to the Hard-float 'd' ABI.

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

Added: 


Modified: 
clang/lib/Interpreter/IncrementalExecutor.cpp
clang/lib/Interpreter/IncrementalExecutor.h
clang/lib/Interpreter/Interpreter.cpp

Removed: 




diff  --git a/clang/lib/Interpreter/IncrementalExecutor.cpp 
b/clang/lib/Interpreter/IncrementalExecutor.cpp
index c055827281b4f..227ab9703dc76 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.cpp
+++ b/clang/lib/Interpreter/IncrementalExecutor.cpp
@@ -12,6 +12,8 @@
 
 #include "IncrementalExecutor.h"
 
+#include "clang/Basic/TargetInfo.h"
+#include "clang/Basic/TargetOptions.h"
 #include "clang/Interpreter/PartialTranslationUnit.h"
 #include "llvm/ExecutionEngine/ExecutionEngine.h"
 #include "llvm/ExecutionEngine/Orc/CompileUtils.h"
@@ -28,12 +30,13 @@ namespace clang {
 
 IncrementalExecutor::IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC,
  llvm::Error &Err,
- const llvm::Triple &Triple)
+ const clang::TargetInfo &TI)
 : TSCtx(TSC) {
   using namespace llvm::orc;
   llvm::ErrorAsOutParameter EAO(&Err);
 
-  auto JTMB = JITTargetMachineBuilder(Triple);
+  auto JTMB = JITTargetMachineBuilder(TI.getTriple());
+  JTMB.addFeatures(TI.getTargetOpts().Features);
   if (auto JitOrErr = LLJITBuilder().setJITTargetMachineBuilder(JTMB).create())
 Jit = std::move(*JitOrErr);
   else {

diff  --git a/clang/lib/Interpreter/IncrementalExecutor.h 
b/clang/lib/Interpreter/IncrementalExecutor.h
index 580724e1e24e2..f11ec0aa9e758 100644
--- a/clang/lib/Interpreter/IncrementalExecutor.h
+++ b/clang/lib/Interpreter/IncrementalExecutor.h
@@ -15,7 +15,6 @@
 
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/ADT/Triple.h"
 #include "llvm/ExecutionEngine/Orc/ExecutionUtils.h"
 
 #include 
@@ -32,6 +31,7 @@ class ThreadSafeContext;
 namespace clang {
 
 struct PartialTranslationUnit;
+class TargetInfo;
 
 class IncrementalExecutor {
   using CtorDtorIterator = llvm::orc::CtorDtorIterator;
@@ -45,7 +45,7 @@ class IncrementalExecutor {
   enum SymbolNameKind { IRName, LinkerName };
 
   IncrementalExecutor(llvm::orc::ThreadSafeContext &TSC, llvm::Error &Err,
-  const llvm::Triple &Triple);
+  const clang::TargetInfo &TI);
   ~IncrementalExecutor();
 
   llvm::Error addModule(PartialTranslationUnit &PTU);

diff  --git a/clang/lib/Interpreter/Interpreter.cpp 
b/clang/lib/Interpreter/Interpreter.cpp
index a10eb79b413b3..0191ad78581d9 100644
--- a/clang/lib/Interpreter/Interpreter.cpp
+++ b/clang/lib/Interpreter/Interpreter.cpp
@@ -213,10 +213,10 @@ Interpreter::Parse(llvm::StringRef Code) {
 llvm::Error Interpreter::Execute(PartialTranslationUnit &T) {
   assert(T.TheModule);
   if (!IncrExecutor) {
-const llvm::Triple &Triple =
-getCompilerInstance()->getASTContext().getTargetInfo().getTriple();
+const clang::TargetInfo &TI =
+getCompilerInstance()->getASTContext().getTargetInfo();
 llvm::Error Err = llvm::Error::success();
-IncrExecutor = std::make_unique(*TSCtx, Err, Triple);
+IncrExecutor = std::make_unique(*TSCtx, Err, TI);
 
 if (Err)
   return Err;



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


[clang-tools-extra] 9b6bb12 - [pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node stats.

2022-06-30 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-06-30T21:20:55+02:00
New Revision: 9b6bb12b85846e8337f8ff75aebd4e9798b56bdd

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

LOG: [pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node 
stats.

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

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
clang-tools-extra/pseudo/lib/Forest.cpp
clang-tools-extra/pseudo/test/glr.cpp
clang-tools-extra/pseudo/tool/ClangPseudo.cpp
clang-tools-extra/pseudo/unittests/ForestTest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
index 29bcac98a64f8..ef9a222faf6bf 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
@@ -43,6 +43,7 @@ namespace pseudo {
 // doesn't have parent pointers.
 class alignas(class ForestNode *) ForestNode {
 public:
+  class RecursiveIterator;
   enum Kind {
 // A Terminal node is a single terminal symbol bound to a token.
 Terminal,
@@ -87,6 +88,22 @@ class alignas(class ForestNode *) ForestNode {
 return children(Data);
   }
 
+  llvm::ArrayRef children() const {
+switch (kind()) {
+case Sequence:
+  return elements();
+case Ambiguous:
+  return alternatives();
+case Terminal:
+case Opaque:
+  return {};
+}
+llvm_unreachable("Bad kind");
+  }
+
+  // Iteration over all nodes in the forest, including this.
+  llvm::iterator_range descendants() const;
+
   std::string dump(const Grammar &) const;
   std::string dumpRecursive(const Grammar &, bool Abbreviated = false) const;
 
@@ -181,6 +198,25 @@ class ForestArena {
   uint32_t NodeCount = 0;
 };
 
+class ForestNode::RecursiveIterator
+: public std::iterator {
+  llvm::DenseSet Seen;
+  struct StackFrame {
+const ForestNode *Parent;
+unsigned ChildIndex;
+  };
+  std::vector Stack;
+  const ForestNode *Cur;
+
+public:
+  RecursiveIterator(const ForestNode *N = nullptr) : Cur(N) {}
+
+  const ForestNode &operator*() const { return *Cur; };
+  void operator++();
+  bool operator==(const RecursiveIterator &I) const { return Cur == I.Cur; }
+  bool operator!=(const RecursiveIterator &I) const { return !(*this == I); }
+};
+
 } // namespace pseudo
 } // namespace clang
 

diff  --git a/clang-tools-extra/pseudo/lib/Forest.cpp 
b/clang-tools-extra/pseudo/lib/Forest.cpp
index 02818547761c8..bea93809c5b38 100644
--- a/clang-tools-extra/pseudo/lib/Forest.cpp
+++ b/clang-tools-extra/pseudo/lib/Forest.cpp
@@ -16,6 +16,35 @@
 namespace clang {
 namespace pseudo {
 
+void ForestNode::RecursiveIterator::operator++() {
+  auto C = Cur->children();
+  // Try to find a child of the current node to descend into.
+  for (unsigned I = 0; I < C.size(); ++I) {
+if (Seen.insert(C[I]).second) {
+  Stack.push_back({Cur, I});
+  Cur = C[I];
+  return;
+}
+  }
+  // Try to find a sibling af an ancestor to advance to.
+  for (; !Stack.empty(); Stack.pop_back()) {
+C = Stack.back().Parent->children();
+unsigned &Index = Stack.back().ChildIndex;
+while (++Index < C.size()) {
+  if (Seen.insert(C[Index]).second) {
+Cur = C[Index];
+return;
+  }
+}
+  }
+  Cur = nullptr;
+}
+
+llvm::iterator_range
+ForestNode::descendants() const {
+  return {RecursiveIterator(this), RecursiveIterator()};
+}
+
 std::string ForestNode::dump(const Grammar &G) const {
   switch (kind()) {
   case Ambiguous:

diff  --git a/clang-tools-extra/pseudo/test/glr.cpp 
b/clang-tools-extra/pseudo/test/glr.cpp
index 2df6fd7405597..0eb19fba2ecc6 100644
--- a/clang-tools-extra/pseudo/test/glr.cpp
+++ b/clang-tools-extra/pseudo/test/glr.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | 
FileCheck %s
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest 
-print-statistics | FileCheck %s
 
 void foo() {
   T* a; // a multiply expression or a pointer declaration?
@@ -22,3 +22,10 @@ void foo() {
 // CHECK-NEXT:   │ └─ptr-declarator~id-expression =#1
 // CHECK-NEXT:   └─; := tok[8]
 }
+
+// CHECK:  3 Ambiguous nodes:
+// CHECK-NEXT: 1 simple-type-specifier
+// CHECK-NEXT: 1 statement
+// CHECK-NEXT: 1 type-name
+// CHECK-EMPTY:
+// CHECK-NEXT: 0 Opaque nodes:

diff  --git a/clang-tools-extra/pseudo/tool/ClangPseudo.cpp 
b/clang-tools-extra/pseudo/tool/ClangPseudo.cpp
index 39ad751aab38d..ff9b893ed3f5a 100644
--- a/clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ b/clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -14,6 +14,8 @@
 #include "clang-pseudo/grammar/LRGraph.h"
 #include "clang-pseudo/grammar/LRTable.h"
 #include "clang/Basic/LangOptio

[PATCH] D128930: [pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node stats.

2022-06-30 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9b6bb12b8584: [pseudo] Add ForestNode descendants iterator, 
print ambiguous/opaque node stats. (authored by sammccall).

Changed prior to commit:
  https://reviews.llvm.org/D128930?vs=441458&id=441482#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128930

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
  clang-tools-extra/pseudo/lib/Forest.cpp
  clang-tools-extra/pseudo/test/glr.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/ForestTest.cpp

Index: clang-tools-extra/pseudo/unittests/ForestTest.cpp
===
--- clang-tools-extra/pseudo/unittests/ForestTest.cpp
+++ clang-tools-extra/pseudo/unittests/ForestTest.cpp
@@ -151,6 +151,30 @@
 "[  0, end) └─A~B =#1\n");
 }
 
+TEST_F(ForestTest, Iteration) {
+  //   Z
+  //  / \
+  //  X Y
+  //  |\|
+  //  A B
+  ForestArena Arena;
+  const auto *A = &Arena.createTerminal(tok::identifier, 0);
+  const auto *B = &Arena.createOpaque(1, 0);
+  const auto *X = &Arena.createSequence(2, 1, {A, B});
+  const auto *Y = &Arena.createSequence(2, 2, {B});
+  const auto *Z = &Arena.createAmbiguous(2, {X, Y});
+
+  std::vector Nodes;
+  for (const ForestNode &N : Z->descendants())
+Nodes.push_back(&N);
+  EXPECT_THAT(Nodes, testing::UnorderedElementsAre(A, B, X, Y, Z));
+
+  Nodes.clear();
+  for (const ForestNode &N : X->descendants())
+Nodes.push_back(&N);
+  EXPECT_THAT(Nodes, testing::UnorderedElementsAre(X, A, B));
+}
+
 } // namespace
 } // namespace pseudo
 } // namespace clang
Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -14,6 +14,8 @@
 #include "clang-pseudo/grammar/LRGraph.h"
 #include "clang-pseudo/grammar/LRTable.h"
 #include "clang/Basic/LangOptions.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -59,6 +61,34 @@
   return Text.get()->getBuffer().str();
 }
 
+namespace clang {
+namespace pseudo {
+namespace {
+
+struct NodeStats {
+  unsigned Total = 0;
+  std::vector> BySymbol;
+
+  NodeStats(const ForestNode &Root,
+llvm::function_ref Filter) {
+llvm::DenseMap Map;
+for (const ForestNode &N : Root.descendants())
+  if (Filter(N)) {
+++Total;
+++Map[N.symbol()];
+  }
+BySymbol = {Map.begin(), Map.end()};
+// Sort by count descending, then symbol ascending.
+llvm::sort(BySymbol, [](const auto &L, const auto &R) {
+  return std::tie(R.second, L.first) < std::tie(L.second, R.first);
+});
+  }
+};
+
+} // namespace
+} // namespace pseudo
+} // namespace clang
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "");
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
@@ -135,6 +165,17 @@
  << " nodes: " << Arena.nodeCount() << "\n";
 llvm::outs() << "GSS bytes: " << GSS.bytes()
  << " nodes: " << GSS.nodesCreated() << "\n";
+
+for (auto &P :
+ {std::make_pair("Ambiguous", clang::pseudo::ForestNode::Ambiguous),
+  std::make_pair("Opaque", clang::pseudo::ForestNode::Opaque)}) {
+  clang::pseudo::NodeStats Stats(
+  Root, [&](const auto &N) { return N.kind() == P.second; });
+  llvm::outs() << "\n" << Stats.Total << " " << P.first << " nodes:\n";
+  for (const auto &S : Stats.BySymbol)
+llvm::outs() << llvm::formatv("  {0,3} {1}\n", S.second,
+  G.symbolName(S.first));
+}
   }
 }
   }
Index: clang-tools-extra/pseudo/test/glr.cpp
===
--- clang-tools-extra/pseudo/test/glr.cpp
+++ clang-tools-extra/pseudo/test/glr.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest -print-statistics | FileCheck %s
 
 void foo() {
   T* a; // a multiply expression or a pointer declaration?
@@ -22,3 +22,10 @@
 // CHECK-NEXT:   │ └─ptr-declarator~id-expression =#1
 // CHECK-NEXT:   └─; := tok[8]
 }
+
+// CHECK:  3 Ambiguous nodes:
+// CHECK-NEXT: 1 simple-type-specifier
+// CHECK-NEXT: 1 statement
+// CHECK-NEXT: 1 type-name
+// CHECK-EMPTY:
+// CHECK-NEXT: 0 Opaque nodes:
Index: clang-tools-extra/pseudo/lib/Forest.cpp
===
--- clang-tools-extra/pseudo/lib/Forest.cpp
+++ clang-tools-extra/pseudo/lib/Forest.cpp
@@ -1

[PATCH] D128930: [pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node stats.

2022-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked an inline comment as done.
sammccall added inline comments.



Comment at: clang-tools-extra/pseudo/tool/ClangPseudo.cpp:68
+
+struct NodeStats {
+  unsigned Total = 0;

hokein wrote:
> I can foresee we will use it in other places (e.g. our internal metric tool), 
> I think it is worth to expose it. It is ok for now.
I had the same thought, but I wasn't sure we'll want exactly the same thing.

e.g. the breakdown-by-SymbolID is a somewhat specialized data structure, our 
(private) mapreduce analysis might want to use mapreduce counters for this.

I'd rather just share the iterator for now, and only expose the simple 
aggregation stuff once we know it's actually reusable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128930

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D126907#3623120 , @JDevlieghere 
wrote:

> This change triggers an assertion when building an LLDB test case:
>
>   UNREACHABLE executed at 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Sema/SemaTemplate.cpp:1726!
>   Assertion failed: (InstantiatingSpecializations.empty() && "failed to clean 
> up an InstantiatingTemplate?"), function ~Sema, file 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Sema/Sema.cpp,
>  line 458.
>   PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
> and include the crash backtrace, preprocessed source, and associated run 
> script.
>   Stack dump:
>   0.  Program arguments: 
> /Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang -fmodules 
> -gmodules 
> -fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-api
>  -gmodules -fcxx-modules -std=c++11 -g -O0 -isysroot 
> /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
>  -arch x86_64 
> -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../../include
>  
> -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span
>  
> -I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make
>  -include 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h
>  -fno-limit-debug-info -fmodules -gmodules 
> -fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-api
>  -gmodules -fcxx-modules -DLLDB_USING_LIBCPP -stdlib=libc++ -std=c++20 
> --driver-mode=g++ -MT main.o -MD -MP -MF main.d -c -o main.o 
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/main.cpp
>   1.  
> /Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/main.cpp:1:2:
>  current parser token 'include'
>   Stack dump without symbol names (ensure you have llvm-symbolizer in your 
> PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
>   0  clang0x000106bc157e 
> llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 46
>   1  clang0x000106bc0258 
> llvm::sys::RunSignalHandlers() + 248
>   2  clang0x000106bc0962 
> llvm::sys::CleanupOnSignal(unsigned long) + 210
>   3  clang0x000106adb82a (anonymous 
> namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 106
>   4  clang0x000106adba2e 
> CrashRecoverySignalHandler(int) + 110
>   5  libsystem_platform.dylib 0x7fff67b405fd _sigtramp + 29
>   6  libsystem_platform.dylib 0x7ffeeab5b460 _sigtramp + 
> 18446744071612509824
>   7  libsystem_c.dylib0x7fff67a12808 abort + 120
>   8  libsystem_c.dylib0x7fff67a11ac6 err + 0
>   9  clang0x000108a1325c clang::Sema::~Sema() + 5660
>   10 clang0x000107698e41 
> clang::CompilerInstance::~CompilerInstance() + 625
>   11 clang0x0001076a7fe5 
> compileModuleImpl(clang::CompilerInstance&, clang::SourceLocation, 
> llvm::StringRef, clang::FrontendInputFile, llvm::StringRef, llvm::StringRef, 
> llvm::function_ref, llvm::function_ref (clang::CompilerInstance&)>) + 4517
>   12 clang0x0001076a9b16 
> compileModuleAndReadASTImpl(clang::CompilerInstance&, clang::SourceLocation, 
> clang::SourceLocation, clang::Module*, llvm::StringRef) + 1238
>   13 clang0x0001076a370b 
> compileModuleAndReadAST(clang::CompilerInstance&, clang::SourceLocation, 
> clang::SourceLocation, clang::Module*, llvm::StringRef) + 1947
>   14 clang0x0001076a2b97 
> clang::CompilerInstance::findOrCompileModuleAndReadAST(llvm::StringRef, 
> clang::SourceLocation, clang::SourceLocation, bool) + 3783
>   15 clang0x0001076a3aa7 
> clang::CompilerInstance::loadModule(clang::SourceLocation, 
> llvm::ArrayRef clang::SourceLocation>>, clang::Module::NameVisibilityKind, bool) + 695
>   16 clang0x000109b8a630 
> clang::Preprocessor::HandleHeaderIncludeOrImport(clang::SourceLocation, 
> clang::Token&, clang::Token&, clang::SourceLocation, 
> clang::detail::SearchDirIteratorImpl, clang::FileEntry const*) + 7792
>   17 clang0x000109b822e1 
> clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, 
> clang::Token&, clang::detail::SearchDirIteratorImpl, clang::FileEntry 
> const

[PATCH] D128589: [clang-repl] Support destructors of global objects.

2022-06-30 Thread Sunho Kim via Phabricator via cfe-commits
sunho added inline comments.



Comment at: clang/test/Interpreter/execute.cpp:22-23
 
+struct D { float f = 1.0; D *m = nullptr; D(){} ~D() { printf("D[f=%f, 
m=0x%llx]\n", f, reinterpret_cast(m)); }} d;
+// CHECK: D[f=1.00, m=0x0]
+

Hahnfeld wrote:
> I think it would be better to add new test cases instead of extending this 
> ever-growing file. And it might also be a good idea to split off some of the 
> previous additions into separate test cases that exercise specific parts of 
> the interpreter infrastructure (D126781 and D123674).
Got it. I will address your comment when relanding the patch after fixing ppc 
failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128589

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-30 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

This change triggers an assertion when building an LLDB test case:

  UNREACHABLE executed at 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Sema/SemaTemplate.cpp:1726!
  Assertion failed: (InstantiatingSpecializations.empty() && "failed to clean 
up an InstantiatingTemplate?"), function ~Sema, file 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/clang/lib/Sema/Sema.cpp,
 line 458.
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace, preprocessed source, and associated run script.
  Stack dump:
  0.Program arguments: 
/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/bin/clang -fmodules 
-gmodules 
-fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-api
 -gmodules -fcxx-modules -std=c++11 -g -O0 -isysroot 
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.sdk
 -arch x86_64 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/../../../../../include
 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span
 
-I/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make
 -include 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/packages/Python/lldbsuite/test/make/test_common.h
 -fno-limit-debug-info -fmodules -gmodules 
-fmodules-cache-path=/Users/buildslave/jenkins/workspace/lldb-cmake/lldb-build/lldb-test-build.noindex/module-cache-clang/lldb-api
 -gmodules -fcxx-modules -DLLDB_USING_LIBCPP -stdlib=libc++ -std=c++20 
--driver-mode=g++ -MT main.o -MD -MP -MF main.d -c -o main.o 
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/main.cpp
  1.
/Users/buildslave/jenkins/workspace/lldb-cmake/llvm-project/lldb/test/API/functionalities/data-formatter/data-formatter-stl/libcxx/span/main.cpp:1:2:
 current parser token 'include'
  Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH 
or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
  0  clang0x000106bc157e 
llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 46
  1  clang0x000106bc0258 llvm::sys::RunSignalHandlers() 
+ 248
  2  clang0x000106bc0962 
llvm::sys::CleanupOnSignal(unsigned long) + 210
  3  clang0x000106adb82a (anonymous 
namespace)::CrashRecoveryContextImpl::HandleCrash(int, unsigned long) + 106
  4  clang0x000106adba2e 
CrashRecoverySignalHandler(int) + 110
  5  libsystem_platform.dylib 0x7fff67b405fd _sigtramp + 29
  6  libsystem_platform.dylib 0x7ffeeab5b460 _sigtramp + 
18446744071612509824
  7  libsystem_c.dylib0x7fff67a12808 abort + 120
  8  libsystem_c.dylib0x7fff67a11ac6 err + 0
  9  clang0x000108a1325c clang::Sema::~Sema() + 5660
  10 clang0x000107698e41 
clang::CompilerInstance::~CompilerInstance() + 625
  11 clang0x0001076a7fe5 
compileModuleImpl(clang::CompilerInstance&, clang::SourceLocation, 
llvm::StringRef, clang::FrontendInputFile, llvm::StringRef, llvm::StringRef, 
llvm::function_ref, llvm::function_ref) + 4517
  12 clang0x0001076a9b16 
compileModuleAndReadASTImpl(clang::CompilerInstance&, clang::SourceLocation, 
clang::SourceLocation, clang::Module*, llvm::StringRef) + 1238
  13 clang0x0001076a370b 
compileModuleAndReadAST(clang::CompilerInstance&, clang::SourceLocation, 
clang::SourceLocation, clang::Module*, llvm::StringRef) + 1947
  14 clang0x0001076a2b97 
clang::CompilerInstance::findOrCompileModuleAndReadAST(llvm::StringRef, 
clang::SourceLocation, clang::SourceLocation, bool) + 3783
  15 clang0x0001076a3aa7 
clang::CompilerInstance::loadModule(clang::SourceLocation, 
llvm::ArrayRef>, 
clang::Module::NameVisibilityKind, bool) + 695
  16 clang0x000109b8a630 
clang::Preprocessor::HandleHeaderIncludeOrImport(clang::SourceLocation, 
clang::Token&, clang::Token&, clang::SourceLocation, 
clang::detail::SearchDirIteratorImpl, clang::FileEntry const*) + 7792
  17 clang0x000109b822e1 
clang::Preprocessor::HandleIncludeDirective(clang::SourceLocation, 
clang::Token&, clang::detail::SearchDirIteratorImpl, clang::FileEntry 
const*) + 177
  18 clang0x000109b82f8c 
clang::Preprocessor::HandleDirective(clang::Token&) + 2604
  19 clang0x000109b50877 
clang::Lexer::LexTokenInternal(clang::Token&, bool) + 6199
  20 clang0x000109b4cf15 
clang::Le

[PATCH] D128930: [pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node stats.

2022-06-30 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

Nice!




Comment at: clang-tools-extra/pseudo/tool/ClangPseudo.cpp:68
+
+struct NodeStats {
+  unsigned Total = 0;

I can foresee we will use it in other places (e.g. our internal metric tool), I 
think it is worth to expose it. It is ok for now.



Comment at: clang-tools-extra/pseudo/tool/ClangPseudo.cpp:70
+  unsigned Total = 0;
+  std::vector> BySymbol;
+

By reading the code, I believe the `unsigned` and `SymbolID` here are swap 
accidentally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128930

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


[PATCH] D122255: Meta directive runtime support

2022-06-30 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:8893-8894
+
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+

abidmalikwaterloo wrote:
> ABataev wrote:
> > make it private
> Any reason behind this? I went through other classes, this function is public 
> in some and private in some.
The AST is immutable, such functions are/must be used in very rare places.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122255

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


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-06-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 441468.
ilya-biryukov added a comment.

- remove leftover test from previous version


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Modules/Inputs/merge-concepts/concepts.h
  clang/test/Modules/Inputs/merge-concepts/conflicting.h
  clang/test/Modules/Inputs/merge-concepts/format.h
  clang/test/Modules/Inputs/merge-concepts/modules.map
  clang/test/Modules/Inputs/merge-concepts/same_as.h
  clang/test/Modules/merge-concepts.cpp

Index: clang/test/Modules/merge-concepts.cpp
===
--- /dev/null
+++ clang/test/Modules/merge-concepts.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t.dir
+// RUN: mkdir %t.dir
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \
+// RUN: -emit-module %S/Inputs/merge-concepts/modules.map \
+// RUN: -o %t.dir/module.pcm
+//
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-file=%t.dir/module.pcm  \
+// RUN: -fmodule-map-file=%S/Inputs/merge-concepts/modules.map \
+// RUN: -I%S/Inputs/merge-concepts \
+// RUN: -fsyntax-only -verify %s
+
+#include "concepts.h"
+#include "conflicting.h"
+#include "format.h"
+
+template  void foo()
+  requires same_as
+{}
+ConflictingConcept auto x = 10; // expected-error {{reference to 'ConflictingConcept' is ambiguous}}
+// expected-note@* 2 {{candidate}}
Index: clang/test/Modules/Inputs/merge-concepts/same_as.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/same_as.h
@@ -0,0 +1,7 @@
+#ifndef SAME_AS_H
+#define SAME_AS_H
+
+template 
+concept same_as = __is_same(T, U);
+
+#endif // SAME_AS_H
Index: clang/test/Modules/Inputs/merge-concepts/modules.map
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/modules.map
@@ -0,0 +1,15 @@
+module "library" {
+	export *
+	module "concepts" {
+		export *
+		header "concepts.h"
+	}
+	module "format" {
+		export *
+		header "format.h"
+	}
+	module "conflicting" {
+		export *
+		header "conflicting.h"
+	}
+}
Index: clang/test/Modules/Inputs/merge-concepts/format.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/format.h
@@ -0,0 +1,11 @@
+#ifndef FORMAT_H
+#define FORMAT_H
+
+#include "concepts.h"
+#include "same_as.h"
+
+template  void foo()
+  requires same_as
+{}
+
+#endif // FORMAT_H
Index: clang/test/Modules/Inputs/merge-concepts/conflicting.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/conflicting.h
@@ -0,0 +1,7 @@
+#ifndef CONFLICTING_H
+#define CONFLICTING_H
+
+template 
+concept ConflictingConcept = true;
+
+#endif // CONFLICTING_H
Index: clang/test/Modules/Inputs/merge-concepts/concepts.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/concepts.h
@@ -0,0 +1,9 @@
+#ifndef SAMEAS_CONCEPTS_H_
+#define SAMEAS_CONCEPTS_H_
+
+#include "same_as.h"
+
+template 
+concept ConflictingConcept = true;
+
+#endif // SAMEAS_CONCEPTS_H
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8655,23 +8655,53 @@
   // Check for conflicting previous declaration.
   DeclarationNameInfo NameInfo(NewDecl->getDeclName(), NameLoc);
   LookupResult Previous(*this, NameInfo, LookupOrdinaryName,
-ForVisibleRedeclaration);
+forRedeclarationInCurContext());
   LookupName(Previous, S);
-
   FilterLookupForScope(Previous, DC, S, /*ConsiderLinkage=*/false,
/*AllowInlineNamespace*/false);
-  if (!Previous.empty()) {
-auto *Old = Previous.getRepresentativeDecl();
-Diag(NameLoc, isa(Old) ? diag::err_redefinition :
- diag::err_redefinition_different_kind) << NewDecl->getDeclName();
-Diag(Old->getLocation(), diag::note_previous_definition);
-  }
+  bool AddToScope = true;
+  CheckConceptRedefinition(NewDecl, Previous, AddToScope);
 
   ActOnDocumentableDecl(NewDecl);
-  PushOnScopeChains(NewDecl, S);
+  if (AddToScope)
+PushOnScopeChains(NewDecl, S);
   return NewDecl;
 }
 
+void Sema::CheckConceptRedefinition(ConceptDecl *NewDecl,
+LookupResult &Previous, bool &AddToScope) {
+  AddToScope = true;
+  if (Previous.empty())
+return;
+  // Check if there is a concept declaration we can merge with.
+  auto *PrevDef =
+  Previous.isSingleResult() ? Previous.getAsSingle() : nullptr;
+  if (PrevDef && !hasVisibleD

[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-06-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

I haven't seen your reply before posting my initial comments. Many thanks for a 
very quick turnaroud on this!
Will wait for module folks to approve.




Comment at: clang/lib/Sema/SemaTemplate.cpp:8674
 auto *Old = Previous.getRepresentativeDecl();
 Diag(NameLoc, isa(Old) ? diag::err_redefinition :
  diag::err_redefinition_different_kind) << NewDecl->getDeclName();

ilya-biryukov wrote:
> Not sure if reporting the redefinition if `isSameEntity` returns false is the 
> right approach here.
> This leads to errors on definitions of something like:
> ```
> // foo.h
> template  concept A = false;
> 
> // bar.h
> template  concept A = true;
> 
> #include "foo.h"
> #include "bar.h" // <-- redefinition error shown here
> ```
> 
> The alternative is the "ambiguous reference" error on the use of the concept. 
> I will check what happens for variables and typedefs in that case and follow 
> the same pattern.
Clang tends to do "ambiguous reference" instead of the behavior we had in this 
patch.
I have updated it to be consistent with what typedefs and other symbols produce.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

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


[PATCH] D128853: [Interpreter] Pass target features to JIT

2022-06-30 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: clang/lib/Interpreter/IncrementalExecutor.h:34
 struct PartialTranslationUnit;
+struct TargetInfo;
 

That's wrong, should be `class TargetInfo`. I'll fix this before landing if my 
other tests go well...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128853

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


[PATCH] D128921: [Sema] Merge C++20 concept definitions from different modules in same TU

2022-06-30 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 441466.
ilya-biryukov added a comment.

- Update code to match how typedefs behave


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128921

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/Modules/Inputs/merge-concepts/concepts.h
  clang/test/Modules/Inputs/merge-concepts/conflicting.h
  clang/test/Modules/Inputs/merge-concepts/format.h
  clang/test/Modules/Inputs/merge-concepts/modules.map
  clang/test/Modules/Inputs/merge-concepts/same_as.h
  clang/test/Modules/merge-concepts.cpp
  clang/test/Modules/merge-concepts.m

Index: clang/test/Modules/merge-concepts.m
===
--- /dev/null
+++ clang/test/Modules/merge-concepts.m
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t.dir
+// RUN: mkdir %t.dir
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \
+// RUN: -emit-module %S/Inputs/merge-concepts/modules.map \
+// RUN: -o %t.dir/module.pcm
+//
+// Note that this file merely checks the module compiles. The contents of this
+// file are never read by the compiler.
Index: clang/test/Modules/merge-concepts.cpp
===
--- /dev/null
+++ clang/test/Modules/merge-concepts.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t.dir
+// RUN: mkdir %t.dir
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-name=library \
+// RUN: -emit-module %S/Inputs/merge-concepts/modules.map \
+// RUN: -o %t.dir/module.pcm
+//
+//
+// RUN: %clang_cc1 -xc++ -std=c++20 -fmodules -fmodule-file=%t.dir/module.pcm  \
+// RUN: -fmodule-map-file=%S/Inputs/merge-concepts/modules.map \
+// RUN: -I%S/Inputs/merge-concepts \
+// RUN: -fsyntax-only -verify %s
+
+#include "concepts.h"
+#include "conflicting.h"
+#include "format.h"
+
+template  void foo()
+  requires same_as
+{}
+ConflictingConcept auto x = 10; // expected-error {{reference to 'ConflictingConcept' is ambiguous}}
+// expected-note@* 2 {{candidate}}
Index: clang/test/Modules/Inputs/merge-concepts/same_as.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/same_as.h
@@ -0,0 +1,7 @@
+#ifndef SAME_AS_H
+#define SAME_AS_H
+
+template 
+concept same_as = __is_same(T, U);
+
+#endif // SAME_AS_H
Index: clang/test/Modules/Inputs/merge-concepts/modules.map
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/modules.map
@@ -0,0 +1,15 @@
+module "library" {
+	export *
+	module "concepts" {
+		export *
+		header "concepts.h"
+	}
+	module "format" {
+		export *
+		header "format.h"
+	}
+	module "conflicting" {
+		export *
+		header "conflicting.h"
+	}
+}
Index: clang/test/Modules/Inputs/merge-concepts/format.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/format.h
@@ -0,0 +1,11 @@
+#ifndef FORMAT_H
+#define FORMAT_H
+
+#include "concepts.h"
+#include "same_as.h"
+
+template  void foo()
+  requires same_as
+{}
+
+#endif // FORMAT_H
Index: clang/test/Modules/Inputs/merge-concepts/conflicting.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/conflicting.h
@@ -0,0 +1,7 @@
+#ifndef CONFLICTING_H
+#define CONFLICTING_H
+
+template 
+concept ConflictingConcept = true;
+
+#endif // CONFLICTING_H
Index: clang/test/Modules/Inputs/merge-concepts/concepts.h
===
--- /dev/null
+++ clang/test/Modules/Inputs/merge-concepts/concepts.h
@@ -0,0 +1,9 @@
+#ifndef SAMEAS_CONCEPTS_H_
+#define SAMEAS_CONCEPTS_H_
+
+#include "same_as.h"
+
+template 
+concept ConflictingConcept = true;
+
+#endif // SAMEAS_CONCEPTS_H
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -8655,23 +8655,53 @@
   // Check for conflicting previous declaration.
   DeclarationNameInfo NameInfo(NewDecl->getDeclName(), NameLoc);
   LookupResult Previous(*this, NameInfo, LookupOrdinaryName,
-ForVisibleRedeclaration);
+forRedeclarationInCurContext());
   LookupName(Previous, S);
-
   FilterLookupForScope(Previous, DC, S, /*ConsiderLinkage=*/false,
/*AllowInlineNamespace*/false);
-  if (!Previous.empty()) {
-auto *Old = Previous.getRepresentativeDecl();
-Diag(NameLoc, isa(Old) ? diag::err_redefinition :
- diag::err_redefinition_different_kind) << NewDecl->getDeclName();
-Diag(Old->getLocation(), diag::note_previous_definition);
-  }
+  bool AddToScope = true;
+  CheckConceptRedefinition(NewD

[PATCH] D119296: KCFI sanitizer

2022-06-30 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers accepted this revision.
nickdesaulniers added a comment.

I see you modified the mir parser & printer; consider adding a .mir test.

Still LGTM. Might be nice to document the generated asm more for other compiler 
vendors to better understand the implementation, rather than having to read the 
tests added here.




Comment at: clang/lib/CodeGen/CodeGenFunction.h:4604
+  void EmitKCFIOperandBundle(const CGCallee &Callee,
+ SmallVectorImpl &Bundles);
+

Should this parameter be an `ArrayRef`? This might be a more precise type, but 
seeing an impl type kind of breaks the whole pImpl idiom; I'm pretty sure 
that's what `ArrayRef` is for.
https://llvm.org/docs/ProgrammersManual.html#llvm-adt-arrayref-h
That said, this header is pretty inconsistent in the use of `SmallVectorImp` vs 
`ArrayRef`, but I *think* `ArrayRef` is strongly preferred.



Comment at: llvm/lib/CodeGen/MachineInstr.cpp:1770-1771
+  if (uint32_t CFIType = getCFIType()) {
+if (!FirstOp) {
+  FirstOp = false;
+  OS << ',';

If `FirstOp` is `false`, reassign it `false`? Is that right?  I see that's 
what's done on L1763, but..."what?"



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:7821-7830
 
+  ConstantInt *CFIType = nullptr;
+  auto Bundle = CB.getOperandBundle(LLVMContext::OB_kcfi);
+  if (Bundle && CB.isIndirectCall()) {
+if (!TLI.supportKCFIBundles())
+  report_fatal_error(
+  "Target doesn't support calls with kcfi operand bundles.");

Can we check whether the `CallBase` is an indirect call first before bothering 
with getting the operand bundle?



Comment at: llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp:7822-7840
+  ConstantInt *CFIType = nullptr;
+  auto Bundle = CB.getOperandBundle(LLVMContext::OB_kcfi);
+  if (Bundle && CB.isIndirectCall()) {
+if (!TLI.supportKCFIBundles())
+  report_fatal_error(
+  "Target doesn't support calls with kcfi operand bundles.");
+CFIType = cast(Bundle->Inputs[0]);

Are we able to reorder these?

```
CLI.setDebugLoc ...
  ...
if (Bundle && CB.isIndirectCall) {
  ...
  CLI.setCFIType ...
```



Comment at: llvm/lib/Target/AArch64/AArch64KCFI.cpp:106
+
+  const AArch64Subtarget &SubTarget = MF.getSubtarget();
+  TII = SubTarget.getInstrInfo();

`const auto &SubTarget = ...`



Comment at: llvm/lib/Target/X86/X86KCFI.cpp:110
+
+  const X86Subtarget &SubTarget = MF.getSubtarget();
+  TII = SubTarget.getInstrInfo();

`const auto &SubTarget = ...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119296

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


[PATCH] D122255: Meta directive runtime support

2022-06-30 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo marked 2 inline comments as done.
abidmalikwaterloo added inline comments.



Comment at: clang/include/clang/AST/OpenMPClause.h:8893-8894
+
+  /// Sets the location of '('.
+  void setLParenLoc(SourceLocation Loc) { LParenLoc = Loc; }
+

ABataev wrote:
> make it private
Any reason behind this? I went through other classes, this function is public 
in some and private in some.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122255

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


[PATCH] D128103: Adds AST Matcher for ObjCStringLiteral

2022-06-30 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud added a comment.



In D128103#363 , @aaron.ballman 
wrote:

> LGTM! Do you need me to commit on your behalf? If so, what name and email 
> address would you like me to use for patch attribution?

Thank you @aaron.ballman. I believe I have the permissions to commit, so I can 
land the patch.


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

https://reviews.llvm.org/D128103

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


[PATCH] D128830: [Pipelines] Introduce DAE after ArgumentPromotion

2022-06-30 Thread Pavel Samolysov via Phabricator via cfe-commits
psamolysov updated this revision to Diff 441462.
psamolysov added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fix `Clang :: CodeGen/thinlto-distributed-newpm.ll`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128830

Files:
  clang/test/CodeGen/thinlto-distributed-newpm.ll
  llvm/lib/Passes/PassBuilderPipelines.cpp
  llvm/test/Other/new-pm-defaults.ll
  llvm/test/Other/new-pm-lto-defaults.ll
  llvm/test/Other/new-pm-thinlto-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
  llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
  llvm/test/Transforms/InstCombine/unused-nonnull.ll
  llvm/test/Transforms/PhaseOrdering/dce-after-argument-promotion.ll

Index: llvm/test/Transforms/PhaseOrdering/dce-after-argument-promotion.ll
===
--- llvm/test/Transforms/PhaseOrdering/dce-after-argument-promotion.ll
+++ llvm/test/Transforms/PhaseOrdering/dce-after-argument-promotion.ll
@@ -9,7 +9,7 @@
 
 define internal void @f(%struct.ss* byval(%struct.ss) align 8 %b, i32* byval(i32) align 4 %X) noinline nounwind  {
 ; CHECK-LABEL: define {{[^@]+}}@f
-; CHECK-SAME: (i32 [[B_0:%.*]], i32 [[X:%.*]]){{[^#]*}} #[[ATTR0:[0-9]+]] {
+; CHECK-SAME: (i32 [[B_0:%.*]]){{[^#]*}} #[[ATTR0:[0-9]+]] {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[TEMP:%.*]] = add i32 [[B_0]], 1
 ; CHECK-NEXT:store i32 [[TEMP]], i32* [[DUMMY]], align 4
@@ -28,8 +28,7 @@
 ; CHECK-LABEL: define {{[^@]+}}@test
 ; CHECK-SAME: (i32* {{[^%]*}} [[X:%.*]]){{[^#]*}} #[[ATTR1:[0-9]+]] {
 ; CHECK-NEXT:  entry:
-; CHECK-NEXT:[[X_VAL:%.*]] = load i32, i32* [[X]], align 4
-; CHECK-NEXT:tail call {{.*}}void @f(i32 1, i32 [[X_VAL]])
+; CHECK-NEXT:tail call {{.*}}void @f(i32 1)
 ; CHECK-NEXT:ret i32 0
 ;
 entry:
Index: llvm/test/Transforms/InstCombine/unused-nonnull.ll
===
--- llvm/test/Transforms/InstCombine/unused-nonnull.ll
+++ llvm/test/Transforms/InstCombine/unused-nonnull.ll
@@ -9,7 +9,7 @@
 
 define i32 @main(i32 %argc, i8** %argv) #0 {
 ; CHECK-LABEL: define {{[^@]+}}@main
-; CHECK-SAME: (i32 [[ARGC:%.*]], i8** nocapture readnone [[ARGV:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
+; CHECK-SAME: (i32 [[ARGC:%.*]], i8** nocapture readonly [[ARGV:%.*]]) local_unnamed_addr #[[ATTR0:[0-9]+]] {
 ; CHECK-NEXT:  entry:
 ; CHECK-NEXT:[[TMP0:%.*]] = icmp slt i32 [[ARGC]], 2
 ; CHECK-NEXT:[[SPEC_SELECT:%.*]] = select i1 [[TMP0]], i32 0, i32 [[ARGC]]
@@ -37,7 +37,8 @@
 
 define i32 @compute(i8* noundef nonnull %ptr, i32 %x) #1 {
 ; CHECK-LABEL: define {{[^@]+}}@compute
-; CHECK-SAME: (i8* nocapture nonnull readnone [[PTR:%.*]], i32 returned [[X:%.*]]) local_unnamed_addr #[[ATTR1:[0-9]+]] {
+; CHECK-SAME: (i8* nocapture noundef nonnull readnone [[PTR:%.*]], i32 returned [[X:%.*]])
+; CHECK-SAME:  local_unnamed_addr #[[ATTR1:[0-9]+]] {
 ; CHECK-NEXT:ret i32 [[X]]
 ;
   ret i32 %x
Index: llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -58,7 +58,6 @@
 ; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 ; CHECK-O-NEXT: Running pass: PromotePass
-; CHECK-O-NEXT: Running pass: DeadArgumentEliminationPass
 ; CHECK-O-NEXT: Running pass: InstCombinePass
 ; CHECK-O-NEXT: Running analysis: BlockFrequencyAnalysis on foo
 ; These next two can appear in any order since they are accessed as parameters
@@ -162,6 +161,7 @@
 ; CHECK-O3-NEXT: Running analysis: DominanceFrontierAnalysis on foo
 ; CHECK-O-NEXT: Running pass: CoroSplitPass
 ; CHECK-O-NEXT: Invalidating analysis: InlineAdvisorAnalysis
+; CHECK-O-NEXT: Running pass: DeadArgumentEliminationPass
 ; CHECK-O-NEXT: Running pass: CoroCleanupPass
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 ; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo
Index: llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
===
--- llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -48,7 +48,6 @@
 ; CHECK-O-NEXT: Running pass: CalledValuePropagationPass
 ; CHECK-O-NEXT: Running pass: GlobalOptPass
 ; CHECK-O-NEXT: Running pass: PromotePass
-; CHECK-O-NEXT: Running pass: DeadArgumentEliminationPass
 ; CHECK-O-NEXT: Running pass: InstCombinePass
 ; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis
 ; CHECK-O-NEXT: Running analysis: AAManager
@@ -197,6 +196,7 @@
 ; CHECK-O3-NEXT: Running analysis: DominanceFrontierAnalysis on foo
 ; 

[PATCH] D128930: [pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node stats.

2022-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Results on the first 1k lines of SemaCodeComplete.cpp:

  Forest bytes: 809824 nodes: 47378
  GSS bytes: 24736 nodes: 41925
  
  1490 Ambiguous nodes:
518 type-name
377 simple-type-specifier
137 namespace-name
135 nested-name-specifier
 65 postfix-expression
 45 decl-specifier-seq
 40 template-argument
 37 parameter-declaration
 26 relational-expression
 25 member-declaration
 21 virt-specifier
 18 function-definition
 16 mem-initializer-id
  9 literal
  7 user-defined-literal
  4 condition
  2 declaration-seq
  2 logical-or-expression
  2 simple-declaration
  2 statement
  1 logical-and-expression
  1 type-specifier-seq
  
  0 Opaque nodes:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128930

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


[PATCH] D128930: [pseudo] Add ForestNode descendants iterator, print ambiguous/opaque node stats.

2022-06-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: hokein.
Herald added a subscriber: mgrang.
Herald added a project: All.
sammccall requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang-tools-extra.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128930

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
  clang-tools-extra/pseudo/lib/Forest.cpp
  clang-tools-extra/pseudo/test/glr.cpp
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/ForestTest.cpp

Index: clang-tools-extra/pseudo/unittests/ForestTest.cpp
===
--- clang-tools-extra/pseudo/unittests/ForestTest.cpp
+++ clang-tools-extra/pseudo/unittests/ForestTest.cpp
@@ -151,6 +151,30 @@
 "[  0, end) └─A~B =#1\n");
 }
 
+TEST_F(ForestTest, Iteration) {
+  //   Z
+  //  / \
+  //  X Y
+  //  |\|
+  //  A B
+  ForestArena Arena;
+  const auto *A = &Arena.createTerminal(tok::identifier, 0);
+  const auto *B = &Arena.createOpaque(1, 0);
+  const auto *X = &Arena.createSequence(2, 1, {A, B});
+  const auto *Y = &Arena.createSequence(2, 2, {B});
+  const auto *Z = &Arena.createAmbiguous(2, {X, Y});
+
+  std::vector Nodes;
+  for (const ForestNode &N : Z->descendants())
+Nodes.push_back(&N);
+  EXPECT_THAT(Nodes, testing::UnorderedElementsAre(A, B, X, Y, Z));
+
+  Nodes.clear();
+  for (const ForestNode &N : X->descendants())
+Nodes.push_back(&N);
+  EXPECT_THAT(Nodes, testing::UnorderedElementsAre(X, A, B));
+}
+
 } // namespace
 } // namespace pseudo
 } // namespace clang
Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -14,6 +14,8 @@
 #include "clang-pseudo/grammar/LRGraph.h"
 #include "clang-pseudo/grammar/LRTable.h"
 #include "clang/Basic/LangOptions.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/STLFunctionalExtras.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FormatVariadic.h"
@@ -59,6 +61,34 @@
   return Text.get()->getBuffer().str();
 }
 
+namespace clang {
+namespace pseudo {
+namespace {
+
+struct NodeStats {
+  unsigned Total = 0;
+  std::vector> BySymbol;
+
+  NodeStats(const ForestNode &Root,
+llvm::function_ref Filter) {
+llvm::DenseMap Map;
+for (const ForestNode &N : Root.descendants())
+  if (Filter(N)) {
+++Total;
+++Map[N.symbol()];
+  }
+BySymbol = {Map.begin(), Map.end()};
+// Sort by count descending, then symbol ascending.
+llvm::sort(BySymbol, [](const auto &L, const auto &R) {
+  return std::tie(R.second, L.first) < std::tie(L.second, R.first);
+});
+  }
+};
+
+} // namespace
+} // namespace pseudo
+} // namespace clang
+
 int main(int argc, char *argv[]) {
   llvm::cl::ParseCommandLineOptions(argc, argv, "");
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
@@ -135,6 +165,17 @@
  << " nodes: " << Arena.nodeCount() << "\n";
 llvm::outs() << "GSS bytes: " << GSS.bytes()
  << " nodes: " << GSS.nodesCreated() << "\n";
+
+for (auto &P :
+ {std::make_pair("Ambiguous", clang::pseudo::ForestNode::Ambiguous),
+  std::make_pair("Opaque", clang::pseudo::ForestNode::Opaque)}) {
+  clang::pseudo::NodeStats Stats(
+  Root, [&](const auto &N) { return N.kind() == P.second; });
+  llvm::outs() << "\n" << Stats.Total << " " << P.first << " nodes:\n";
+  for (const auto &S : Stats.BySymbol)
+llvm::outs() << llvm::formatv("  {0,3} {1}\n", S.second,
+  G.symbolName(S.first));
+}
   }
 }
   }
Index: clang-tools-extra/pseudo/test/glr.cpp
===
--- clang-tools-extra/pseudo/test/glr.cpp
+++ clang-tools-extra/pseudo/test/glr.cpp
@@ -1,4 +1,4 @@
-// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest | FileCheck %s
+// RUN: clang-pseudo -grammar=%cxx-bnf-file -source=%s --print-forest -print-statistics | FileCheck %s
 
 void foo() {
   T* a; // a multiply expression or a pointer declaration?
@@ -22,3 +22,10 @@
 // CHECK-NEXT:   │ └─ptr-declarator~id-expression =#1
 // CHECK-NEXT:   └─; := tok[8]
 }
+
+// CHECK:  3 Ambiguous nodes:
+// CHECK-NEXT: 1 simple-type-specifier
+// CHECK-NEXT: 1 statement
+// CHECK-NEXT: 1 type-name
+// CHECK-EMPTY:
+// CHECK-NEXT: 0 Opaque nodes:
Index: clang-tools-extra/pseudo/lib/Forest.cpp
===
--- clang-tools-extra/pseudo/lib/Forest.cpp
+++ clang-tools-extra/pseudo/lib/Forest.cpp
@@ -16,6 +16,35 @@
 namespace clang {
 namespace pseudo {
 
+void ForestNode::RecursiveIterator::

[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2022-06-30 Thread Vaibhav Yenamandra via Phabricator via cfe-commits
vaibhav.y added a comment.

In D109701#3622983 , @aaron.ballman 
wrote:

> I had to roll it back because of failures with test bots:
>
> https://lab.llvm.org/buildbot/#/builders/91/builds/11328
>
> So this was reverted in b46ad1b5be694feefabd4c6cd112cbbd04a7b3a7 
> , can 
> you take a look when you get the chance?

Odd! I'll try to reproduce that at the earliest.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

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


[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2022-06-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I had to roll it back because of failures with test bots:

https://lab.llvm.org/buildbot/#/builders/91/builds/11328

So this was reverted in b46ad1b5be694feefabd4c6cd112cbbd04a7b3a7 
, can you 
take a look when you get the chance?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

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


[clang] b46ad1b - Revert "[clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface"

2022-06-30 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2022-06-30T13:39:47-04:00
New Revision: b46ad1b5be694feefabd4c6cd112cbbd04a7b3a7

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

LOG: Revert "[clang] Emit SARIF Diagnostics: Create 
`clang::SarifDocumentWriter` interface"

This reverts commit 329fae7103d355e728cc326a0a9abef889ccc577.

This should fix failing test bots like:
https://lab.llvm.org/buildbot/#/builders/91/builds/11328

Added: 


Modified: 
clang/lib/Basic/CMakeLists.txt
clang/unittests/Basic/CMakeLists.txt

Removed: 
clang/include/clang/Basic/Sarif.h
clang/lib/Basic/Sarif.cpp
clang/unittests/Basic/SarifTest.cpp



diff  --git a/clang/include/clang/Basic/Sarif.h 
b/clang/include/clang/Basic/Sarif.h
deleted file mode 100644
index 818d78668ff15..0
--- a/clang/include/clang/Basic/Sarif.h
+++ /dev/null
@@ -1,440 +0,0 @@
-//== clang/Basic/Sarif.h - SARIF Diagnostics Object Model ---*- C++ 
-*--==//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-/// \file
-/// Defines clang::SarifDocumentWriter, clang::SarifRule, clang::SarifResult.
-///
-/// The document built can be accessed as a JSON Object.
-/// Several value semantic types are also introduced which represent properties
-/// of the SARIF standard, such as 'artifact', 'result', 'rule'.
-///
-/// A SARIF (Static Analysis Results Interchange Format) document is JSON
-/// document that describes in detail the results of running static analysis
-/// tools on a project. Each (non-trivial) document consists of at least one
-/// "run", which are themselves composed of details such as:
-/// * Tool: The tool that was run
-/// * Rules: The rules applied during the tool run, represented by
-///   \c reportingDescriptor objects in SARIF
-/// * Results: The matches for the rules applied against the project(s) being
-///   evaluated, represented by \c result objects in SARIF
-///
-/// Reference:
-/// 1. https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html";>The
 SARIF standard
-/// 2. https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317836";>SARIFreportingDescriptor
-/// 3. https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317638";>SARIFresult
-//===--===//
-
-#ifndef LLVM_CLANG_BASIC_SARIF_H
-#define LLVM_CLANG_BASIC_SARIF_H
-
-#include "clang/Basic/SourceLocation.h"
-#include "clang/Basic/Version.h"
-#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/StringMap.h"
-#include "llvm/ADT/StringRef.h"
-#include "llvm/Support/JSON.h"
-#include 
-#include 
-#include 
-#include 
-#include 
-
-namespace clang {
-
-class SarifDocumentWriter;
-class SourceManager;
-
-namespace detail {
-
-/// \internal
-/// An artifact location is SARIF's way of describing the complete location
-/// of an artifact encountered during analysis. The \c artifactLocation object
-/// typically consists of a URI, and/or an index to reference the artifact it
-/// locates.
-///
-/// This builder makes an additional assumption: that every artifact 
encountered
-/// by \c clang will be a physical, top-level artifact. Which is why the static
-/// creation method \ref SarifArtifactLocation::create takes a mandatory URI
-/// parameter. The official standard states that either a \c URI or \c Index
-/// must be available in the object, \c clang picks the \c URI as a reasonable
-/// default, because it intends to deal in physical artifacts for now.
-///
-/// Reference:
-/// 1. https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317427";>artifactLocation
 object
-/// 2. \ref SarifArtifact
-class SarifArtifactLocation {
-private:
-  friend class clang::SarifDocumentWriter;
-
-  llvm::Optional Index;
-  std::string URI;
-
-  SarifArtifactLocation() = delete;
-  explicit SarifArtifactLocation(const std::string &URI) : URI(URI) {}
-
-public:
-  static SarifArtifactLocation create(llvm::StringRef URI) {
-return SarifArtifactLocation{URI.str()};
-  }
-
-  SarifArtifactLocation setIndex(uint32_t Idx) {
-Index = Idx;
-return *this;
-  }
-};
-
-/// \internal
-/// An artifact in SARIF is any object (a sequence of bytes) addressable by
-/// a URI (RFC 3986). The most common type of artifact for clang's use-case
-/// would be source files. SARIF's artifact object is described in detail in
-/// section 3.24.
-//
-/// Since every clang artifact MUST have a location (there being no nested
-/// artifac

[PATCH] D127807: [clang-tidy] Properly forward clang-tidy output when running tests

2022-06-30 Thread Nicolas van Kempen via Phabricator via cfe-commits
nicovank added a reviewer: serge-sans-paille.
nicovank added a comment.

Did some digging, looks like this was added in rG7f92a1a84b96 
, most 
likely to also fix that CI build error with `misc-misleading-identifier`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127807

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


[clang] 329fae7 - [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2022-06-30 Thread Aaron Ballman via cfe-commits

Author: Vaibhav Yenamandra
Date: 2022-06-30T13:23:15-04:00
New Revision: 329fae7103d355e728cc326a0a9abef889ccc577

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

LOG: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` 
interface

Create an interface for writing SARIF documents from within clang:

The primary intent of this change is to introduce the interface
clang::SarifDocumentWriter, which allows incrementally adding
diagnostic data to a JSON backed document. The proposed interface is
not yet connected to the compiler internals, which will be covered in
future work. As such this change will not change the input/output
interface of clang.

This change also introduces the clang::FullSourceRange type that is
modeled after clang::SourceRange + clang::FullSourceLoc, this is useful
for packaging a pair of clang::SourceLocation objects with their
corresponding SourceManagers.

Previous discussions:

RFC for this change: 
https://lists.llvm.org/pipermail/cfe-dev/2021-March/067907.html
https://lists.llvm.org/pipermail/cfe-dev/2021-July/068480.html
SARIF Standard (2.1.0):

https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html

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

Added: 
clang/include/clang/Basic/Sarif.h
clang/lib/Basic/Sarif.cpp
clang/unittests/Basic/SarifTest.cpp

Modified: 
clang/lib/Basic/CMakeLists.txt
clang/unittests/Basic/CMakeLists.txt

Removed: 




diff  --git a/clang/include/clang/Basic/Sarif.h 
b/clang/include/clang/Basic/Sarif.h
new file mode 100644
index ..818d78668ff1
--- /dev/null
+++ b/clang/include/clang/Basic/Sarif.h
@@ -0,0 +1,440 @@
+//== clang/Basic/Sarif.h - SARIF Diagnostics Object Model ---*- C++ 
-*--==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+/// \file
+/// Defines clang::SarifDocumentWriter, clang::SarifRule, clang::SarifResult.
+///
+/// The document built can be accessed as a JSON Object.
+/// Several value semantic types are also introduced which represent properties
+/// of the SARIF standard, such as 'artifact', 'result', 'rule'.
+///
+/// A SARIF (Static Analysis Results Interchange Format) document is JSON
+/// document that describes in detail the results of running static analysis
+/// tools on a project. Each (non-trivial) document consists of at least one
+/// "run", which are themselves composed of details such as:
+/// * Tool: The tool that was run
+/// * Rules: The rules applied during the tool run, represented by
+///   \c reportingDescriptor objects in SARIF
+/// * Results: The matches for the rules applied against the project(s) being
+///   evaluated, represented by \c result objects in SARIF
+///
+/// Reference:
+/// 1. https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html";>The
 SARIF standard
+/// 2. https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317836";>SARIFreportingDescriptor
+/// 3. https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317638";>SARIFresult
+//===--===//
+
+#ifndef LLVM_CLANG_BASIC_SARIF_H
+#define LLVM_CLANG_BASIC_SARIF_H
+
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/Version.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/JSON.h"
+#include 
+#include 
+#include 
+#include 
+#include 
+
+namespace clang {
+
+class SarifDocumentWriter;
+class SourceManager;
+
+namespace detail {
+
+/// \internal
+/// An artifact location is SARIF's way of describing the complete location
+/// of an artifact encountered during analysis. The \c artifactLocation object
+/// typically consists of a URI, and/or an index to reference the artifact it
+/// locates.
+///
+/// This builder makes an additional assumption: that every artifact 
encountered
+/// by \c clang will be a physical, top-level artifact. Which is why the static
+/// creation method \ref SarifArtifactLocation::create takes a mandatory URI
+/// parameter. The official standard states that either a \c URI or \c Index
+/// must be available in the object, \c clang picks the \c URI as a reasonable
+/// default, because it intends to deal in physical artifacts for now.
+///
+/// Reference:
+/// 1. https://docs.oasis-open.org/sarif/sarif/v2.1.0/os/sarif-v2.1.0-os.html#_Toc34317427";>artifactLocation
 object
+/// 2. \ref SarifArtifact
+class SarifAr

[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

2022-06-30 Thread Aaron Ballman 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 rG329fae7103d3: [clang] Emit SARIF Diagnostics: Create 
`clang::SarifDocumentWriter` interface (authored by vaibhav.y, committed by 
aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

Files:
  clang/include/clang/Basic/Sarif.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/Sarif.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/SarifTest.cpp

Index: clang/unittests/Basic/SarifTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/SarifTest.cpp
@@ -0,0 +1,320 @@
+//===- unittests/Basic/SarifTest.cpp - Test writing SARIF documents ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/Sarif.h"
+#include "clang/Basic/DiagnosticIDs.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include "clang/Basic/FileManager.h"
+#include "clang/Basic/FileSystemOptions.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/JSON.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/VirtualFileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest-death-test.h"
+#include "gtest/gtest-matchers.h"
+#include "gtest/gtest.h"
+
+#include 
+
+using namespace clang;
+
+namespace {
+
+using LineCol = std::pair;
+
+static std::string serializeSarifDocument(llvm::json::Object &&Doc) {
+  std::string Output;
+  llvm::json::Value value(std::move(Doc));
+  llvm::raw_string_ostream OS{Output};
+  OS << llvm::formatv("{0}", value);
+  OS.flush();
+  return Output;
+}
+
+class SarifDocumentWriterTest : public ::testing::Test {
+protected:
+  SarifDocumentWriterTest()
+  : InMemoryFileSystem(new llvm::vfs::InMemoryFileSystem),
+FileMgr(FileSystemOptions(), InMemoryFileSystem),
+DiagID(new DiagnosticIDs()), DiagOpts(new DiagnosticOptions()),
+Diags(DiagID, DiagOpts.get(), new IgnoringDiagConsumer()),
+SourceMgr(Diags, FileMgr) {}
+
+  IntrusiveRefCntPtr InMemoryFileSystem;
+  FileManager FileMgr;
+  IntrusiveRefCntPtr DiagID;
+  IntrusiveRefCntPtr DiagOpts;
+  DiagnosticsEngine Diags;
+  SourceManager SourceMgr;
+  LangOptions LangOpts;
+
+  FileID registerSource(llvm::StringRef Name, const char *SourceText,
+bool IsMainFile = false) {
+std::unique_ptr SourceBuf =
+llvm::MemoryBuffer::getMemBuffer(SourceText);
+const FileEntry *SourceFile =
+FileMgr.getVirtualFile(Name, SourceBuf->getBufferSize(), 0);
+SourceMgr.overrideFileContents(SourceFile, std::move(SourceBuf));
+FileID FID = SourceMgr.getOrCreateFileID(SourceFile, SrcMgr::C_User);
+if (IsMainFile)
+  SourceMgr.setMainFileID(FID);
+return FID;
+  }
+
+  CharSourceRange getFakeCharSourceRange(FileID FID, LineCol Begin,
+ LineCol End) {
+auto BeginLoc = SourceMgr.translateLineCol(FID, Begin.first, Begin.second);
+auto EndLoc = SourceMgr.translateLineCol(FID, End.first, End.second);
+return CharSourceRange{SourceRange{BeginLoc, EndLoc}, /* ITR = */ false};
+  }
+};
+
+TEST_F(SarifDocumentWriterTest, createEmptyDocument) {
+  // GIVEN:
+  SarifDocumentWriter Writer{SourceMgr};
+
+  // WHEN:
+  const llvm::json::Object &EmptyDoc = Writer.createDocument();
+  std::vector Keys(EmptyDoc.size());
+  std::transform(EmptyDoc.begin(), EmptyDoc.end(), Keys.begin(),
+ [](auto item) { return item.getFirst(); });
+
+  // THEN:
+  ASSERT_THAT(Keys, testing::UnorderedElementsAre("$schema", "version"));
+}
+
+// Test that a newly inserted run will associate correct tool names
+TEST_F(SarifDocumentWriterTest, documentWithARun) {
+  // GIVEN:
+  SarifDocumentWriter Writer{SourceMgr};
+  const char *ShortName = "sariftest";
+  const char *LongName = "sarif writer test";
+
+  // WHEN:
+  Writer.createRun(ShortName, LongName);
+  Writer.endRun();
+  const llvm::json::Object &Doc = Writer.createDocument();
+  const llvm::json::Array *Runs = Doc.getArray("runs");
+
+  // THEN:
+  // A run was created
+  ASSERT_THAT(Runs, testing::NotNull());
+
+  // It is the only run
+  ASSERT_EQ(Runs->size(), 1UL);
+
+  // The tool associated with the run was the tool
+  const llvm::json::Object *driver =
+  Runs->begin()->getAsObject()->getObject("tool")->getObject("driver");
+  ASSERT_THAT(driver, testing::NotNull());
+
+  ASSERT_TRUE(

[PATCH] D128844: Improve the formatting of static_assert messages

2022-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 441448.
cor3ntin added a comment.

Missing -re in a few places


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp
  
libcxx/test/libcxx/input.output/file.streams/fstreams/filebuf/traits_mismatch.fail.cpp
  libcxx/test/libcxx/input.output/file.streams/fstreams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/input.output/iostream.format/input.streams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/input.output/iostream.format/output.streams/traits_mismatch.fail.cpp
  libcxx/test/libcxx/input.output/string.streams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/iterators/predef.iterators/reverse.iterators/bad_template_argument.verify.cpp
  
libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp
  
libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/pair.tuple_element.fail.cpp
  
libcxx/test/libcxx/utilities/variant/variant.variant/variant.helper/variant_alternative.fail.cpp
  
libcxx/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.fail.cpp
  
libcxx/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp
  libcxx/test/std/containers/associative/map/map.cons/deduct.fail.cpp
  libcxx/test/std/containers/associative/multimap/multimap.cons/deduct.fail.cpp
  libcxx/test/std/containers/sequences/array/array.fill/fill.fail.cpp
  libcxx/test/std/containers/sequences/array/array.swap/swap.fail.cpp
  libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
  libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp
  
libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
  libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
  
libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp
  
libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
  libcxx/test/std/numerics/numbers/illformed.verify.cpp
  libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/params.fail.cpp
  libcxx/test/std/strings/basic.string/char.bad.verify.cpp
  libcxx/test/std/strings/string.view/char.bad.fail.cpp
  libcxx/test/std/time/time.hms/hhmmss.fail.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.verify.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.verify.cpp
  libcxx/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp
  libcxx/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ctor.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp
  libcxx/test/std/utilities/optional/optional.syn/optional_in_place_t.fail.cpp
  libcxx/test/std/utilities/utility/forward/forward.fail.cpp
  libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp

Index: libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
===
--- libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
+++ libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
@@ -75,7 +75,7 @@
   using V = std::variant;
   V v1(42);
   V v2(101);
-  // expected-error-re@variant:* 6 {{static_assert failed {{.*}}"the relational operator does not return a type which is implicitly convertible to bool"}}
+  // expected-error-re@variant:* 6 {{static_assert failed{{.*}}the relational operator does not return a type which is implicitly convertible to bool}}
   // expected-error@variant:* 6 {{no viable conversion}}
   (void)(

[PATCH] D128844: Improve the formatting of static_assert messages

2022-06-30 Thread Mark de Wever via Phabricator via cfe-commits
Mordante accepted this revision.
Mordante added a comment.

In D128844#360 , @aaron.ballman 
wrote:

> So I *think* this LG, but am not certain what will happen when you land it. I 
> think the precommit CI failures are not failures that will happen when 
> testing against the just-built clang.

Most Linux runner use the apt.llvm.org nightly builds and are updated on an 
irregular interval. The Bootstrapping build will use the just-built Clang. So 
when the CI is green all should be fine.

I wanted to suggest a regex, but I see the latest patch already does that.

Thanks for improving the readability of the diagnostics! LGTM when the CI 
passes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

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


[PATCH] D109701: [clang] Emit SARIF Diagnostics: Create `clang::SarifDocumentWriter` interface

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

LGTM! Thank you for the fixes to this! I'll land this again on your behalf with 
the same information as before.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109701

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


[PATCH] D121141: [Clang] Add `-funstable` flag to enable unstable and experimental features: follow-up fixes

2022-06-30 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

Thanks @egorzhdan for working on this, I seem to have overlooked this item in 
the review queue.
SGMT, but it seems the libc++ CI hasn't been triggered with this change. Maybe 
change one file in libc++ to give the CI a spin?




Comment at: clang/docs/ClangCommandLineReference.rst:278
+
+This option enables various language and library features that are either 
experimental (also known as TSes), or have been standardized but are not stable 
yet. This option should not be used in production code, since neither ABI nor 
API stability are guaranteed.
+

I'm not happy with the word "should", I don't want to decide what users should 
or should not do. Several of these experimental features are perfectly usable. 
If you can rebuild your entire software stack ABI and API stability might be 
less of an issue. (The lack of polish of some features might be a reason not to 
use them.)



Comment at: clang/include/clang/Driver/Options.td:1167
+  "This option enables various language and library features that are 
either experimental (also known as TSes),"
+  " or have been standardized but are not stable yet. This option 
should not be used in production code, since "
+  "neither ABI nor API stability are guaranteed">,

Likewise regarding should.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121141

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


[PATCH] D103096: [analyzer] Implement cast for ranges of symbolic integers

2022-06-30 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D103096#3613059 , @ASDenysPetrov 
wrote:

> @martong Just FYI. I've been working on reworking this solution to using 
> `EquivalenceClasses` for several weeks. It turned out that this is an 
> extremely hard task to acomplish. There're a lot of cast cases like: 
> `(int8)x==y, (uint16)a==(int64)b, (uint8)y == b`, Merging and inferring all 
> of this without going beyond the complexity O(n) is really tricky.

Please elaborate. I don't see how is it different than merging and inferring 
without the handling of casts. My understanding is that, we have more symbols 
(additional `SymbolCast`s) indeed. But, the merging algorithm should not change 
at all, that should be agnostic to the actual symbol kind (whether that is a 
`SymbolCast` or a `SymbolData` or a `SymSymEpxr`).
The infer algorithm might be different though, but there I think the original 
algorithm you delved for `SymExpr`s should work as well for 
`EquivalenceClass`es.




Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:1289-1291
+  auto It = llvm::find_if(*CM, [MinBitWidth](CastMap::value_type &Item) {
+return Item.first >= MinBitWidth;
+  });

ASDenysPetrov wrote:
> martong wrote:
> > There might be a problem here because the iteration of the map is 
> > non-deterministic. We should probably have a copy that is sorted, or the 
> > container should be sorted (sorted immutable list maybe?).
> > 
> > Your tests below passed probably because the cast chains are too small. 
> > Could you please have a test, where the chain is really long (20 maybe) and 
> > shuffled.
> > (My thanks for @steakhal for this additional comment.)
> I've checked. `ImmutableSet` gave me a sorted order. But I agree that it 
> could be just a coincidence. I'll try to add more tests.
Yes, your are right, and I was wrong. `ImmutableSet` is based on an AVL tree, 
which is a balanced binary tree and the `begin()` gives such an iterator that 
conducts an inorder - thus sorted - traversal. And the key is an integer. (I 
don't know now how, but we were mislead, @steakhal too. I guess, we thought 
that the key of `CastMap` is a pointer.)



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:2300-2303
+for (auto &Item : *CM) {
+  // Stop after reaching a bigger bitwidth.
+  if (Item.first > MinBitWidth)
+break;

martong wrote:
> Same here.
Please disregard the comment above.


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

https://reviews.llvm.org/D103096

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


[PATCH] D128844: Improve the formatting of static_assert messages

2022-06-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 441439.
cor3ntin added a comment.

Pushing for CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128844

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_add_explicit.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub.verify.cpp
  
libcxx/test/libcxx/atomics/atomics.types.operations/atomics.types.operations.req/atomic_fetch_sub_explicit.verify.cpp
  
libcxx/test/libcxx/input.output/file.streams/fstreams/filebuf/traits_mismatch.fail.cpp
  libcxx/test/libcxx/input.output/file.streams/fstreams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/input.output/iostream.format/input.streams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/input.output/iostream.format/output.streams/traits_mismatch.fail.cpp
  libcxx/test/libcxx/input.output/string.streams/traits_mismatch.fail.cpp
  
libcxx/test/libcxx/iterators/predef.iterators/reverse.iterators/bad_template_argument.verify.cpp
  
libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.cnstr/PR20855_tuple_ref_binding_diagnostics.fail.cpp
  
libcxx/test/libcxx/utilities/utility/pairs/pairs.pair/pair.tuple_element.fail.cpp
  
libcxx/test/libcxx/utilities/variant/variant.variant/variant.helper/variant_alternative.fail.cpp
  
libcxx/test/std/algorithms/alg.modifying.operations/alg.random.sample/sample.fail.cpp
  
libcxx/test/std/algorithms/alg.sorting/alg.min.max/requires_forward_iterator.fail.cpp
  libcxx/test/std/containers/associative/map/map.cons/deduct.fail.cpp
  libcxx/test/std/containers/associative/multimap/multimap.cons/deduct.fail.cpp
  libcxx/test/std/containers/sequences/array/array.fill/fill.fail.cpp
  libcxx/test/std/containers/sequences/array/array.swap/swap.fail.cpp
  libcxx/test/std/containers/sequences/array/array.tuple/get.fail.cpp
  libcxx/test/std/containers/sequences/array/array.tuple/tuple_element.fail.cpp
  
libcxx/test/std/containers/sequences/vector/vector.modifiers/resize_not_move_insertable.fail.cpp
  libcxx/test/std/containers/views/views.span/span.sub/subspan.verify.cpp
  
libcxx/test/std/experimental/language.support/support.coroutines/coroutine.handle/coroutine.handle.export/from_address.fail.cpp
  
libcxx/test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
  libcxx/test/std/numerics/numbers/illformed.verify.cpp
  libcxx/test/std/numerics/rand/rand.eng/rand.eng.lcong/params.fail.cpp
  libcxx/test/std/strings/basic.string/char.bad.verify.cpp
  libcxx/test/std/strings/string.view/char.bad.fail.cpp
  libcxx/test/std/time/time.hms/hhmmss.fail.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/any_cast_request_invalid_value_category.fail.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/const_correctness.verify.cpp
  
libcxx/test/std/utilities/any/any.nonmembers/any.cast/not_copy_constructible.verify.cpp
  libcxx/test/std/utilities/any/any.nonmembers/any.cast/reference_types.fail.cpp
  libcxx/test/std/utilities/intseq/intseq.make/make_integer_seq.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/ctor.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.fail.cpp
  
libcxx/test/std/utilities/optional/optional.object/optional_requires_destructible_object.fail.cpp
  libcxx/test/std/utilities/optional/optional.syn/optional_in_place_t.fail.cpp
  libcxx/test/std/utilities/utility/forward/forward.fail.cpp
  libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp

Index: libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
===
--- libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
+++ libcxx/test/std/utilities/variant/variant.relops/relops_bool_conv.fail.cpp
@@ -75,7 +75,7 @@
   using V = std::variant;
   V v1(42);
   V v2(101);
-  // expected-error-re@variant:* 6 {{static_assert failed {{.*}}"the relational operator does not return a type which is implicitly convertible to bool"}}
+  // expected-error-re@variant:* 6 {{static_assert failed{{.*}}the relational operator does not return a type which is implicitly convertible to bool}}
   // expected-error@variant:* 6 {{no viable conversion}}
   (void)(v1 == v2); //

[PATCH] D128927: [libc++] Always build c++experimental.a

2022-06-30 Thread Mark de Wever via Phabricator via cfe-commits
Mordante accepted this revision.
Mordante added a comment.
This revision is now accepted and ready to land.

Thanks for working on this! LGTM with some suggestions.




Comment at: libcxx/docs/ReleaseNotes.rst:226
+  experimental features provided by it. Note that vendors are encouraged to 
ship the
+  experimental library now that the compiler provides an ergonomic way to use 
it.

I agree this is a build system change, but I wonder how many users read this 
part and find the hidden gem.
Should we add a note at new features too? Maybe there we can mention format and 
ranges are available with this new switch.
(technically that actually belongs in the next patch, but I wouldn't mind to do 
it in this patch.)



Comment at: libcxx/docs/UsingLibcxx.rst:42
+default because they are neither API nor ABI stable. However, the Clang flag 
``-funstable``
+can be used to turn those features on.
 

I think it would be good to explain what experimental features are. The current 
wording makes it sound the features may not be part of an IS, WP, or TS.

How about something like
```
Libc++ provides implementations of some experimental features. Experimental 
features
are either a TS or a feature in the Standard whose implementation is 
incomplete. Those
features are disabled by default because they are neither API nor ABI stable. 
However,
the Clang flag ``-funstable`` can be used to turn those features on.
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2022-06-30 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: clang/include/clang/Basic/TokenKinds.def:911
 
+// Annotation for the riscv pragma directives - #pragma clang riscv intrinsic 
..
+PRAGMA_ANNOTATION(pragma_riscv)

Why only 2 periods at the end. Should be 3 like on like 908 or in the middle of 
line 903



Comment at: clang/include/clang/Sema/Sema.h:1590
 
+  /// Indicate RVV builtin funtions enabled or not.
+  bool DeclareRVVBuiltins = false;

funtion -> functions



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:110
   }
+  bool operator==(const PrototypeDescriptor &PD) const {
+return !(*this != PD);

I think it's more conventional to define operator== as `PD.PT == PT && PD.VTM 
== VTM && PD.TM == TM` and operator!= as `!(*this == PD)`



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:114
   bool operator>(const PrototypeDescriptor &PD) const {
-return !(PD.PT <= PT && PD.VTM <= VTM && PD.TM <= TM);
+if (PD.PT != PT)
+  return PD.PT > PT;

This can be written as

`return std::tie(PD.PT, PD.VTM, PD.TM) > std::tie(PT, VTM, TM);`

Though it's still surprising that PD is on the left. This is operator> but the 
implementation looks more like operator<.



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:364
+
+  // Overloaded intrinsic name, could be empty if can be computed from Name
+  // e.g. vadd

"if can" -> "if it can"



Comment at: clang/include/clang/Support/RISCVVIntrinsicUtils.h:395
+
+  // Supported type, mask of BasicType
+  uint8_t TypeRangeMask;

Missing period at end of comment.



Comment at: clang/lib/Parse/ParsePragma.cpp:3960
+  IdentifierInfo *II = Tok.getIdentifierInfo();
+  if (!II || (!II->isStr("intrinsic"))) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)

Drop parenthese arounds `(!II->isStr("intrinsic"))`



Comment at: clang/lib/Parse/ParsePragma.cpp:3968
+  II = Tok.getIdentifierInfo();
+  if (!II || (!II->isStr("vector"))) {
+PP.Diag(Tok.getLocation(), diag::warn_pragma_invalid_argument)

Drop parentheses around `(!II->isStr("vector"))`



Comment at: clang/lib/Sema/CMakeLists.txt:49
   SemaLookup.cpp
+  SemaRISCVVectorLookup.cpp
   SemaModule.cpp

These are supposed to be in alphabetical order



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:68
+   uint8_t Length) {
+  return ArrayRef(&RVVSignatureTable[Index], Length);
+}

Can this use makeArrayRef?



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:117
+
+  if (Type->isConstant()) {
+QT = Context.getConstType(QT);

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:122
+  // Transform the type to a pointer as the last step, if necessary.
+  if (Type->isPointer()) {
+QT = Context.getPointerType(QT);

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:262
+
+  if (IsMask) {
+Name += "_m";

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:277
+  std::string BuiltinName = "__builtin_rvv_" + std::string(Record.Name);
+  if (IsMask) {
+BuiltinName += "_m";

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:311
+  // Skip return type, and convert RVVType to QualType for arguments.
+  for (size_t i = 1; i < SigLength; ++i) {
+ArgTypes.push_back(RVVType2Qual(Context, Sigs[i]));

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:364
+auto OvIntrinsicDef = OvIItr->second;
+for (auto Index : OvIntrinsicDef.Indexs) {
+  CreateRVVIntrinsicDecl(S, LR, II, PP, Index,

Drop curly braces



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:382
+
+  // It's not RVV intrinsics.
+  return false;

"It's not an RVV intrinsic."



Comment at: clang/lib/Sema/SemaRISCVVectorLookup.cpp:389
+   Preprocessor &PP) {
+  static std::unique_ptr IntrinsicManager =
+  std::make_unique(S.Context);

Should this be a member of Sema instead of a function static? 
RVVIntrinsicManager holds a reference to ASTContext but will outlive it.



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:76
+
+  // Create compressed hsignature table from SemaRecords.
+  void init(const std::vector &SemaRecords);

Is `hsignature` a typo?



Comment at: clang/utils/TableGen/RISCVVEmitter.cpp:582
+  BasicType TypeRangeMask = BasicType::Unknown

[PATCH] D128927: [libc++] Always build c++experimental.a

2022-06-30 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a subscriber: mstorsjo.
ldionne added a comment.

@mstorsjo I might need some assistance figuring out what to do with the Windows 
parts of this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128927

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


  1   2   >