[clang] ee57212 - [C++20] [Modules] Use '-' as the separator of partitions when searching

2022-03-30 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-03-31T11:21:58+08:00
New Revision: ee572129ae15bc15e34fcae63643d6998352dab3

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

LOG: [C++20] [Modules] Use '-' as the separator of partitions when searching
in filesystems

It is simpler to search for module unit by -fprebuilt-module-path
option. However, the separator ':' of partitions is not friendly.
According to the discussion in https://reviews.llvm.org/D118586, I think
we get consensus to use '-' as the separator instead. The '-' is the
choice of GCC too.

Previously I thought it would be better to add an option. But I feel it
is over-engineering now. Another reason here is that there are too many
options for modules (for clang module mainly) now. Given it is not bad
to use '-' when searching, I think it is acceptable to not add an
option.

Reviewed By: iains

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

Added: 
clang/test/Modules/search-partitions.cpp

Modified: 
clang/lib/Lex/HeaderSearch.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index 082e62da124f1..d16b9a52bff63 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -194,10 +194,19 @@ std::string 
HeaderSearch::getPrebuiltModuleFileName(StringRef ModuleName,
   for (const std::string  : HSOpts->PrebuiltModulePaths) {
 SmallString<256> Result(Dir);
 llvm::sys::fs::make_absolute(Result);
-llvm::sys::path::append(Result, ModuleName + ".pcm");
+if (ModuleName.contains(':'))
+  // The separator of C++20 modules partitions (':') is not good for file
+  // systems, here clang and gcc choose '-' by default since it is not a
+  // valid character of C++ indentifiers. So we could avoid conflicts.
+  llvm::sys::path::append(Result, ModuleName.split(':').first + "-" +
+  ModuleName.split(':').second +
+  ".pcm");
+else
+  llvm::sys::path::append(Result, ModuleName + ".pcm");
 if (getFileMgr().getFile(Result.str()))
   return std::string(Result);
   }
+
   return {};
 }
 

diff  --git a/clang/test/Modules/search-partitions.cpp 
b/clang/test/Modules/search-partitions.cpp
new file mode 100644
index 0..571160def7e9b
--- /dev/null
+++ b/clang/test/Modules/search-partitions.cpp
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition1.cpp \
+// RUN:  -o %t/A-Part1.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition2.cpp \
+// RUN:  -o %t/A-Part2.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition3.cpp \
+// RUN:  -o %t/A-Part3.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/moduleA.cpp \
+// RUN:  -fprebuilt-module-path=%t
+
+// expected-no-diagnostics
+
+//--- partition1.cpp
+export module A:Part1;
+
+int part1();
+
+//--- partition2.cpp
+
+export module A:Part2;
+
+int part2();
+
+//--- partition3.cpp
+
+export module A:Part3;
+
+int part3();
+
+//--- moduleA.cpp
+
+export module A;
+
+import :Part1;
+export import :Part2;
+import :Part3;
+
+int foo();



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


[PATCH] D120874: [C++20] [Modules] Use '-' as the separator of partitions when searching in filesystems

2022-03-30 Thread Chuanqi Xu 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 rGee572129ae15: [C++20] [Modules] Use - as the 
separator of partitions when searching (authored by ChuanqiXu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120874

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/search-partitions.cpp


Index: clang/test/Modules/search-partitions.cpp
===
--- /dev/null
+++ clang/test/Modules/search-partitions.cpp
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition1.cpp \
+// RUN:  -o %t/A-Part1.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition2.cpp \
+// RUN:  -o %t/A-Part2.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition3.cpp \
+// RUN:  -o %t/A-Part3.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/moduleA.cpp \
+// RUN:  -fprebuilt-module-path=%t
+
+// expected-no-diagnostics
+
+//--- partition1.cpp
+export module A:Part1;
+
+int part1();
+
+//--- partition2.cpp
+
+export module A:Part2;
+
+int part2();
+
+//--- partition3.cpp
+
+export module A:Part3;
+
+int part3();
+
+//--- moduleA.cpp
+
+export module A;
+
+import :Part1;
+export import :Part2;
+import :Part3;
+
+int foo();
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -194,10 +194,19 @@
   for (const std::string  : HSOpts->PrebuiltModulePaths) {
 SmallString<256> Result(Dir);
 llvm::sys::fs::make_absolute(Result);
-llvm::sys::path::append(Result, ModuleName + ".pcm");
+if (ModuleName.contains(':'))
+  // The separator of C++20 modules partitions (':') is not good for file
+  // systems, here clang and gcc choose '-' by default since it is not a
+  // valid character of C++ indentifiers. So we could avoid conflicts.
+  llvm::sys::path::append(Result, ModuleName.split(':').first + "-" +
+  ModuleName.split(':').second +
+  ".pcm");
+else
+  llvm::sys::path::append(Result, ModuleName + ".pcm");
 if (getFileMgr().getFile(Result.str()))
   return std::string(Result);
   }
+
   return {};
 }
 


Index: clang/test/Modules/search-partitions.cpp
===
--- /dev/null
+++ clang/test/Modules/search-partitions.cpp
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition1.cpp \
+// RUN:  -o %t/A-Part1.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition2.cpp \
+// RUN:  -o %t/A-Part2.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition3.cpp \
+// RUN:  -o %t/A-Part3.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/moduleA.cpp \
+// RUN:  -fprebuilt-module-path=%t
+
+// expected-no-diagnostics
+
+//--- partition1.cpp
+export module A:Part1;
+
+int part1();
+
+//--- partition2.cpp
+
+export module A:Part2;
+
+int part2();
+
+//--- partition3.cpp
+
+export module A:Part3;
+
+int part3();
+
+//--- moduleA.cpp
+
+export module A;
+
+import :Part1;
+export import :Part2;
+import :Part3;
+
+int foo();
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -194,10 +194,19 @@
   for (const std::string  : HSOpts->PrebuiltModulePaths) {
 SmallString<256> Result(Dir);
 llvm::sys::fs::make_absolute(Result);
-llvm::sys::path::append(Result, ModuleName + ".pcm");
+if (ModuleName.contains(':'))
+  // The separator of C++20 modules partitions (':') is not good for file
+  // systems, here clang and gcc choose '-' by default since it is not a
+  // valid character of C++ indentifiers. So we could avoid conflicts.
+  llvm::sys::path::append(Result, ModuleName.split(':').first + "-" +
+  ModuleName.split(':').second +
+  ".pcm");
+else
+  llvm::sys::path::append(Result, ModuleName + ".pcm");
 if (getFileMgr().getFile(Result.str()))
   return std::string(Result);
   }
+
   return {};
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D121271: [C++20] [Modules] Don't generate strong function of a partition in importing modules

2022-03-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 419325.
ChuanqiXu added a comment.

Rebase


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

https://reviews.llvm.org/D121271

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CodeGenCXX/partitions.cpp

Index: clang/test/CodeGenCXX/partitions.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/partitions.cpp
@@ -0,0 +1,50 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/parta.cppm -o %t/mod-parta.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partb.cppm -o %t/mod-partb.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=%t/mod-parta.pcm \
+// RUN: -fmodule-file=%t/mod-partb.pcm %t/mod.cppm -o %t/mod.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm -disable-llvm-passes -o - \
+// RUN: | FileCheck %t/mod.cppm
+// RUN: %clang_cc1 -std=c++20 -O2 -emit-module-interface -fmodule-file=%t/mod-parta.pcm \
+// RUN: -fmodule-file=%t/mod-partb.pcm %t/mod.cppm -o %t/mod.pcm
+// RUN: %clang_cc1 -std=c++20 -O2 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm -disable-llvm-passes -o - \
+// RUN: | FileCheck %t/mod.cppm  -check-prefix=CHECK-OPT
+
+//--- parta.cppm
+export module mod:parta;
+
+export int a = 43;
+
+export int foo() {
+  return 3 + a;
+}
+
+//--- partb.cppm
+module mod:partb;
+
+int b = 43;
+
+int bar() {
+  return 43 + b;
+}
+
+//--- mod.cppm
+export module mod;
+import :parta;
+import :partb;
+export int use() {
+  return foo() + bar() + a + b;
+}
+
+// CHECK: @_ZW3mod1a = available_externally global
+// CHECK: @_ZW3mod1b = available_externally global
+// CHECK: declare{{.*}} i32 @_ZW3mod3foov
+// CHECK: declare{{.*}} i32 @_ZW3mod3barv
+
+// CHECK-OPT: @_ZW3mod1a = available_externally global
+// CHECK-OPT: @_ZW3mod1b = available_externally global
+// CHECK-OPT: define available_externally{{.*}} i32 @_ZW3mod3foov
+// CHECK-OPT: define available_externally{{.*}} i32 @_ZW3mod3barv
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1029,12 +1029,12 @@
 if (Writer.WritingModule &&
 !D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
 !isa(D)) {
-  // When building a C++ Modules TS module interface unit, a strong
-  // definition in the module interface is provided by the compilation of
-  // that module interface unit, not by its users. (Inline variables are
-  // still emitted in module users.)
+  // When building a C++20 module interface unit or a partition unit, a
+  // strong definition in the module interface is provided by the
+  // compilation of that unit, not by its users. (Inline variables are still
+  // emitted in module users.)
   ModulesCodegen =
-  (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit ||
+  (Writer.WritingModule->isInterfaceOrPartition() ||
(D->hasAttr() &&
 Writer.Context->getLangOpts().BuildingPCHWithObjectFile)) &&
   Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal;
@@ -2470,11 +2470,11 @@
   if (!FD->isDependentContext()) {
 Optional Linkage;
 if (Writer->WritingModule &&
-Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
-  // When building a C++ Modules TS module interface unit, a strong
-  // definition in the module interface is provided by the compilation of
-  // that module interface unit, not by its users. (Inline functions are
-  // still emitted in module users.)
+Writer->WritingModule->isInterfaceOrPartition()) {
+  // When building a C++20 module interface unit or a partition unit, a
+  // strong definition in the module interface is provided by the
+  // compilation of that unit, not by its users. (Inline functions are still
+  // emitted in module users.)
   Linkage = Writer->Context->GetGVALinkageForFunction(FD);
   ModulesCodegen = *Linkage == GVA_StrongExternal;
 }
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -529,6 +529,10 @@
 
   /// Is this module a header unit.
   bool isHeaderUnit() const { return Kind == ModuleHeaderUnit; }
+  // Is this a C++20 module interface or a partition.
+  bool isInterfaceOrPartition() const {
+return Kind == ModuleInterfaceUnit || isModulePartition();
+  }
 
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
___
cfe-commits mailing list

[PATCH] D120874: [C++20] [Modules] Use '-' as the separator of partitions when searching in filesystems

2022-03-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 419324.
ChuanqiXu added a comment.

Rebase


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

https://reviews.llvm.org/D120874

Files:
  clang/lib/Lex/HeaderSearch.cpp
  clang/test/Modules/search-partitions.cpp


Index: clang/test/Modules/search-partitions.cpp
===
--- /dev/null
+++ clang/test/Modules/search-partitions.cpp
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition1.cpp \
+// RUN:  -o %t/A-Part1.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition2.cpp \
+// RUN:  -o %t/A-Part2.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition3.cpp \
+// RUN:  -o %t/A-Part3.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/moduleA.cpp \
+// RUN:  -fprebuilt-module-path=%t
+
+// expected-no-diagnostics
+
+//--- partition1.cpp
+export module A:Part1;
+
+int part1();
+
+//--- partition2.cpp
+
+export module A:Part2;
+
+int part2();
+
+//--- partition3.cpp
+
+export module A:Part3;
+
+int part3();
+
+//--- moduleA.cpp
+
+export module A;
+
+import :Part1;
+export import :Part2;
+import :Part3;
+
+int foo();
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -194,10 +194,19 @@
   for (const std::string  : HSOpts->PrebuiltModulePaths) {
 SmallString<256> Result(Dir);
 llvm::sys::fs::make_absolute(Result);
-llvm::sys::path::append(Result, ModuleName + ".pcm");
+if (ModuleName.contains(':'))
+  // The separator of C++20 modules partitions (':') is not good for file
+  // systems, here clang and gcc choose '-' by default since it is not a
+  // valid character of C++ indentifiers. So we could avoid conflicts.
+  llvm::sys::path::append(Result, ModuleName.split(':').first + "-" +
+  ModuleName.split(':').second +
+  ".pcm");
+else
+  llvm::sys::path::append(Result, ModuleName + ".pcm");
 if (getFileMgr().getFile(Result.str()))
   return std::string(Result);
   }
+
   return {};
 }
 


Index: clang/test/Modules/search-partitions.cpp
===
--- /dev/null
+++ clang/test/Modules/search-partitions.cpp
@@ -0,0 +1,44 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition1.cpp \
+// RUN:  -o %t/A-Part1.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition2.cpp \
+// RUN:  -o %t/A-Part2.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partition3.cpp \
+// RUN:  -o %t/A-Part3.pcm
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/moduleA.cpp \
+// RUN:  -fprebuilt-module-path=%t
+
+// expected-no-diagnostics
+
+//--- partition1.cpp
+export module A:Part1;
+
+int part1();
+
+//--- partition2.cpp
+
+export module A:Part2;
+
+int part2();
+
+//--- partition3.cpp
+
+export module A:Part3;
+
+int part3();
+
+//--- moduleA.cpp
+
+export module A;
+
+import :Part1;
+export import :Part2;
+import :Part3;
+
+int foo();
Index: clang/lib/Lex/HeaderSearch.cpp
===
--- clang/lib/Lex/HeaderSearch.cpp
+++ clang/lib/Lex/HeaderSearch.cpp
@@ -194,10 +194,19 @@
   for (const std::string  : HSOpts->PrebuiltModulePaths) {
 SmallString<256> Result(Dir);
 llvm::sys::fs::make_absolute(Result);
-llvm::sys::path::append(Result, ModuleName + ".pcm");
+if (ModuleName.contains(':'))
+  // The separator of C++20 modules partitions (':') is not good for file
+  // systems, here clang and gcc choose '-' by default since it is not a
+  // valid character of C++ indentifiers. So we could avoid conflicts.
+  llvm::sys::path::append(Result, ModuleName.split(':').first + "-" +
+  ModuleName.split(':').second +
+  ".pcm");
+else
+  llvm::sys::path::append(Result, ModuleName + ".pcm");
 if (getFileMgr().getFile(Result.str()))
   return std::string(Result);
   }
+
   return {};
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122781: This patch aims to conform AMDGPUOpenMP driver sanitizer changes w.r.t HIPAMD toolchain.

2022-03-30 Thread Amit Kumar Pandey via Phabricator via cfe-commits
ampandey-AMD updated this revision to Diff 419323.
ampandey-AMD added a comment.

This patch aims to conform AMDGPUOpenMP driver sanitizer changes w.r.t HIPAMD 
toolchain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122781

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/hip-sanitize-options.hip

Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -62,7 +62,7 @@
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-mlink-builtin-bitcode" ".*hip.bc".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
 // RDC-NOT: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 
-// FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
+// FAIL: error: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
 
 // XNACK-DAG: warning: ignoring '-fsanitize=leak' option as it is not currently supported for target 'amdgcn-amd-amdhsa'
 // XNACK-DAG: warning: ignoring '-fsanitize=address' option as it is not currently supported for offload arch 'gfx900:xnack-'. Use it with an offload arch containing 'xnack+' instead
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -35,43 +35,6 @@
 #define NULL_FILE "/dev/null"
 #endif
 
-static bool shouldSkipSanitizeOption(const ToolChain ,
- const llvm::opt::ArgList ,
- StringRef TargetID,
- const llvm::opt::Arg *A) {
-  // For actions without targetID, do nothing.
-  if (TargetID.empty())
-return false;
-  Option O = A->getOption();
-  if (!O.matches(options::OPT_fsanitize_EQ))
-return false;
-
-  if (!DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
-  options::OPT_fno_gpu_sanitize, true))
-return true;
-
-  auto  = TC.getDriver().getDiags();
-
-  // For simplicity, we only allow -fsanitize=address
-  SanitizerMask K = parseSanitizerValue(A->getValue(), /*AllowGroups=*/false);
-  if (K != SanitizerKind::Address)
-return true;
-
-  llvm::StringMap FeatureMap;
-  auto OptionalGpuArch = parseTargetID(TC.getTriple(), TargetID, );
-
-  assert(OptionalGpuArch && "Invalid Target ID");
-  (void)OptionalGpuArch;
-  auto Loc = FeatureMap.find("xnack");
-  if (Loc == FeatureMap.end() || !Loc->second) {
-Diags.Report(
-clang::diag::warn_drv_unsupported_option_for_offload_arch_req_feature)
-<< A->getAsString(DriverArgs) << TargetID << "xnack+";
-return true;
-  }
-  return false;
-}
-
 void AMDGCN::Linker::constructLldCommand(Compilation , const JobAction ,
  const InputInfoList ,
  const InputInfo ,
@@ -337,12 +300,7 @@
 getSanitizerArgs(DriverArgs).needsAsanRt()) {
   auto AsanRTL = RocmInstallation.getAsanRTLPath();
   if (AsanRTL.empty()) {
-unsigned DiagID = getDriver().getDiags().getCustomDiagID(
-DiagnosticsEngine::Error,
-"AMDGPU address sanitizer runtime library (asanrtl) is not found. "
-"Please install ROCm device library which supports address "
-"sanitizer");
-getDriver().Diag(DiagID);
+getDriver().Diag(diag::err_drv_no_asan_rt_lib);
 return {};
   } else
 BCLibs.push_back({AsanRTL.str(), /*ShouldInternalize=*/false});
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
@@ -93,6 +93,10 @@
 
   SanitizerMask getSupportedSanitizers() const override;
 
+  RocmInstallationDetector getRocmInstallationLoc() const {
+return RocmInstallation;
+  }
+
   VersionTuple
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList ) const override;
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -16,6 +16,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"

[PATCH] D120874: [C++20] [Modules] Use '-' as the separator of partitions when searching in filesystems

2022-03-30 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 419322.
ChuanqiXu added a comment.
Herald added a subscriber: dexonsmith.

Rebase


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

https://reviews.llvm.org/D120874

Files:
  clang/include/clang/Basic/Module.h
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CodeGenCXX/partitions.cpp

Index: clang/test/CodeGenCXX/partitions.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/partitions.cpp
@@ -0,0 +1,50 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/parta.cppm -o %t/mod-parta.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/partb.cppm -o %t/mod-partb.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface -fmodule-file=%t/mod-parta.pcm \
+// RUN: -fmodule-file=%t/mod-partb.pcm %t/mod.cppm -o %t/mod.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm -disable-llvm-passes -o - \
+// RUN: | FileCheck %t/mod.cppm
+// RUN: %clang_cc1 -std=c++20 -O2 -emit-module-interface -fmodule-file=%t/mod-parta.pcm \
+// RUN: -fmodule-file=%t/mod-partb.pcm %t/mod.cppm -o %t/mod.pcm
+// RUN: %clang_cc1 -std=c++20 -O2 -triple %itanium_abi_triple %t/mod.pcm -S -emit-llvm -disable-llvm-passes -o - \
+// RUN: | FileCheck %t/mod.cppm  -check-prefix=CHECK-OPT
+
+//--- parta.cppm
+export module mod:parta;
+
+export int a = 43;
+
+export int foo() {
+  return 3 + a;
+}
+
+//--- partb.cppm
+module mod:partb;
+
+int b = 43;
+
+int bar() {
+  return 43 + b;
+}
+
+//--- mod.cppm
+export module mod;
+import :parta;
+import :partb;
+export int use() {
+  return foo() + bar() + a + b;
+}
+
+// CHECK: @_ZW3mod1a = available_externally global
+// CHECK: @_ZW3mod1b = available_externally global
+// CHECK: declare{{.*}} i32 @_ZW3mod3foov
+// CHECK: declare{{.*}} i32 @_ZW3mod3barv
+
+// CHECK-OPT: @_ZW3mod1a = available_externally global
+// CHECK-OPT: @_ZW3mod1b = available_externally global
+// CHECK-OPT: define available_externally{{.*}} i32 @_ZW3mod3foov
+// CHECK-OPT: define available_externally{{.*}} i32 @_ZW3mod3barv
Index: clang/lib/Serialization/ASTWriterDecl.cpp
===
--- clang/lib/Serialization/ASTWriterDecl.cpp
+++ clang/lib/Serialization/ASTWriterDecl.cpp
@@ -1029,12 +1029,12 @@
 if (Writer.WritingModule &&
 !D->getDescribedVarTemplate() && !D->getMemberSpecializationInfo() &&
 !isa(D)) {
-  // When building a C++ Modules TS module interface unit, a strong
-  // definition in the module interface is provided by the compilation of
-  // that module interface unit, not by its users. (Inline variables are
-  // still emitted in module users.)
+  // When building a C++20 module interface unit or a partition unit, a
+  // strong definition in the module interface is provided by the
+  // compilation of that unit, not by its users. (Inline variables are still
+  // emitted in module users.)
   ModulesCodegen =
-  (Writer.WritingModule->Kind == Module::ModuleInterfaceUnit ||
+  (Writer.WritingModule->isInterfaceOrPartition() ||
(D->hasAttr() &&
 Writer.Context->getLangOpts().BuildingPCHWithObjectFile)) &&
   Writer.Context->GetGVALinkageForVariable(D) == GVA_StrongExternal;
@@ -2470,11 +2470,11 @@
   if (!FD->isDependentContext()) {
 Optional Linkage;
 if (Writer->WritingModule &&
-Writer->WritingModule->Kind == Module::ModuleInterfaceUnit) {
-  // When building a C++ Modules TS module interface unit, a strong
-  // definition in the module interface is provided by the compilation of
-  // that module interface unit, not by its users. (Inline functions are
-  // still emitted in module users.)
+Writer->WritingModule->isInterfaceOrPartition()) {
+  // When building a C++20 module interface unit or a partition unit, a
+  // strong definition in the module interface is provided by the
+  // compilation of that unit, not by its users. (Inline functions are still
+  // emitted in module users.)
   Linkage = Writer->Context->GetGVALinkageForFunction(FD);
   ModulesCodegen = *Linkage == GVA_StrongExternal;
 }
Index: clang/include/clang/Basic/Module.h
===
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -529,6 +529,10 @@
 
   /// Is this module a header unit.
   bool isHeaderUnit() const { return Kind == ModuleHeaderUnit; }
+  // Is this a C++20 module interface or a partition.
+  bool isInterfaceOrPartition() const {
+return Kind == ModuleInterfaceUnit || isModulePartition();
+  }
 
   /// Get the primary module interface name from a partition.
   StringRef getPrimaryModuleInterfaceName() const {
___

[PATCH] D122781: This patch aims to conform AMDGPUOpenMP driver sanitizer changes w.r.t HIPAMD toolchain.

2022-03-30 Thread Amit Kumar Pandey via Phabricator via cfe-commits
ampandey-AMD updated this revision to Diff 419317.
ampandey-AMD added a comment.

This patch aims to conform AMDGPUOpenMP driver sanitizer changes w.r.t HIPAMD 
toolchain.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122781

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/hip-sanitize-options.hip

Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -62,7 +62,7 @@
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-mlink-builtin-bitcode" ".*hip.bc".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
 // RDC-NOT: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 
-// FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
+// FAIL: error: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
 
 // XNACK-DAG: warning: ignoring '-fsanitize=leak' option as it is not currently supported for target 'amdgcn-amd-amdhsa'
 // XNACK-DAG: warning: ignoring '-fsanitize=address' option as it is not currently supported for offload arch 'gfx900:xnack-'. Use it with an offload arch containing 'xnack+' instead
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -35,43 +35,6 @@
 #define NULL_FILE "/dev/null"
 #endif
 
-static bool shouldSkipSanitizeOption(const ToolChain ,
- const llvm::opt::ArgList ,
- StringRef TargetID,
- const llvm::opt::Arg *A) {
-  // For actions without targetID, do nothing.
-  if (TargetID.empty())
-return false;
-  Option O = A->getOption();
-  if (!O.matches(options::OPT_fsanitize_EQ))
-return false;
-
-  if (!DriverArgs.hasFlag(options::OPT_fgpu_sanitize,
-  options::OPT_fno_gpu_sanitize, true))
-return true;
-
-  auto  = TC.getDriver().getDiags();
-
-  // For simplicity, we only allow -fsanitize=address
-  SanitizerMask K = parseSanitizerValue(A->getValue(), /*AllowGroups=*/false);
-  if (K != SanitizerKind::Address)
-return true;
-
-  llvm::StringMap FeatureMap;
-  auto OptionalGpuArch = parseTargetID(TC.getTriple(), TargetID, );
-
-  assert(OptionalGpuArch && "Invalid Target ID");
-  (void)OptionalGpuArch;
-  auto Loc = FeatureMap.find("xnack");
-  if (Loc == FeatureMap.end() || !Loc->second) {
-Diags.Report(
-clang::diag::warn_drv_unsupported_option_for_offload_arch_req_feature)
-<< A->getAsString(DriverArgs) << TargetID << "xnack+";
-return true;
-  }
-  return false;
-}
-
 void AMDGCN::Linker::constructLldCommand(Compilation , const JobAction ,
  const InputInfoList ,
  const InputInfo ,
@@ -337,12 +300,7 @@
 getSanitizerArgs(DriverArgs).needsAsanRt()) {
   auto AsanRTL = RocmInstallation.getAsanRTLPath();
   if (AsanRTL.empty()) {
-unsigned DiagID = getDriver().getDiags().getCustomDiagID(
-DiagnosticsEngine::Error,
-"AMDGPU address sanitizer runtime library (asanrtl) is not found. "
-"Please install ROCm device library which supports address "
-"sanitizer");
-getDriver().Diag(DiagID);
+unsigned DiagID = getDriver().Diag(diag::err_drv_no_asan_rt_lib);
 return {};
   } else
 BCLibs.push_back({AsanRTL.str(), /*ShouldInternalize=*/false});
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
@@ -93,6 +93,10 @@
 
   SanitizerMask getSupportedSanitizers() const override;
 
+  RocmInstallationDetector getRocmInstallationLoc() const {
+return RocmInstallation;
+  }
+
   VersionTuple
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList ) const override;
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -16,6 +16,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include 

[PATCH] D122781: This patch aims to conform AMDGPUOpenMP driver sanitizer changes w.r.t HIPAMD toolchain.

2022-03-30 Thread Amit Kumar Pandey via Phabricator via cfe-commits
ampandey-AMD created this revision.
Herald added subscribers: kerbowa, guansong, t-tye, tpr, dstuttard, yaxunl, 
jvesely, kzhuravl.
Herald added a project: All.
ampandey-AMD requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay, wdng.
Herald added a reviewer: jdoerfert.
Herald added a project: clang.

Signed-off-by: Amit Pandey 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122781

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
  clang/lib/Driver/ToolChains/HIPAMD.cpp
  clang/test/Driver/hip-sanitize-options.hip

Index: clang/test/Driver/hip-sanitize-options.hip
===
--- clang/test/Driver/hip-sanitize-options.hip
+++ clang/test/Driver/hip-sanitize-options.hip
@@ -62,7 +62,7 @@
 // RDC: {{"[^"]*clang[^"]*".* "-emit-llvm-bc".* "-fcuda-is-device".* "-mlink-bitcode-file" ".*asanrtl.bc".* "-mlink-builtin-bitcode" ".*hip.bc".* "-fsanitize=address".*}} "-o" "[[OUT:[^"]*.bc]]"
 // RDC-NOT: {{"[^"]*lld(\.exe){0,1}".*}} "[[OUT]]" {{".*asanrtl.bc" ".*hip.bc"}}
 
-// FAIL: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
+// FAIL: error: AMDGPU address sanitizer runtime library (asanrtl) is not found. Please install ROCm device library which supports address sanitizer
 
 // XNACK-DAG: warning: ignoring '-fsanitize=leak' option as it is not currently supported for target 'amdgcn-amd-amdhsa'
 // XNACK-DAG: warning: ignoring '-fsanitize=address' option as it is not currently supported for offload arch 'gfx900:xnack-'. Use it with an offload arch containing 'xnack+' instead
Index: clang/lib/Driver/ToolChains/HIPAMD.cpp
===
--- clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -337,12 +337,7 @@
 getSanitizerArgs(DriverArgs).needsAsanRt()) {
   auto AsanRTL = RocmInstallation.getAsanRTLPath();
   if (AsanRTL.empty()) {
-unsigned DiagID = getDriver().getDiags().getCustomDiagID(
-DiagnosticsEngine::Error,
-"AMDGPU address sanitizer runtime library (asanrtl) is not found. "
-"Please install ROCm device library which supports address "
-"sanitizer");
-getDriver().Diag(DiagID);
+unsigned DiagID = getDriver().Diag(diag::err_drv_no_asan_rt_lib);
 return {};
   } else
 BCLibs.push_back({AsanRTL.str(), /*ShouldInternalize=*/false});
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.h
@@ -93,6 +93,10 @@
 
   SanitizerMask getSupportedSanitizers() const override;
 
+  RocmInstallationDetector getRocmInstallationLoc() const {
+return RocmInstallation;
+  }
+
   VersionTuple
   computeMSVCVersion(const Driver *D,
  const llvm::opt::ArgList ) const override;
Index: clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -16,6 +16,7 @@
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/InputInfo.h"
 #include "clang/Driver/Options.h"
+#include "clang/Driver/SanitizerArgs.h"
 #include "clang/Driver/Tool.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FileSystem.h"
@@ -304,7 +305,8 @@
 
   if (DeviceOffloadKind == Action::OFK_OpenMP) {
 for (Arg *A : Args)
-  if (!llvm::is_contained(*DAL, A))
+  if (!shouldSkipSanitizeOption(*this, Args, BoundArch, A) &&
+  !llvm::is_contained(*DAL, A))
 DAL->append(A);
 
 std::string Arch = DAL->getLastArgValue(options::OPT_march_EQ).str();
Index: clang/lib/Driver/ToolChains/AMDGPU.h
===
--- clang/lib/Driver/ToolChains/AMDGPU.h
+++ clang/lib/Driver/ToolChains/AMDGPU.h
@@ -99,6 +99,12 @@
   /// Needed for translating LTO options.
   const char *getDefaultLinker() const override { return "ld.lld"; }
 
+  /// Should skip Sanitize options
+  bool shouldSkipSanitizeOption(const ToolChain ,
+const llvm::opt::ArgList ,
+StringRef TargetID,
+const llvm::opt::Arg *A) const;
+
   /// Should skip argument.
   bool shouldSkipArgument(const llvm::opt::Arg *Arg) const;
 
Index: clang/lib/Driver/ToolChains/AMDGPU.cpp
===
--- clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -911,6 

[PATCH] D121445: [Clang][CSKY] Add the CSKY target and compiler driver

2022-03-30 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.

In D121445#3416518 , @rengolin wrote:

> There is also a test error:
>
>    TEST 'Clang :: Driver/csky-toolchain.c' FAILED 
> 
>   ...
>   /home/rengolin/devel/llvm-project/clang/test/Driver/csky-toolchain.c:16:24: 
> error: C-CSKY-LINUX-MULTI: expected string not found in input
>   // C-CSKY-LINUX-MULTI: 
> "{{.*}}/Inputs/multilib_csky_linux_sdk/lib/gcc/csky-linux-gnuabiv2/6.3.0/../../..{{/|}}..{{/|}}csky-linux-gnuabiv2/bin{{/|}}ld"
>   
>  ^
>
> I'm guessing this is the path of a local sysroot you have on your machine?
>
> If possible, try to get a new environment (container, VM, alternative 
> machine) and make sure a clean build still passes the tests.

I have met this before because the downloading of patch will ignore empty 
files. You can have a check that your apply does not contain new empty files in 
multilib_csky_linux_sdk.


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

https://reviews.llvm.org/D121445

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


[PATCH] D122713: [RISCV] [NFC] Add tests for vector load/store overloaded intrinsics of FP16

2022-03-30 Thread Chenbing.Zheng via Phabricator via cfe-commits
Chenbing.Zheng added a comment.

In D122713#3417033 , @craig.topper 
wrote:

> These tests files are already too long and have been timing out in 
> phabricator. @4vtomat has a patch D122370  
> to split them up.

OK, I will follow it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122713

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


[PATCH] D122698: [clangd] Add support to extract method for ExtractFunction Tweak

2022-03-30 Thread Fabio R. Sluzala via Phabricator via cfe-commits
FabioRS added a comment.

In D122698#3418018 , @sammccall wrote:

> Thanks! I'll look at the changes in the morning, just wanted to mention one 
> thing
>
> In D122698#3417946 , @FabioRS wrote:
>
>> I can not run the test the consteval, so it is not in the diff.
>>
>>   TestTU failed to build (suppress with /*error-ok*/): 
>>   [1:4-1:13] unknown type name 'consteval'; did you mean 'constexpr'?, 
>> fixes: {change 'consteval' to 'constexpr' {1:4-1:13 => "constexpr"}}
>
> It's a c++20 feature, so you'll need to add something like 
> `ExtraArgs.push_back("-std=c++20");`.
>
> Though if there's no real difference between handling constexpr vs consteval, 
> up to you whether it's worth a separate test.

Thank you!
I think it is interesting to have the test to keep the consteval branch 
covered. I think maybe there will be more things to change, so I can send the 
test case for consteval tomorrow with the others changes.




Comment at: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp:455
+  return std::string(llvm::formatv("{0}{1} {2}({3}){4}", renderAttributes(),
+   printType(ReturnType, 
*EnclosingFuncContext),
+   Name, renderParametersForDefinition(),

sammccall wrote:
> For out-of-line defined methods, this is the wrong DC, which may lead to the 
> type being incorrectly qualified. The DC should rather be the enclosing class.
> 
> Similarly, renderParametersForDefinition uses EnclosingFuncContext too - 
> instead it should take the EnclosingFuncContext as a parameter. (And be 
> renamed `renderParametersForDeclaration`, since it's no longer just for 
> definitions)
It is only for out-of-line methods? I put this verification in the 
getEnclosing() of the new diff.



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

https://reviews.llvm.org/D122698

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-03-30 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

As discussed in https://github.com/llvm/llvm-project/issues/54654, this needs 
to be added for SPMDization with this patch. Not sure whether further handling 
is required.

diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp 
b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index c4736521e475..23cfa6fe5e27 100644

- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp

+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -4260,6 +4260,7 @@ struct AAKernelInfoCallSite : AAKernelInfo {

  case OMPRTL___kmpc_nvptx_parallel_reduce_nowait_v2:
  case OMPRTL___kmpc_nvptx_teams_reduce_nowait_v2:
  case OMPRTL___kmpc_nvptx_end_reduce_nowait:

+case OMPRTL___kmpc_alloc_aggregate_arg:

break;
  case OMPRTL___kmpc_distribute_static_init_4:
  case OMPRTL___kmpc_distribute_static_init_4u:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D122698: [clangd] Add support to extract method for ExtractFunction Tweak

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

Thanks! I'll look at the changes in the morning, just wanted to mention one 
thing

In D122698#3417946 , @FabioRS wrote:

> I can not run the test the consteval, so it is not in the diff.
>
>   TestTU failed to build (suppress with /*error-ok*/): 
>   [1:4-1:13] unknown type name 'consteval'; did you mean 'constexpr'?, fixes: 
> {change 'consteval' to 'constexpr' {1:4-1:13 => "constexpr"}}

It's a c++20 feature, so you'll need to add something like 
`ExtraArgs.push_back("-std=c++20");`.

Though if there's no real difference between handling constexpr vs consteval, 
up to you whether it's worth a separate test.


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

https://reviews.llvm.org/D122698

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


[PATCH] D122774: [clang][extract-api] Add Objective-C Category support

2022-03-30 Thread Zixu Wang via Phabricator via cfe-commits
zixuw updated this revision to Diff 419298.
zixuw added a comment.

Remove probably unnecessary includes added automatically by clangd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122774

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/objc_category.m

Index: clang/test/ExtractAPI/objc_category.m
===
--- /dev/null
+++ clang/test/ExtractAPI/objc_category.m
@@ -0,0 +1,284 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
+// RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+@protocol Protocol;
+
+@interface Interface
+@end
+
+@interface Interface (Category) 
+@property int Property;
+- (void)InstanceMethod;
++ (void)ClassMethod;
+@end
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(im)InstanceMethod",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(cm)ClassMethod",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(py)Property",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "conformsTo",
+  "source": "c:objc(cs)Interface",
+  "target": "c:objc(pl)Protocol"
+}
+  ],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@interface"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Interface"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(cs)Interface"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "objective-c.class"
+  },
+  "location": {
+"character": 12,
+"line": 3,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Interface"
+  }
+],
+"title": "Interface"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "text",
+  "spelling": "- ("
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+},
+{
+  "kind": "identifier",
+  "spelling": "InstanceMethod"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(cs)Interface(im)InstanceMethod"
+  },
+  "kind": {
+"displayName": "Instance Method",
+"identifier": "objective-c.method"
+  },
+  "location": {
+"character": 1,
+"line": 8,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "text",
+"spelling": "- "
+  },
+  {
+"kind": "identifier",
+"spelling": "InstanceMethod"
+  }
+],
+"title": "InstanceMethod"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "text",
+  "spelling": "+ ("
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+},
+{
+  "kind": 

[PATCH] D122774: [clang][extract-api] Add Objective-C Category support

2022-03-30 Thread Zixu Wang via Phabricator via cfe-commits
zixuw created this revision.
Herald added a reviewer: dang.
Herald added a project: All.
zixuw requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Add (partial) support for Objective-C category records in ExtractAPI.
The current ExtractAPI collects everything for an Objective-C category,
but not fully serialized in the SymbolGraphSerializer. Categories
extending external interfaces are disgarded during serialization, and
categories extending known interfaces are merged (all members surfaced)
into the interfaces.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122774

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/objc_category.m

Index: clang/test/ExtractAPI/objc_category.m
===
--- /dev/null
+++ clang/test/ExtractAPI/objc_category.m
@@ -0,0 +1,284 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api -x objective-c-header -target arm64-apple-macosx \
+// RUN: %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+@protocol Protocol;
+
+@interface Interface
+@end
+
+@interface Interface (Category) 
+@property int Property;
+- (void)InstanceMethod;
++ (void)ClassMethod;
+@end
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(im)InstanceMethod",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(cm)ClassMethod",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "memberOf",
+  "source": "c:objc(cs)Interface(py)Property",
+  "target": "c:objc(cs)Interface"
+},
+{
+  "kind": "conformsTo",
+  "source": "c:objc(cs)Interface",
+  "target": "c:objc(pl)Protocol"
+}
+  ],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "@interface"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "Interface"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(cs)Interface"
+  },
+  "kind": {
+"displayName": "Class",
+"identifier": "objective-c.class"
+  },
+  "location": {
+"character": 12,
+"line": 3,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "Interface"
+  }
+],
+"title": "Interface"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "text",
+  "spelling": "- ("
+},
+{
+  "kind": "typeIdentifier",
+  "preciseIdentifier": "c:v",
+  "spelling": "void"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+},
+{
+  "kind": "identifier",
+  "spelling": "InstanceMethod"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:objc(cs)Interface(im)InstanceMethod"
+  },
+  "kind": {
+"displayName": "Instance Method",
+"identifier": "objective-c.method"
+  },
+  "location": {
+"character": 1,
+"line": 8,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "text",
+"spelling": "- "
+  },
+  {
+"kind": "identifier",
+"spelling": "InstanceMethod"
+  }
+],
+"title": "InstanceMethod"
+  }
+   

[PATCH] D122698: [clangd] Add support to extract method for ExtractFunction Tweak

2022-03-30 Thread Fabio R. Sluzala via Phabricator via cfe-commits
FabioRS updated this revision to Diff 419296.
FabioRS added a comment.

Full patch


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

https://reviews.llvm.org/D122698

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -114,16 +114,48 @@
   // Don't extract when we need to make a function as a parameter.
   EXPECT_THAT(apply("void f() { [[int a; f();]] }"), StartsWith("fail"));
 
-  // We don't extract from methods for now since they may involve multi-file
-  // edits
-  std::string MethodFailInput = R"cpp(
+  std::string MethodInput = R"cpp(
 class T {
   void f() {
 [[int x;]]
   }
 };
   )cpp";
-  EXPECT_EQ(apply(MethodFailInput), "unavailable");
+  std::string MethodCheckOutput = R"cpp(
+class T {
+  void extracted() {
+int x;
+}
+void f() {
+extracted();
+  }
+};
+  )cpp";
+  EXPECT_EQ(apply(MethodInput), MethodCheckOutput);
+
+  std::string OutOfLineMethodInput = R"cpp(
+class T {
+  void f();
+};
+
+void T::f() {
+  [[int x;]]
+}
+  )cpp";
+  std::string OutOfLineMethodCheckOutput = R"cpp(
+class T {
+  void extracted();
+void f();
+};
+
+void T::extracted() {
+int x;
+}
+void T::f() {
+  extracted();
+}
+  )cpp";
+  EXPECT_EQ(apply(OutOfLineMethodInput), OutOfLineMethodCheckOutput);
 
   // We don't extract from templated functions for now as templates are hard
   // to deal with.
@@ -159,6 +191,198 @@
   EXPECT_EQ(apply(CompoundFailInput), "unavailable");
 }
 
+TEST_F(ExtractFunctionTest, DifferentHeaderSourceTest) {
+  Header = R"cpp(
+class SomeClass {
+  void f();
+};
+  )cpp";
+
+  std::string OutOfLineSource = R"cpp(
+void SomeClass::f() {
+  [[int x;]]
+}
+  )cpp";
+
+  std::string OutOfLineSourceOutputCheck = R"cpp(
+void SomeClass::extracted() {
+int x;
+}
+void SomeClass::f() {
+  extracted();
+}
+  )cpp";
+
+  std::string HeaderOutputCheck = R"cpp(
+class SomeClass {
+  void extracted();
+void f();
+};
+  )cpp";
+
+  llvm::StringMap EditedFiles;
+
+  EXPECT_EQ(apply(OutOfLineSource, ), OutOfLineSourceOutputCheck);
+  EXPECT_EQ(EditedFiles.begin()->second, HeaderOutputCheck);
+}
+
+TEST_F(ExtractFunctionTest, DifferentFilesNestedTest) {
+  Header = R"cpp(
+class T {
+class SomeClass {
+  void f();
+};
+};
+  )cpp";
+
+  std::string NestedOutOfLineSource = R"cpp(
+void T::SomeClass::f() {
+  [[int x;]]
+}
+  )cpp";
+
+  std::string NestedOutOfLineSourceOutputCheck = R"cpp(
+void T::SomeClass::extracted() {
+int x;
+}
+void T::SomeClass::f() {
+  extracted();
+}
+  )cpp";
+
+  std::string NestedHeaderOutputCheck = R"cpp(
+class T {
+class SomeClass {
+  void extracted();
+void f();
+};
+};
+  )cpp";
+
+  llvm::StringMap EditedFiles;
+
+  EXPECT_EQ(apply(NestedOutOfLineSource, ),
+NestedOutOfLineSourceOutputCheck);
+  EXPECT_EQ(EditedFiles.begin()->second, NestedHeaderOutputCheck);
+}
+
+TEST_F(ExtractFunctionTest, ConstexprDifferentHeaderSourceTest) {
+  Header = R"cpp(
+class SomeClass {
+  constexpr void f() const;
+};
+  )cpp";
+
+  std::string OutOfLineSource = R"cpp(
+constexpr void SomeClass::f() const {
+  [[int x;]]
+}
+  )cpp";
+
+  std::string OutOfLineSourceOutputCheck = R"cpp(
+constexpr void SomeClass::extracted() const {
+int x;
+}
+constexpr void SomeClass::f() const {
+  extracted();
+}
+  )cpp";
+
+  std::string HeaderOutputCheck = R"cpp(
+class SomeClass {
+  constexpr void extracted() const;
+constexpr void f() const;
+};
+  )cpp";
+
+  llvm::StringMap EditedFiles;
+
+  EXPECT_EQ(apply(OutOfLineSource, ), OutOfLineSourceOutputCheck);
+  EXPECT_NE(EditedFiles.begin(), EditedFiles.end())
+  << "The header should be edited and receives the declaration of the new "
+ "function";
+
+  if (EditedFiles.begin() != EditedFiles.end()) {
+EXPECT_EQ(EditedFiles.begin()->second, HeaderOutputCheck);
+  }
+}
+
+TEST_F(ExtractFunctionTest, ConstDifferentHeaderSourceTest) {
+  Header = R"cpp(
+class SomeClass {
+  void f() const;
+};
+  )cpp";
+
+  std::string OutOfLineSource = R"cpp(
+void SomeClass::f() const {
+  [[int x;]]
+}
+  )cpp";
+
+  std::string OutOfLineSourceOutputCheck = R"cpp(
+void SomeClass::extracted() const {
+int x;
+}
+void SomeClass::f() const {
+  extracted();
+}
+  )cpp";
+
+  std::string HeaderOutputCheck = R"cpp(
+class SomeClass {
+  void extracted() const;
+void f() const;
+};
+  )cpp";
+
+  llvm::StringMap EditedFiles;
+
+  

[PATCH] D122698: [clangd] Add support to extract method for ExtractFunction Tweak

2022-03-30 Thread Fabio R. Sluzala via Phabricator via cfe-commits
FabioRS updated this revision to Diff 419290.
FabioRS marked 14 inline comments as done.
FabioRS added a comment.

I am not sure about the LangOptions object, the NestedNameSpecifier needs it to 
correctly print the nested classes-name and not sure about the getEnclosing() 
too.

I can not run the test the consteval, so it is not in the diff.

  TestTU failed to build (suppress with /*error-ok*/): 
  [1:4-1:13] unknown type name 'consteval'; did you mean 'constexpr'?, fixes: 
{change 'consteval' to 'constexpr' {1:4-1:13 => "constexpr"}}
  
  For code:
  
  consteval void SomeClass::f() const {
int x;
  }


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

https://reviews.llvm.org/D122698

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -226,6 +226,87 @@
   EXPECT_EQ(EditedFiles.begin()->second, HeaderOutputCheck);
 }
 
+TEST_F(ExtractFunctionTest, DifferentFilesNestedTest) {
+  Header = R"cpp(
+class T {
+class SomeClass {
+  void f();
+};
+};
+  )cpp";
+
+  std::string NestedOutOfLineSource = R"cpp(
+void T::SomeClass::f() {
+  [[int x;]]
+}
+  )cpp";
+
+  std::string NestedOutOfLineSourceOutputCheck = R"cpp(
+void T::SomeClass::extracted() {
+int x;
+}
+void T::SomeClass::f() {
+  extracted();
+}
+  )cpp";
+
+  std::string NestedHeaderOutputCheck = R"cpp(
+class T {
+class SomeClass {
+  void extracted();
+void f();
+};
+};
+  )cpp";
+
+  llvm::StringMap EditedFiles;
+
+  EXPECT_EQ(apply(NestedOutOfLineSource, ),
+NestedOutOfLineSourceOutputCheck);
+  EXPECT_EQ(EditedFiles.begin()->second, NestedHeaderOutputCheck);
+}
+
+TEST_F(ExtractFunctionTest, ConstexprDifferentHeaderSourceTest) {
+  Header = R"cpp(
+class SomeClass {
+  constexpr void f() const;
+};
+  )cpp";
+
+  std::string OutOfLineSource = R"cpp(
+constexpr void SomeClass::f() const {
+  [[int x;]]
+}
+  )cpp";
+
+  std::string OutOfLineSourceOutputCheck = R"cpp(
+constexpr void SomeClass::extracted() const {
+int x;
+}
+constexpr void SomeClass::f() const {
+  extracted();
+}
+  )cpp";
+
+  std::string HeaderOutputCheck = R"cpp(
+class SomeClass {
+  constexpr void extracted() const;
+constexpr void f() const;
+};
+  )cpp";
+
+  llvm::StringMap EditedFiles;
+
+  EXPECT_EQ(apply(OutOfLineSource, ), OutOfLineSourceOutputCheck);
+  EXPECT_NE(EditedFiles.begin(), EditedFiles.end())
+  << "The header should be edited and receives the declaration of the new "
+ "function";
+
+  if (EditedFiles.begin() != EditedFiles.end()) {
+EXPECT_EQ(EditedFiles.begin()->second, HeaderOutputCheck);
+  }
+}
+
 TEST_F(ExtractFunctionTest, ConstDifferentHeaderSourceTest) {
   Header = R"cpp(
 class SomeClass {
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractFunction.cpp
@@ -56,6 +56,8 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclBase.h"
+#include "clang/AST/ExternalASTSource.h"
+#include "clang/AST/NestedNameSpecifier.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/Stmt.h"
 #include "clang/Basic/LangOptions.h"
@@ -71,6 +73,8 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/raw_os_ostream.h"
 
 namespace clang {
 namespace clangd {
@@ -88,6 +92,12 @@
   OutsideFunc // Outside EnclosingFunction.
 };
 
+enum FunctionDeclKind {
+  InlineDefinition,
+  ForwardDeclaration,
+  OutOfLineDefinition
+};
+
 // A RootStmt is a statement that's fully selected including all it's children
 // and it's parent is unselected.
 // Check if a node is a root statement.
@@ -340,45 +350,62 @@
   QualType ReturnType;
   std::vector Parameters;
   SourceRange BodyRange;
-  SourceLocation InsertionPoint;
-  llvm::Optional DeclarationPoint;
-  llvm::Optional ParentContext;
-  const DeclContext *EnclosingFuncContext;
+  SourceLocation DefinitionPoint;
+  llvm::Optional ForwardDeclarationPoint;
+  llvm::Optional EnclosingClass;
+  NestedNameSpecifier *NestedNameSpec = nullptr;
+  const DeclContext *EnclosingFuncContext = nullptr;
   bool CallerReturnsValue = false;
   bool Static = false;
-  bool Constexpr = false;
-  bool OutOfLine = false;
-  bool ContextConst = false;
+  ConstexprSpecKind Constexpr = ConstexprSpecKind::Unspecified;
+  bool Const = false;
+
+  

[PATCH] D122704: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members

2022-03-30 Thread Wang Yihan via Phabricator via cfe-commits
yihanaa added a comment.

Thank you for the reviews @erichkeane.   I've applied for commit access and 
commit in 907d3acefc3bdd6eb83f21589c6473ca7e88b3eb 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122704

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


[PATCH] D122704: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members

2022-03-30 Thread Wang Yihan 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 rG907d3acefc3b: [Clang][CodeGen]Beautify dump format, add 
indent for nested struct and struct… (authored by yihanaa).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122704

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/dump-struct-builtin.c

Index: clang/test/CodeGen/dump-struct-builtin.c
===
--- clang/test/CodeGen/dump-struct-builtin.c
+++ clang/test/CodeGen/dump-struct-builtin.c
@@ -5,93 +5,93 @@
 
 // CHECK: @__const.unit1.a = private unnamed_addr constant %struct.U1A { i16 12 }, align 2
 // CHECK-NEXT: [[STRUCT_STR_U1:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"struct U1A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U1:@[0-9]+]] = private unnamed_addr constant [15 x i8] c"short a = %hd\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U1:@[0-9]+]] = private unnamed_addr constant [19 x i8] c"short a = %hd\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U1:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit2.a = private unnamed_addr constant %struct.U2A { i16 12 }, align 2
 // CHECK-NEXT: [[STRUCT_STR_U2:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"struct U2A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U2:@[0-9]+]] = private unnamed_addr constant [24 x i8] c"unsigned short a = %hu\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U2:@[0-9]+]] = private unnamed_addr constant [28 x i8] c"unsigned short a = %hu\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U2:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit3.a = private unnamed_addr constant %struct.U3A { i32 12 }, align 4
 // CHECK-NEXT: [[STRUCT_STR_U3:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"struct U3A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U3:@[0-9]+]] = private unnamed_addr constant [12 x i8] c"int a = %d\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U3:@[0-9]+]] = private unnamed_addr constant [16 x i8] c"int a = %d\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U3:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit4.a = private unnamed_addr constant %struct.U4A { i32 12 }, align 4
 // CHECK-NEXT: [[STRUCT_STR_U4:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"struct U4A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U4:@[0-9]+]] = private unnamed_addr constant [21 x i8] c"unsigned int a = %u\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U4:@[0-9]+]] = private unnamed_addr constant [25 x i8] c"unsigned int a = %u\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U4:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit5.a = private unnamed_addr constant %struct.U5A { i64 12 }, align 8
 // CHECK-NEXT: [[STRUCT_STR_U5:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"struct U5A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U5:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"long a = %ld\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U5:@[0-9]+]] = private unnamed_addr constant [18 x i8] c"long a = %ld\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U5:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit6.a = private unnamed_addr constant %struct.U6A { i64 12 }, align 8
 // CHECK-NEXT: [[STRUCT_STR_U6:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"struct U6A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U6:@[0-9]+]] = private unnamed_addr constant [23 x i8] c"unsigned long a = %lu\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U6:@[0-9]+]] = private unnamed_addr constant [27 x i8] c"unsigned long a = %lu\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U6:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit7.a = private unnamed_addr constant %struct.U7A { i64 12 }, align 8
 // CHECK-NEXT: [[STRUCT_STR_U7:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"struct U7A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U7:@[0-9]+]] = private unnamed_addr constant [20 x i8] c"long long a = %lld\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U7:@[0-9]+]] = private unnamed_addr constant [24 x i8] c"long long a = %lld\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U7:@[0-9]+]] = private unnamed_addr constant [3 x i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit8.a = private unnamed_addr constant %struct.U8A { i64 12 }, align 8
 // CHECK-NEXT: [[STRUCT_STR_U8:@[0-9]+]] = private unnamed_addr constant [14 x i8] c"struct U8A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U8:@[0-9]+]] = private unnamed_addr constant [29 x i8] c"unsigned long long a = %llu\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U8:@[0-9]+]] = private unnamed_addr constant [33 x i8] c"unsigned long long 

[clang] 907d3ac - [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members

2022-03-30 Thread via cfe-commits

Author: wangyihan
Date: 2022-03-31T07:38:37+08:00
New Revision: 907d3acefc3bdd6eb83f21589c6473ca7e88b3eb

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

LOG: [Clang][CodeGen]Beautify dump format, add indent for nested struct and 
struct members

Beautify dump format, add indent for nested struct and struct members, also fix 
test cases in dump-struct-builtin.c
for example:
struct:
```
  struct A {
int a;
struct B {
  int b;
  struct C {
struct D {
  int d;
  union E {
int x;
int y;
  } e;
} d;
int c;
  } c;
} b;
  };
```
Before:
```
struct A {
int a = 0
struct B {
int b = 0
struct C {
struct D {
int d = 0
union E {
int x = 0
int y = 0
}
}
int c = 0
}
}
}
```
After:
```
struct A {
int a = 0
struct B {
int b = 0
struct C {
struct D {
int d = 0
union E {
int x = 0
int y = 0
}
}
int c = 0
}
}
}
```

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/dump-struct-builtin.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 69806fa4407dc..acc433f2bc86b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -117,6 +117,7 @@ Non-comprehensive list of changes in this release
   - Support bitfields in struct and union.
   - Improve the dump format, dump both bitwidth(if its a bitfield) and field 
value.
   - Remove anonymous tag locations.
+  - Beautify dump format, add indent for nested struct and struct members.
 
 New Compiler Flags
 --

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 2159dd7139101..ffba93846958e 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2049,11 +2049,12 @@ static llvm::Value *dumpRecord(CodeGenFunction , 
QualType RType,
   ASTContext  = CGF.getContext();
   RecordDecl *RD = RType->castAs()->getDecl()->getDefinition();
   std::string Pad = std::string(Lvl * 4, ' ');
+  std::string ElementPad = std::string((Lvl + 1) * 4, ' ');
 
   PrintingPolicy Policy(Context.getLangOpts());
   Policy.AnonymousTagLocations = false;
-  Value *GString =
-  CGF.Builder.CreateGlobalStringPtr(RType.getAsString(Policy) + " {\n");
+  Value *GString = CGF.Builder.CreateGlobalStringPtr(
+llvm::Twine(Pad).concat(RType.getAsString(Policy)).concat(" {\n").str());
   Value *Res = CGF.Builder.CreateCall(Func, {GString});
 
   static llvm::DenseMap Types;
@@ -2081,7 +2082,7 @@ static llvm::Value *dumpRecord(CodeGenFunction , 
QualType RType,
   for (const auto *FD : RD->fields()) {
 Value *TmpRes = nullptr;
 
-std::string Format = llvm::Twine(Pad)
+std::string Format = llvm::Twine(ElementPad)
  .concat(FD->getType().getAsString())
  .concat(llvm::Twine(' '))
  .concat(FD->getNameAsString())

diff  --git a/clang/test/CodeGen/dump-struct-builtin.c 
b/clang/test/CodeGen/dump-struct-builtin.c
index 8b5db4dbbe280..faa1fa7889f1c 100644
--- a/clang/test/CodeGen/dump-struct-builtin.c
+++ b/clang/test/CodeGen/dump-struct-builtin.c
@@ -5,93 +5,93 @@
 
 // CHECK: @__const.unit1.a = private unnamed_addr constant %struct.U1A { i16 
12 }, align 2
 // CHECK-NEXT: [[STRUCT_STR_U1:@[0-9]+]] = private unnamed_addr constant [14 x 
i8] c"struct U1A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U1:@[0-9]+]] = private unnamed_addr constant [15 x i8] 
c"short a = %hd\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U1:@[0-9]+]] = private unnamed_addr constant [19 x i8] 
c"short a = %hd\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U1:@[0-9]+]] = private unnamed_addr constant [3 x 
i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit2.a = private unnamed_addr constant %struct.U2A { i16 
12 }, align 2
 // CHECK-NEXT: [[STRUCT_STR_U2:@[0-9]+]] = private unnamed_addr constant [14 x 
i8] c"struct U2A {\0A\00", align 1
-// CHECK-NEXT: [[FIELD_U2:@[0-9]+]] = private unnamed_addr constant [24 x i8] 
c"unsigned short a = %hu\0A\00", align 1
+// CHECK-NEXT: [[FIELD_U2:@[0-9]+]] = private unnamed_addr constant [28 x i8] 
c"unsigned short a = %hu\0A\00", align 1
 // CHECK-NEXT: [[END_STRUCT_U2:@[0-9]+]] = private unnamed_addr constant [3 x 
i8] c"}\0A\00", align 1
 
 // CHECK: @__const.unit3.a = private unnamed_addr constant %struct.U3A { i32 
12 }, align 4
 // CHECK-NEXT: 

[PATCH] D122627: [HLSL] Fix MSFT Attribute parsing, add numthreads

2022-03-30 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D122627#3417557 , @aaron.ballman 
wrote:

> Are you sure that's what you want? This returns true for a static C++ member 
> function, false for a static free function, and false for within an unnamed 
> namespace, and true otherwise.

You're right this isn't quite right, but getting closer... HLSL doesn't support 
unnamed namespaces, and we only support static free functions by accident... 
(the current compiler ignores static on free functions).

This actually revealed some gaps in the documentation for HLSL, I've gone back 
and gotten feedback from my team's HLSL expert and I think I've got the right 
set of constraints for where this can be applied now (clang will even have this 
better than the HLSL compiler).

> Also, I didn't see any new test coverage for function merging behavior.

Doh! I knew I was forgetting something. Juggling too many balls today. I'll get 
that covered too!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122627

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


[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage NFC

2022-03-30 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

Maybe it's because I removed the final empty line when I pasted the diff as I 
thought that LF was a line terminator instead of a line separator.  I will try 
using arc from now on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121754

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


[PATCH] D121906: [clang-format] Indent import statements in JavaScript.

2022-03-30 Thread sstwcw 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 rGf6740fe483e9: [clang-format] Indent import statements in 
JavaScript. (authored by sstwcw).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121906

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -1875,6 +1875,11 @@
   " myX} from 'm';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
+  // Ensure an import statement inside a block is at the correct level.
+  verifyFormat("function() {\n"
+   "  var x;\n"
+   "  import 'some/module.js';\n"
+   "}");
 
   verifyFormat("export function fn() {\n"
"  return 'fn';\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1431,8 +1431,10 @@
   if (Newlines)
 Indent = NewlineIndent;
 
-  // Preprocessor directives get indented before the hash only if specified
-  if (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
+  // Preprocessor directives get indented before the hash only if specified. In
+  // Javascript import statements are indented like normal statements.
+  if (!Style.isJavaScript() &&
+  Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
   (Line.Type == LT_PreprocessorDirective ||
Line.Type == LT_ImportStatement))
 Indent = 0;


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -1875,6 +1875,11 @@
   " myX} from 'm';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
+  // Ensure an import statement inside a block is at the correct level.
+  verifyFormat("function() {\n"
+   "  var x;\n"
+   "  import 'some/module.js';\n"
+   "}");
 
   verifyFormat("export function fn() {\n"
"  return 'fn';\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1431,8 +1431,10 @@
   if (Newlines)
 Indent = NewlineIndent;
 
-  // Preprocessor directives get indented before the hash only if specified
-  if (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
+  // Preprocessor directives get indented before the hash only if specified. In
+  // Javascript import statements are indented like normal statements.
+  if (!Style.isJavaScript() &&
+  Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
   (Line.Type == LT_PreprocessorDirective ||
Line.Type == LT_ImportStatement))
 Indent = 0;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] f6740fe - [clang-format] Indent import statements in JavaScript.

2022-03-30 Thread via cfe-commits

Author: sstwcw
Date: 2022-03-30T23:17:27Z
New Revision: f6740fe483e9fa0c76aa9f176ff68f51f47a1302

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

LOG: [clang-format] Indent import statements in JavaScript.

[clang-format] Indent import statements in JavaScript.

Take for example this piece of code found at
.

```
for (const link of document.querySelectorAll("nav > a")) {
  link.addEventListener("click", e => {
e.preventDefault();

import('/modules/my-module.js')
.then(module => {
  module.loadPageInto(main);
})
.catch(err => {
  main.textContent = err.message;
});
  });
}
```

Previously the import line would be unindented, looking like this.

```
for (const link of document.querySelectorAll("nav > a")) {
  link.addEventListener("click", e => {
e.preventDefault();

import('/modules/my-module.js')
.then(module => {
  module.loadPageInto(main);
})
.catch(err => {
  main.textContent = err.message;
});
  });
}
```

Actually we were going to fix this along with fixing Verilog import
statements.  But the patch got too big.

Reviewed By: MyDeveloperDay, curdeius

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTestJS.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 1393a2a321183..e2dbc35c22004 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1431,8 +1431,10 @@ void UnwrappedLineFormatter::formatFirstToken(
   if (Newlines)
 Indent = NewlineIndent;
 
-  // Preprocessor directives get indented before the hash only if specified
-  if (Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
+  // Preprocessor directives get indented before the hash only if specified. In
+  // Javascript import statements are indented like normal statements.
+  if (!Style.isJavaScript() &&
+  Style.IndentPPDirectives != FormatStyle::PPDIS_BeforeHash &&
   (Line.Type == LT_PreprocessorDirective ||
Line.Type == LT_ImportStatement))
 Indent = 0;

diff  --git a/clang/unittests/Format/FormatTestJS.cpp 
b/clang/unittests/Format/FormatTestJS.cpp
index 6077d21c5e582..9883aae62191a 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1875,6 +1875,11 @@ TEST_F(FormatTestJS, Modules) {
   " myX} from 'm';");
   verifyFormat("import * as lib from 'some/module.js';");
   verifyFormat("var x = {import: 1};\nx.import = 2;");
+  // Ensure an import statement inside a block is at the correct level.
+  verifyFormat("function() {\n"
+   "  var x;\n"
+   "  import 'some/module.js';\n"
+   "}");
 
   verifyFormat("export function fn() {\n"
"  return 'fn';\n"



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


[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location

2022-03-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

(I don't think the argument about '\' in include lines applies to this patch 
(?))


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122766

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


[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location

2022-03-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

As said elsewhere, I think this is too simplistic.

It's good to make this dependent on the triple, instead of on the host 
platform. But we should have a flag that controls which slash direction to use 
on windows triples, since different people will want different things.

And since most people who use clang-cl run it on Windows, the default for that 
flag should imho stay a backslash (but projects can add the forward direction 
flag if they want).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122766

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


[PATCH] D122377: [PowerPC][Linux] Support 16-byte lock free atomics on pwr8 and up

2022-03-30 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: clang/test/CodeGen/PowerPC/atomic-alignment.c:45
+// PPC64: @q = global %struct.Q zeroinitializer, align 16{{$}}
+// AIX64: @q = global %struct.Q zeroinitializer, align 1{{$}}
 _Atomic(Q) q; // expected-no-diagnostics

Although it is a change that affects layout compatibility with the short 
history of 16-byte atomic types compiled with LLVM-based compilers on AIX, 
having this 16-byte atomic type aligned also on AIX for PPC64 would be 
reasonable. The consequences of not doing so is that operations on some types 
would be lock-free only on ELF-based platforms.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122377

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


[PATCH] D122768: [WIP][Clang] Support capturing structured bindings in lambdas

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:9060
 continue;
-  const VarDecl *VD = LC.getCapturedVar();
+  const VarDecl *VD = cast(LC.getCapturedVar());
   if (LC.getCaptureKind() != LCK_ByRef && !VD->getType()->isPointerType())

I'm not sure we currently prohibit capturing a structured binding in openmp, i 
should fix that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122768

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


[PATCH] D121556: [randstruct] Add randomize structure layout support

2022-03-30 Thread Bill Wendling via Phabricator via cfe-commits
void updated this revision to Diff 419282.
void added a comment.

Moved the randomization to a better spot.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121556

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Randstruct.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/CMakeLists.txt
  clang/lib/AST/Decl.cpp
  clang/lib/AST/Randstruct.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/unittests/AST/CMakeLists.txt
  clang/unittests/AST/RandstructTest.cpp

Index: clang/unittests/AST/RandstructTest.cpp
===
--- /dev/null
+++ clang/unittests/AST/RandstructTest.cpp
@@ -0,0 +1,418 @@
+//===- unittest/AST/RandstructTest.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file contains tests for Clang's structure field layout randomization.
+//
+//===--===//
+
+/*
+ * Build this test suite by running `make ASTTests` in the build folder.
+ *
+ * Run this test suite by running the following in the build folder:
+ * ` ./tools/clang/unittests/AST/ASTTests
+ * --gtest_filter=StructureLayoutRandomization*`
+ */
+
+#include "clang/AST/Randstruct.h"
+#include "gtest/gtest.h"
+
+#include "DeclMatcher.h"
+#include "clang/AST/RecordLayout.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Frontend/ASTUnit.h"
+#include "clang/Testing/CommandLineArgs.h"
+#include "clang/Tooling/Tooling.h"
+
+#include 
+
+using namespace clang;
+using namespace clang::ast_matchers;
+using namespace clang::randstruct;
+
+using field_names = std::vector;
+
+namespace {
+
+std::unique_ptr makeAST(const std::string ) {
+  std::vector Args = getCommandLineArgsForTesting(Lang_C99);
+  Args.push_back("-frandstruct-seed=1234567890abcdef");
+
+  std::unique_ptr AST =
+  tooling::buildASTFromCodeWithArgs(SourceCode, Args);
+
+  EXPECT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+  return AST;
+}
+
+RecordDecl *getRecordDeclFromAST(const ASTContext , const std::string ) {
+  RecordDecl *RD = FirstDeclMatcher().match(
+  C.getTranslationUnitDecl(), recordDecl(hasName(Name)));
+  return RD;
+}
+
+std::vector getFieldNamesFromRecord(const RecordDecl *RD) {
+  std::vector Fields;
+
+  Fields.reserve(8);
+  for (auto *Field : RD->fields())
+Fields.push_back(Field->getNameAsString());
+
+  return Fields;
+}
+
+bool isSubsequence(const field_names , const field_names ) {
+  unsigned SeqLen = Seq.size();
+  unsigned SubLen = Subseq.size();
+
+  bool IsSubseq = false;
+  for (unsigned I = 0; I < SeqLen; ++I)
+if (Seq[I] == Subseq[0]) {
+  IsSubseq = true;
+  for (unsigned J = 0; J + I < SeqLen && J < SubLen; ++J) {
+if (Seq[J + I] != Subseq[J]) {
+  IsSubseq = false;
+  break;
+}
+  }
+}
+
+  return IsSubseq;
+}
+
+} // end anonymous namespace
+
+namespace clang {
+namespace ast_matchers {
+
+#define RANDSTRUCT_TEST_SUITE_TEST StructureLayoutRandomizationTestSuiteTest
+
+TEST(RANDSTRUCT_TEST_SUITE_TEST, CanDetermineIfSubsequenceExists) {
+  const field_names Seq = {"a", "b", "c", "d"};
+
+  ASSERT_TRUE(isSubsequence(Seq, {"b", "c"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"a", "b", "c", "d"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"b", "c", "d"}));
+  ASSERT_TRUE(isSubsequence(Seq, {"a"}));
+  ASSERT_FALSE(isSubsequence(Seq, {"a", "d"}));
+}
+
+#define RANDSTRUCT_TEST StructureLayoutRandomization
+
+TEST(RANDSTRUCT_TEST, UnmarkedStruct) {
+  const std::unique_ptr AST = makeAST(R"c(
+struct test {
+int bacon;
+long lettuce;
+long long tomato;
+float mayonnaise;
+};
+  )c");
+
+  const RecordDecl *RD = getRecordDeclFromAST(AST->getASTContext(), "test");
+  const field_names Expected = {"bacon", "lettuce", "tomato", "mayonnaise"};
+
+  ASSERT_FALSE(RD->getAttr());
+  ASSERT_FALSE(RD->isRandomized());
+  ASSERT_EQ(Expected, getFieldNamesFromRecord(RD));
+}
+
+TEST(RANDSTRUCT_TEST, MarkedNoRandomize) {
+  const std::unique_ptr AST = makeAST(R"c(
+struct test {
+int bacon;
+long lettuce;
+long long tomato;
+float mayonnaise;
+  

[PATCH] D122768: [WIP][Clang] Support capturing structured bindings in lambdas

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

Remote commented-out code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122768

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/LambdaCapture.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/ScopeInfo.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/SemaCXX/cxx1z-decomposition.cpp
  clang/test/SemaCXX/decomposition-blocks.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1144,7 +1144,7 @@
 
   Structured binding extensions
   https://wg21.link/p1091r3;>P1091R3
-  Partial
+  Clang 15
 
   
 https://wg21.link/p1381r1;>P1381R1
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3350,9 +3350,10 @@
C != CEnd; ++C) {
 if (!C->capturesVariable())
   continue;
-
-if (Visit(MakeCursorVariableRef(C->getCapturedVar(), C->getLocation(),
-TU)))
+// TODO: hamdle structured bindings here ?
+if (!isa(C->getCapturedVar()))
+continue;
+if(Visit(MakeCursorVariableRef(cast(C->getCapturedVar()), C->getLocation(), TU)))
   return true;
   }
   // Visit init captures
Index: clang/test/SemaCXX/decomposition-blocks.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/decomposition-blocks.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s -fblocks
+
+struct S {
+int i : 1;
+int j;
+};
+
+void run(void (^)());
+void test() {
+auto [i, j] = S{1, 42}; // expected-note {{'i' declared here}}
+run(^{ (void) i; }); // expected-error {{reference to local binding 'i' declared in enclosing function 'test'}}
+}
Index: clang/test/SemaCXX/cxx1z-decomposition.cpp
===
--- clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++17 -Wc++20-extensions -verify=expected %s
+// RUN: %clang_cc1 -std=c++20 -Wpre-c++20-compat -verify=expected %s
 
 void use_from_own_init() {
   auto [a] = a; // expected-error {{binding 'a' cannot appear in the initializer of its own decomposition declaration}}
@@ -46,27 +47,60 @@
 }
 static_assert(f({1, 2}) == 12);
 
-constexpr bool g(S &) { 
+constexpr bool g(S &) {
   auto &[a, b] = s;
   return  ==  &&  ==  &&  != 
 }
 static_assert(g({1, 2}));
 
-auto [outer1, outer2] = S{1, 2};
+struct S1 {
+  int a, b;
+};
+struct S2 {
+  int a : 1; // expected-note 2{{bit-field is declared here}}
+  int b;
+};
+
+
+auto [outer1, outer2] = S1{1, 2};
+auto [outerbit1, outerbit2] = S1{1, 2}; // expected-note {{declared here}}
+
 void enclosing() {
   struct S { int a = outer1; };
-  auto [n] = S(); // expected-note 2{{'n' declared here}}
+  auto [n] = S(); // expected-note 3{{'n' declared here}}
+
+  struct Q { int f() { return n; } }; // expected-error {{reference to local binding 'n' declared in enclosing function 'enclosing'}}
+
+  (void) [&] { return n; };  // expected-warning {{C++20}}
+  (void) [n] {return n;};   //expected-warning {{C++20}}
 
-  struct Q { int f() { return n; } }; // expected-error {{reference to local binding 'n' declared in enclosing function}}
-  (void) [&] { return n; }; // expected-error {{reference to local binding 'n' declared in enclosing function}}
-  (void) [n] {}; // 

[PATCH] D122768: [WIP][Clang] Support capturing structured bindings in lambdas

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

This is not quite mature.
I think it needs a few more tests, notably codegen tests which I'm not sure how 
to write properly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122768

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


[PATCH] D122768: [Clang] Support capturing structured bindings in lambdas

2022-03-30 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added subscribers: carlosgalvezp, martong, arphaman, zzheng.
Herald added a reviewer: shafik.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added projects: clang, clang-tools-extra.

This completes the implementation of P1091R3 and P1381R1.

This patch allow the capture of structured bindings
both for C++20+ and C++17, with extension/compat warning.

In addition, capturing an anonymous union member,
a bitfield, or a structured binding thereof now has a
better diagnostic.

Fixes https://github.com/llvm/llvm-project/issues/54300
Fixes https://github.com/llvm/llvm-project/issues/54300
Fixes https://github.com/llvm/llvm-project/issues/52720


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122768

Files:
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/LambdaCapture.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/ScopeInfo.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/Stmt.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/AnalysisDeclContext.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/ScopeInfo.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTWriter.cpp
  clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedLambdaCapturesChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/LoopUnrolling.cpp
  clang/test/SemaCXX/cxx1z-decomposition.cpp
  clang/test/SemaCXX/decomposition-blocks.cpp
  clang/tools/libclang/CIndex.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1144,7 +1144,7 @@
 
   Structured binding extensions
   https://wg21.link/p1091r3;>P1091R3
-  Partial
+  Clang 15
 
   
 https://wg21.link/p1381r1;>P1381R1
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -3350,9 +3350,10 @@
C != CEnd; ++C) {
 if (!C->capturesVariable())
   continue;
-
-if (Visit(MakeCursorVariableRef(C->getCapturedVar(), C->getLocation(),
-TU)))
+// TODO: hamdle structured bindings here ?
+if (!isa(C->getCapturedVar()))
+continue;
+if(Visit(MakeCursorVariableRef(cast(C->getCapturedVar()), C->getLocation(), TU)))
   return true;
   }
   // Visit init captures
Index: clang/test/SemaCXX/decomposition-blocks.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/decomposition-blocks.cpp
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++17 -fsyntax-only -verify %s -fblocks
+
+struct S {
+int i : 1;
+int j;
+};
+
+void run(void (^)());
+void test() {
+auto [i, j] = S{1, 42}; // expected-note {{'i' declared here}}
+run(^{ (void) i; }); // expected-error {{reference to local binding 'i' declared in enclosing function 'test'}}
+}
Index: clang/test/SemaCXX/cxx1z-decomposition.cpp
===
--- clang/test/SemaCXX/cxx1z-decomposition.cpp
+++ clang/test/SemaCXX/cxx1z-decomposition.cpp
@@ -1,4 +1,5 @@
-// RUN: %clang_cc1 -std=c++17 -verify %s
+// RUN: %clang_cc1 -std=c++17 -Wc++20-extensions -verify=expected %s
+// RUN: %clang_cc1 -std=c++20 -Wpre-c++20-compat -verify=expected %s
 
 void use_from_own_init() {
   auto [a] = a; // expected-error {{binding 'a' cannot appear in the initializer of its own decomposition declaration}}
@@ -46,27 +47,60 @@
 }
 static_assert(f({1, 2}) == 12);
 
-constexpr bool g(S &) { 
+constexpr bool g(S &) {
   auto &[a, b] = s;
   return  ==  &&  ==  &&  != 
 }
 static_assert(g({1, 2}));
 
-auto [outer1, outer2] = S{1, 2};
+struct S1 {
+  int a, b;
+};
+struct S2 {
+  int a : 1; // expected-note 2{{bit-field is declared here}}
+  int b;
+};
+
+
+auto [outer1, outer2] = S1{1, 2};
+auto [outerbit1, outerbit2] = S1{1, 2}; // expected-note {{declared here}}
+
 void enclosing() {
   struct S { int a = outer1; };

[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location

2022-03-30 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao updated this revision to Diff 419277.
ayzhao added a comment.

Remove errant diff


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122766

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Preprocessor/file_test_windows.c


Index: clang/test/Preprocessor/file_test_windows.c
===
--- clang/test/Preprocessor/file_test_windows.c
+++ clang/test/Preprocessor/file_test_windows.c
@@ -8,19 +8,19 @@
 filename: __FILE__
 #include "Inputs/include-file-test/file_test.h"
 
-// CHECK: filename: "A:\\UNLIKELY_PATH\\empty\\file_test_windows.c"
-// CHECK: filename: 
"A:\\UNLIKELY_PATH\\empty/Inputs/include-file-test/file_test.h"
-// CHECK: basefile: "A:\\UNLIKELY_PATH\\empty\\file_test_windows.c"
+// CHECK: filename: "A:/UNLIKELY_PATH/empty/file_test_windows.c"
+// CHECK: filename: 
"A:/UNLIKELY_PATH/empty/Inputs/include-file-test/file_test.h"
+// CHECK: basefile: "A:/UNLIKELY_PATH/empty/file_test_windows.c"
 // CHECK-NOT: filename:
 
-// CHECK-EVIL: filename: "A:\\UNLIKELY_PATH=empty\\file_test_windows.c"
-// CHECK-EVIL: filename: 
"A:\\UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
-// CHECK-EVIL: basefile: "A:\\UNLIKELY_PATH=empty\\file_test_windows.c"
+// CHECK-EVIL: filename: "A:/UNLIKELY_PATH=empty/file_test_windows.c"
+// CHECK-EVIL: filename: 
"A:/UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
+// CHECK-EVIL: basefile: "A:/UNLIKELY_PATH=empty/file_test_windows.c"
 // CHECK-EVIL-NOT: filename:
 
-// CHECK-CASE: filename: "A:\\UNLIKELY_PATH_BASE\\file_test_windows.c"
-// CHECK-CASE: filename: "A:\\UNLIKELY_PATH_INC\\include-file-test/file_test.h"
-// CHECK-CASE: basefile: "A:\\UNLIKELY_PATH_BASE\\file_test_windows.c"
+// CHECK-CASE: filename: "A:/UNLIKELY_PATH_BASE/file_test_windows.c"
+// CHECK-CASE: filename: "A:/UNLIKELY_PATH_INC/include-file-test/file_test.h"
+// CHECK-CASE: basefile: "A:/UNLIKELY_PATH_BASE/file_test_windows.c"
 // CHECK-CASE-NOT: filename:
 
 // CHECK-REMOVE: filename: "file_test_windows.c"
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -1512,6 +1512,10 @@
 FN += PLoc.getFilename();
   }
   getLangOpts().remapPathPrefix(FN);
+  if (getTargetInfo().getTriple().isOSWindows()) {
+llvm::sys::path::make_preferred(FN,
+llvm::sys::path::Style::windows_slash);
+  }
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2191,6 +2191,10 @@
   case SourceLocExpr::File: {
 SmallString<256> Path(PLoc.getFilename());
 Ctx.getLangOpts().remapPathPrefix(Path);
+if (Ctx.getTargetInfo().getTriple().isOSWindows()) {
+  llvm::sys::path::make_preferred(Path,
+  llvm::sys::path::Style::windows_slash);
+}
 return MakeStringLiteral(Path);
   }
   case SourceLocExpr::Function: {
@@ -2224,6 +2228,10 @@
   if (Name == "_M_file_name") {
 SmallString<256> Path(PLoc.getFilename());
 Ctx.getLangOpts().remapPathPrefix(Path);
+if (Ctx.getTargetInfo().getTriple().isOSWindows()) {
+  llvm::sys::path::make_preferred(
+  Path, llvm::sys::path::Style::windows_slash);
+}
 Value.getStructField(F->getFieldIndex()) = MakeStringLiteral(Path);
   } else if (Name == "_M_function_name") {
 // Note: this emits the PrettyFunction name -- different than what


Index: clang/test/Preprocessor/file_test_windows.c
===
--- clang/test/Preprocessor/file_test_windows.c
+++ clang/test/Preprocessor/file_test_windows.c
@@ -8,19 +8,19 @@
 filename: __FILE__
 #include "Inputs/include-file-test/file_test.h"
 
-// CHECK: filename: "A:\\UNLIKELY_PATH\\empty\\file_test_windows.c"
-// CHECK: filename: "A:\\UNLIKELY_PATH\\empty/Inputs/include-file-test/file_test.h"
-// CHECK: basefile: "A:\\UNLIKELY_PATH\\empty\\file_test_windows.c"
+// CHECK: filename: "A:/UNLIKELY_PATH/empty/file_test_windows.c"
+// CHECK: filename: "A:/UNLIKELY_PATH/empty/Inputs/include-file-test/file_test.h"
+// CHECK: basefile: "A:/UNLIKELY_PATH/empty/file_test_windows.c"
 // CHECK-NOT: filename:
 
-// CHECK-EVIL: filename: "A:\\UNLIKELY_PATH=empty\\file_test_windows.c"
-// CHECK-EVIL: filename: "A:\\UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
-// CHECK-EVIL: basefile: "A:\\UNLIKELY_PATH=empty\\file_test_windows.c"
+// CHECK-EVIL: filename: "A:/UNLIKELY_PATH=empty/file_test_windows.c"
+// CHECK-EVIL: filename: "A:/UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
+// CHECK-EVIL: basefile: 

[PATCH] D122766: [clang] Use forward slash as the path separator for Windows in __FILE__, __builtin_FILE(), and std::source_location

2022-03-30 Thread Alan Zhao via Phabricator via cfe-commits
ayzhao created this revision.
Herald added subscribers: frasercrmck, luismarques, apazos, sameer.abuasal, 
s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, 
edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, 
asb, hiraditya, arichardson.
Herald added a project: All.
ayzhao requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, MaskRay.
Herald added projects: clang, LLVM.

When targeting Windows, the path separator used when targeting Windows
depends on the build environment when Clang _itself_ is built. This
leads to inconsistencies in Chrome builds where Clang running on
non-Windows environments uses the forward slash (/) path separator
while Clang running on Windows builds uses the backslash (\) path
separator. To fix this, we make Clang use forward slashes whenever it is
targeting Windows.

We chose to use forward slashes instead of backslashes in builds
targeting Windows because according to the C standard, backslashes in
\#include directives result in undefined behavior[1]. We may change this
decision though depending on the review.

[0]: https://crbug.com/1310767
[1]: https://stackoverflow.com/a/5790259


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122766

Files:
  clang/lib/AST/Expr.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/test/Preprocessor/file_test_windows.c
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp


Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp
===
--- llvm/lib/Target/RISCV/RISCVISelLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp
@@ -493,10 +493,12 @@
 ISD::VP_MERGE,   ISD::VP_SELECT,  ISD::VP_FPTOSI};
 
 static const unsigned FloatingPointVPOps[] = {
-ISD::VP_FADD,ISD::VP_FSUB,ISD::VP_FMUL,
-ISD::VP_FDIV,ISD::VP_FNEG,ISD::VP_FMA,
-ISD::VP_REDUCE_FADD, ISD::VP_REDUCE_SEQ_FADD, ISD::VP_REDUCE_FMIN,
-ISD::VP_REDUCE_FMAX, ISD::VP_MERGE,   ISD::VP_SELECT,
+ISD::VP_FADD,ISD::VP_FSUB,
+ISD::VP_FMUL,ISD::VP_FDIV,
+ISD::VP_FNEG,ISD::VP_FMA,
+ISD::VP_REDUCE_FADD, ISD::VP_REDUCE_SEQ_FADD,
+ISD::VP_REDUCE_FMIN, ISD::VP_REDUCE_FMAX,
+ISD::VP_MERGE,   ISD::VP_SELECT,
 ISD::VP_SITOFP};
 
 if (!Subtarget.is64Bit()) {
Index: clang/test/Preprocessor/file_test_windows.c
===
--- clang/test/Preprocessor/file_test_windows.c
+++ clang/test/Preprocessor/file_test_windows.c
@@ -8,19 +8,19 @@
 filename: __FILE__
 #include "Inputs/include-file-test/file_test.h"
 
-// CHECK: filename: "A:\\UNLIKELY_PATH\\empty\\file_test_windows.c"
-// CHECK: filename: 
"A:\\UNLIKELY_PATH\\empty/Inputs/include-file-test/file_test.h"
-// CHECK: basefile: "A:\\UNLIKELY_PATH\\empty\\file_test_windows.c"
+// CHECK: filename: "A:/UNLIKELY_PATH/empty/file_test_windows.c"
+// CHECK: filename: 
"A:/UNLIKELY_PATH/empty/Inputs/include-file-test/file_test.h"
+// CHECK: basefile: "A:/UNLIKELY_PATH/empty/file_test_windows.c"
 // CHECK-NOT: filename:
 
-// CHECK-EVIL: filename: "A:\\UNLIKELY_PATH=empty\\file_test_windows.c"
-// CHECK-EVIL: filename: 
"A:\\UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
-// CHECK-EVIL: basefile: "A:\\UNLIKELY_PATH=empty\\file_test_windows.c"
+// CHECK-EVIL: filename: "A:/UNLIKELY_PATH=empty/file_test_windows.c"
+// CHECK-EVIL: filename: 
"A:/UNLIKELY_PATH=empty/Inputs/include-file-test/file_test.h"
+// CHECK-EVIL: basefile: "A:/UNLIKELY_PATH=empty/file_test_windows.c"
 // CHECK-EVIL-NOT: filename:
 
-// CHECK-CASE: filename: "A:\\UNLIKELY_PATH_BASE\\file_test_windows.c"
-// CHECK-CASE: filename: "A:\\UNLIKELY_PATH_INC\\include-file-test/file_test.h"
-// CHECK-CASE: basefile: "A:\\UNLIKELY_PATH_BASE\\file_test_windows.c"
+// CHECK-CASE: filename: "A:/UNLIKELY_PATH_BASE/file_test_windows.c"
+// CHECK-CASE: filename: "A:/UNLIKELY_PATH_INC/include-file-test/file_test.h"
+// CHECK-CASE: basefile: "A:/UNLIKELY_PATH_BASE/file_test_windows.c"
 // CHECK-CASE-NOT: filename:
 
 // CHECK-REMOVE: filename: "file_test_windows.c"
Index: clang/lib/Lex/PPMacroExpansion.cpp
===
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -1512,6 +1512,10 @@
 FN += PLoc.getFilename();
   }
   getLangOpts().remapPathPrefix(FN);
+  if (getTargetInfo().getTriple().isOSWindows()) {
+llvm::sys::path::make_preferred(FN,
+llvm::sys::path::Style::windows_slash);
+  }
   Lexer::Stringify(FN);
   OS << '"' << FN << '"';
 }
Index: clang/lib/AST/Expr.cpp
===
--- clang/lib/AST/Expr.cpp
+++ clang/lib/AST/Expr.cpp
@@ -2191,6 +2191,10 @@
   case SourceLocExpr::File: {

[PATCH] D115232: [clangd] Indexing of standard library

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:313
+llvm::StringRef DirPath = llvm::sys::path::parent_path(HeaderPath);
+if (!HS.getFileMgr().getVirtualFileSystem().getRealPath(DirPath, Path))
+  SearchPaths.emplace_back(Path);

sammccall wrote:
> kadircet wrote:
> > why do we resolve the symlinks ?
> Oops, because I read the documentation of getCanonicalPath() instead of the 
> implementation, and they diverged in 
> https://github.com/llvm/llvm-project/commit/dd67793c0c549638cd93cad1142d324b979ba682
>  :-D
> 
> Ultimately we're forming URIs to lexically compare with the ones emitted by 
> the indexer, which uses getCanonicalPath(). Today getCanonicalPath() wants a 
> FileEntry and we don't have one, but I think there's no fundamental reason 
> for that, I can fix it.
> 
> (I'll do it as a separate patch, for now it's just calling getCanonicalPath 
> with the wrong arguments)
Actually, nevermind, the code is correct and I'd just forgotten why :-) Added a 
comment to StdLibLocation.

getCanonicalPath() does actually resolve symlinks and so on: it asks the 
FileManager for the directory entry and grabs the its "canonical name" which is 
just FS->getRealPath behind a cache.
So the strings are going to match the indexer after all.

It'd be possible to modify getCanonicalPath() so we can call it here, but I 
don't think it helps. Calling it with (path, filemanager) is inconvenient for 
the (many) existing callsites, so it'd have to be a new overload just for this 
case. And the FileManager caching we'd gain doesn't matter here.
I can still do it if you like, though.

(Also, relevant to your interests, realpath is probably taking care of case 
mismatches too!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115232

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


[PATCH] D115232: [clangd] Indexing of standard library

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 419265.
sammccall added a comment.

revert to previous version of realpath code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115232

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/StdLib.cpp
  clang-tools-extra/clangd/index/StdLib.h
  clang-tools-extra/clangd/index/SymbolOrigin.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/StdLibTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1120,7 +1120,8 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification )
 : BlockVersion(BlockVersion), N(N) {}
-void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext ,
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &, ASTContext ,
Preprocessor &, const CanonicalIncludes &) override {
   if (Version == BlockVersion)
 N.wait();
Index: clang-tools-extra/clangd/unittests/StdLibTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/StdLibTests.cpp
@@ -0,0 +1,125 @@
+//===-- StdLibTests.cpp -*- 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
+//
+//===--===//
+
+#include "Compiler.h"
+#include "Config.h"
+#include "TestFS.h"
+#include "index/StdLib.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace testing;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Check the generated header sources contains usual standard library headers.
+TEST(StdLibTests, getStdlibUmbrellaHeader) {
+  LangOptions LO;
+  LO.CPlusPlus = true;
+
+  auto CXX = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, Not(HasSubstr("#include ")));
+
+  LO.CPlusPlus = false;
+  auto C = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, HasSubstr("#include "));
+}
+
+MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+
+// Build an index, and check if it contains the right symbols.
+TEST(StdLibTests, indexStandardLibrary) {
+  MockFS FS;
+  FS.Files["std/foo.h"] = R"cpp(
+  #include 
+  #if __cplusplus >= 201703L
+int foo17();
+  #elif __cplusplus >= 201402L
+int foo14();
+  #else
+bool foo98();
+  #endif
+  )cpp";
+  FS.Files["nonstd/platform_stuff.h"] = "int magic = 42;";
+
+  ParseInputs OriginalInputs;
+  OriginalInputs.TFS = 
+  OriginalInputs.CompileCommand.Filename = testPath("main.cc");
+  OriginalInputs.CompileCommand.CommandLine = {"clang++", testPath("main.cc"),
+   "-isystemstd/",
+   "-isystemnonstd/", "-std=c++14"};
+  OriginalInputs.CompileCommand.Directory = testRoot();
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(OriginalInputs, Diags);
+  ASSERT_TRUE(CI);
+
+  StdLibLocation Loc;
+  Loc.Paths.push_back(testPath("std/"));
+
+  auto Symbols =
+  indexStandardLibrary("#include ", std::move(CI), Loc, FS);
+  EXPECT_THAT(Symbols, ElementsAre(Named("foo14")));
+}
+
+TEST(StdLibTests, StdLibSet) {
+  StdLibSet Set;
+  MockFS FS;
+  FS.Files["std/_"] = "";
+  FS.Files["libc/_"] = "";
+
+  auto Add = [&](const LangOptions ,
+ std::vector SearchPath) {
+SourceManagerForFile SM("scratch", "");
+SM.get().getFileManager().setVirtualFileSystem(FS.view(llvm::None));
+HeaderSearch HS(/*HSOpts=*/nullptr, SM.get(), SM.get().getDiagnostics(), LO,
+/*Target=*/nullptr);
+for (auto P : SearchPath)
+  HS.AddSearchPath(
+  DirectoryLookup(
+  

[PATCH] D115232: [clangd] Indexing of standard library

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 419262.
sammccall added a comment.

Revert StdLibLocation to realpath, document why


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115232

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/StdLib.cpp
  clang-tools-extra/clangd/index/StdLib.h
  clang-tools-extra/clangd/index/SymbolOrigin.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/StdLibTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1120,7 +1120,8 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification )
 : BlockVersion(BlockVersion), N(N) {}
-void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext ,
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &, ASTContext ,
Preprocessor &, const CanonicalIncludes &) override {
   if (Version == BlockVersion)
 N.wait();
Index: clang-tools-extra/clangd/unittests/StdLibTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/StdLibTests.cpp
@@ -0,0 +1,125 @@
+//===-- StdLibTests.cpp -*- 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
+//
+//===--===//
+
+#include "Compiler.h"
+#include "Config.h"
+#include "TestFS.h"
+#include "index/StdLib.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace testing;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Check the generated header sources contains usual standard library headers.
+TEST(StdLibTests, getStdlibUmbrellaHeader) {
+  LangOptions LO;
+  LO.CPlusPlus = true;
+
+  auto CXX = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, Not(HasSubstr("#include ")));
+
+  LO.CPlusPlus = false;
+  auto C = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, HasSubstr("#include "));
+}
+
+MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+
+// Build an index, and check if it contains the right symbols.
+TEST(StdLibTests, indexStandardLibrary) {
+  MockFS FS;
+  FS.Files["std/foo.h"] = R"cpp(
+  #include 
+  #if __cplusplus >= 201703L
+int foo17();
+  #elif __cplusplus >= 201402L
+int foo14();
+  #else
+bool foo98();
+  #endif
+  )cpp";
+  FS.Files["nonstd/platform_stuff.h"] = "int magic = 42;";
+
+  ParseInputs OriginalInputs;
+  OriginalInputs.TFS = 
+  OriginalInputs.CompileCommand.Filename = testPath("main.cc");
+  OriginalInputs.CompileCommand.CommandLine = {"clang++", testPath("main.cc"),
+   "-isystemstd/",
+   "-isystemnonstd/", "-std=c++14"};
+  OriginalInputs.CompileCommand.Directory = testRoot();
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(OriginalInputs, Diags);
+  ASSERT_TRUE(CI);
+
+  StdLibLocation Loc;
+  Loc.Paths.push_back(testPath("std/"));
+
+  auto Symbols =
+  indexStandardLibrary("#include ", std::move(CI), Loc, FS);
+  EXPECT_THAT(Symbols, ElementsAre(Named("foo14")));
+}
+
+TEST(StdLibTests, StdLibSet) {
+  StdLibSet Set;
+  MockFS FS;
+  FS.Files["std/_"] = "";
+  FS.Files["libc/_"] = "";
+
+  auto Add = [&](const LangOptions ,
+ std::vector SearchPath) {
+SourceManagerForFile SM("scratch", "");
+SM.get().getFileManager().setVirtualFileSystem(FS.view(llvm::None));
+HeaderSearch HS(/*HSOpts=*/nullptr, SM.get(), SM.get().getDiagnostics(), LO,
+/*Target=*/nullptr);
+for (auto P : SearchPath)
+  HS.AddSearchPath(
+  DirectoryLookup(
+  

[PATCH] D122759: [time-report] Add timers to codegen actions

2022-03-30 Thread Wei Wang via Phabricator via cfe-commits
weiwang updated this revision to Diff 419261.
weiwang added a comment.

fix typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122759

Files:
  clang/include/clang/Frontend/FrontendAction.h
  clang/include/clang/Parse/ParseAST.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/lib/Parse/ParseAST.cpp

Index: clang/lib/Parse/ParseAST.cpp
===
--- clang/lib/Parse/ParseAST.cpp
+++ clang/lib/Parse/ParseAST.cpp
@@ -23,6 +23,7 @@
 #include "clang/Sema/TemplateInstCallback.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/Timer.h"
 #include 
 #include 
 
@@ -111,7 +112,8 @@
   ParseAST(*S.get(), PrintStats, SkipFunctionBodies);
 }
 
-void clang::ParseAST(Sema , bool PrintStats, bool SkipFunctionBodies) {
+void clang::ParseAST(Sema , bool PrintStats, bool SkipFunctionBodies,
+ bool TimePassesIsEnabled) {
   // Collect global stats on Decls/Stmts (until we have a module streamer).
   if (PrintStats) {
 Decl::EnableStatistics();
@@ -152,6 +154,8 @@
 
   if (HaveLexer) {
 llvm::TimeTraceScope TimeScope("Frontend");
+llvm::NamedRegionTimer T("Parse AST", "Parse AST", "Clang Compilation",
+ "Clang Compilation", TimePassesIsEnabled);
 P.Initialize();
 Parser::DeclGroupPtrTy ADecl;
 Sema::ModuleImportState ImportState;
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -186,6 +186,9 @@
 Act = std::make_unique(std::move(Act),
 FEOpts.ASTMergeFiles);
 
+  if (CI.getCodeGenOpts().TimePasses)
+Act->enableTimePasses();
+
   return Act;
 }
 
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -1137,7 +1137,7 @@
 CI.createSema(getTranslationUnitKind(), CompletionConsumer);
 
   ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats,
-   CI.getFrontendOpts().SkipFunctionBodies);
+   CI.getFrontendOpts().SkipFunctionBodies, isTimePassesEnabled());
 }
 
 void PluginASTAction::anchor() { }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -294,6 +294,9 @@
 void HandleTranslationUnit(ASTContext ) override {
   {
 llvm::TimeTraceScope TimeScope("Frontend");
+llvm::NamedRegionTimer T("IR Generation", "IR Generation",
+ "Clang Compilation", "Clang Compilation",
+ CodeGenOpts.TimePasses);
 PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
 if (TimerIsEnabled) {
   LLVMIRGenerationRefCount += 1;
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1500,6 +1500,8 @@
   {
 PrettyStackTraceString CrashInfo("Optimizer");
 llvm::TimeTraceScope TimeScope("Optimizer");
+llvm::NamedRegionTimer T("Optimizer", "Optimizer", "Clang Compilation",
+ "Clang Compilation", CodeGenOpts.TimePasses);
 MPM.run(*TheModule, MAM);
   }
 }
@@ -1536,6 +1538,9 @@
   {
 PrettyStackTraceString CrashInfo("Code generation");
 llvm::TimeTraceScope TimeScope("CodeGenPasses");
+llvm::NamedRegionTimer T("CodeGenPasses", "CodeGenPasses",
+ "Clang Compilation", "Clang Compilation",
+ CodeGenOpts.TimePasses);
 CodeGenPasses.run(*TheModule);
   }
 }
Index: clang/include/clang/Parse/ParseAST.h
===
--- clang/include/clang/Parse/ParseAST.h
+++ clang/include/clang/Parse/ParseAST.h
@@ -44,7 +44,8 @@
   /// Parse the main file known to the preprocessor, producing an
   /// abstract syntax tree.
   void ParseAST(Sema , bool PrintStats = false,
-bool SkipFunctionBodies = false);
+bool SkipFunctionBodies = false,
+bool TimePassesIsEnabled = false);
 
 }  // end namespace clang
 
Index: clang/include/clang/Frontend/FrontendAction.h
===
--- clang/include/clang/Frontend/FrontendAction.h
+++ clang/include/clang/Frontend/FrontendAction.h
@@ -37,6 +37,7 @@
   FrontendInputFile CurrentInput;
  

[PATCH] D115232: [clangd] Indexing of standard library

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

(sorry about the long delay, would still love to merge this)




Comment at: clang-tools-extra/clangd/index/StdLib.cpp:92
+  // The umbrella header is the same for all versions of each language.
+  // Headers that are unsupported in old lang versions are usually guarded by
+  // #if. Some headers may be not present in old stdlib versions, the umbrella

kadircet wrote:
> maybe move second half of this comment into `buildUmbrella` ?
I think that removes the context of why we're #including them.



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:160
+if (!S.IncludeHeaders.empty() &&
+StandardHeaders.contains(S.IncludeHeaders.front().IncludeHeader)) {
+  GoodHeader[S.CanonicalDeclaration.FileURI] = true;

kadircet wrote:
> `StandardHeaders` are always in verbatim format, but are we sure if that 
> holds for the `IncludeHeader` ?
> 
> I suppose that should be the case since we map known path suffixes back to a 
> verbatim umbrella header, I just wonder how exhaustive the list is. (it might 
> be nice to manually check no implementation detail headers falls out of 
> cracks)
Right, I looked at these manually and the headers (and symbols) we were 
dropping seemed reasonable.

Note that we're **not** filtering symbols in this loop, just building a list of 
blessed files to **add** to the StdLibLocation.

So we only drop symbols that:
 - aren't recognized by the indexer as being in the standard library
 - aren't in the standard library directory
 - don't share a file with anything recognized as being in the standard library




Comment at: clang-tools-extra/clangd/index/StdLib.cpp:177
+  }
+  for (const auto  : GoodHeader)
+if (Good.second)

kadircet wrote:
> seems like debugging artifact, either drop or put in `#ifndef NDEBUG`
This is useful for debugging, and fits well with the other dlog()s in this 
file, I'd like to check it in.

I was going to call you paranoid, being sure this would get compiled out.
but indeed not: https://godbolt.org/z/hKWhro3Mv (gcc manages it)

Added #ifndef NDEBUG



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:204
+  !CI->getPreprocessorOpts().ImplicitPCHInclude.empty()) {
+elog("Indexing standard library failed: bad CompilerInvocation");
+assert(false && "indexing stdlib with a dubious CompilerInvocation!");

kadircet wrote:
> why log if we think we can't hit this case?
Because I'm not certain, and would much rather get a user bug report with this 
log line in it than without!

(Assert because I'd most rather find out before release of course)



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:216
+  IgnoreDiagnostics IgnoreDiags;
+  CI->getPreprocessorOpts().clearRemappedFiles();
+  auto Clang = prepareCompilerInstance(

kadircet wrote:
> why are we doing this exactly? once we override the same file multiple times, 
> I believe the last one takes precedence. it's definitely safer to clear the 
> remapped files here rather than relying on that fact, but I am afraid of 
> losing other mappings, possibly set outside of clangd's knowledge (e.g. 
> through flags like `-remap-file`?)
We map dirty buffers ourselves. Conceivably, it may be part of the standard 
library itself that was remapped to some dirty buffer content!

We're reusing the CompilerInvocation from building a preamble, where we remap 
the main-file buffer to the dirty contents. (We do this in 
prepareCompilerInstance, but the PPOptions are shared).
This isn't part of the "compilerinvocation-as-proxy-for-build-flags" that we're 
trying to index.

I don't think it's a realistic possibility that anyone would rely on `-Xclang 
-remap-file` to find the standard library (note that it's a cc1 flag, not a 
public one...).



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:233
+  // Sadly we can't use IndexOpts.FileFilter to restrict indexing scope.
+  // Files from outside the location may define true std symbols anyway.
+  // We end up "blessing" such headers, and can only do that by indexing

kadircet wrote:
> what does `the location` refer to here? I think we should also stress the 
> fact that even when indexing the same file, we have a good chance of seeing 
> different symbols due to PP directives (and different std versions)
> what does the location refer to here? 

It refers to the StdLibLocation Loc, made that explicit.

> I think we should also stress the fact that even when indexing the same file, 
> we have a good chance of seeing different symbols due to PP directives (and 
> different std versions)

Different than what? Do you mean "why might different calls to 
indexStandardLibrary see different symbols" from the same file?



Comment at: clang-tools-extra/clangd/index/StdLib.cpp:256
+  if (HadErrors) {
+log("Errors when 

[PATCH] D115232: [clangd] Indexing of standard library

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 419259.
sammccall marked 15 inline comments as done.
sammccall added a comment.
Herald added a project: All.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115232

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/Config.h
  clang-tools-extra/clangd/ConfigCompile.cpp
  clang-tools-extra/clangd/ConfigFragment.h
  clang-tools-extra/clangd/ConfigYAML.cpp
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/index/FileIndex.cpp
  clang-tools-extra/clangd/index/FileIndex.h
  clang-tools-extra/clangd/index/StdLib.cpp
  clang-tools-extra/clangd/index/StdLib.h
  clang-tools-extra/clangd/index/SymbolOrigin.cpp
  clang-tools-extra/clangd/index/SymbolOrigin.h
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/StdLibTests.cpp
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -1120,7 +1120,8 @@
   public:
 BlockPreambleThread(llvm::StringRef BlockVersion, Notification )
 : BlockVersion(BlockVersion), N(N) {}
-void onPreambleAST(PathRef Path, llvm::StringRef Version, ASTContext ,
+void onPreambleAST(PathRef Path, llvm::StringRef Version,
+   const CompilerInvocation &, ASTContext ,
Preprocessor &, const CanonicalIncludes &) override {
   if (Version == BlockVersion)
 N.wait();
Index: clang-tools-extra/clangd/unittests/StdLibTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/StdLibTests.cpp
@@ -0,0 +1,125 @@
+//===-- StdLibTests.cpp -*- 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
+//
+//===--===//
+
+#include "Compiler.h"
+#include "Config.h"
+#include "TestFS.h"
+#include "index/StdLib.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceManager.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+using namespace testing;
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Check the generated header sources contains usual standard library headers.
+TEST(StdLibTests, getStdlibUmbrellaHeader) {
+  LangOptions LO;
+  LO.CPlusPlus = true;
+
+  auto CXX = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, HasSubstr("#include "));
+  EXPECT_THAT(CXX, Not(HasSubstr("#include ")));
+
+  LO.CPlusPlus = false;
+  auto C = getStdlibUmbrellaHeader(LO);
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, Not(HasSubstr("#include ")));
+  EXPECT_THAT(C, HasSubstr("#include "));
+}
+
+MATCHER_P(Named, Name, "") { return arg.Name == Name; }
+
+// Build an index, and check if it contains the right symbols.
+TEST(StdLibTests, indexStandardLibrary) {
+  MockFS FS;
+  FS.Files["std/foo.h"] = R"cpp(
+  #include 
+  #if __cplusplus >= 201703L
+int foo17();
+  #elif __cplusplus >= 201402L
+int foo14();
+  #else
+bool foo98();
+  #endif
+  )cpp";
+  FS.Files["nonstd/platform_stuff.h"] = "int magic = 42;";
+
+  ParseInputs OriginalInputs;
+  OriginalInputs.TFS = 
+  OriginalInputs.CompileCommand.Filename = testPath("main.cc");
+  OriginalInputs.CompileCommand.CommandLine = {"clang++", testPath("main.cc"),
+   "-isystemstd/",
+   "-isystemnonstd/", "-std=c++14"};
+  OriginalInputs.CompileCommand.Directory = testRoot();
+  IgnoreDiagnostics Diags;
+  auto CI = buildCompilerInvocation(OriginalInputs, Diags);
+  ASSERT_TRUE(CI);
+
+  StdLibLocation Loc;
+  Loc.Paths.push_back(testPath("std/"));
+
+  auto Symbols =
+  indexStandardLibrary("#include ", std::move(CI), Loc, FS);
+  EXPECT_THAT(Symbols, ElementsAre(Named("foo14")));
+}
+
+TEST(StdLibTests, StdLibSet) {
+  StdLibSet Set;
+  MockFS FS;
+  FS.Files["std/_"] = "";
+  FS.Files["libc/_"] = "";
+
+  auto Add = [&](const LangOptions ,
+ std::vector SearchPath) {
+SourceManagerForFile SM("scratch", "");
+SM.get().getFileManager().setVirtualFileSystem(FS.view(llvm::None));
+HeaderSearch HS(/*HSOpts=*/nullptr, SM.get(), SM.get().getDiagnostics(), LO,
+/*Target=*/nullptr);
+for (auto P : SearchPath)
+  HS.AddSearchPath(
+  

[PATCH] D122760: [OpenMP] Add OpenMP variant extension to keep the unmangled name

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

The test currently fails because we don't do the stripping when we emit the 
precompiled header, it will simply be imported using the mangled version and it 
will not have in the original input info associated with it. I will need to 
figure out where we emit the PCH definitions and also demangle it there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122760

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


[PATCH] D122760: [OpenMP] Add OpenMP variant extension to keep the unmangled name

2022-03-30 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added a reviewer: jdoerfert.
Herald added subscribers: asavonic, dexonsmith, guansong, yaxunl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, sstefan1.
Herald added projects: clang, LLVM.

The OpenMP variant clause current ensures unique function identifiers by
mangling the name with `$ompvariant...`. This patch adds an extension to
prevent this by stripping off the mangling during code generation. Doing
this will conflict with the other symbols in the module, but it will
allow us to overload the names of existing symbols if their definitions
are allowed to be dropped. This is most useful for overloading the
meaning of math functions without changing the symbol so they can still
be identified by LLVM.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122760

Files:
  clang/include/clang/Basic/IdentifierTable.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1157,6 +1157,7 @@
 __OMP_TRAIT_PROPERTY(implementation, extension, match_none)
 __OMP_TRAIT_PROPERTY(implementation, extension, disable_implicit_base)
 __OMP_TRAIT_PROPERTY(implementation, extension, allow_templates)
+__OMP_TRAIT_PROPERTY(implementation, extension, keep_original_name)
 
 __OMP_TRAIT_SET(user)
 
Index: clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
===
--- clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
+++ clang/test/OpenMP/nvptx_declare_variant_name_mangling.cpp
@@ -8,12 +8,16 @@
 // CHECK-DAG: @_Z3bazv
 // CHECK-DAG: define{{.*}} @"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
 // CHECK-DAG: define{{.*}} @"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"
+// CHECK-DAG: define{{.*}} @_ZL73foo
 // CHECK-DAG: call noundef i32 @"_Z53bar$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"()
 // CHECK-DAG: call noundef i32 @"_Z53baz$ompvariant$S2$s7$Pnvptx$Pnvptx64$S3$s9$Pmatch_anyv"()
+// CHECK-DAG: call noundef i32 @_ZL73foo()
 
 #ifndef HEADER
 #define HEADER
 
+static int foo() { return 3; }
+
 #pragma omp declare target
 
 int bar() { return 1; }
@@ -28,13 +32,22 @@
 
 #pragma omp end declare variant
 
+#pragma omp begin declare variant match(device = {arch(nvptx, nvptx64)}, implementation = {extension(match_any, keep_original_name)})
+
+static int foo() { return 2; }
+
+#pragma omp end declare variant
+
 #pragma omp end declare target
 
 int main() {
   int res;
 #pragma omp target map(from \
: res)
-  res = bar() + baz();
+  res += bar() + baz();
+#pragma omp target map(from \
+   : res)
+  res += foo();
   return res;
 }
 
Index: clang/lib/Sema/SemaOpenMP.cpp
===
--- clang/lib/Sema/SemaOpenMP.cpp
+++ clang/lib/Sema/SemaOpenMP.cpp
@@ -6881,6 +6881,8 @@
   IdentifierInfo  = Context.Idents.get(MangledName);
 
   VariantII.setMangledOpenMPVariantName(true);
+  VariantII.setKeepOpenMPVariantName(DVScope.TI->isExtensionActive(
+  llvm::omp::TraitProperty::implementation_extension_keep_original_name));
   D.SetIdentifier(, D.getBeginLoc());
 }
 
Index: clang/lib/Parse/ParseOpenMP.cpp
===
--- clang/lib/Parse/ParseOpenMP.cpp
+++ clang/lib/Parse/ParseOpenMP.cpp
@@ -957,6 +957,10 @@
   TraitProperty::implementation_extension_allow_templates)
 return true;
 
+  if (TIProperty.Kind ==
+  TraitProperty::implementation_extension_keep_original_name)
+return true;
+
   auto IsMatchExtension = [](OMPTraitProperty ) {
 return (TP.Kind ==
 llvm::omp::TraitProperty::implementation_extension_match_all ||
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1477,6 +1477,14 @@
  GD.getWithKernelReferenceKind(KernelReferenceKind::Kernel),
  ND));
 
+  // If this is an OpenMP variant with the `keep_original_name` extension we
+  // remove the variant mangling.
+  const IdentifierInfo *II = ND->getIdentifier();
+  if (II && II->isMangledOpenMPVariantName() && II->keepOpenMPVariantName())
+MangledName = StringRef(MangledName)
+  .split(getOpenMPVariantManglingSeparatorStr())
+  .first.str();
+
   auto Result = Manglings.insert(std::make_pair(MangledName, GD));
   return MangledDeclNames[CanonicalGD] = 

[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang closed this revision.
dang added a comment.

529a0570f7e8c5144bd3ad057e43f00e3af58d1b 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang closed this revision.
dang added a comment.

a9909d23e9bb8c4649cba1c14d479c28df4ca185 



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

https://reviews.llvm.org/D122648

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


[PATCH] D120952: [clang][AST matchers] adding submatchers under cudaKernelCallExpr to match kernel launch config

2022-03-30 Thread Alister Johnson via Phabricator via cfe-commits
ajohnson-uoregon updated this revision to Diff 419252.
ajohnson-uoregon added a comment.

Removing specific argument matchers and leaving just hasKernelConfig()


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120952

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/Dynamic/Registry.cpp


Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -320,6 +320,7 @@
   REGISTER_MATCHER(hasInit);
   REGISTER_MATCHER(hasInitializer);
   REGISTER_MATCHER(hasInitStatement);
+  REGISTER_MATCHER(hasKernelConfig);
   REGISTER_MATCHER(hasKeywordSelector);
   REGISTER_MATCHER(hasLHS);
   REGISTER_MATCHER(hasLocalQualifiers);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7826,6 +7826,20 @@
 extern const internal::VariadicDynCastAllOfMatcher
 cudaKernelCallExpr;
 
+/// Matches the kernel launch config (in <<<>>>) on CUDA kernel calls.
+///
+/// Example: cudaKernelCallExpr(hasKernelConfig()) will match <<>> in
+/// \code
+///   kernel<<>>();
+/// \endcode
+AST_MATCHER_P(CUDAKernelCallExpr, hasKernelConfig, internal::Matcher,
+  InnerMatcher) {
+  if (const CallExpr *Config = Node.getConfig()) {
+return InnerMatcher.matches(*Config, Finder, Builder);
+  }
+  return false;
+}
+
 /// Matches expressions that resolve to a null pointer constant, such as
 /// GNU's __null, C++11's nullptr, or C's NULL macro.
 ///
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -6422,6 +6422,14 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html;>CUDAKernelCallExprhasKernelConfigMatcherhttps://clang.llvm.org/doxygen/classclang_1_1CallExpr.html;>CallExpr
 InnerMatcher
+Matches the kernel 
launch config (in ) on CUDA kernel calls.
+
+Example: cudaKernelCallExpr(hasKernelConfig()) will match 
i,j in
+  kerneli,j();
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html;>CXXBaseSpecifierhasTypeLocMatcherhttps://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html;>TypeLoc
 Inner
 Matches if the type 
location of a node matches the inner matcher.
 


Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -320,6 +320,7 @@
   REGISTER_MATCHER(hasInit);
   REGISTER_MATCHER(hasInitializer);
   REGISTER_MATCHER(hasInitStatement);
+  REGISTER_MATCHER(hasKernelConfig);
   REGISTER_MATCHER(hasKeywordSelector);
   REGISTER_MATCHER(hasLHS);
   REGISTER_MATCHER(hasLocalQualifiers);
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7826,6 +7826,20 @@
 extern const internal::VariadicDynCastAllOfMatcher
 cudaKernelCallExpr;
 
+/// Matches the kernel launch config (in <<<>>>) on CUDA kernel calls.
+///
+/// Example: cudaKernelCallExpr(hasKernelConfig()) will match <<>> in
+/// \code
+///   kernel<<>>();
+/// \endcode
+AST_MATCHER_P(CUDAKernelCallExpr, hasKernelConfig, internal::Matcher,
+  InnerMatcher) {
+  if (const CallExpr *Config = Node.getConfig()) {
+return InnerMatcher.matches(*Config, Finder, Builder);
+  }
+  return false;
+}
+
 /// Matches expressions that resolve to a null pointer constant, such as
 /// GNU's __null, C++11's nullptr, or C's NULL macro.
 ///
Index: clang/docs/LibASTMatchersReference.html
===
--- clang/docs/LibASTMatchersReference.html
+++ clang/docs/LibASTMatchersReference.html
@@ -6422,6 +6422,14 @@
 
 
 
+Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CUDAKernelCallExpr.html;>CUDAKernelCallExprhasKernelConfigMatcherhttps://clang.llvm.org/doxygen/classclang_1_1CallExpr.html;>CallExpr InnerMatcher
+Matches the kernel launch config (in ) on CUDA kernel calls.
+
+Example: cudaKernelCallExpr(hasKernelConfig()) will match i,j in
+  kerneli,j();
+
+
+
 Matcherhttps://clang.llvm.org/doxygen/classclang_1_1CXXBaseSpecifier.html;>CXXBaseSpecifierhasTypeLocMatcherhttps://clang.llvm.org/doxygen/classclang_1_1TypeLoc.html;>TypeLoc Inner
 Matches if the type location of a node matches the inner matcher.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

My windows bot cycled green, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D122759: [time-report] Add timers to codegen actions

2022-03-30 Thread Wei Wang via Phabricator via cfe-commits
weiwang created this revision.
Herald added subscribers: ormris, hoy, wenlei.
Herald added a project: All.
weiwang requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122759

Files:
  clang/include/clang/Frontend/FrontendAction.h
  clang/include/clang/Parse/ParseAST.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  clang/lib/Parse/ParseAST.cpp

Index: clang/lib/Parse/ParseAST.cpp
===
--- clang/lib/Parse/ParseAST.cpp
+++ clang/lib/Parse/ParseAST.cpp
@@ -23,6 +23,7 @@
 #include "clang/Sema/TemplateInstCallback.h"
 #include "llvm/Support/CrashRecoveryContext.h"
 #include "llvm/Support/TimeProfiler.h"
+#include "llvm/Support/Timer.h"
 #include 
 #include 
 
@@ -111,7 +112,8 @@
   ParseAST(*S.get(), PrintStats, SkipFunctionBodies);
 }
 
-void clang::ParseAST(Sema , bool PrintStats, bool SkipFunctionBodies) {
+void clang::ParseAST(Sema , bool PrintStats, bool SkipFunctionBodies,
+ bool TimePassesIsEnabled) {
   // Collect global stats on Decls/Stmts (until we have a module streamer).
   if (PrintStats) {
 Decl::EnableStatistics();
@@ -152,6 +154,8 @@
 
   if (HaveLexer) {
 llvm::TimeTraceScope TimeScope("Frontend");
+llvm::NamedRegionTimer T("Parse AST", "Parse AST", "Clang Compilation",
+ "Clang Commpilation", TimePassesIsEnabled);
 P.Initialize();
 Parser::DeclGroupPtrTy ADecl;
 Sema::ModuleImportState ImportState;
Index: clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
===
--- clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
+++ clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp
@@ -186,6 +186,9 @@
 Act = std::make_unique(std::move(Act),
 FEOpts.ASTMergeFiles);
 
+  if (CI.getCodeGenOpts().TimePasses)
+Act->enableTimePasses();
+
   return Act;
 }
 
Index: clang/lib/Frontend/FrontendAction.cpp
===
--- clang/lib/Frontend/FrontendAction.cpp
+++ clang/lib/Frontend/FrontendAction.cpp
@@ -1137,7 +1137,7 @@
 CI.createSema(getTranslationUnitKind(), CompletionConsumer);
 
   ParseAST(CI.getSema(), CI.getFrontendOpts().ShowStats,
-   CI.getFrontendOpts().SkipFunctionBodies);
+   CI.getFrontendOpts().SkipFunctionBodies, isTimePassesEnabled());
 }
 
 void PluginASTAction::anchor() { }
Index: clang/lib/CodeGen/CodeGenAction.cpp
===
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -294,6 +294,9 @@
 void HandleTranslationUnit(ASTContext ) override {
   {
 llvm::TimeTraceScope TimeScope("Frontend");
+llvm::NamedRegionTimer T("IR Generation", "IR Generation",
+ "Clang Compilation", "Clang Compilation",
+ CodeGenOpts.TimePasses);
 PrettyStackTraceString CrashInfo("Per-file LLVM IR generation");
 if (TimerIsEnabled) {
   LLVMIRGenerationRefCount += 1;
Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -1500,6 +1500,8 @@
   {
 PrettyStackTraceString CrashInfo("Optimizer");
 llvm::TimeTraceScope TimeScope("Optimizer");
+llvm::NamedRegionTimer T("Optimizer", "Optimizer", "Clang Compilation",
+ "Clang Compilation", CodeGenOpts.TimePasses);
 MPM.run(*TheModule, MAM);
   }
 }
@@ -1536,6 +1538,9 @@
   {
 PrettyStackTraceString CrashInfo("Code generation");
 llvm::TimeTraceScope TimeScope("CodeGenPasses");
+llvm::NamedRegionTimer T("CodeGenPasses", "CodeGenPasses",
+ "Clang Compilation", "Clang Compilation",
+ CodeGenOpts.TimePasses);
 CodeGenPasses.run(*TheModule);
   }
 }
Index: clang/include/clang/Parse/ParseAST.h
===
--- clang/include/clang/Parse/ParseAST.h
+++ clang/include/clang/Parse/ParseAST.h
@@ -44,7 +44,8 @@
   /// Parse the main file known to the preprocessor, producing an
   /// abstract syntax tree.
   void ParseAST(Sema , bool PrintStats = false,
-bool SkipFunctionBodies = false);
+bool SkipFunctionBodies = false,
+bool TimePassesIsEnabled = false);
 
 }  // end namespace clang
 
Index: clang/include/clang/Frontend/FrontendAction.h
===
--- clang/include/clang/Frontend/FrontendAction.h
+++ 

[PATCH] D122699: [HLSL] Add Semantic syntax, and SV_GroupIndex

2022-03-30 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseDecl.cpp:6965-6966
 // Parse GNU attributes, if present.
 MaybeParseGNUAttributes(ParmDeclarator);
+MaybeParseHLSLSemantics(DS.getAttributes());
 

beanz wrote:
> aaron.ballman wrote:
> > This means the order is very specific -- should this be using 
> > `MaybeParseAttributes()` so that the syntaxes can be intermingled?
> > 
> > This reminds me, I don't see a change to `ParseAttrKindMask`, but perhaps 
> > we want that for both the microsoft and HLSL semantic attributes?
> This is kinda 6 one way half dozen the other. GNU attribute syntax isn't 
> supported in HLSL, I just haven't gotten around to disabling it yet.
> 
> If you have a preferred implementation I'm happy to go whatever way you 
> suggest.
> 
> The HLSL language doesn't support Semantics or Microsoft-style attributes in 
> all that many places in code. MS attributes are only used on functions, and 
> semantics are restricted to input/output data (which is a little more 
> complicated than it sounds, but basically is function parameters, returns, 
> global variables and struct members).
Okay, then let's leave this as-is -- we can address it if someone hits an 
actual pain point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122699

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


[PATCH] D122627: [HLSL] Fix MSFT Attribute parsing, add numthreads

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

In D122627#3417495 , @beanz wrote:

> @aaron.ballman I pushed updates in rGff6696c842ba 
> .
>
> The one bit we discussed that I didn't do anything for is the template case. 
> Neither clang or the HLSL compiler support parsing Microsoft attributes on 
> templates right now, so the parser falls over and errors. It would be better 
> to have a nicer diagnostic, but since the current state matches our compiler 
> I left it as-is.

That sounds reasonable to me.

> Thank you!

Thanks for the post-commit changes! One question on them:

  def GlobalFunction
  : SubsetSubjectisGlobal()}], "global functions">;

Are you sure that's what you want? This returns true for a static C++ member 
function, false for a static free function, and false for within an unnamed 
namespace, and true otherwise.

Also, I didn't see any new test coverage for function merging behavior.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122627

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


[PATCH] D120949: [clang][AST matchers] adding attributedStmt AST matcher

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

In D120949#3417545 , 
@ajohnson-uoregon wrote:

> Okay, I put the assert back in and made a thing similar to HasSizeMatcher 
> that works and all the tests pass.
>
> What do you mean by a release note, in the commit message, in the docs...?

https://github.com/llvm/llvm-project/blob/main/clang/docs/ReleaseNotes.rst has 
a section for AST Matchers, so you should add the notes there.

Otherwise, the changes here all LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120949

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


[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added a comment.

@thakis I am UK based so I am logging off as it's 9pm over here. The fix I 
committed has fixed the issue on other buildbots that were failing due to this. 
If it still fails on Windows, would you be able to revert the change for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D120949: [clang][AST matchers] adding attributedStmt AST matcher

2022-03-30 Thread Alister Johnson via Phabricator via cfe-commits
ajohnson-uoregon updated this revision to Diff 419248.
ajohnson-uoregon added a comment.

Okay, I put the assert back in and made a thing similar to HasSizeMatcher that 
works and all the tests pass.

What do you mean by a release note, in the commit message, in the docs...?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120949

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/ASTMatchers/ASTMatchersInternal.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
@@ -184,9 +184,9 @@
 
 TEST(ASTMatchersTestCUDA, HasAttrCUDA) {
   EXPECT_TRUE(matchesWithCuda("__attribute__((device)) void f() {}",
-  hasAttr(clang::attr::CUDADevice)));
+  decl(hasAttr(clang::attr::CUDADevice;
   EXPECT_FALSE(notMatchesWithCuda("__attribute__((global)) void f() {}",
-  hasAttr(clang::attr::CUDAGlobal)));
+  decl(hasAttr(clang::attr::CUDAGlobal;
 }
 
 TEST_P(ASTMatchersTest, ValueDecl) {
@@ -2509,6 +2509,37 @@
   EXPECT_FALSE(Finder.addDynamicMatcher(hasName("x"), nullptr));
 }
 
+TEST(ASTMatchersTest, AttributedStmtBasic) {
+  StringRef Code = "int foo() { [[likely]] return 1; }";
+  EXPECT_TRUE(
+  matchesConditionally(Code, attributedStmt(), true, {"-std=c++20"}));
+}
+
+TEST(ASTMatchersTest, AttributedStmt_hasAttr) {
+  StringRef Code = "int foo() { [[unlikely]] return 1; }";
+  EXPECT_TRUE(matchesConditionally(
+  Code, attributedStmt(hasAttr(attr::Unlikely)), true, {"-std=c++20"}));
+  EXPECT_FALSE(matchesConditionally(
+  Code, attributedStmt(hasAttr(attr::Builtin)), true, {"-std=c++20"}));
+}
+
+TEST(ASTMatchersTest, AttributedStmt_hasSubStmt) {
+  StringRef Code = "int foo() { [[likely]] return 1; }";
+  EXPECT_TRUE(matchesConditionally(
+  Code, attributedStmt(hasSubStmt(returnStmt())), true, {"-std=c++20"}));
+  EXPECT_FALSE(matchesConditionally(Code, attributedStmt(hasSubStmt(ifStmt())),
+true, {"-std=c++20"}));
+}
+
+TEST(ASTMatchersTest, AttributedStmt_multipleAttrs) {
+  StringRef Code = "int foo();\n int main() {\n  [[clang::nomerge]] [[likely]] "
+   "return foo();\n }";
+  EXPECT_TRUE(matchesConditionally(Code, attributedStmt(hasAttr(attr::Likely)),
+   true, {"-std=c++20"}));
+  EXPECT_TRUE(matchesConditionally(Code, attributedStmt(hasAttr(attr::NoMerge)),
+   true, {"-std=c++20"}));
+}
+
 TEST(MatchFinderAPI, MatchesDynamic) {
   StringRef SourceCode = "struct A { void f() {} };";
   auto Matcher = functionDecl(isDefinition()).bind("method");
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -142,6 +142,7 @@
   REGISTER_MATCHER(atomicExpr);
   REGISTER_MATCHER(atomicType);
   REGISTER_MATCHER(attr);
+  REGISTER_MATCHER(attributedStmt);
   REGISTER_MATCHER(autoType);
   REGISTER_MATCHER(autoreleasePoolStmt)
   REGISTER_MATCHER(binaryConditionalOperator);
@@ -355,6 +356,7 @@
   REGISTER_MATCHER(hasSpecializedTemplate);
   REGISTER_MATCHER(hasStaticStorageDuration);
   REGISTER_MATCHER(hasStructuredBlock);
+  REGISTER_MATCHER(hasSubStmt);
   REGISTER_MATCHER(hasSyntacticForm);
   REGISTER_MATCHER(hasTargetDecl);
   REGISTER_MATCHER(hasTemplateArgument);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -981,6 +981,8 @@
 predefinedExpr;
 const internal::VariadicDynCastAllOfMatcher
 designatedInitExpr;
+const internal::VariadicDynCastAllOfMatcher
+attributedStmt;
 const internal::VariadicOperatorMatcherFunc<
 2, std::numeric_limits::max()>
 eachOf = {internal::DynTypedMatcher::VO_EachOf};
Index: clang/include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -35,6 +35,7 @@
 #define LLVM_CLANG_ASTMATCHERS_ASTMATCHERSINTERNAL_H
 
 #include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/Attr.h"
 #include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclFriend.h"
@@ -2187,6 +2188,21 @@
   return Node.getSubStmt();
 }
 

[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added a comment.

Committed a revert of the changes in that particular function in commit 
985eaa1a3da2a1b88ea70a65ffd5783aa82ea65e 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[clang] 985eaa1 - [clang][extract-api][NFC] Don't remap the generated input buffer in PPOpts

2022-03-30 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-03-30T20:38:09+01:00
New Revision: 985eaa1a3da2a1b88ea70a65ffd5783aa82ea65e

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

LOG: [clang][extract-api][NFC] Don't remap the generated input buffer in PPOpts

This was triggering some build failures so removing this change for now.

Added: 


Modified: 
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp

Removed: 




diff  --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp 
b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index 266acff9a72ef..cf95c3d739b60 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -617,17 +617,13 @@ bool 
ExtractAPIAction::PrepareToExecuteAction(CompilerInstance ) {
 HeaderContents += "\"\n";
   }
 
-  auto Buffer = llvm::MemoryBuffer::getMemBufferCopy(HeaderContents,
- getInputBufferName());
+  Buffer = llvm::MemoryBuffer::getMemBufferCopy(HeaderContents,
+getInputBufferName());
 
   // Set that buffer up as our "real" input in the CompilerInstance.
   Inputs.clear();
   Inputs.emplace_back(Buffer->getMemBufferRef(), Kind, /*IsSystem*/ false);
 
-  // Tell the processor about the input file.
-  CI.getPreprocessorOpts().addRemappedFile(Buffer->getBufferIdentifier(),
-   Buffer.release());
-
   return true;
 }
 



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


[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added a comment.

I have what should be a NFC fix that should fix the issue, just checking 
everything still works and will commit it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D122231: [clang][dataflow] Add support for `value_or` in a comparison.

2022-03-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added inline comments.



Comment at: 
clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp:275
+  State.Env.getValue(*ValueOrPredExpr, SkipPast::None));
+  if (ExprValue == nullptr) {
+auto  = State.Env.createStorageLocation(*ValueOrPredExpr);

sgatev wrote:
> Why do this conditionally? I think we should set a value regardless of 
> whether another model has already done so.
Why? I figured we're agnostic to the underlying value, and only care about 
relating it via the implication. We're setting it only so we have something to 
anchor that implication on.  If we always set it, then we're erasing the 
information from another model.



Comment at: 
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:1244
   Ctx, UncheckedOptionalAccessModelOptions{
/*IgnoreSmartPointerDereference=*/true});
 },

Note: this came from sync'ing to HEAD and picking up my other patch.



Comment at: 
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:1811-1812
+void target() {
+  $ns::$optional opt;
+  auto *opt_p = 
+  if (opt_p->value_or(0) != 0) {

sgatev wrote:
> These can be combined in a `$ns::$optional *opt` parameter.
Unfortunately, that crashes (which must be why I did this to begin with). But, 
I did reduce to only one var and one param.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122231

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


[PATCH] D122231: [clang][dataflow] Add support for `value_or` in a comparison.

2022-03-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 419243.
ymandel added a comment.

delete line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122231

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -496,6 +496,24 @@
 #endif // ABSL_TYPE_TRAITS_H
 )";
 
+static constexpr char StdStringHeader[] = R"(
+#ifndef STRING_H
+#define STRING_H
+
+namespace std {
+
+struct string {
+  string(const char*);
+  ~string();
+  bool empty();
+};
+bool operator!=(const string , const char *RHS);
+
+} // namespace std
+
+#endif // STRING_H
+)";
+
 static constexpr char StdUtilityHeader[] = R"(
 #ifndef UTILITY_H
 #define UTILITY_H
@@ -1198,6 +1216,7 @@
 std::vector> Headers;
 Headers.emplace_back("cstddef.h", CSDtdDefHeader);
 Headers.emplace_back("std_initializer_list.h", StdInitializerListHeader);
+Headers.emplace_back("std_string.h", StdStringHeader);
 Headers.emplace_back("std_type_traits.h", StdTypeTraitsHeader);
 Headers.emplace_back("std_utility.h", StdUtilityHeader);
 Headers.emplace_back("std_optional.h", StdOptionalHeader);
@@ -1209,6 +1228,7 @@
   #include "base_optional.h"
   #include "std_initializer_list.h"
   #include "std_optional.h"
+  #include "std_string.h"
   #include "std_utility.h"
 
   template 
@@ -1712,6 +1732,102 @@
  UnorderedElementsAre(Pair("check", "safe")));
 }
 
+TEST_P(UncheckedOptionalAccessTest, ValueOrComparison) {
+  // Pointers.
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional opt) {
+  if (opt.value_or(nullptr) != nullptr) {
+opt.value();
+/*[[check-ptrs-1]]*/
+  } else {
+opt.value();
+/*[[check-ptrs-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(Pair("check-ptrs-1", "safe"),
+   Pair("check-ptrs-2", "unsafe: input.cc:9:9")));
+
+  // Integers.
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional opt) {
+  if (opt.value_or(0) != 0) {
+opt.value();
+/*[[check-ints-1]]*/
+  } else {
+opt.value();
+/*[[check-ints-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(Pair("check-ints-1", "safe"),
+   Pair("check-ints-2", "unsafe: input.cc:9:9")));
+
+  // Strings.
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional opt) {
+  if (!opt.value_or("").empty()) {
+opt.value();
+/*[[check-strings-1]]*/
+  } else {
+opt.value();
+/*[[check-strings-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(Pair("check-strings-1", "safe"),
+   Pair("check-strings-2", "unsafe: input.cc:9:9")));
+
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional opt) {
+  if (opt.value_or("") != "") {
+opt.value();
+/*[[check-strings-neq-1]]*/
+  } else {
+opt.value();
+/*[[check-strings-neq-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(
+  Pair("check-strings-neq-1", "safe"),
+  Pair("check-strings-neq-2", "unsafe: input.cc:9:9")));
+
+  // Pointer-to-optional.
+  //
+  // FIXME: make `opt` a parameter directly, once we ensure that all `optional`
+  // values have a `has_value` property.
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional p) {
+  $ns::$optional *opt = 
+  if (opt->value_or(0) != 0) {
+opt->value();
+/*[[check-pto-1]]*/
+  } else {
+opt->value();
+/*[[check-pto-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(Pair("check-pto-1", "safe"),
+   Pair("check-pto-2", "unsafe: input.cc:10:9")));
+}
+
 TEST_P(UncheckedOptionalAccessTest, Emplace) {
   ExpectLatticeChecksFor(R"(
 #include "unchecked_optional_access_test.h"
@@ -2038,5 +2154,4 @@
 // - constructors (copy, move)
 // - assignment operators (default, copy, move)
 // - invalidation (passing optional by non-const reference/pointer)
-// - `value_or(nullptr) != nullptr`, `value_or(0) != 0`, `value_or("").empty()`
 // - nested `optional` values
Index: clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp

[PATCH] D122748: [Sema] Don't check bounds for function pointer

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

I think I'm generally in favor, would still like to see the feedback from the 
original submitter here to see if there is more work to do in here that would 
be valuable.




Comment at: clang/lib/Sema/SemaChecking.cpp:15471
   if (IsUnboundedArray) {
+if (EffectiveType->isFunctionType())
+  return;

Ah, I see...  I originally made the comment thinking that we wanted to be able 
to get to ~15540 (which this 'return' would seem to undo), but I see this block 
ends in 'return' anyway.  I'm happy with this change the way it is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122748

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


[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like either this or your other commit at the same time broke tests on 
windows: http://45.33.8.238/win/55345/step_7.txt

Please take a look, and revert for now if it takes a while to fix.

(Also, please add a "Differential Revision: https://reviews.llvm.org/D122611; 
line to the bottom of your commit, to make it easy to find the review from the 
commit message.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D122748: [Sema] Don't check bounds for function pointer

2022-03-30 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added a comment.

In D122748#3417240 , @erichkeane 
wrote:

> That said, we might not want to early-exist here, I think we can just skip 
> the `IsUnboundedArray` branch?

It seems you are right, thanks, fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122748

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


[PATCH] D122627: [HLSL] Fix MSFT Attribute parsing, add numthreads

2022-03-30 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

@aaron.ballman I pushed updates in rGff6696c842ba 
.

The one bit we discussed that I didn't do anything for is the template case. 
Neither clang or the HLSL compiler support parsing Microsoft attributes on 
templates right now, so the parser falls over and errors. It would be better to 
have a nicer diagnostic, but since the current state matches our compiler I 
left it as-is.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122627

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


[PATCH] D122748: [Sema] Don't check bounds for function pointer

2022-03-30 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX updated this revision to Diff 419242.
ArcsinX added a comment.

Check for function type only if IsUnboundedArray is true


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122748

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/unbounded-array-bounds.c


Index: clang/test/Sema/unbounded-array-bounds.c
===
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15468,6 +15468,8 @@
 ND = ME->getMemberDecl();
 
   if (IsUnboundedArray) {
+if (EffectiveType->isFunctionType())
+  return;
 if (index.isUnsigned() || !index.isNegative()) {
   const auto  = getASTContext();
   unsigned AddrBits =


Index: clang/test/Sema/unbounded-array-bounds.c
===
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15468,6 +15468,8 @@
 ND = ME->getMemberDecl();
 
   if (IsUnboundedArray) {
+if (EffectiveType->isFunctionType())
+  return;
 if (index.isUnsigned() || !index.isNegative()) {
   const auto  = getASTContext();
   unsigned AddrBits =
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] ff6696c - Expanding HLSL attribute diagnostics

2022-03-30 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-03-30T14:15:01-05:00
New Revision: ff6696c842bac0b15fc04015b25ead721768eac9

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

LOG: Expanding HLSL attribute diagnostics

Updating the diagnostics as per the feedback on
https://reviews.llvm.org/D122627.

This change correctly handles missing argument lists, and changes the
subject for the `numthreads` attribute to be global functions.

I did not handle applying the attribute to template functions because
that currently fails parsing in a way that is consisetent with the
current DXC codebase (Microsoft attributes are not supported on
templates).

A future improvement to the diagnostic maybe warranted.

Added: 


Modified: 
clang/include/clang/Basic/Attr.td
clang/lib/Parse/ParseDeclCXX.cpp
clang/test/SemaHLSL/num_threads.hlsl

Removed: 




diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 408ea11388c07..97b1027742f60 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -126,6 +126,9 @@ def FunctionTmpl
  FunctionDecl::TK_FunctionTemplate}],
 "function templates">;
 
+def GlobalFunction
+: SubsetSubjectisGlobal()}], "global functions">;
+
 def ClassTmpl : SubsetSubjectgetDescribedClassTemplate()}],
   "class templates">;
 
@@ -3943,7 +3946,7 @@ def Error : InheritableAttr {
 def HLSLNumThreads: InheritableAttr {
   let Spellings = [Microsoft<"numthreads">];
   let Args = [IntArgument<"X">, IntArgument<"Y">, IntArgument<"Z">];
-  let Subjects = SubjectList<[Function]>;
+  let Subjects = SubjectList<[GlobalFunction]>;
   let LangOpts = [HLSL];
   let Documentation = [NumThreadsDocs];
 }

diff  --git a/clang/lib/Parse/ParseDeclCXX.cpp 
b/clang/lib/Parse/ParseDeclCXX.cpp
index 553dcba94fed6..5d417f5aad1e8 100644
--- a/clang/lib/Parse/ParseDeclCXX.cpp
+++ b/clang/lib/Parse/ParseDeclCXX.cpp
@@ -4701,12 +4701,24 @@ void Parser::ParseMicrosoftAttributes(ParsedAttributes 
) {
 IdentifierInfo *II = Tok.getIdentifierInfo();
 SourceLocation NameLoc = Tok.getLocation();
 ConsumeToken();
-if (Tok.is(tok::l_paren)) {
-  CachedTokens OpenMPTokens;
-  ParseCXX11AttributeArgs(II, NameLoc, Attrs, , nullptr,
-  SourceLocation(), OpenMPTokens);
-  ReplayOpenMPAttributeTokens(OpenMPTokens);
-} // FIXME: handle attributes that don't have arguments
+ParsedAttr::Kind AttrKind =
+ParsedAttr::getParsedKind(II, nullptr, ParsedAttr::AS_Microsoft);
+// For HLSL we want to handle all attributes, but for MSVC compat, we
+// silently ignore unknown Microsoft attributes.
+if (getLangOpts().HLSL || AttrKind != ParsedAttr::UnknownAttribute) {
+  bool AttrParsed = false;
+  if (Tok.is(tok::l_paren)) {
+CachedTokens OpenMPTokens;
+AttrParsed =
+ParseCXX11AttributeArgs(II, NameLoc, Attrs, , nullptr,
+SourceLocation(), OpenMPTokens);
+ReplayOpenMPAttributeTokens(OpenMPTokens);
+  }
+  if (!AttrParsed) {
+Attrs.addNew(II, NameLoc, nullptr, SourceLocation(), nullptr, 0,
+ ParsedAttr::AS_Microsoft);
+  }
+}
   }
 }
 

diff  --git a/clang/test/SemaHLSL/num_threads.hlsl 
b/clang/test/SemaHLSL/num_threads.hlsl
index 46e4fa131aa75..cf9e24804a093 100644
--- a/clang/test/SemaHLSL/num_threads.hlsl
+++ b/clang/test/SemaHLSL/num_threads.hlsl
@@ -13,6 +13,12 @@
 #if __SHADER_TARGET_STAGE == __SHADER_STAGE_COMPUTE || __SHADER_TARGET_STAGE 
== __SHADER_STAGE_MESH || __SHADER_TARGET_STAGE == __SHADER_STAGE_AMPLIFICATION 
|| __SHADER_TARGET_STAGE == __SHADER_STAGE_LIBRARY
 #ifdef FAIL
 #if __SHADER_TARGET_MAJOR == 6
+// expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}
+[numthreads]
+// expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}
+[numthreads()]
+// expected-error@+1 {{'numthreads' attribute requires exactly 3 arguments}}
+[numthreads(1,2,3,4)]
 // expected-error@+1 {{'numthreads' attribute requires an integer constant}}
 [numthreads("1",2,3)]
 // expected-error@+1 {{argument 'X' to numthreads attribute cannot exceed 
1024}}
@@ -38,6 +44,15 @@
 int entry() {
  return 1;
 }
+
+// expected-warning@+1 {{'numthreads' attribute only applies to global 
functions}}
+[numthreads(1,1,1)]
+struct Fido {
+  // expected-warning@+1 {{'numthreads' attribute only applies to global 
functions}}
+  [numthreads(1,1,1)]
+  void wag() {}
+};
+
 #else
 // expected-error-re@+1 {{attribute 'numthreads' is unsupported in 
{{[A-Za-z]+}} 

[PATCH] D122231: [clang][dataflow] Add support for `value_or` in a comparison.

2022-03-30 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 419240.
ymandel marked 5 inline comments as done.
ymandel added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122231

Files:
  clang/lib/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.cpp
  clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp
@@ -496,6 +496,24 @@
 #endif // ABSL_TYPE_TRAITS_H
 )";
 
+static constexpr char StdStringHeader[] = R"(
+#ifndef STRING_H
+#define STRING_H
+
+namespace std {
+
+struct string {
+  string(const char*);
+  ~string();
+  bool empty();
+};
+bool operator!=(const string , const char *RHS);
+
+} // namespace std
+
+#endif // STRING_H
+)";
+
 static constexpr char StdUtilityHeader[] = R"(
 #ifndef UTILITY_H
 #define UTILITY_H
@@ -1198,6 +1216,7 @@
 std::vector> Headers;
 Headers.emplace_back("cstddef.h", CSDtdDefHeader);
 Headers.emplace_back("std_initializer_list.h", StdInitializerListHeader);
+Headers.emplace_back("std_string.h", StdStringHeader);
 Headers.emplace_back("std_type_traits.h", StdTypeTraitsHeader);
 Headers.emplace_back("std_utility.h", StdUtilityHeader);
 Headers.emplace_back("std_optional.h", StdOptionalHeader);
@@ -1209,6 +1228,7 @@
   #include "base_optional.h"
   #include "std_initializer_list.h"
   #include "std_optional.h"
+  #include "std_string.h"
   #include "std_utility.h"
 
   template 
@@ -1712,6 +1732,102 @@
  UnorderedElementsAre(Pair("check", "safe")));
 }
 
+TEST_P(UncheckedOptionalAccessTest, ValueOrComparison) {
+  // Pointers.
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional opt) {
+  if (opt.value_or(nullptr) != nullptr) {
+opt.value();
+/*[[check-ptrs-1]]*/
+  } else {
+opt.value();
+/*[[check-ptrs-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(Pair("check-ptrs-1", "safe"),
+   Pair("check-ptrs-2", "unsafe: input.cc:9:9")));
+
+  // Integers.
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional opt) {
+  if (opt.value_or(0) != 0) {
+opt.value();
+/*[[check-ints-1]]*/
+  } else {
+opt.value();
+/*[[check-ints-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(Pair("check-ints-1", "safe"),
+   Pair("check-ints-2", "unsafe: input.cc:9:9")));
+
+  // Strings.
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional opt) {
+  if (!opt.value_or("").empty()) {
+opt.value();
+/*[[check-strings-1]]*/
+  } else {
+opt.value();
+/*[[check-strings-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(Pair("check-strings-1", "safe"),
+   Pair("check-strings-2", "unsafe: input.cc:9:9")));
+
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional opt) {
+  if (opt.value_or("") != "") {
+opt.value();
+/*[[check-strings-neq-1]]*/
+  } else {
+opt.value();
+/*[[check-strings-neq-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(
+  Pair("check-strings-neq-1", "safe"),
+  Pair("check-strings-neq-2", "unsafe: input.cc:9:9")));
+
+  // Pointer-to-optional.
+  //
+  // FIXME: make `opt` a parameter directly, once we ensure that all `optional`
+  // values have a `has_value` property.
+  ExpectLatticeChecksFor(
+  R"code(
+#include "unchecked_optional_access_test.h"
+
+void target($ns::$optional p) {
+  $ns::$optional *opt = 
+  if (opt->value_or(0) != 0) {
+opt->value();
+/*[[check-pto-1]]*/
+  } else {
+opt->value();
+/*[[check-pto-2]]*/
+  }
+}
+  )code",
+  UnorderedElementsAre(Pair("check-pto-1", "safe"),
+   Pair("check-pto-2", "unsafe: input.cc:10:9")));
+}
+
 TEST_P(UncheckedOptionalAccessTest, Emplace) {
   ExpectLatticeChecksFor(R"(
 #include "unchecked_optional_access_test.h"
@@ -2038,5 +2154,4 @@
 // - constructors (copy, move)
 // - assignment operators (default, copy, move)
 // - invalidation (passing optional by non-const reference/pointer)
-// - `value_or(nullptr) != nullptr`, `value_or(0) != 0`, `value_or("").empty()`
 // - nested `optional` values
Index: 

[PATCH] D122756: [clang-format] Fix a crash in qualifier alignment

2022-03-30 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, curdeius, HazardyKnusperkeks.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Related to #54513 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122756

Files:
  clang/lib/Format/QualifierAlignmentFixer.cpp
  clang/unittests/Format/QualifierFixerTest.cpp


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -816,6 +816,7 @@
   EXPECT_EQ(ReplacementCount, 0);
   verifyFormat("static const uint32 foo[] = {0, 31};", Style);
   verifyFormat("#define MACRO static const", Style);
+  verifyFormat("using sc = static const", Style);
   EXPECT_EQ(ReplacementCount, 0);
 }
 
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -303,6 +303,8 @@
 
   if (LastQual && Qual != LastQual && Qual->is(QualifierType)) {
 rotateTokens(SourceMgr, Fixes, Tok, Qual, /*Left=*/true);
+if (!Qual->Next)
+  return Tok;
 Tok = Qual->Next;
   } else if (Tok->startsSequence(tok::identifier, QualifierType)) {
 if (Tok->Next->Next && Tok->Next->Next->isOneOf(tok::identifier, tok::star,


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -816,6 +816,7 @@
   EXPECT_EQ(ReplacementCount, 0);
   verifyFormat("static const uint32 foo[] = {0, 31};", Style);
   verifyFormat("#define MACRO static const", Style);
+  verifyFormat("using sc = static const", Style);
   EXPECT_EQ(ReplacementCount, 0);
 }
 
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -303,6 +303,8 @@
 
   if (LastQual && Qual != LastQual && Qual->is(QualifierType)) {
 rotateTokens(SourceMgr, Fixes, Tok, Qual, /*Left=*/true);
+if (!Qual->Next)
+  return Tok;
 Tok = Qual->Next;
   } else if (Tok->startsSequence(tok::identifier, QualifierType)) {
 if (Tok->Next->Next && Tok->Next->Next->isOneOf(tok::identifier, tok::star,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-03-30 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.
Herald added a project: All.

I added https://github.com/llvm/llvm-project/issues/54654 documenting what I 
found when testing this patch on amdgpu.

@ggeorgakoudis Can you please rebase this patch on top of main? Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D122549: [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-30 Thread Ben Barham 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 rG3fda0edc51fd: [VFS] RedirectingFileSystem only replace path 
if not already mapped (authored by bnbarham).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122549

Files:
  clang/lib/Basic/FileManager.cpp
  clang/test/VFS/external-names-multi-overlay.c
  llvm/include/llvm/Support/VirtualFileSystem.h
  llvm/lib/Support/VirtualFileSystem.cpp
  llvm/unittests/Support/VirtualFileSystemTest.cpp

Index: llvm/unittests/Support/VirtualFileSystemTest.cpp
===
--- llvm/unittests/Support/VirtualFileSystemTest.cpp
+++ llvm/unittests/Support/VirtualFileSystemTest.cpp
@@ -1442,12 +1442,12 @@
   ErrorOr S = O->status("//root/file1");
   ASSERT_FALSE(S.getError());
   EXPECT_EQ("//root/foo/bar/a", S->getName());
-  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->ExposesExternalVFSPath);
 
   ErrorOr SLower = O->status("//root/foo/bar/a");
   EXPECT_EQ("//root/foo/bar/a", SLower->getName());
   EXPECT_TRUE(S->equivalent(*SLower));
-  EXPECT_FALSE(SLower->IsVFSMapped);
+  EXPECT_FALSE(SLower->ExposesExternalVFSPath);
 
   // file after opening
   auto OpenedF = O->openFileForRead("//root/file1");
@@ -1455,7 +1455,7 @@
   auto OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_TRUE(OpenedS->ExposesExternalVFSPath);
 
   // directory
   S = O->status("//root/");
@@ -1467,27 +1467,27 @@
   S = O->status("//root/mappeddir");
   ASSERT_FALSE(S.getError());
   EXPECT_TRUE(S->isDirectory());
-  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->ExposesExternalVFSPath);
   EXPECT_TRUE(S->equivalent(*O->status("//root/foo/bar")));
 
   SLower = O->status("//root/foo/bar");
   EXPECT_EQ("//root/foo/bar", SLower->getName());
   EXPECT_TRUE(S->equivalent(*SLower));
-  EXPECT_FALSE(SLower->IsVFSMapped);
+  EXPECT_FALSE(SLower->ExposesExternalVFSPath);
 
   // file in remapped directory
   S = O->status("//root/mappeddir/a");
   ASSERT_FALSE(S.getError());
-  ASSERT_FALSE(S->isDirectory());
-  ASSERT_TRUE(S->IsVFSMapped);
-  ASSERT_EQ("//root/foo/bar/a", S->getName());
+  EXPECT_FALSE(S->isDirectory());
+  EXPECT_TRUE(S->ExposesExternalVFSPath);
+  EXPECT_EQ("//root/foo/bar/a", S->getName());
 
   // file in remapped directory, with use-external-name=false
   S = O->status("//root/mappeddir2/a");
   ASSERT_FALSE(S.getError());
-  ASSERT_FALSE(S->isDirectory());
-  ASSERT_TRUE(S->IsVFSMapped);
-  ASSERT_EQ("//root/mappeddir2/a", S->getName());
+  EXPECT_FALSE(S->isDirectory());
+  EXPECT_FALSE(S->ExposesExternalVFSPath);
+  EXPECT_EQ("//root/mappeddir2/a", S->getName());
 
   // file contents in remapped directory
   OpenedF = O->openFileForRead("//root/mappeddir/a");
@@ -1495,7 +1495,7 @@
   OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_TRUE(OpenedS->ExposesExternalVFSPath);
 
   // file contents in remapped directory, with use-external-name=false
   OpenedF = O->openFileForRead("//root/mappeddir2/a");
@@ -1503,7 +1503,7 @@
   OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/mappeddir2/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_FALSE(OpenedS->ExposesExternalVFSPath);
 
   // broken mapping
   EXPECT_EQ(O->status("//root/file2").getError(),
@@ -1535,12 +1535,12 @@
   ErrorOr S = O->status("//mappedroot/a");
   ASSERT_FALSE(S.getError());
   EXPECT_EQ("//root/foo/bar/a", S->getName());
-  EXPECT_TRUE(S->IsVFSMapped);
+  EXPECT_TRUE(S->ExposesExternalVFSPath);
 
   ErrorOr SLower = O->status("//root/foo/bar/a");
   EXPECT_EQ("//root/foo/bar/a", SLower->getName());
   EXPECT_TRUE(S->equivalent(*SLower));
-  EXPECT_FALSE(SLower->IsVFSMapped);
+  EXPECT_FALSE(SLower->ExposesExternalVFSPath);
 
   // file after opening
   auto OpenedF = O->openFileForRead("//mappedroot/a");
@@ -1548,7 +1548,7 @@
   auto OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("//root/foo/bar/a", OpenedS->getName());
-  EXPECT_TRUE(OpenedS->IsVFSMapped);
+  EXPECT_TRUE(OpenedS->ExposesExternalVFSPath);
 
   EXPECT_EQ(0, NumDiagnostics);
 }
@@ -1696,12 +1696,12 @@
   auto OpenedS = (*OpenedF)->status();
   ASSERT_FALSE(OpenedS.getError());
   EXPECT_EQ("a", OpenedS->getName());
-  EXPECT_FALSE(OpenedS->IsVFSMapped);
+  EXPECT_FALSE(OpenedS->ExposesExternalVFSPath);
 
   auto DirectS = RemappedFS->status("a");
   ASSERT_FALSE(DirectS.getError());
   EXPECT_EQ("a", DirectS->getName());
-  EXPECT_FALSE(DirectS->IsVFSMapped);
+  EXPECT_FALSE(DirectS->ExposesExternalVFSPath);
 
   EXPECT_EQ(0, NumDiagnostics);
 }
@@ -1736,12 +1736,12 @@
   auto 

[clang] 3fda0ed - [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-30 Thread Ben Barham via cfe-commits

Author: Ben Barham
Date: 2022-03-30T11:52:41-07:00
New Revision: 3fda0edc51fd68192a30e302d45db081bb02d7f9

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

LOG: [VFS] RedirectingFileSystem only replace path if not already mapped

If the `ExternalFS` has already remapped a path then the
`RedirectingFileSystem` should not change it to the originally provided
path. This fixes the original path always being used if multiple VFS
overlays were provided and the path wasn't found in the highest (ie.
first in the chain).

This also renames `IsVFSMapped` to `ExposesExternalVFSPath` and only
sets it if `UseExternalName` is true. This flag then represents that the
`Status` has an external path that's different from its virtual path.
Right now the contained path is still the external path, but further PRs
will change this to *always* be the virtual path. Clients that need the
external can then request it specifically.

Note that even though `ExposesExternalVFSPath` isn't set for all
VFS-mapped paths, `IsVFSMapped` was only being used by a hack in
`FileManager` that was specific to module searching. In that case
`UseExternalNames` is always `true` and so that hack still applies.

Resolves rdar://90578880 and llvm-project#53306.

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

Added: 
clang/test/VFS/external-names-multi-overlay.c

Modified: 
clang/lib/Basic/FileManager.cpp
llvm/include/llvm/Support/VirtualFileSystem.h
llvm/lib/Support/VirtualFileSystem.cpp
llvm/unittests/Support/VirtualFileSystemTest.cpp

Removed: 




diff  --git a/clang/lib/Basic/FileManager.cpp b/clang/lib/Basic/FileManager.cpp
index f4cf27848d7d9..d30a5f72b9836 100644
--- a/clang/lib/Basic/FileManager.cpp
+++ b/clang/lib/Basic/FileManager.cpp
@@ -270,12 +270,15 @@ FileManager::getFileRef(StringRef Filename, bool 
openFile, bool CacheFailure) {
   // This occurs when one dir is symlinked to another, for example.
   FileEntry  = UniqueRealFiles[Status.getUniqueID()];
 
+  // FIXME: This should just check `!Status.ExposesExternalVFSPath`, but the
+  // else branch also ends up fixing up relative paths to be the actually
+  // looked up absolute path. This isn't necessarily desired, but does seem to
+  // be relied on in some clients.
   if (Status.getName() == Filename) {
 // The name matches. Set the FileEntry.
 NamedFileEnt->second = FileEntryRef::MapValue(UFE, DirInfo);
   } else {
-// Name mismatch. We need a redirect. First grab the actual entry we want
-// to return.
+// We need a redirect. First grab the actual entry we want to return.
 //
 // This redirection logic intentionally leaks the external name of a
 // redirected file that uses 'use-external-name' in \a
@@ -285,9 +288,11 @@ FileManager::getFileRef(StringRef Filename, bool openFile, 
bool CacheFailure) {
 //
 // FIXME: This is pretty complicated. It's also inconsistent with how
 // "real" filesystems behave and confuses parts of clang expect to see the
-// name-as-accessed on the \a FileEntryRef. Maybe the returned \a
-// FileEntryRef::getName() could return the accessed name unmodified, but
-// make the external name available via a separate API.
+// name-as-accessed on the \a FileEntryRef. To remove this we should
+// implement the FIXME on `ExposesExternalVFSPath`, ie. update the
+// `FileEntryRef::getName()` path to *always* be the virtual path and have
+// clients request the external path only when required through a separate
+// API.
 auto  =
 *SeenFileEntries
  .insert({Status.getName(), FileEntryRef::MapValue(UFE, DirInfo)})
@@ -308,13 +313,16 @@ FileManager::getFileRef(StringRef Filename, bool 
openFile, bool CacheFailure) {
   FileEntryRef ReturnedRef(*NamedFileEnt);
   if (UFE.isValid()) { // Already have an entry with this inode, return it.
 
-// FIXME: this hack ensures that if we look up a file by a virtual path in
-// the VFS that the getDir() will have the virtual path, even if we found
-// the file by a 'real' path first. This is required in order to find a
-// module's structure when its headers/module map are mapped in the VFS.
-// We should remove this as soon as we can properly support a file having
-// multiple names.
-if (() != UFE.Dir && Status.IsVFSMapped)
+// FIXME: This hack ensures that `getDir()` will use the path that was
+// used to lookup this file, even if we found a file by 
diff erent path
+// first. This is required in order to find a module's structure when its
+// headers/module map are mapped in the VFS.
+//
+// This should be removed once `HeaderSearch` is updated to use `*Ref`s
+// *and* the redirection hack above is removed. The removal of 

[PATCH] D121754: [clang-format] Refactor determineStarAmpUsage NFC

2022-03-30 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.

I cannot view the diff between the last two revisions:

> Unhandled Exception ("Exception")
> Found unknown intradiff source line, expected a line beginning with "+", "-", 
> or " " (space): \ No newline at end of file
> .




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121754

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


[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

This change is causing 9 test failures on a buildbot, can you please take a 
look and revert if you need time to investigate?

https://lab.llvm.org/buildbot/#/builders/139/builds/19441


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

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


[PATCH] D122732: [Clang][AArch64][SVE] Allow subscript operator for SVE types

2022-03-30 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

> Subscript on svbool_t is not allowed as this doesn't really have meaningful 
> semantics.

Not sure what you mean by this; LLVM supports extractelement on `` vectors.  I guess the fact that it's a "vscale x 16" element vector might 
not be intuitive?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122732

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


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

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 419225.
sammccall marked 10 inline comments as done.
sammccall added a comment.
Herald added a project: All.

address comments
(sorry for long turnaround)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116514

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/MemberwiseConstructorTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/MemberwiseConstructorTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/MemberwiseConstructorTests.cpp
@@ -0,0 +1,99 @@
+//===-- MemberwiseConstructorTests.cpp ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+using testing::AllOf;
+using testing::Eq;
+using testing::HasSubstr;
+using testing::Not;
+
+TWEAK_TEST(MemberwiseConstructor);
+
+TEST_F(MemberwiseConstructorTest, Availability) {
+  EXPECT_AVAILABLE("^struct ^S ^{ int x, y; };");
+  EXPECT_UNAVAILABLE("struct S { ^int ^x, y; }; struct ^S;");
+  EXPECT_UNAVAILABLE("struct ^S {};");
+  EXPECT_UNAVAILABLE("union ^S { int x; };");
+  EXPECT_UNAVAILABLE("struct ^S { int x = 0; };");
+  EXPECT_UNAVAILABLE("struct ^S { struct { int x; }; };");
+  EXPECT_UNAVAILABLE("struct ^{ int x; } e;");
+}
+
+TEST_F(MemberwiseConstructorTest, Edits) {
+  Header = R"cpp(
+struct Move {
+  Move(Move&&) = default;
+  Move(const Move&) = delete;
+};
+struct Copy {
+  Copy(Copy&&) = delete;
+  Copy(const Copy&);
+};
+  )cpp";
+  EXPECT_EQ(apply("struct ^S{Move M; Copy C; int I; int J=4;};"),
+"struct S{"
+"S(Move M, const Copy , int I) : M(std::move(M)), C(C), I(I) {}\n"
+"Move M; Copy C; int I; int J=4;};");
+}
+
+TEST_F(MemberwiseConstructorTest, FieldTreatment) {
+  Header = R"cpp(
+struct MoveOnly {
+  MoveOnly(MoveOnly&&) = default;
+  MoveOnly(const MoveOnly&) = delete;
+};
+struct CopyOnly {
+  CopyOnly(CopyOnly&&) = delete;
+  CopyOnly(const CopyOnly&);
+};
+struct CopyTrivial {
+  CopyTrivial(CopyTrivial&&) = default;
+  CopyTrivial(const CopyTrivial&) = default;
+};
+struct Immovable {
+  Immovable(Immovable&&) = delete;
+  Immovable(const Immovable&) = delete;
+};
+template 
+struct Traits { using Type = typename T::Type; };
+using IntAlias = int;
+  )cpp";
+
+  auto Fail = Eq("unavailable");
+  auto Move = HasSubstr(": Member(std::move(Member))");
+  auto CopyRef = AllOf(HasSubstr("S(const "), HasSubstr(": Member(Member)"));
+  auto Copy = AllOf(Not(HasSubstr("S(const ")), HasSubstr(": Member(Member)"));
+  auto With = [](llvm::StringRef Type) {
+return ("struct ^S { " + Type + " Member; };").str();
+  };
+
+  EXPECT_THAT(apply(With("Immovable")), Fail);
+  EXPECT_THAT(apply(With("MoveOnly")), Move);
+  EXPECT_THAT(apply(With("CopyOnly")), CopyRef);
+  EXPECT_THAT(apply(With("CopyTrivial")), Copy);
+  EXPECT_THAT(apply(With("int")), Copy);
+  EXPECT_THAT(apply(With("IntAlias")), Copy);
+  EXPECT_THAT(apply(With("Immovable*")), Copy);
+  EXPECT_THAT(apply(With("Immovable&")), Copy);
+
+  EXPECT_THAT(apply("template " + With("T")), Move);
+  EXPECT_THAT(apply("template " + With("typename Traits::Type")),
+  Move);
+  EXPECT_THAT(apply("template " + With("T*")), Copy);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -117,6 +117,7 @@
   tweaks/ExpandMacroTests.cpp
   tweaks/ExtractFunctionTests.cpp
   tweaks/ExtractVariableTests.cpp
+  tweaks/MemberwiseConstructorTests.cpp
   tweaks/ObjCLocalizeStringLiteralTests.cpp
   tweaks/ObjCMemberwiseInitializerTests.cpp
   tweaks/PopulateSwitchTests.cpp
Index: clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/MemberwiseConstructor.cpp
@@ -0,0 +1,267 @@
+//===--- MemberwiseConstructor.cpp - Generate C++ constructor -===//
+//
+// 

[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

2022-03-30 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added subscribers: Fznamznon, erichkeane.
erichkeane added a comment.

Attn: @Fznamznon


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119136

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


[PATCH] D122549: [VFS] RedirectingFileSystem only replace path if not already mapped

2022-03-30 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith accepted this revision.
dexonsmith 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/D122549/new/

https://reviews.llvm.org/D122549

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


[PATCH] D119996: [safestack] Support safestack in stack size diagnostics

2022-03-30 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 419222.
paulkirth added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119996

Files:
  clang/test/Frontend/stack-usage-safestack.c
  llvm/include/llvm/CodeGen/MachineFrameInfo.h
  llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
  llvm/lib/CodeGen/MachineFunction.cpp
  llvm/lib/CodeGen/PrologEpilogInserter.cpp
  llvm/lib/CodeGen/SafeStack.cpp
  llvm/test/Transforms/SafeStack/ARM/debug.ll

Index: llvm/test/Transforms/SafeStack/ARM/debug.ll
===
--- llvm/test/Transforms/SafeStack/ARM/debug.ll
+++ llvm/test/Transforms/SafeStack/ARM/debug.ll
@@ -10,8 +10,8 @@
 ; void Capture(char*x);
 ; void f() { char c[16]; Capture(c); }
 
-; CHECK: !35 = !DILocation(line: 3, column: 11, scope: !17, inlinedAt: !36)
-; CHECK: !36 = distinct !DILocation(line: 6, scope: !27)
+; CHECK: !36 = !DILocation(line: 3, column: 11, scope: !17, inlinedAt: !37)
+; CHECK: !37 = distinct !DILocation(line: 6, scope: !27)
 
 @addr = common local_unnamed_addr global i8*** null, align 4, !dbg !0
 
Index: llvm/lib/CodeGen/SafeStack.cpp
===
--- llvm/lib/CodeGen/SafeStack.cpp
+++ llvm/lib/CodeGen/SafeStack.cpp
@@ -48,6 +48,7 @@
 #include "llvm/IR/IntrinsicInst.h"
 #include "llvm/IR/Intrinsics.h"
 #include "llvm/IR/MDBuilder.h"
+#include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/Use.h"
@@ -642,6 +643,13 @@
   // FIXME: no need to update BasePointer in leaf functions.
   unsigned FrameSize = alignTo(SSL.getFrameSize(), StackAlignment);
 
+  MDBuilder MDB(F.getContext());
+  SmallVector Data;
+  Data.push_back(MDB.createString("unsafe-stack-size"));
+  Data.push_back(MDB.createConstant(ConstantInt::get(Int32Ty, FrameSize)));
+  MDNode *MD = MDTuple::get(F.getContext(), Data);
+  F.setMetadata(LLVMContext::MD_annotation, MD);
+
   // Update shadow stack pointer in the function epilogue.
   IRB.SetInsertPoint(BasePointer->getNextNode());
 
Index: llvm/lib/CodeGen/PrologEpilogInserter.cpp
===
--- llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -283,6 +283,9 @@
 assert(!Failed && "Invalid warn-stack-size fn attr value");
 (void)Failed;
   }
+  if (MF.getFunction().hasFnAttribute(Attribute::SafeStack)) {
+StackSize += MFI.getUnsafeStackSize();
+  }
   if (StackSize > Threshold) {
 DiagnosticInfoStackSize DiagStackSize(F, StackSize, Threshold, DS_Warning);
 F.getContext().diagnose(DiagStackSize);
Index: llvm/lib/CodeGen/MachineFunction.cpp
===
--- llvm/lib/CodeGen/MachineFunction.cpp
+++ llvm/lib/CodeGen/MachineFunction.cpp
@@ -107,6 +107,27 @@
   llvm_unreachable("Invalid machine function property");
 }
 
+void setUnsafeStackSize(const Function , MachineFrameInfo ) {
+  if (!F.hasFnAttribute(Attribute::SafeStack))
+return;
+
+  auto *Existing =
+  dyn_cast_or_null(F.getMetadata(LLVMContext::MD_annotation));
+
+  if (!Existing || Existing->getNumOperands() != 2)
+return;
+
+  auto *MetadataName = "unsafe-stack-size";
+  if (auto  = Existing->getOperand(0)) {
+if (cast(N.get())->getString() == MetadataName) {
+  if (auto  = Existing->getOperand(1)) {
+auto Val = mdconst::extract(Op)->getZExtValue();
+FrameInfo.setUnsafeStackSize(Val);
+  }
+}
+  }
+}
+
 // Pin the vtable to this file.
 void MachineFunction::Delegate::anchor() {}
 
@@ -175,6 +196,8 @@
   /*ForcedRealign=*/CanRealignSP &&
   F.hasFnAttribute(Attribute::StackAlignment));
 
+  setUnsafeStackSize(F, *FrameInfo);
+
   if (F.hasFnAttribute(Attribute::StackAlignment))
 FrameInfo->ensureMaxAlignment(*F.getFnStackAlign());
 
Index: llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -1186,7 +1186,8 @@
   OutStreamer->SwitchSection(StackSizeSection);
 
   const MCSymbol *FunctionSymbol = getFunctionBegin();
-  uint64_t StackSize = FrameInfo.getStackSize();
+  uint64_t StackSize =
+  FrameInfo.getStackSize() + FrameInfo.getUnsafeStackSize();
   OutStreamer->emitSymbolValue(FunctionSymbol, TM.getProgramPointerSize());
   OutStreamer->emitULEB128IntValue(StackSize);
 
@@ -1201,7 +1202,8 @@
 return;
 
   const MachineFrameInfo  = MF.getFrameInfo();
-  uint64_t StackSize = FrameInfo.getStackSize();
+  uint64_t StackSize =
+  FrameInfo.getStackSize() + FrameInfo.getUnsafeStackSize();
 
   if (StackUsageStream == nullptr) {
 std::error_code EC;
Index: llvm/include/llvm/CodeGen/MachineFrameInfo.h
===
--- 

[clang] 73ab5fd - [clang] Fix shared build. NFC.

2022-03-30 Thread Michael Liao via cfe-commits

Author: Michael Liao
Date: 2022-03-30T14:05:14-04:00
New Revision: 73ab5fd17b5726543554621410124ebae953dc6b

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

LOG: [clang] Fix shared build. NFC.

Added: 


Modified: 
clang/lib/ExtractAPI/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/ExtractAPI/CMakeLists.txt 
b/clang/lib/ExtractAPI/CMakeLists.txt
index 044caa0922483..f194ae342c20f 100644
--- a/clang/lib/ExtractAPI/CMakeLists.txt
+++ b/clang/lib/ExtractAPI/CMakeLists.txt
@@ -14,4 +14,5 @@ add_clang_library(clangExtractAPI
   clangBasic
   clangFrontend
   clangIndex
+  clangLex
   )



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


[PATCH] D116490: [clangd] Code action to declare missing move/copy constructor/assignment

2022-03-30 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 419213.
sammccall marked 3 inline comments as done.
sammccall added a comment.
Herald added a project: All.

Oops, this never got landed!

Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116490

Files:
  clang-tools-extra/clangd/ParsedAST.cpp
  clang-tools-extra/clangd/ParsedAST.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
  clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/SpecialMembersTests.cpp
@@ -0,0 +1,47 @@
+//===-- SpecialMembersTests.cpp ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TweakTesting.h"
+#include "gmock/gmock-matchers.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(SpecialMembers);
+
+TEST_F(SpecialMembersTest, Test) {
+  EXPECT_AVAILABLE("struct ^S {};");
+  EXPECT_UNAVAILABLE("struct S { ^ };");
+  EXPECT_UNAVAILABLE("union ^U {};");
+  EXPECT_AVAILABLE("struct ^S { S(const S&); S(S&&); };");
+  EXPECT_UNAVAILABLE("struct ^S {"
+ "S(const S&); S(S&&);"
+ "S =(S&&); S =(const S&);"
+ "};");
+
+  const char *Output = R"cpp(struct S{S(const S &) = default;
+  S(S &&) = default;
+  S =(const S &) = default;
+  S =(S &&) = default;
+};)cpp";
+  EXPECT_EQ(apply("struct ^S{};"), Output);
+
+  Output = R"cpp(struct S{S(const S &) = default;
+S(S &&) = default;
+S =(const S &) = delete;
+S =(S &&) = delete;
+int& ref;};)cpp";
+  EXPECT_EQ(apply("struct ^S{int& ref;};"), Output);
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/refactor/tweaks/SpecialMembers.cpp
@@ -0,0 +1,153 @@
+//===--- SpecialMembers.cpp - Generate C++ special member functions ---===//
+//
+// 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 "ParsedAST.h"
+#include "refactor/InsertionPoint.h"
+#include "refactor/Tweak.h"
+#include "support/Logger.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/Basic/SourceLocation.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Sema/Sema.h"
+#include "clang/Tooling/Core/Replacement.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// Returns code to declare missing copy/move constructors/assignment operators.
+// They will be deleted or defaulted to match the class's current state.
+std::string buildSpecialMemberDeclarations(const CXXRecordDecl ) {
+  struct Members {
+const CXXMethodDecl *Copy = nullptr;
+const CXXMethodDecl *Move = nullptr;
+  } Ctor, Assign;
+
+  for (const auto  : Class.methods()) {
+if (M->isCopyAssignmentOperator())
+  Assign.Copy = M;
+else if (M->isMoveAssignmentOperator())
+  Assign.Move = M;
+if (const auto *C = llvm::dyn_cast(M)) {
+  if (C->isCopyConstructor())
+Ctor.Copy = C;
+  else if (C->isMoveConstructor())
+Ctor.Move = C;
+}
+  }
+
+  std::string S;
+  llvm::raw_string_ostream OS(S);
+
+  auto PrintMember = [&](const CXXMethodDecl *D, const char *MemberPattern,
+ const char *ParmPattern) {
+if (D && !D->isImplicit())
+  return;
+bool Delete = !D || D->isDeleted();
+OS << llvm::formatv(
+"{0} = {1};\n",
+llvm::formatv(MemberPattern, Class.getName(),
+  llvm::formatv(ParmPattern, Class.getName())),
+Delete ? "delete" : "default");
+  };
+  auto PrintMembers = [&](const Members , const char *MemberPattern) {
+PrintMember(M.Copy, MemberPattern, /*ParmPattern=*/"const {0}&");
+PrintMember(M.Move, MemberPattern, /*ParmPattern=*/"{0}&&");
+  };
+  PrintMembers(Ctor, /*MemberPattern=*/"{0}({1})");
+  PrintMembers(Assign, /*MemberPattern=*/"{0} =({1})");
+
+  return S;
+}
+
+// A tweak that adds missing declarations of copy & move constructors.
+//
+// e.g. given `struct ^S{};`, produces:

[PATCH] D122748: [Sema] Don't check bounds for function pointer

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

It seems like this entire section of code was added here: 
https://github.com/llvm/llvm-project/commit/ce44fe199bbfd4b5a44764b678c431fdc117116a

@chrish_ericsson_atx should probably take a look at this.  That said, we might 
not want to early-exist here, I think we can just skip the `IsUnboundedArray` 
branch?  This example worked correctly in the 12.0 branch, so I think it was 
fine before then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122748

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


[clang] 529a057 - [clang][extract-api] Add support for macros

2022-03-30 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-03-30T18:33:10+01:00
New Revision: 529a0570f7e8c5144bd3ad057e43f00e3af58d1b

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

LOG: [clang][extract-api] Add support for macros

To achieve this we hook into the preprocessor during the
ExtractAPIAction and record definitions for macros that don't get
undefined during preprocessing.

Added: 
clang/test/ExtractAPI/macro_undefined.c
clang/test/ExtractAPI/macros.c

Modified: 
clang/include/clang/ExtractAPI/API.h
clang/include/clang/ExtractAPI/DeclarationFragments.h
clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
clang/lib/ExtractAPI/API.cpp
clang/lib/ExtractAPI/DeclarationFragments.cpp
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/API.h 
b/clang/include/clang/ExtractAPI/API.h
index 57397e7c256ea..142dd7a45de47 100644
--- a/clang/include/clang/ExtractAPI/API.h
+++ b/clang/include/clang/ExtractAPI/API.h
@@ -30,6 +30,7 @@
 #include "llvm/Support/Allocator.h"
 #include "llvm/Support/Casting.h"
 #include 
+#include 
 
 namespace clang {
 namespace extractapi {
@@ -49,6 +50,9 @@ namespace extractapi {
 /// \endcode
 using DocComment = std::vector;
 
+// Classes deriving from APIRecord need to have Name be the first constructor
+// argument. This is so that they are compatible with `addTopLevelRecord`
+// defined in API.cpp
 /// The base representation of an API record. Holds common symbol information.
 struct APIRecord {
   StringRef Name;
@@ -83,6 +87,7 @@ struct APIRecord {
 RK_ObjCMethod,
 RK_ObjCInterface,
 RK_ObjCProtocol,
+RK_MacroDefinition,
   };
 
 private:
@@ -119,10 +124,11 @@ struct GlobalRecord : APIRecord {
   /// The function signature of the record if it is a function.
   FunctionSignature Signature;
 
-  GlobalRecord(GVKind Kind, StringRef Name, StringRef USR, PresumedLoc Loc,
+  GlobalRecord(StringRef Name, StringRef USR, PresumedLoc Loc,
const AvailabilityInfo , LinkageInfo Linkage,
const DocComment , DeclarationFragments Declaration,
-   DeclarationFragments SubHeading, FunctionSignature Signature)
+   DeclarationFragments SubHeading, GVKind Kind,
+   FunctionSignature Signature)
   : APIRecord(RK_Global, Name, USR, Loc, Availability, Linkage, Comment,
   Declaration, SubHeading),
 GlobalKind(Kind), Signature(Signature) {}
@@ -374,6 +380,21 @@ struct ObjCProtocolRecord : ObjCContainerRecord {
   virtual void anchor();
 };
 
+struct MacroDefinitionRecord : APIRecord {
+  MacroDefinitionRecord(StringRef Name, StringRef USR, PresumedLoc Loc,
+DeclarationFragments Declaration,
+DeclarationFragments SubHeading)
+  : APIRecord(RK_MacroDefinition, Name, USR, Loc, AvailabilityInfo(),
+  LinkageInfo(), {}, Declaration, SubHeading) {}
+
+  static bool classof(const APIRecord *Record) {
+return Record->getKind() == RK_MacroDefinition;
+  }
+
+private:
+  virtual void anchor();
+};
+
 /// APISet holds the set of API records collected from given inputs.
 class APISet {
 public:
@@ -530,29 +551,24 @@ class APISet {
   DeclarationFragments Declaration,
   DeclarationFragments SubHeading);
 
-  /// A map to store the set of GlobalRecord%s with the declaration name as the
-  /// key.
-  using GlobalRecordMap =
-  llvm::MapVector>;
-
-  /// A map to store the set of EnumRecord%s with the declaration name as the
-  /// key.
-  using EnumRecordMap = llvm::MapVector>;
-
-  /// A map to store the set of StructRecord%s with the declaration name as the
-  /// key.
-  using StructRecordMap =
-  llvm::MapVector>;
-
-  /// A map to store the set of ObjCInterfaceRecord%s with the declaration name
-  /// as the key.
-  using ObjCInterfaceRecordMap =
-  llvm::MapVector>;
-
-  /// A map to store the set of ObjCProtocolRecord%s with the declaration name
-  /// as the key.
-  using ObjCProtocolRecordMap =
-  llvm::MapVector>;
+  /// Create a macro definition record into the API set.
+  ///
+  /// Note: the caller is responsible for keeping the StringRef \p Name and
+  /// \p USR alive. APISet::copyString provides a way to copy strings into
+  /// APISet itself, and APISet::recordUSRForMacro(StringRef Name,
+  /// SourceLocation SL, const SourceManager ) is a helper method to 
generate
+  /// the USR for the macro and keep it alive in APISet.
+  MacroDefinitionRecord *addMacroDefinition(StringRef Name, StringRef USR,
+PresumedLoc Loc,
+ 

[clang] a9909d2 - [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via cfe-commits

Author: Daniel Grumberg
Date: 2022-03-30T18:32:58+01:00
New Revision: a9909d23e9bb8c4649cba1c14d479c28df4ca185

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

LOG: [clang][extractapi] Tie API and serialization to the FrontendAction

Make the API records a property of the action instead of the ASTVisitor
so that it can be accessed outside the AST visitation and push back
serialization to the end of the frontend action.

This will allow accessing and modifying the API records outside of the
ASTVisitor, which is a prerequisite for supporting macros.

Added: 


Modified: 
clang/include/clang/ExtractAPI/FrontendActions.h
clang/lib/ExtractAPI/ExtractAPIConsumer.cpp

Removed: 




diff  --git a/clang/include/clang/ExtractAPI/FrontendActions.h 
b/clang/include/clang/ExtractAPI/FrontendActions.h
index 4c9449fe73a92..2bdb61dc6994d 100644
--- a/clang/include/clang/ExtractAPI/FrontendActions.h
+++ b/clang/include/clang/ExtractAPI/FrontendActions.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
 #define LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
 
+#include "clang/ExtractAPI/API.h"
 #include "clang/Frontend/FrontendAction.h"
 
 namespace clang {
@@ -25,11 +26,19 @@ class ExtractAPIAction : public ASTFrontendAction {
  StringRef InFile) override;
 
 private:
+  /// A representation of the APIs this action extracts.
+  std::unique_ptr API;
+
+  /// A stream to the output file of this action.
+  std::unique_ptr OS;
+
+  /// The product this action is extracting API information for.
+  std::string ProductName;
+
   /// The synthesized input buffer that contains all the provided input header
   /// files.
   std::unique_ptr Buffer;
 
-public:
   /// Prepare to execute the action on the given CompilerInstance.
   ///
   /// This is called before executing the action on any inputs. This generates 
a
@@ -37,8 +46,15 @@ class ExtractAPIAction : public ASTFrontendAction {
   /// list with it before actually executing the action.
   bool PrepareToExecuteAction(CompilerInstance ) override;
 
+  /// Called after executing the action on the synthesized input buffer.
+  ///
+  /// Note: Now that we have gathered all the API definitions to surface we can
+  /// emit them in this callback.
+  void EndSourceFileAction() override;
+
   static std::unique_ptr
   CreateOutputFile(CompilerInstance , StringRef InFile);
+
   static StringRef getInputBufferName() { return ""; }
 };
 

diff  --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp 
b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index bcc01dbd710d8..10b28873611e9 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -41,8 +41,8 @@ namespace {
 /// information.
 class ExtractAPIVisitor : public RecursiveASTVisitor {
 public:
-  ExtractAPIVisitor(ASTContext , Language Lang)
-  : Context(Context), API(Context.getTargetInfo().getTriple(), Lang) {}
+  ExtractAPIVisitor(ASTContext , APISet )
+  : Context(Context), API(API) {}
 
   const APISet () const { return API; }
 
@@ -489,43 +489,40 @@ class ExtractAPIVisitor : public 
RecursiveASTVisitor {
   }
 
   ASTContext 
-  APISet API;
+  APISet 
 };
 
 class ExtractAPIConsumer : public ASTConsumer {
 public:
-  ExtractAPIConsumer(ASTContext , StringRef ProductName, Language Lang,
- std::unique_ptr OS)
-  : Visitor(Context, Lang), ProductName(ProductName), OS(std::move(OS)) {}
+  ExtractAPIConsumer(ASTContext , APISet )
+  : Visitor(Context, API) {}
 
   void HandleTranslationUnit(ASTContext ) override {
 // Use ExtractAPIVisitor to traverse symbol declarations in the context.
 Visitor.TraverseDecl(Context.getTranslationUnitDecl());
-
-// Setup a SymbolGraphSerializer to write out collected API information in
-// the Symbol Graph format.
-// FIXME: Make the kind of APISerializer configurable.
-SymbolGraphSerializer SGSerializer(Visitor.getAPI(), ProductName);
-SGSerializer.serialize(*OS);
   }
 
 private:
   ExtractAPIVisitor Visitor;
-  std::string ProductName;
-  std::unique_ptr OS;
 };
 
 } // namespace
 
 std::unique_ptr
 ExtractAPIAction::CreateASTConsumer(CompilerInstance , StringRef InFile) {
-  std::unique_ptr OS = CreateOutputFile(CI, InFile);
+  OS = CreateOutputFile(CI, InFile);
   if (!OS)
 return nullptr;
-  return std::make_unique(
-  CI.getASTContext(), CI.getInvocation().getFrontendOpts().ProductName,
-  CI.getFrontendOpts().Inputs.back().getKind().getLanguage(),
-  std::move(OS));
+
+  ProductName = CI.getFrontendOpts().ProductName;
+
+  // Now that we have enough information about the language options and the
+  // target triple, let's create the APISet before anyone uses it.
+  API = 

[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Zixu Wang via Phabricator via cfe-commits
zixuw accepted this revision.
zixuw 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/D122611/new/

https://reviews.llvm.org/D122611

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


[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Zixu Wang via Phabricator via cfe-commits
zixuw accepted this revision.
zixuw added a comment.
This revision is now accepted and ready to land.

LGTM!


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

https://reviews.llvm.org/D122648

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


[PATCH] D122748: [Sema] Don't check bounds for function pointer

2022-03-30 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
ArcsinX added reviewers: aaron.ballman, erichkeane, abhinavgaba, 
chrish_ericsson_atx.
Herald added a project: All.
ArcsinX requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Currently, clang crashes with i386 target on the following code:

  void f() {
f + 0xdeadUL;
  }

This problem is similar to the problem fixed in D104424 
, but that fix can't handle function pointer 
case, because `getTypeSizeInCharsIfKnown()` says that size is known and equal 
to 0 for function type.

This patch prevents bounds checking for function pointer, thus fixes the crash.

Fixes https://github.com/llvm/llvm-project/issues/50463


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D122748

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/Sema/unbounded-array-bounds.c


Index: clang/test/Sema/unbounded-array-bounds.c
===
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15447,7 +15447,7 @@
   const Type *BaseType =
   ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr();
   bool IsUnboundedArray = (BaseType == nullptr);
-  if (EffectiveType->isDependentType() ||
+  if (EffectiveType->isDependentType() || EffectiveType->isFunctionType() ||
   (!IsUnboundedArray && BaseType->isDependentType()))
 return;
 


Index: clang/test/Sema/unbounded-array-bounds.c
===
--- clang/test/Sema/unbounded-array-bounds.c
+++ clang/test/Sema/unbounded-array-bounds.c
@@ -80,3 +80,7 @@
   (void *)0 + 0xdeadUL;
   // no array-bounds warning, and no crash
 }
+
+void func() {
+  func + 0xdeadUL; // no crash
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -15447,7 +15447,7 @@
   const Type *BaseType =
   ArrayTy == nullptr ? nullptr : ArrayTy->getElementType().getTypePtr();
   bool IsUnboundedArray = (BaseType == nullptr);
-  if (EffectiveType->isDependentType() ||
+  if (EffectiveType->isDependentType() || EffectiveType->isFunctionType() ||
   (!IsUnboundedArray && BaseType->isDependentType()))
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-03-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary updated this revision to Diff 419208.
lenary added a comment.

- Remove whitespace change in ARMSubtarget
- Remove commented-out debug lines in RDFGraph


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-fix-cortex-a57-aes-1742098.c
  llvm/lib/Target/ARM/ARM.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMFixCortexA57AES1742098Pass.cpp
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/ARM/CMakeLists.txt
  llvm/test/CodeGen/ARM/O3-pipeline.ll
  llvm/test/CodeGen/ARM/aes-erratum-fix.ll

Index: llvm/test/CodeGen/ARM/aes-erratum-fix.ll
===
--- llvm/test/CodeGen/ARM/aes-erratum-fix.ll
+++ llvm/test/CodeGen/ARM/aes-erratum-fix.ll
@@ -24,6 +24,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r0]
 ; CHECK-FIX-NEXT:vmov.i32 q9, #0x0
+; CHECK-FIX-NEXT:vorr q9, q9, q9
 ; CHECK-FIX-NEXT:aese.8 q9, q8
 ; CHECK-FIX-NEXT:aesmc.8 q8, q9
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r0]
@@ -55,6 +56,8 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_once_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
 ; CHECK-FIX-LABEL: aese_once_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q1, q0
 ; CHECK-FIX-NEXT:aesmc.8 q0, q1
 ; CHECK-FIX-NEXT:bx lr
@@ -91,6 +94,9 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_twice_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
 ; CHECK-FIX-LABEL: aese_twice_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q1, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q1
 ; CHECK-FIX-NEXT:aese.8 q8, q0
@@ -154,6 +160,8 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_loop_via_val(i32 %0, <16 x i8> %1, <16 x i8> %2) nounwind {
 ; CHECK-FIX-LABEL: aese_loop_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:cmp r0, #0
 ; CHECK-FIX-NEXT:beq .LBB6_2
 ; CHECK-FIX-NEXT:  .LBB6_1: @ =>This Inner Loop Header: Depth=1
@@ -186,6 +194,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r0]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r1]
@@ -202,8 +211,10 @@
 define arm_aapcs_vfpcc void @aese_set8_via_val(i8 zeroext %0, <16 x i8> %1, <16 x i8>* %2) nounwind {
 ; CHECK-FIX-LABEL: aese_set8_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
 ; CHECK-FIX-NEXT:vmov.8 d16[0], r0
+; CHECK-FIX-NEXT:vorr q8, q8, q8
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r1]
@@ -225,6 +236,7 @@
 ; CHECK-FIX-NEXT:  @ %bb.1:
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r1]
 ; CHECK-FIX-NEXT:  .LBB9_2:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r2]
@@ -248,12 +260,14 @@
 define arm_aapcs_vfpcc void @aese_set8_cond_via_val(i1 zeroext %0, i8 zeroext %1, <16 x i8> %2, <16 x i8>* %3) nounwind {
 ; CHECK-FIX-LABEL: aese_set8_cond_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:cmp r0, #0
 ; CHECK-FIX-NEXT:beq .LBB10_2
 ; CHECK-FIX-NEXT:  @ %bb.1:
 ; CHECK-FIX-NEXT:vmov.8 d16[0], r1
 ; CHECK-FIX-NEXT:  .LBB10_2: @ %select.end
+; CHECK-FIX-NEXT:vorr q8, q8, q8
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r2]
@@ -276,6 +290,7 @@
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r1]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:  .LBB11_2: @ =>This Inner Loop Header: Depth=1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:subs r0, r0, #1
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
@@ -318,6 +333,7 @@
 ; CHECK-FIX-NEXT:vmov.8 d0[0], r1
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:  .LBB12_2: @ =>This Inner Loop Header: Depth=1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:subs r0, r0, #1
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
@@ -355,6 +371,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.16 {d0[0]}, [r0:16]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 

[PATCH] D122611: [clang][extract-api] Add support for macros

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 419207.
dang marked 3 inline comments as done.
dang added a comment.

Update with code review feedback and the rebased code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122611

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/macro_undefined.c
  clang/test/ExtractAPI/macros.c

Index: clang/test/ExtractAPI/macros.c
===
--- /dev/null
+++ clang/test/ExtractAPI/macros.c
@@ -0,0 +1,344 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api --product-name=Macros -target arm64-apple-macosx \
+// RUN: -x objective-c-header %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+#define HELLO 1
+#define WORLD 2
+#define MACRO_FUN(x) x x
+#define FUN(x, y, z) x + y + z
+#define FUNC99(x, ...)
+#define FUNGNU(x...)
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "Macros",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "HELLO"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@8@macro@HELLO"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 1,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "HELLO"
+  }
+],
+"title": "HELLO"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "WORLD"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@24@macro@WORLD"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 2,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "WORLD"
+  }
+],
+"title": "WORLD"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "MACRO_FUN"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@40@macro@MACRO_FUN"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 3,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "MACRO_FUN"
+  }
+],
+"title": "MACRO_FUN"
+  }
+},
+{
+  

[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang added inline comments.



Comment at: clang/include/clang/ExtractAPI/FrontendActions.h:42-58
   /// Prepare to execute the action on the given CompilerInstance.
   ///
   /// This is called before executing the action on any inputs. This generates 
a
   /// single header that includes all of CI's inputs and replaces CI's input
   /// list with it before actually executing the action.
   bool PrepareToExecuteAction(CompilerInstance ) override;
 

zixuw wrote:
> Should these methods be private?
Yes I checked and existing frontend actions mark these as private.


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

https://reviews.llvm.org/D122648

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


[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 419205.
dang added a comment.

Update using the correct patch this time around.


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

https://reviews.llvm.org/D122648

Files:
  clang/include/clang/ExtractAPI/FrontendActions.h
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp

Index: clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
===
--- clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -41,8 +41,8 @@
 /// information.
 class ExtractAPIVisitor : public RecursiveASTVisitor {
 public:
-  ExtractAPIVisitor(ASTContext , Language Lang)
-  : Context(Context), API(Context.getTargetInfo().getTriple(), Lang) {}
+  ExtractAPIVisitor(ASTContext , APISet )
+  : Context(Context), API(API) {}
 
   const APISet () const { return API; }
 
@@ -489,43 +489,40 @@
   }
 
   ASTContext 
-  APISet API;
+  APISet 
 };
 
 class ExtractAPIConsumer : public ASTConsumer {
 public:
-  ExtractAPIConsumer(ASTContext , StringRef ProductName, Language Lang,
- std::unique_ptr OS)
-  : Visitor(Context, Lang), ProductName(ProductName), OS(std::move(OS)) {}
+  ExtractAPIConsumer(ASTContext , APISet )
+  : Visitor(Context, API) {}
 
   void HandleTranslationUnit(ASTContext ) override {
 // Use ExtractAPIVisitor to traverse symbol declarations in the context.
 Visitor.TraverseDecl(Context.getTranslationUnitDecl());
-
-// Setup a SymbolGraphSerializer to write out collected API information in
-// the Symbol Graph format.
-// FIXME: Make the kind of APISerializer configurable.
-SymbolGraphSerializer SGSerializer(Visitor.getAPI(), ProductName);
-SGSerializer.serialize(*OS);
   }
 
 private:
   ExtractAPIVisitor Visitor;
-  std::string ProductName;
-  std::unique_ptr OS;
 };
 
 } // namespace
 
 std::unique_ptr
 ExtractAPIAction::CreateASTConsumer(CompilerInstance , StringRef InFile) {
-  std::unique_ptr OS = CreateOutputFile(CI, InFile);
+  OS = CreateOutputFile(CI, InFile);
   if (!OS)
 return nullptr;
-  return std::make_unique(
-  CI.getASTContext(), CI.getInvocation().getFrontendOpts().ProductName,
-  CI.getFrontendOpts().Inputs.back().getKind().getLanguage(),
-  std::move(OS));
+
+  ProductName = CI.getFrontendOpts().ProductName;
+
+  // Now that we have enough information about the language options and the
+  // target triple, let's create the APISet before anyone uses it.
+  API = std::make_unique(
+  CI.getTarget().getTriple(),
+  CI.getFrontendOpts().Inputs.back().getKind().getLanguage());
+
+  return std::make_unique(CI.getASTContext(), *API);
 }
 
 bool ExtractAPIAction::PrepareToExecuteAction(CompilerInstance ) {
@@ -557,6 +554,18 @@
   return true;
 }
 
+void ExtractAPIAction::EndSourceFileAction() {
+  if (!OS)
+return;
+
+  // Setup a SymbolGraphSerializer to write out collected API information in
+  // the Symbol Graph format.
+  // FIXME: Make the kind of APISerializer configurable.
+  SymbolGraphSerializer SGSerializer(*API, ProductName);
+  SGSerializer.serialize(*OS);
+  OS->flush();
+}
+
 std::unique_ptr
 ExtractAPIAction::CreateOutputFile(CompilerInstance , StringRef InFile) {
   std::unique_ptr OS =
Index: clang/include/clang/ExtractAPI/FrontendActions.h
===
--- clang/include/clang/ExtractAPI/FrontendActions.h
+++ clang/include/clang/ExtractAPI/FrontendActions.h
@@ -14,6 +14,7 @@
 #ifndef LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
 #define LLVM_CLANG_EXTRACTAPI_FRONTEND_ACTIONS_H
 
+#include "clang/ExtractAPI/API.h"
 #include "clang/Frontend/FrontendAction.h"
 
 namespace clang {
@@ -25,11 +26,19 @@
  StringRef InFile) override;
 
 private:
+  /// A representation of the APIs this action extracts.
+  std::unique_ptr API;
+
+  /// A stream to the output file of this action.
+  std::unique_ptr OS;
+
+  /// The product this action is extracting API information for.
+  std::string ProductName;
+
   /// The synthesized input buffer that contains all the provided input header
   /// files.
   std::unique_ptr Buffer;
 
-public:
   /// Prepare to execute the action on the given CompilerInstance.
   ///
   /// This is called before executing the action on any inputs. This generates a
@@ -37,8 +46,15 @@
   /// list with it before actually executing the action.
   bool PrepareToExecuteAction(CompilerInstance ) override;
 
+  /// Called after executing the action on the synthesized input buffer.
+  ///
+  /// Note: Now that we have gathered all the API definitions to surface we can
+  /// emit them in this callback.
+  void EndSourceFileAction() override;
+
   static std::unique_ptr
   CreateOutputFile(CompilerInstance , StringRef InFile);
+
   static StringRef getInputBufferName() { return ""; }
 };
 
___
cfe-commits mailing list

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

2022-03-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 rG0550601d1801: [Clang] Add a compatibiliy warning for 
non-literals in constexpr. (authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp

Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx2b.cpp
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -1,7 +1,8 @@
 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx2a %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wno-c++2b-extensions
 // RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify=expected,cxx2b %s -fcxx-exceptions -triple=x86_64-linux-gnu -Wpre-c++2b-compat
 
-struct NonLiteral { // cxx2a-note {{'NonLiteral' is not literal}}
+struct NonLiteral { // cxx2a-note {{'NonLiteral' is not literal}} \
+// cxx2b-note 2{{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
@@ -96,7 +97,7 @@
 constexpr int non_literal(bool b) {
   if (!b)
 return 0;
-  NonLiteral n;
+  NonLiteral n; // cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int non_literal_1 = non_literal(false);
@@ -164,7 +165,8 @@
   auto non_literal = [](bool b) constexpr {
 if (!b)
   NonLiteral n; // cxx2b-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
-// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}}
+// cxx2a-error {{variable of non-literal type 'NonLiteral' cannot be defined in a constexpr function before C++2b}} \
+// cxx2b-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 return 0;
   };
 
@@ -227,7 +229,7 @@
 }
 
 template 
-constexpr auto dependent_var_def_lambda(void) {
+constexpr auto dependent_var_def_lambda() {
   return [](bool b) { // cxx2a-note {{declared here}}
 if (!b)
   T t;
@@ -237,4 +239,4 @@
 
 constexpr auto non_literal_valid_in_cxx2b = dependent_var_def_lambda()(true); // \
 // cxx2a-error {{constexpr variable 'non_literal_valid_in_cxx2b' must be initialized by a constant expression}} \
-// cxx2a-note  {{non-constexpr function}}
+// cxx2a-note {{non-constexpr function}}
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -25,17 +25,18 @@
 label:; // expected-warning {{use of this statement in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
-struct NonLiteral {
+struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of non-literal type in a constexpr function is incompatible with C++ standards before C++2b}}
 }
 
 constexpr int c_thread_local(int n) {
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,11 +1901,17 @@
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, 

[clang] 0550601 - [Clang] Add a compatibiliy warning for non-literals in constexpr.

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

Author: Corentin Jabot
Date: 2022-03-30T19:18:53+02:00
New Revision: 0550601d180111a1c48baf170c2e7e9c7fac28c2

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

LOG: [Clang] Add a compatibiliy warning for non-literals in constexpr.

Reviewed By: aaron.ballman, hubert.reinterpretcast

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
clang/test/SemaCXX/constant-expression-cxx2b.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d3055fed20828..a272cb741270f 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2721,9 +2721,9 @@ def ext_constexpr_static_var : ExtWarn<
   "definition of a %select{static|thread_local}1 variable "
   "in a constexpr %select{function|constructor}0 "
   "is a C++2b extension">, InGroup;
-def warn_cxx20_compat_constexpr_static_var : Warning<
-  "definition of a %select{static|thread_local}1 variable "
-  "in a constexpr %select{function|constructor}0 "
+def warn_cxx20_compat_constexpr_var : Warning<
+  "definition of a %select{static variable|thread_local variable|variable "
+  "of non-literal type}1 in a constexpr %select{function|constructor}0 "
   "is incompatible with C++ standards before C++2b">,
   InGroup, DefaultIgnore;
 def err_constexpr_local_var_non_literal_type : Error<

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 48fb642ad15e1..0f56e6024f332 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -1893,7 +1893,7 @@ static bool CheckConstexprDeclStmt(Sema , const 
FunctionDecl *Dcl,
   if (Kind == Sema::CheckConstexprKind::Diagnose) {
 SemaRef.Diag(VD->getLocation(),
  SemaRef.getLangOpts().CPlusPlus2b
- ? diag::warn_cxx20_compat_constexpr_static_var
+ ? diag::warn_cxx20_compat_constexpr_var
  : diag::ext_constexpr_static_var)
 << isa(Dcl)
 << (VD->getTLSKind() == VarDecl::TLS_Dynamic);
@@ -1901,11 +1901,17 @@ static bool CheckConstexprDeclStmt(Sema , const 
FunctionDecl *Dcl,
 return false;
   }
 }
-if (!SemaRef.LangOpts.CPlusPlus2b &&
-CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
- diag::err_constexpr_local_var_non_literal_type,
- isa(Dcl)))
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  CheckLiteralType(SemaRef, Kind, VD->getLocation(), VD->getType(),
+   diag::warn_cxx20_compat_constexpr_var,
+   isa(Dcl),
+   /*variable of non-literal type*/ 2);
+} else if (CheckLiteralType(
+   SemaRef, Kind, VD->getLocation(), VD->getType(),
+   diag::err_constexpr_local_var_non_literal_type,
+   isa(Dcl))) {
   return false;
+}
 if (!VD->getType()->isDependentType() &&
 !VD->hasInit() && !VD->isCXXForRangeDecl()) {
   if (Kind == Sema::CheckConstexprKind::Diagnose) {

diff  --git a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp 
b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
index 671895b278bdf..3ba5cbba79ce2 100644
--- a/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
+++ b/clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
@@ -25,17 +25,18 @@ constexpr void h() {
 label:; // expected-warning {{use of this statement in a constexpr function is 
incompatible with C++ standards before C++2b}}
 }
 
-struct NonLiteral {
+struct NonLiteral { // expected-note 2 {{'NonLiteral' is not literal}}
   NonLiteral() {}
 };
 
 constexpr void non_literal() { // expected-error {{constexpr function never 
produces a constant expression}}
-  NonLiteral n;// expected-note {{non-literal type 
'NonLiteral' cannot be used in a constant expression}}
+  NonLiteral n;// expected-note {{non-literal type 
'NonLiteral' cannot be used in a constant expression}} \
+   // expected-warning {{definition of a variable 
of non-literal type in a constexpr function is incompatible with C++ standards 
before C++2b}}
 }
 
 constexpr void non_literal2(bool b) {
   if (!b)
-NonLiteral n;
+NonLiteral n; // expected-warning {{definition of a variable of 
non-literal type in a constexpr function is incompatible with C++ standards 

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

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

I thing to support the template case, we would have to modify 
`TemplateDeclInstantiator::VisitVarDecl` - which seems the best way to have a 
diagnostic without running through the whole function AST twice.
However, there is currently no check of any sort there so it would be a bit 
novel and odd!

Thank you both for the review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-03-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary planned changes to this revision.
lenary added inline comments.



Comment at: llvm/lib/CodeGen/RDFGraph.cpp:1096
 RegisterRef RR = PDA.Addr->getRegRef(*this);
-#ifndef NDEBUG
-// Assert if the register is defined in two or more unrelated defs.
-// This could happen if there are two or more def operands defining it.
-if (!Defined.insert(RR.Reg).second) {
-  MachineInstr *MI = NodeAddr(IA).Addr->getCode();
-  dbgs() << "Multiple definitions of register: "
- << Print(RR, *this) << " in\n  " << *MI << "in "
- << printMBBReference(*MI->getParent()) << '\n';
-  llvm_unreachable(nullptr);
-}
-#endif
+// #ifndef NDEBUG
+// // Assert if the register is defined in two or more unrelated defs.

I forgot to remove these comments, will update shortly.



Comment at: llvm/lib/Target/ARM/ARMSubtarget.h:543
   unsigned getGPRAllocationOrder(const MachineFunction ) const;
+
 };

I missed this, will update again shortly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

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


[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-03-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary removed a reviewer: kparzysz.
lenary added a comment.

@kparzysz I have rewritten this to avoid using RDFGraph, so I don't think this 
needs you to review it any more.




Comment at: llvm/test/CodeGen/ARM/aes-erratum-fix.ll:49
+
+define <16 x i8> @aese_once_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
+; CHECK-FIX-NOSCHED-LABEL: aese_once_via_val:

dmgreen wrote:
> Adding arm_aapcs_vfpcc will make the function "hardfp", which might be useful 
> for testing inputs from argument that don't need to be passed via gpr regs.
Yeah, seems I was too zealous with removing some of these attributes. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

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


[PATCH] D119720: [ARM] Pass for Cortex-A57 and Cortex-A72 Fused AES Erratum

2022-03-30 Thread Sam Elliott via Phabricator via cfe-commits
lenary updated this revision to Diff 419202.
lenary added a comment.

- Rewrite pass in terms of ReachingDefAnalysis
- Split tests into separate commit, for ease of review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119720

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  clang/test/Driver/arm-fix-cortex-a57-aes-1742098.c
  llvm/lib/CodeGen/RDFGraph.cpp
  llvm/lib/Target/ARM/ARM.h
  llvm/lib/Target/ARM/ARM.td
  llvm/lib/Target/ARM/ARMFixCortexA57AES1742098Pass.cpp
  llvm/lib/Target/ARM/ARMSubtarget.h
  llvm/lib/Target/ARM/ARMTargetMachine.cpp
  llvm/lib/Target/ARM/CMakeLists.txt
  llvm/test/CodeGen/ARM/O3-pipeline.ll
  llvm/test/CodeGen/ARM/aes-erratum-fix.ll

Index: llvm/test/CodeGen/ARM/aes-erratum-fix.ll
===
--- llvm/test/CodeGen/ARM/aes-erratum-fix.ll
+++ llvm/test/CodeGen/ARM/aes-erratum-fix.ll
@@ -24,6 +24,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r0]
 ; CHECK-FIX-NEXT:vmov.i32 q9, #0x0
+; CHECK-FIX-NEXT:vorr q9, q9, q9
 ; CHECK-FIX-NEXT:aese.8 q9, q8
 ; CHECK-FIX-NEXT:aesmc.8 q8, q9
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r0]
@@ -55,6 +56,8 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_once_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
 ; CHECK-FIX-LABEL: aese_once_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q1, q0
 ; CHECK-FIX-NEXT:aesmc.8 q0, q1
 ; CHECK-FIX-NEXT:bx lr
@@ -91,6 +94,9 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_twice_via_val(<16 x i8> %0, <16 x i8> %1) nounwind {
 ; CHECK-FIX-LABEL: aese_twice_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q1, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q1
 ; CHECK-FIX-NEXT:aese.8 q8, q0
@@ -154,6 +160,8 @@
 define arm_aapcs_vfpcc <16 x i8> @aese_loop_via_val(i32 %0, <16 x i8> %1, <16 x i8> %2) nounwind {
 ; CHECK-FIX-LABEL: aese_loop_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q1, q1, q1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:cmp r0, #0
 ; CHECK-FIX-NEXT:beq .LBB6_2
 ; CHECK-FIX-NEXT:  .LBB6_1: @ =>This Inner Loop Header: Depth=1
@@ -186,6 +194,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r0]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r1]
@@ -202,8 +211,10 @@
 define arm_aapcs_vfpcc void @aese_set8_via_val(i8 zeroext %0, <16 x i8> %1, <16 x i8>* %2) nounwind {
 ; CHECK-FIX-LABEL: aese_set8_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
 ; CHECK-FIX-NEXT:vmov.8 d16[0], r0
+; CHECK-FIX-NEXT:vorr q8, q8, q8
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r1]
@@ -225,6 +236,7 @@
 ; CHECK-FIX-NEXT:  @ %bb.1:
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r1]
 ; CHECK-FIX-NEXT:  .LBB9_2:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r2]
@@ -248,12 +260,14 @@
 define arm_aapcs_vfpcc void @aese_set8_cond_via_val(i1 zeroext %0, i8 zeroext %1, <16 x i8> %2, <16 x i8>* %3) nounwind {
 ; CHECK-FIX-LABEL: aese_set8_cond_via_val:
 ; CHECK-FIX:   @ %bb.0:
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:cmp r0, #0
 ; CHECK-FIX-NEXT:beq .LBB10_2
 ; CHECK-FIX-NEXT:  @ %bb.1:
 ; CHECK-FIX-NEXT:vmov.8 d16[0], r1
 ; CHECK-FIX-NEXT:  .LBB10_2: @ %select.end
+; CHECK-FIX-NEXT:vorr q8, q8, q8
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
 ; CHECK-FIX-NEXT:vst1.64 {d16, d17}, [r2]
@@ -276,6 +290,7 @@
 ; CHECK-FIX-NEXT:vld1.8 {d0[0]}, [r1]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:  .LBB11_2: @ =>This Inner Loop Header: Depth=1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:subs r0, r0, #1
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
@@ -318,6 +333,7 @@
 ; CHECK-FIX-NEXT:vmov.8 d0[0], r1
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r2]
 ; CHECK-FIX-NEXT:  .LBB12_2: @ =>This Inner Loop Header: Depth=1
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:aese.8 q8, q0
 ; CHECK-FIX-NEXT:subs r0, r0, #1
 ; CHECK-FIX-NEXT:aesmc.8 q8, q8
@@ -355,6 +371,7 @@
 ; CHECK-FIX:   @ %bb.0:
 ; CHECK-FIX-NEXT:vld1.16 {d0[0]}, [r0:16]
 ; CHECK-FIX-NEXT:vld1.64 {d16, d17}, [r1]
+; CHECK-FIX-NEXT:vorr q0, q0, q0
 ; CHECK-FIX-NEXT:

[clang] 61d67c8 - Revert "[ASTMatchers] Output currently matching node on crash"

2022-03-30 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2022-03-30T18:10:48+01:00
New Revision: 61d67c8eecd2547bc690f9a6bba61b9ba814c71b

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

LOG: Revert "[ASTMatchers] Output currently matching node on crash"

This reverts commit 6e33e45b943061f79ab6de1b60d04d4c6f32f8f9.

Fails to build on 32bit machines due to PointerUnion limitations

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchFinder.cpp
clang/unittests/ASTMatchers/ASTMatchersInternalTest.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchFinder.cpp 
b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
index e4141232d1c6f..70598460151ae 100644
--- a/clang/lib/ASTMatchers/ASTMatchFinder.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchFinder.cpp
@@ -761,166 +761,53 @@ class MatchASTVisitor : public 
RecursiveASTVisitor,
 D);
   }
 
-private:
-  bool TraversingASTNodeNotSpelledInSource = false;
-  bool TraversingASTNodeNotAsIs = false;
-  bool TraversingASTChildrenNotSpelledInSource = false;
-
-  class CurMatchData {
-  public:
-CurMatchData() = default;
-
-template 
-void SetCallbackAndRawNode(const MatchCallback *CB, const NodeType ) {
-  assertEmpty();
-  Callback = CB;
-  MatchingNode = 
-}
-
-const MatchCallback *getCallback() const { return Callback; }
-
-void SetBoundNodes(const BoundNodes ) {
-  assertHoldsState();
-  BNodes = 
-}
-
-void clearBoundNodes() {
-  assertHoldsState();
-  BNodes = nullptr;
-}
-
-template  const T *getNode() const {
-  assertHoldsState();
-  return MatchingNode.dyn_cast();
-}
-
-const BoundNodes *getBoundNodes() const {
-  assertHoldsState();
-  return BNodes;
-}
-
-void reset() {
-  assertHoldsState();
-  Callback = nullptr;
-  MatchingNode = nullptr;
-}
-
-  private:
-void assertHoldsState() const {
-  assert(Callback != nullptr && !MatchingNode.isNull());
-}
-
-void assertEmpty() const {
-  assert(Callback == nullptr && MatchingNode.isNull() && BNodes == 
nullptr);
-}
-
-const MatchCallback *Callback = nullptr;
-const BoundNodes *BNodes = nullptr;
-
-llvm::PointerUnion<
-const QualType *, const TypeLoc *, const NestedNameSpecifier *,
-const NestedNameSpecifierLoc *, const CXXCtorInitializer *,
-const TemplateArgumentLoc *, const Attr *, const DynTypedNode *>
-MatchingNode;
-  } CurMatchState;
-
-  struct CurMatchRAII {
-template 
-CurMatchRAII(MatchASTVisitor , const MatchCallback *CB,
- const NodeType )
-: MV(MV) {
-  MV.CurMatchState.SetCallbackAndRawNode(CB, NT);
-}
-
-~CurMatchRAII() { MV.CurMatchState.reset(); }
-
-  private:
-MatchASTVisitor 
-  };
-
-public:
   class TraceReporter : llvm::PrettyStackTraceEntry {
-static void dumpNode(const ASTContext , const DynTypedNode ,
- raw_ostream ) {
-  if (const auto *D = Node.get()) {
-OS << D->getDeclKindName() << "Decl ";
-if (const auto *ND = dyn_cast(D)) {
-  ND->printQualifiedName(OS);
-  OS << " : ";
-} else
-  OS << ": ";
-D->getSourceRange().print(OS, Ctx.getSourceManager());
-  } else if (const auto *S = Node.get()) {
-OS << S->getStmtClassName() << " : ";
-S->getSourceRange().print(OS, Ctx.getSourceManager());
-  } else if (const auto *T = Node.get()) {
-OS << T->getTypeClassName() << "Type : ";
-QualType(T, 0).print(OS, Ctx.getPrintingPolicy());
-  } else if (const auto *QT = Node.get()) {
-OS << "QualType : ";
-QT->print(OS, Ctx.getPrintingPolicy());
-  } else {
-OS << Node.getNodeKind().asStringRef() << " : ";
-Node.getSourceRange().print(OS, Ctx.getSourceManager());
-  }
-}
-
-static void dumpNodeFromState(const ASTContext ,
-  const CurMatchData , raw_ostream ) {
-  if (const DynTypedNode *MatchNode = State.getNode()) {
-dumpNode(Ctx, *MatchNode, OS);
-  } else if (const auto *QT = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*QT), OS);
-  } else if (const auto *TL = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*TL), OS);
-  } else if (const auto *NNS = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*NNS), OS);
-  } else if (const auto *NNSL = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*NNSL), OS);
-  } else if (const auto *CtorInit = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*CtorInit), OS);
-  } else if (const auto *TAL = State.getNode()) {
-dumpNode(Ctx, DynTypedNode::create(*TAL), OS);
-  } else if (const auto *At = 

[PATCH] D122249: [Clang] Add a compatibiliy warning for non-literals in constexpr.

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

LGTM




Comment at: clang/lib/Sema/SemaDeclCXX.cpp:1905
+if (SemaRef.LangOpts.CPlusPlus2b) {
+  if (!VD->getType()->isLiteralType(SemaRef.Context))
+SemaRef.Diag(VD->getLocation(),

hubert.reinterpretcast wrote:
> cor3ntin wrote:
> > aaron.ballman wrote:
> > > aaron.ballman wrote:
> > > > cor3ntin wrote:
> > > > > hubert.reinterpretcast wrote:
> > > > > > This seems to trigger even when the type is dependent:
> > > > > > ```
> > > > > > :1:36: warning: definition of a variable of non-literal type 
> > > > > > in a constexpr function is incompatible with C++ standards before 
> > > > > > C++2b [-Wpre-c++2b-compat]
> > > > > > auto qq = [](auto x) { decltype(x) n; };
> > > > > >^
> > > > > > 1 warning generated.
> > > > > > ```
> > > > > > 
> > > > > > This also seems to emit even when `Kind` is not 
> > > > > > `Sema::CheckConstexprKind::Diagnose` (unlike the 
> > > > > > `static`/`thread_local` case above). Is the `CheckLiteralType` 
> > > > > > logic not reusable for this?
> > > > > You are right, thanks for noticing that, it was rather bogus.
> > > > > The reason I'm not using CheckLiteralType is to avoid duplicating a 
> > > > > diagnostics message, as CheckLiteralType doesn't allow us to pass 
> > > > > parameter to the diagnostic message.
> > > > > 
> > > > > It leaves us with an uncovered scenario though: We do not emit the 
> > > > > warning on template instantiation, and I don't think there is an  
> > > > > easy way to do that.
> > > > > The reason I'm not using CheckLiteralType is to avoid duplicating a 
> > > > > diagnostics message, as CheckLiteralType doesn't allow us to pass 
> > > > > parameter to the diagnostic message.
> > > > 
> > > > Huh?
> > > > 
> > > > ```
> > > > static bool CheckLiteralType(Sema , Sema::CheckConstexprKind 
> > > > Kind,
> > > >  SourceLocation Loc, QualType T, unsigned 
> > > > DiagID,
> > > >  Ts &&...DiagArgs) {
> > > >   ...
> > > > }
> > > > ```
> > > > I would hope `DiagArgs` should do exactly that? :-)
> > > > It leaves us with an uncovered scenario though: We do not emit the 
> > > > warning on template instantiation, and I don't think there is an easy 
> > > > way to do that.
> > > 
> > > I believe the code paths that lead us here all come from 
> > > `Sema::CheckConstexprFunctionDefinition()` which is called from 
> > > `Sema::ActOnFinishFunctionBody()` which seems to be called when 
> > > instantiating templates in `Sema::InstantiateFunctionDefinition()`, so 
> > > perhaps some more investigation is needed as to why we're not reaching 
> > > this for template instantiations.
> > We could add something in addition of 
> > `Sema::CheckConstexprKind::CheckValid` and 
> > `Sema::CheckConstexprKind::Diagnose`, but 
> > 
> > * not for implicit lambdas, because we should not warn on lambdas that 
> > won't be constexpr
> > * for explicit constexpr lambdas / functions, it would force us to call 
> > CheckConstexprFunctionDefinition  on instanciation, which we currently 
> > don't do, and is not free for that one warning - and we would have to 
> > not-reemit the other warnings. It seems like quite a fair amount of work 
> > for a diagnostic not enabled by default.
> > so perhaps some more investigation is needed as to why we're not reaching 
> > this for template instantiations.
> 
> @aaron.ballman, do you have any position on whether we want this 
> investigation before moving forward with this patch?
>>so perhaps some more investigation is needed as to why we're not reaching 
>>this for template instantiations.
> @aaron.ballman, do you have any position on whether we want this 
> investigation before moving forward with this patch?

@hubert.reinterpretcast -- I think @cor3ntin did that investigation and found 
that we don't make it to this code path because of 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Sema/SemaDecl.cpp#L14961.

I think this is incremental progress, and we can handle the template 
instantiation cases in a follow-up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122249

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


[PATCH] D122648: [clang][extractapi] Tie API and serialization to the FrontendAction

2022-03-30 Thread Daniel Grumberg via Phabricator via cfe-commits
dang updated this revision to Diff 419197.
dang marked 2 inline comments as done.
dang added a comment.

Rebase on top of latest changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122648

Files:
  clang/include/clang/ExtractAPI/API.h
  clang/include/clang/ExtractAPI/DeclarationFragments.h
  clang/include/clang/ExtractAPI/Serialization/SymbolGraphSerializer.h
  clang/lib/ExtractAPI/API.cpp
  clang/lib/ExtractAPI/DeclarationFragments.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
  clang/test/ExtractAPI/macro_undefined.c
  clang/test/ExtractAPI/macros.c

Index: clang/test/ExtractAPI/macros.c
===
--- /dev/null
+++ clang/test/ExtractAPI/macros.c
@@ -0,0 +1,344 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s@INPUT_DIR@%/t@g" %t/reference.output.json.in >> \
+// RUN: %t/reference.output.json
+// RUN: %clang -extract-api --product-name=Macros -target arm64-apple-macosx \
+// RUN: -x objective-c-header %t/input.h -o %t/output.json | FileCheck -allow-empty %s
+
+// Generator version is not consistent across test runs, normalize it.
+// RUN: sed -e "s@\"generator\": \".*\"@\"generator\": \"?\"@g" \
+// RUN: %t/output.json >> %t/output-normalized.json
+// RUN: diff %t/reference.output.json %t/output-normalized.json
+
+// CHECK-NOT: error:
+// CHECK-NOT: warning:
+
+//--- input.h
+#define HELLO 1
+#define WORLD 2
+#define MACRO_FUN(x) x x
+#define FUN(x, y, z) x + y + z
+#define FUNC99(x, ...)
+#define FUNGNU(x...)
+
+//--- reference.output.json.in
+{
+  "metadata": {
+"formatVersion": {
+  "major": 0,
+  "minor": 5,
+  "patch": 3
+},
+"generator": "?"
+  },
+  "module": {
+"name": "Macros",
+"platform": {
+  "architecture": "arm64",
+  "operatingSystem": {
+"minimumVersion": {
+  "major": 11,
+  "minor": 0,
+  "patch": 0
+},
+"name": "macosx"
+  },
+  "vendor": "apple"
+}
+  },
+  "relationhips": [],
+  "symbols": [
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "HELLO"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@8@macro@HELLO"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 1,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "HELLO"
+  }
+],
+"title": "HELLO"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "WORLD"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@24@macro@WORLD"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 2,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "WORLD"
+  }
+],
+"title": "WORLD"
+  }
+},
+{
+  "declarationFragments": [
+{
+  "kind": "keyword",
+  "spelling": "#define"
+},
+{
+  "kind": "text",
+  "spelling": " "
+},
+{
+  "kind": "identifier",
+  "spelling": "MACRO_FUN"
+},
+{
+  "kind": "text",
+  "spelling": "("
+},
+{
+  "kind": "internalParam",
+  "spelling": "x"
+},
+{
+  "kind": "text",
+  "spelling": ")"
+}
+  ],
+  "identifier": {
+"interfaceLanguage": "objective-c",
+"precise": "c:input.h@40@macro@MACRO_FUN"
+  },
+  "kind": {
+"displayName": "Macro",
+"identifier": "objective-c.macro"
+  },
+  "location": {
+"character": 9,
+"line": 3,
+"uri": "file://INPUT_DIR/input.h"
+  },
+  "names": {
+"subHeading": [
+  {
+"kind": "identifier",
+"spelling": "MACRO_FUN"
+  }
+],
+"title": "MACRO_FUN"
+  }
+},
+{
+  "declarationFragments": [
+{
+ 

[PATCH] D122589: Additionally set f32 mode with denormal-fp-math

2022-03-30 Thread David Candler via Phabricator via cfe-commits
dcandler added a comment.

The issue I found was trying to use getDefaultDenormalModeForType during 
constant folding to account for denormals (https://reviews.llvm.org/D116952). 
Setting denormal-fp-math to a non-IEEE mode without specifying 
denormal-fp-math-f32 still results in the denormal-fp-math-f32 attribute being 
present (even if unsued elsewhere), which leads to the wrong result for targets 
that do not support denormal-fp-math-f32.

Only emitting denormal-fp-math-f32 when specified makes sense, but the current 
default effectively always specifies it as IEEE. One alternative would be to 
simply change the default.


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

https://reviews.llvm.org/D122589

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


[PATCH] D122471: [IR] Require intrinsic struct return type to be anonymous

2022-03-30 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

In D122471#3416797 , @nikic wrote:

> @uabelho Can you please check whether 
> https://github.com/llvm/llvm-project/commit/d6887256c2cae1b1b721bd47459be6d86003db6f
>  fixes the problem you're seeing?

Hi @nikic

Yes, that patch solves the problem. Great, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122471

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


[PATCH] D122713: [RISCV] [NFC] Add tests for vector load/store overloaded intrinsics of FP16

2022-03-30 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

These tests files are already too long and have been timing out in phabricator. 
@4vtomat has a patch D122370  to split them 
up.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122713

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


[PATCH] D115907: [misexpect] Re-implement MisExpect Diagnostics

2022-03-30 Thread Paul Kirth via Phabricator via cfe-commits
paulkirth updated this revision to Diff 419181.
paulkirth added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115907

Files:
  clang/docs/MisExpect.rst
  clang/docs/ReleaseNotes.rst
  clang/docs/index.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/Profile/Inputs/misexpect-branch-nonconst-expect-arg.proftext
  clang/test/Profile/Inputs/misexpect-branch.proftext
  clang/test/Profile/Inputs/misexpect-switch-default-only.proftext
  clang/test/Profile/Inputs/misexpect-switch-default.proftext
  clang/test/Profile/Inputs/misexpect-switch-nonconst.proftext
  clang/test/Profile/Inputs/misexpect-switch.proftext
  clang/test/Profile/misexpect-branch-cold.c
  clang/test/Profile/misexpect-branch-nonconst-expected-val.c
  clang/test/Profile/misexpect-branch-unpredictable.c
  clang/test/Profile/misexpect-branch.c
  clang/test/Profile/misexpect-switch-default.c
  clang/test/Profile/misexpect-switch-nonconst.c
  clang/test/Profile/misexpect-switch-only-default-case.c
  clang/test/Profile/misexpect-switch.c
  llvm/docs/MisExpect.rst
  llvm/docs/UserGuides.rst
  llvm/include/llvm/IR/DiagnosticInfo.h
  llvm/include/llvm/IR/LLVMContext.h
  llvm/include/llvm/Target/TargetOptions.h
  llvm/include/llvm/Transforms/Utils/MisExpect.h
  llvm/lib/IR/DiagnosticInfo.cpp
  llvm/lib/IR/LLVMContext.cpp
  llvm/lib/IR/LLVMContextImpl.h
  llvm/lib/Transforms/IPO/SampleProfile.cpp
  llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp
  llvm/lib/Transforms/Scalar/LowerExpectIntrinsic.cpp
  llvm/lib/Transforms/Utils/CMakeLists.txt
  llvm/lib/Transforms/Utils/MisExpect.cpp
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch-threshold.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-branch.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch-correct.proftext
  llvm/test/Transforms/PGOProfile/Inputs/misexpect-switch.proftext
  llvm/test/Transforms/PGOProfile/misexpect-branch-correct.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch-stripped.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch-unpredictable.ll
  llvm/test/Transforms/PGOProfile/misexpect-branch.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch-default.ll
  llvm/test/Transforms/PGOProfile/misexpect-switch.ll

Index: llvm/test/Transforms/PGOProfile/misexpect-switch.ll
===
--- /dev/null
+++ llvm/test/Transforms/PGOProfile/misexpect-switch.ll
@@ -0,0 +1,285 @@
+; Test misexpect diagnostics handle swich statements, and report source locations correctly
+
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch.proftext -o %t.profdata
+; RUN: llvm-profdata merge %S/Inputs/misexpect-switch-correct.proftext -o %t.c.profdata
+
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -S 2>&1 | FileCheck %s --check-prefix=WARNING
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=BOTH
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.profdata -S 2>&1 | FileCheck %s --check-prefix=DISABLED
+
+; RUN: opt < %s -passes="function(lower-expect),pgo-instr-use" -pgo-test-profile-file=%t.c.profdata -pgo-warn-misexpect -pass-remarks=misexpect -S 2>&1 | FileCheck %s --check-prefix=CORRECT
+
+; WARNING-DAG: warning: misexpect-switch.c:26:30: 0.00%
+; WARNING-NOT: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; REMARK-NOT: warning: misexpect-switch.c:26:30: 0.00%
+; REMARK-DAG: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; BOTH-DAG: warning: misexpect-switch.c:26:30: 0.00%
+; BOTH-DAG: remark: misexpect-switch.c:26:30: Potential performance regression from use of the llvm.expect intrinsic: Annotation was correct on 0.00% (0 / 8112) of profiled executions.
+
+; DISABLED-NOT: warning: misexpect-switch.c:26:30: 0.00%
+; DISABLED-NOT: remark: misexpect-switch.c:26:30: Potential performance regression from 

  1   2   >