[PATCH] D119051: Extend the C++03 definition of POD to include defaulted functions

2022-06-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119051

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


[PATCH] D128043: [flang][driver] Add support for `-O{0|1|2|3}`

2022-06-21 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added a comment.

Thanks for this patch. This is one big progress to use `flang-new` for real 
workloads. Mostly looks good to me. I have several minor comments. If supporing 
`-Ofast` requires more changes, I prefer to push forward with the current patch.

summary: fronted -> frontend

Confirmed with the following case:

  program m
integer :: x = 1, y = 2, z = 0
call add(x, y, z)
print *, z
  contains
subroutine add(a, b, c)
  integer :: a, b, c
  integer :: i
  do i = 1, 10
c = c + a + b
  enddo
end
  end

  $ flang-new -fc1 -emit-llvm test.f90 -O3
  $ cat test.ll 
  ; ModuleID = 'FIRModule'
  source_filename = "FIRModule"
  target triple = "aarch64-unknown-linux-gnu"
  
  @_QFEz = internal unnamed_addr global i32 0
  @_QQcl.2E2F746573742E66393000 = linkonce constant [11 x i8] c"./test.f90\00"
  
  define void @_QQmain() local_unnamed_addr !dbg !3 {
%1 = load i32, ptr @_QFEz, align 4, !dbg !7
%2 = add i32 %1, 30, !dbg !7
store i32 %2, ptr @_QFEz, align 4, !dbg !7
%3 = tail call ptr @_FortranAioBeginExternalListOutput(i32 -1, ptr nonnull 
@_QQcl.2E2F746573742E66393000, i32 5), !dbg !12
%4 = tail call i1 @_FortranAioOutputInteger32(ptr %3, i32 %2), !dbg !13
%5 = tail call i32 @_FortranAioEndIoStatement(ptr %3), !dbg !12
ret void, !dbg !14
  }
  ; Function Attrs: argmemonly nofree norecurse nosync nounwind
  define void @_QFPadd(ptr nocapture readonly %0, ptr nocapture readonly %1, 
ptr nocapture %2) local_unnamed_addr #0 !dbg !9 {
 ...




Comment at: clang/include/clang/Driver/Options.td:732
+def O_flag : Flag<["-"], "O">, Flags<[CC1Option,FC1Option]>, Alias, 
AliasArgs<["1"]>;
 def Ofast : Joined<["-"], "Ofast">, Group, Flags<[CC1Option]>;
 def P : Flag<["-"], "P">, Flags<[CC1Option,FlangOption,FC1Option]>, 
Group,

Will enabling Ofast require more changes in the flang frontend? If yes, it is 
OK to support it in another patch later.



Comment at: flang/include/flang/Frontend/CodeGenOptions.def:30
+
+VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
+

I saw `clang/include/clang/Basic/CodeGenOptions.def` has the following:
```
VALUE_CODEGENOPT(OptimizationLevel, 2, 0) ///< The -O[0-3] option specified.
VALUE_CODEGENOPT(OptimizeSize, 2, 0) ///< If -Os (==1) or -Oz (==2) is 
specified.
```

Do `-Os` and `-Oz` need extra processing in flang drivers? If yes, it is OK to 
support it in another patch later.



Comment at: flang/lib/Frontend/CodeGenOptions.cpp:8
+//===--===//
+
+#include "flang/Frontend/CodeGenOptions.h"

Miss the following?
```
//
// Coding style: https://mlir.llvm.org/getting_started/DeveloperGuide/
//
//===--===//
```



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128043

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


[PATCH] D128246: [ADT][NFC] Remove unuse code

2022-06-21 Thread Pretty-box via Phabricator via cfe-commits
Pretty-box created this revision.
Pretty-box added reviewers: benshi001, kazu.
Pretty-box added projects: LLVM, All.
Pretty-box 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/D128246

Files:
  clang/include/clang/Basic/DirectoryEntry.h


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,7 +131,6 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
 
   RefTy &value() & {
 assert(has_value());


Index: clang/include/clang/Basic/DirectoryEntry.h
===
--- clang/include/clang/Basic/DirectoryEntry.h
+++ clang/include/clang/Basic/DirectoryEntry.h
@@ -131,7 +131,6 @@
   void reset() { MaybeRef = optional_none_tag(); }
 
   bool has_value() const { return MaybeRef.hasOptionalValue(); }
-  bool hasValue() const { return MaybeRef.hasOptionalValue(); }
 
   RefTy &value() & {
 assert(has_value());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127313: [libc++] Implement P0618R0 (Deprecating )

2022-06-21 Thread Nikolas Klauser via Phabricator via cfe-commits
philnik updated this revision to Diff 438576.
philnik added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127313

Files:
  libcxx/docs/ReleaseNotes.rst
  libcxx/docs/Status/Cxx17Papers.csv
  libcxx/include/codecvt
  libcxx/include/locale
  libcxx/src/locale.cpp
  
libcxx/test/libcxx/localization/locales/locale.convenience/conversions/conversions.string/ctor_move.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_mode.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_always_noconv.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_unshift.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_always_noconv.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_encoding.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_in.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_length.pass.cpp
  
libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_max_length.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_out.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/codecvt_utf8_utf16_unshift.pass.cpp
  libcxx/test/std/localization/locale.stdcvt/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/ctor.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/overflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/pbackfail.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/rdbuf.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/seekoff.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/test.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.buffer/underflow.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/converted.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_codecvt_state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_copy.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/depr.verify.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/from_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/state.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/to_bytes.pass.cpp
  
libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/types.pass.cpp
  libcxx/test/support/platform_support.h

Index: libcxx/test/support/platform_support.h
===
--- libcxx/test/support/platform_support.h
+++ libcxx/test/support/platform_support.h
@@ -14,6 +14,8 @@
 #ifndef PLATFORM_SUPPORT_H
 #define PLATFORM_SUPPORT_H
 
+#include "test_macros.h"
+
 // locale names
 #define LOCALE_en_US   "en_US"
 #define LOCALE_en_US_UTF_8 "en_US.UTF-8"
@@ -88,14 +90,19 @@
 #endif
 }
 
+_LIBCPP_SUPPRESS_DEPRECATED_PUSH
 #ifdef _LIBCPP_HAS_OPEN_WITH_WCHAR
 inline
 std::wstrin

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

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

[Clang] update help text of "ftime-trace-path"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/tools/driver/cc1_main.cpp


Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -255,7 +255,16 @@
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
+if (Clang->getFrontendOpts().TimeTracePath.empty()) {
+  // replace the suffix to '.json' directly
+  llvm::sys::path::replace_extension(Path, "json");
+} else {
+  // change path prefix to the aim path, then add suffix '.json'
+  Path.assign(Clang->getFrontendOpts().TimeTracePath);
+  Path.append(
+  llvm::sys::path::filename(Clang->getFrontendOpts().OutputFile));
+  Path.append(".json");
+}
 if (auto profilerOutput = Clang->createOutputFile(
 Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6183,6 +6183,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_path);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
   Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
Index: clang/include/clang/Frontend/FrontendOptions.h
===
--- clang/include/clang/Frontend/FrontendOptions.h
+++ clang/include/clang/Frontend/FrontendOptions.h
@@ -499,6 +499,9 @@
   /// Minimum time granularity (in microseconds) traced by time profiler.
   unsigned TimeTraceGranularity;
 
+  /// Directory which stores the output files for -ftime-trace
+  std::string TimeTracePath;
+
 public:
   FrontendOptions()
   : DisableFree(false), RelocatablePCH(false), ShowHelp(false),
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -2828,6 +2828,10 @@
   HelpText<"Minimum time granularity (in microseconds) traced by time 
profiler">,
   Flags<[CC1Option, CoreOption]>,
   MarshallingInfoInt, "500u">;
+def ftime_trace_path : Joined<["-"], "ftime-trace-path=">, Group,
+  HelpText<"Directory which stores the output files for -ftime-trace">,
+  Flags<[CC1Option, CoreOption]>,
+  MarshallingInfoString>;
 def fproc_stat_report : Joined<["-"], "fproc-stat-report">, Group,
   HelpText<"Print subprocess statistics">;
 def fproc_stat_report_EQ : Joined<["-"], "fproc-stat-report=">, Group,


Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -255,7 +255,16 @@
 
   if (llvm::timeTraceProfilerEnabled()) {
 SmallString<128> Path(Clang->getFrontendOpts().OutputFile);
-llvm::sys::path::replace_extension(Path, "json");
+if (Clang->getFrontendOpts().TimeTracePath.empty()) {
+  // replace the suffix to '.json' directly
+  llvm::sys::path::replace_extension(Path, "json");
+} else {
+  // change path prefix to the aim path, then add suffix '.json'
+  Path.assign(Clang->getFrontendOpts().TimeTracePath);
+  Path.append(
+  llvm::sys::path::filename(Clang->getFrontendOpts().OutputFile));
+  Path.append(".json");
+}
 if (auto profilerOutput = Clang->createOutputFile(
 Path.str(), /*Binary=*/false, /*RemoveFileOnSignal=*/false,
 /*useTemporary=*/false)) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6183,6 +6183,7 @@
   Args.AddLastArg(CmdArgs, options::OPT_ftime_report_EQ);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace);
   Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_granularity_EQ);
+  Args.AddLastArg(CmdArgs, options::OPT_ftime_trace_path);
   Args.AddLastArg(CmdArgs, options::OPT_ftrapv);
   Args.AddLastArg(CmdArgs, options::OPT_malign_double);
   Args.AddLastArg(CmdArgs, options::OPT_fno_temp_file);
Index: clang/include/clang/Frontend/FrontendOpt

[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

2022-06-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, rsmith.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When calling `hasArrayFiller()` on a `APValue` that's not an array, the two 
functions called inside `hasArrayFiller()` would both run into their 
`isArray()` assertions.

This triggered for me with the included test case in `ExprConstant.cpp`:

  if (!Result.hasArrayFiller())
return Success;

adding a `!Result.isArray() ||` there would also work of course but I think the 
version in this patch is safer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128248

Files:
  clang/include/clang/AST/APValue.h
  clang/test/SemaCXX/constexpr-array-init.cpp


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+struct Foo {
+  int a; // expected-note {{subobject declared here}}
+  constexpr Foo()
+  : a(get_int()) {
+  }
+
+  constexpr int get_int() {
+return 5;
+  }
+};
+
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 
'bar' must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' 
is not initialized}}
+{{}},
+};
Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -508,6 +508,8 @@
 return const_cast(this)->getArrayInitializedElt(I);
   }
   bool hasArrayFiller() const {
+if (!isArray())
+  return false;
 return getArrayInitializedElts() != getArraySize();
   }
   APValue &getArrayFiller() {


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+struct Foo {
+  int a; // expected-note {{subobject declared here}}
+  constexpr Foo()
+  : a(get_int()) {
+  }
+
+  constexpr int get_int() {
+return 5;
+  }
+};
+
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 'bar' must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' is not initialized}}
+{{}},
+};
Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -508,6 +508,8 @@
 return const_cast(this)->getArrayInitializedElt(I);
   }
   bool hasArrayFiller() const {
+if (!isArray())
+  return false;
 return getArrayInitializedElts() != getArraySize();
   }
   APValue &getArrayFiller() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128249: Adding clone_attrs attribute.

2022-06-21 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi created this revision.
plotfi added a reviewer: arphaman.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
plotfi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is just experimental for the time being. Posting to phab to get some 
comments.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128249

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/AST/attr-swift_bridge.m

Index: clang/test/AST/attr-swift_bridge.m
===
--- clang/test/AST/attr-swift_bridge.m
+++ clang/test/AST/attr-swift_bridge.m
@@ -1,11 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -ast-dump %s | FileCheck %s
 
-struct __attribute__((__swift_bridge__("BridgedS"))) S;
-// CHECK: RecordDecl {{.*}} struct S
-// CHECK: SwiftBridgeAttr {{.*}} "BridgedS"
+int ;
 
-struct S {
-};
-
-// CHECK: RecordDecl {{.*}} struct S definition
-// CHECK: SwiftBridgeAttr {{.*}} Inherited "BridgedS"
+struct __attribute__((__clone_attrs_from__())) S;
\ No newline at end of file
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -3300,6 +3300,37 @@
   D->addAttr(::new (S.Context) MinVectorWidthAttr(S.Context, AL, VecWidth));
 }
 
+static void handleCloneAttrsFrom(Sema &S, Decl *D, const ParsedAttr &AL) {
+
+  if (AL.getNumArgs() != 1) {
+S.Diag(D->getLocation(), diag::err_attribute_clone_attrs_from_arg_not_named_decl) << 0;
+return;
+  }
+
+  Expr *E = AL.getArgAsExpr(0);
+  SourceLocation Loc = E->getExprLoc();
+
+  auto *DRE = dyn_cast(E);
+  if (!DRE) {
+S.Diag(Loc, diag::err_attribute_clone_attrs_from_arg_not_named_decl) << 0;
+return;
+  }
+
+  if (DRE->hasQualifier())
+S.Diag(Loc, diag::warn_clone_attrs_from_ext);
+
+  NamedDecl *ND = dyn_cast(DRE->getDecl());
+  if (!ND) {
+DeclarationNameInfo NI = DRE->getNameInfo();
+S.Diag(Loc, diag::err_attribute_clone_attrs_from_arg_not_named_decl)
+<< 1 << NI.getName();
+return;
+  }
+
+  ND->addAttr(::new (S.Context) CloneAttrsFromAttr(S.Context, AL, ND));
+  D->addAttr(::new (S.Context) CloneAttrsFromAttr(S.Context, AL, ND));
+}
+
 static void handleCleanupAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
   Expr *E = AL.getArgAsExpr(0);
   SourceLocation Loc = E->getExprLoc();
@@ -8486,6 +8517,10 @@
 handleSwiftAsyncError(S, D, AL);
 break;
 
+  case ParsedAttr::AT_CloneAttrsFrom:
+handleCloneAttrsFrom(S, D, AL);
+break;
+
   // XRay attributes.
   case ParsedAttr::AT_XRayLogArgs:
 handleXRayLogArgsAttr(S, D, AL);
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -4091,6 +4091,12 @@
   "'sentinel' parameter 1 less than zero">;
 def err_attribute_sentinel_not_zero_or_one : Error<
   "'sentinel' parameter 2 not 0 or 1">;
+def err_attribute_clone_attrs_from_arg_not_named_decl : Error<
+  "'clone_attrs_from' argument %select{|%1 |%1 }0is not a %select{||single }0named decl">;
+def warn_clone_attrs_from_ext : Warning<
+  "Clang does not allow the 'clone_attrs_from' attribute argument to be anything other "
+  "than a simple identifier">,
+  InGroup;
 def warn_cleanup_ext : Warning<
   "GCC does not allow the 'cleanup' attribute argument to be anything other "
   "than a simple identifier">,
Index: clang/include/clang/Basic/AttrDocs.td
===
--- clang/include/clang/Basic/AttrDocs.td
+++ clang/include/clang/Basic/AttrDocs.td
@@ -4186,6 +4186,15 @@
   }];
 }
 
+def CloneAttrsFromDocs : Documentation {
+  let Category = DocCatDecl;
+  let Heading = "clone_attrs_from";
+  let Content = [{
+The ``clone_attrs_from`` attribute indicates that the declaration to which the
+attribute appertains contains the same attributes as another named decl.
+  }];
+}
+
 def OMPDeclareSimdDocs : Documentation {
   let Category = DocCatFunction;
   let Heading = "#pragma omp declare simd";
Index: clang/include/clang/Basic/Attr.td
===
--- clang/include/clang/Basic/Attr.td
+++ clang/include/clang/Basic/Attr.td
@@ -2414,6 +2414,14 @@
   let SimpleHandler = 1;
 }
 
+def CloneAttrsFrom : InheritableAttr {
+  let Spellings = [GNU<"clone_attrs_from">];
+  let Args = [DeclArgument];
+  let Subjects = SubjectList<[Tag, TypedefName],
+ ErrorDiag>;
+  let Documentation = [CloneAttrsFromDocs];
+}
+
 def NoDeref : TypeAttr {
   let Spellings = [Clang<"noderef">];
   let Documentation = [NoDerefDocs];
__

[PATCH] D128249: Adding clone_attrs attribute.

2022-06-21 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

This is pretty incomplete. Please ignore for now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128249

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


[PATCH] D112916: [clang-tidy] Confusable identifiers detection

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

Address most reviewers comment:

- formatting style
- reduced memory consumption
- be clear about TR39 divergence
- class and option renaming
- getName() usage


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

https://reviews.llvm.org/D112916

Files:
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.cpp
  clang-tools-extra/clang-tidy/misc/ConfusableIdentifierCheck.h
  clang-tools-extra/clang-tidy/misc/ConfusableTable/BuildConfusableTable.cpp
  clang-tools-extra/clang-tidy/misc/ConfusableTable/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/ConfusableTable/confusables.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-confusable-identifiers.rst
  clang-tools-extra/test/clang-tidy/checkers/misc-confusable-identifiers.cpp

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


[PATCH] D128235: [RISCV] Add support for the Zawrs extension

2022-06-21 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

> This is still some sort of very early draft and I'm not sure what the rules 
> are in LLVM land for merging that sort of code. It's a fast track extension 
> so it should be done soon

The policy we ended up with is that support for not-yet-ratified extensions can 
be merged, but they're made to stick out like a sore thumb by calling the 
feature -experimental-foo and requiring `-menable-experimental-extensions` in 
clang. Given the simplicity of zawrs there's substantially less scope for 
drastic changes, but I think conforming to that is probably the best patch 
forwards. You should be able to see an example by looking at one of the stalled 
bitmanip extensions, e.g. experimental-zbp.


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

https://reviews.llvm.org/D128235

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


[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-21 Thread Stephan Bergmann via Phabricator via cfe-commits
sberg added a comment.

In D127593#3598020 , @royjacobson 
wrote:

> Is it possible to check how often PDFium uses `__has_trivial_assign`? 
> Depending on how large this breakage is we might need to revert and proceed 
> more carefully..

The setup is a bit convoluted:  I ran into this when building LibreOffice with 
clang-cl on Windows.  LibreOffice builds a bundled PDFium (where it obtained 
the PDFium source tarball, including PDFium's bundled `third-party/abseil-cpp`, 
with a recipe documented at 
https://git.libreoffice.org/core/+/71b952340726190d1f178ef0dadfa89677f2c1dd/external/pdfium/README#6).
  That PDFium in turn contains a bundled `third-party/abseil-cpp`, whose 
`absl/meta/type_traits.h` defines an `absl::is_trivially_copy_assignable` 
struct that is implemented via `__has_trivial_assign`, but then in its 
implementation also does a `static_assert` to verify that its behavior (based 
on `__has_trivial_assign`) matches the behavior of 
std::is_trivially_copy_assignable` (which is based on 
`__is_trivially_assignable`).  And that `static_assert` started to fail now 
with clang-cl on Windows against the MSVC standard library:

  In file included from 
C:/lo-clang/core/workdir/UnpackedTarball/pdfium/core/fxge/win32/cgdi_plus_ext.cpp:19:
  In file included from 
C:/lo-clang/core/workdir/UnpackedTarball/pdfium\core/fxcrt/fx_string.h:14:
  In file included from 
C:/lo-clang/core/workdir/UnpackedTarball/pdfium\core/fxcrt/bytestring.h:23:
  In file included from 
C:/lo-clang/core/workdir/UnpackedTarball/pdfium\core/fxcrt/string_view_template.h:18:
  In file included from 
C:/lo-clang/core/workdir/UnpackedTarball/pdfium\third_party/abseil-cpp/absl/types/optional.h:39:
  In file included from 
C:/lo-clang/core/workdir/UnpackedTarball/pdfium/third_party/abseil-cpp\absl/utility/utility.h:51:
  
C:/lo-clang/core/workdir/UnpackedTarball/pdfium/third_party/abseil-cpp\absl/meta/type_traits.h(501,3):
 error: static_assert failed due to requirement 'compliant || 
std::is_trivially_copy_assignable>::value' "Not compliant with std::is_trivially_copy_assignable; Standard: 
false, Implementation: true"
static_assert(compliant || std::is_trivially_copy_assignable::value,
^ 
  
C:/lo-clang/core/workdir/UnpackedTarball/pdfium/third_party/abseil-cpp\absl/types/internal/optional.h(175,21):
 note: in instantiation of template class 
'absl::is_trivially_copy_assignable>' requested here
absl::is_trivially_copy_assignable>' required here
  class optional : private optional_internal::optional_data,
  ^~~~
  
C:/lo-clang/core/workdir/UnpackedTarball/pdfium/core/fxge/win32/cgdi_plus_ext.cpp(384,43):
 note: in instantiation of template class 'absl::optional>' requested here
  absl::optional> IsSmallTriangle(
^

Both the PDFium tarball bundled by LibreOffice, and the `third-party/abseil` in 
turn bundled in that PDFium tarball, may be a bit dated, but I checked that 
PDFium's recent main branch 
https://pdfium.googlesource.com/pdfium/+/2c495300230ed67f87302716c8b262a146ae26af/core/fxge/win32/cgdi_plus_ext.cpp#375
 still uses `absl::optional>`, and Abseil's recent 
master branch 
https://github.com/abseil/abseil-cpp/blob/42f22a28401c952f1fc5942231c7fdac80811bf5/absl/meta/type_traits.h#L264
 definition of `absl::is_trivially_copy_assignable` still works as described 
above.

In general, there's still a handful of `__has_trivial_*` calls across Abseil's 
recent master branch `absl/meta/type_traits.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

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


[PATCH] D126266: Mark the file entry invalid, until reread. Invalidate SLocEntry cache, readd it on reread. Do not use translateFile, because it pulls in parts of the pch.

2022-06-21 Thread Tapasweni Pathak via Phabricator via cfe-commits
tapaswenipathak updated this revision to Diff 438597.
tapaswenipathak added a comment.

git clang-format HEAD~1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126266

Files:
  clang/include/clang/Basic/FileEntry.h
  clang/include/clang/Basic/FileManager.h
  clang/include/clang/Basic/SourceManager.h
  clang/lib/Basic/FileManager.cpp
  clang/lib/Basic/SourceManager.cpp
  clang/unittests/Basic/FileManagerTest.cpp
  clang/unittests/Basic/SourceManagerTest.cpp

Index: clang/unittests/Basic/SourceManagerTest.cpp
===
--- clang/unittests/Basic/SourceManagerTest.cpp
+++ clang/unittests/Basic/SourceManagerTest.cpp
@@ -26,6 +26,15 @@
 
 using namespace clang;
 
+void clang::SourceManagerTestHelper(SourceManager &SourceMgr,
+FileManager &FileMgr) {
+  FileID mainFileID = SourceMgr.getMainFileID();
+  const SrcMgr::ContentCache *Cache =
+  &(SourceMgr.getSLocEntry(mainFileID).getFile().getContentCache());
+  // EXPECT_FALSE(Cache->Buffer);
+  ASSERT_TRUE(FileMgr.FileEntriesToReread.empty());
+}
+
 namespace {
 
 // The test fixture.
@@ -51,6 +60,36 @@
   IntrusiveRefCntPtr Target;
 };
 
+// Test for invalidate cache success, making the file entry invalid, until
+// reread
+TEST_F(SourceManagerTest, invalidateCacheSuccess) {
+  const char *Source = "int x;";
+
+  std::unique_ptr Buf =
+  llvm::MemoryBuffer::getMemBuffer(Source);
+  const FileEntry *SourceFile =
+  FileMgr.getVirtualFile("mainFile.cpp", Buf->getBufferSize(), 0);
+
+  FileID mainFileID = SourceMgr.createFileID(std::move(Buf));
+  SourceMgr.overrideFileContents(SourceFile, std::move(Buf));
+  SourceMgr.setMainFileID(mainFileID);
+
+  SourceMgr.invalidateCache(mainFileID);
+
+  EXPECT_FALSE(SourceFile->isValid());
+  EXPECT_FALSE(mainFileID.isInvalid());
+
+  const SrcMgr::ContentCache *Cache =
+  &(SourceMgr.getSLocEntry(mainFileID).getFile().getContentCache());
+
+  EXPECT_EQ(SourceMgr.getNonBuiltinFilenameForID(mainFileID), None);
+  // EXPECT_EQ(SourceMgr.getBufferDataIfLoaded(mainFileID), None);
+
+  EXPECT_FALSE(Cache->IsBufferInvalid);
+
+  SourceManagerTestHelper(SourceMgr, FileMgr);
+}
+
 TEST_F(SourceManagerTest, isBeforeInTranslationUnit) {
   const char *source =
 "#define M(x) [x]\n"
Index: clang/unittests/Basic/FileManagerTest.cpp
===
--- clang/unittests/Basic/FileManagerTest.cpp
+++ clang/unittests/Basic/FileManagerTest.cpp
@@ -18,6 +18,10 @@
 using namespace llvm;
 using namespace clang;
 
+void clang::FileManagerTestHelper(FileManager &manager) {
+  ASSERT_TRUE(!manager.FileEntriesToReread.empty());
+}
+
 namespace {
 
 // Used to create a fake file system for running the tests with such
@@ -99,6 +103,29 @@
   FileManager manager;
 };
 
+// If file entry valid, mark the file entry invalid, until reread.
+TEST_F(FileManagerTest, invalidateCacheSuccess) {
+  auto statCache = std::make_unique();
+  statCache->InjectFile("file.cpp", 42);
+
+  manager.setStatCache(std::move(statCache));
+  manager.getVirtualFile("file.cpp", 100, 0);
+  auto file = manager.getFile("file.cpp");
+
+  // Check for file null assertion success
+  // manager.invalidateCache(NULL);
+
+  auto FileRef = manager.getFileRef("file.cpp");
+
+  ASSERT_FALSE(!FileRef);
+
+  FileEntry *FileEntryObj = const_cast(&FileRef->getFileEntry());
+  manager.invalidateCache(FileEntryObj);
+  FileManagerTestHelper(manager);
+
+  ASSERT_FALSE(FileEntryObj->isValid());
+}
+
 // When a virtual file is added, its getDir() field has correct name.
 TEST_F(FileManagerTest, getVirtualFileSetsTheDirFieldCorrectly) {
   FileEntryRef file = manager.getVirtualFileRef("foo.cpp", 42, 0);
Index: clang/lib/Basic/SourceManager.cpp
===
--- clang/lib/Basic/SourceManager.cpp
+++ clang/lib/Basic/SourceManager.cpp
@@ -358,6 +358,25 @@
   return false;
 }
 
+void SourceManager::invalidateCache(FileID FID) {
+  const FileEntry *Entry = getFileEntryForID(FID);
+  if (!Entry)
+return;
+  if (ContentCache *&E = FileInfos[Entry]) {
+E->setBuffer(nullptr);
+E = 0;
+  }
+  if (!FID.isInvalid()) {
+const SrcMgr::SLocEntry &SLocE = getSLocEntry(FID);
+if (SLocE.isFile()) {
+  SrcMgr::ContentCache &CC =
+  const_cast(SLocE.getFile().getContentCache());
+  CC.setBuffer(nullptr);
+}
+  }
+  getFileManager().invalidateCache(const_cast(Entry));
+}
+
 void SourceManager::initializeForReplay(const SourceManager &Old) {
   assert(MainFileID.isInvalid() && "expected uninitialized SourceManager");
 
Index: clang/lib/Basic/FileManager.cpp
===
--- clang/lib/Basic/FileManager.cpp
+++ clang/lib/Basic/FileManager.cpp
@@ -635,6 +635,12 @@
   return std::error_code();
 }
 
+void FileManager::invalidateCache

[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-06-21 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

@kees does the new version looks good to you?


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

https://reviews.llvm.org/D126864

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


[PATCH] D127270: [clang-format] Add space in placement new expression

2022-06-21 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

Thanks for the Screenshot, please remember to mark your comments as "Done" once 
you've addressed them. From what I can tell this looks good.




Comment at: clang/include/clang/Format/Format.h:3559
   AfterFunctionDefinitionName(false), AfterIfMacros(false),
-  AfterOverloadedOperator(false), AfterRequiresInClause(false),
-  AfterRequiresInExpression(false), BeforeNonEmptyParentheses(false) {}
+  AfterOverloadedOperator(false), AfterPlacementOperator(APO_Always),
+  AfterRequiresInClause(false), AfterRequiresInExpression(false),

HazardyKnusperkeks wrote:
> As said in the other comment, there is code that depends on setting to never 
> in the default constructor, so please do.
Why Never and not Leave? basically introducing one or the other as a default 
won't that causes changes for people who don't want to use this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127270

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


[clang-tools-extra] d9afb8c - [clang-tidy] cppcoreguidelines-virtual-class-destructor should ignore final classes

2022-06-21 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2022-06-21T11:02:18+02:00
New Revision: d9afb8c3e8fd01a3c89ab2ddebcd44602a30a975

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

LOG: [clang-tidy] cppcoreguidelines-virtual-class-destructor should ignore 
final classes

The `cppcoreguidelines-virtual-class-destructor` supposed to enforce
http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#c35-a-base-class-destructor-should-be-either-public-and-virtual-or-protected-and-non-virtual

Quote:
> A **base** class destructor should be either public and virtual, or
> protected and non-virtual
[emphasis mine]

However, this check still rules the following case:

  class MostDerived final : public Base {
  public:
MostDerived() = default;
~MostDerived() = default;
void func() final;
  };

Even though `MostDerived` class is marked `final`, thus it should not be
considered as a **base** class. Consequently, the rule is satisfied, yet
the check still flags this code.

In this patch, I'm proposing to ignore `final` classes since they cannot
be //base// classes.

Reviewed By: whisperity

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

Added: 


Modified: 

clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
index 26ee7ca6eca57..e730fb6fa01db 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
@@ -41,6 +41,7 @@ void 
VirtualClassDestructorCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(
   cxxRecordDecl(
   anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod),
+  unless(isFinal()),
   unless(hasPublicVirtualOrProtectedNonVirtualDestructor()))
   .bind("ProblematicClassOrStruct"),
   this);

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 36cac762f0d31..26d99420d3e4b 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -165,6 +165,12 @@ Changes in existing checks
   Fixed an issue when there was already an initializer in the constructor and
   the check would try to create another initializer for the same member.
 
+- Fixed a false positive in :doc:`cppcoreguidelines-virtual-class-destructor
+  ` involving
+  ``final`` classes. The check will not diagnose classes marked ``final``, 
since
+  those cannot be used as base classes, consequently, they can not violate the
+  rule.
+
 - Fixed a crash in :doc:`llvmlibc-callee-namespace
   ` when executing for C++ code
   that contain calls to advanced constructs, e.g. overloaded operators.

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
index c14a2e68def88..fcf558dcac8e6 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
@@ -320,3 +320,22 @@ class FooBar5 {
 #undef XMACRO
 #undef CONCAT
 } // namespace macro_tests
+
+namespace FinalClassCannotBeBaseClass {
+class Base {
+public:
+  Base() = default;
+  virtual void func() = 0;
+
+protected:
+  ~Base() = default;
+};
+
+// no-warning: 'MostDerived' cannot be a base class, since it's marked 'final'.
+class MostDerived final : public Base {
+public:
+  MostDerived() = default;
+  ~MostDerived() = default;
+  void func() final;
+};
+} // namespace FinalClassCannotBeBaseClass



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


[PATCH] D126891: [clang-tidy] The check should ignore final classes

2022-06-21 Thread Balázs Benics via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
steakhal marked an inline comment as done.
Closed by commit rGd9afb8c3e8fd: [clang-tidy] 
cppcoreguidelines-virtual-class-destructor should ignore final… (authored by 
steakhal).

Changed prior to commit:
  https://reviews.llvm.org/D126891?vs=435054&id=438599#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126891

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
@@ -320,3 +320,22 @@
 #undef XMACRO
 #undef CONCAT
 } // namespace macro_tests
+
+namespace FinalClassCannotBeBaseClass {
+class Base {
+public:
+  Base() = default;
+  virtual void func() = 0;
+
+protected:
+  ~Base() = default;
+};
+
+// no-warning: 'MostDerived' cannot be a base class, since it's marked 'final'.
+class MostDerived final : public Base {
+public:
+  MostDerived() = default;
+  ~MostDerived() = default;
+  void func() final;
+};
+} // namespace FinalClassCannotBeBaseClass
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -165,6 +165,12 @@
   Fixed an issue when there was already an initializer in the constructor and
   the check would try to create another initializer for the same member.
 
+- Fixed a false positive in :doc:`cppcoreguidelines-virtual-class-destructor
+  ` involving
+  ``final`` classes. The check will not diagnose classes marked ``final``, 
since
+  those cannot be used as base classes, consequently, they can not violate the
+  rule.
+
 - Fixed a crash in :doc:`llvmlibc-callee-namespace
   ` when executing for C++ code
   that contain calls to advanced constructs, e.g. overloaded operators.
Index: 
clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
===
--- 
clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
+++ 
clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
@@ -41,6 +41,7 @@
   Finder->addMatcher(
   cxxRecordDecl(
   anyOf(has(cxxMethodDecl(isVirtual())), InheritsVirtualMethod),
+  unless(isFinal()),
   unless(hasPublicVirtualOrProtectedNonVirtualDestructor()))
   .bind("ProblematicClassOrStruct"),
   this);


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-virtual-class-destructor.cpp
@@ -320,3 +320,22 @@
 #undef XMACRO
 #undef CONCAT
 } // namespace macro_tests
+
+namespace FinalClassCannotBeBaseClass {
+class Base {
+public:
+  Base() = default;
+  virtual void func() = 0;
+
+protected:
+  ~Base() = default;
+};
+
+// no-warning: 'MostDerived' cannot be a base class, since it's marked 'final'.
+class MostDerived final : public Base {
+public:
+  MostDerived() = default;
+  ~MostDerived() = default;
+  void func() final;
+};
+} // namespace FinalClassCannotBeBaseClass
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -165,6 +165,12 @@
   Fixed an issue when there was already an initializer in the constructor and
   the check would try to create another initializer for the same member.
 
+- Fixed a false positive in :doc:`cppcoreguidelines-virtual-class-destructor
+  ` involving
+  ``final`` classes. The check will not diagnose classes marked ``final``, since
+  those cannot be used as base classes, consequently, they can not violate the
+  rule.
+
 - Fixed a crash in :doc:`llvmlibc-callee-namespace
   ` when executing for C++ code
   that contain calls to advanced constructs, e.g. overloaded operators.
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
===
--- clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/VirtualClassDestructorCheck.cpp
@@ -41,6 +41,7 @@
   Finder->addMatcher(
   c

[PATCH] D127579: [clang][WIP] add option to keep types of ptr args for non-kernel functions in metadata

2022-06-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D127579#3595461 , @nikic wrote:

> In D127579#3588626 , @Anastasia 
> wrote:
>
>> In D127579#3586092 , @nikic wrote:
>>
>>> @Anastasia Thanks, that does sound like a legitimate reason to include the 
>>> information. I want to double check though, does linking the modules 
>>> actually fail if the functions have signatures that differ only by pointer 
>>> types? At least for normal LLVM IR this would work fine, and would just 
>>> result in the insertion of a bitcast during linking (and then typically the 
>>> bitcast would get shifted from the called function to the call arguments 
>>> later).
>>
>> @nikic If I use `spirv-link` with two modules that have mismatching pointee 
>> type in a function parameter I get an error:
>>
>>   error: 0: Type mismatch on symbol "foo" between imported variable/function 
>> %6 and exported variable/function %17. 
>>
>> The way I understand a bitcast instruction in SPIR-V (`OpBitcast` in 
>> https://www.khronos.org/registry/SPIR-V/specs/unified1/SPIRV.html#_conversion_instructions)
>>  is that it can only apply to pointer types which are distinct from function 
>> types. Note that I believe that function pointers are illegal, at least we 
>> disallow them in OpenCL.
>
> Okay ... can we maybe turn this around then? Always emit function parameters 
> as `i8*` and bitcast them as needed, even if it is possible to guess a better 
> type based on the definition? (Let's ignore the image type case here, which 
> seems to have different requirements from the rest.)

So where would bitcasts be emitted to reconstruct the function prototypes 
correctly?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127579

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


[PATCH] D128012: [HLSL] Add ExternalSemaSource & vector alias

2022-06-21 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D128012#3592126 , @beanz wrote:

> In D128012#3592098 , @Anastasia 
> wrote:
>
>> aha, are you having a lot of these types then? Ok that sounds similar 
>> problem to OpenCL builtin functions as we had to go away from a simple 
>> header include due to long parsing time.
>
> Very similar problem. We have a two-part problem where we both have enough of 
> them that parsing a header would be too slow _and_ the HLSL language actually 
> can't represent them. The later we're working to fix. My hope is that 
> eventually we can write the HLSL libraries in HLSL and use a pre-compilation 
> step (PCH or Module-style) to get past the performance issues.

PCH have large in-memory size compared to the sources, but if it's not an issue 
then it should be reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128012

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


[PATCH] D127579: [clang][WIP] add option to keep types of ptr args for non-kernel functions in metadata

2022-06-21 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

In D127579#3598306 , @Anastasia wrote:

> In D127579#3595461 , @nikic wrote:
>
>> In D127579#3588626 , @Anastasia 
>> wrote:
>>
>>> In D127579#3586092 , @nikic wrote:
>>>
 @Anastasia Thanks, that does sound like a legitimate reason to include the 
 information. I want to double check though, does linking the modules 
 actually fail if the functions have signatures that differ only by pointer 
 types? At least for normal LLVM IR this would work fine, and would just 
 result in the insertion of a bitcast during linking (and then typically 
 the bitcast would get shifted from the called function to the call 
 arguments later).
>>>
>>> @nikic If I use `spirv-link` with two modules that have mismatching pointee 
>>> type in a function parameter I get an error:
>>>
>>>   error: 0: Type mismatch on symbol "foo" between imported 
>>> variable/function %6 and exported variable/function %17. 
>>>
>>> The way I understand a bitcast instruction in SPIR-V (`OpBitcast` in 
>>> https://www.khronos.org/registry/SPIR-V/specs/unified1/SPIRV.html#_conversion_instructions)
>>>  is that it can only apply to pointer types which are distinct from 
>>> function types. Note that I believe that function pointers are illegal, at 
>>> least we disallow them in OpenCL.
>>
>> Okay ... can we maybe turn this around then? Always emit function parameters 
>> as `i8*` and bitcast them as needed, even if it is possible to guess a 
>> better type based on the definition? (Let's ignore the image type case here, 
>> which seems to have different requirements from the rest.)
>
> So where would bitcasts be emitted to reconstruct the function prototypes 
> correctly?

The bitcasts would be in the definition only, when the pointer arguments 
actually get used in a typed manner. The prototype would always include `i8*` 
arguments only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127579

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


[PATCH] D127961: [OpenCL] Reduce emitting candidate notes for builtins

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

LGTM! Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127961

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


[clang-tools-extra] ae76b2f - [clang-tidy][docs] Fix wrong sphinx link after d9afb8c3e8fd01a3c89ab2ddebcd44602a30a975

2022-06-21 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2022-06-21T11:42:09+02:00
New Revision: ae76b2f455016efb8cac5519d382be575b2d2edc

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

LOG: [clang-tidy][docs] Fix wrong sphinx link after 
d9afb8c3e8fd01a3c89ab2ddebcd44602a30a975

There was a copy-paste mistake at the embedded link:
  `clang-tidy/checks/cppcoreguidelines-virtual-class-destructor`
  ->
  `clang-tidy/checks/cppcoreguidelines/virtual-class-destructor`

Sphinx error:
/home/zbebnal/git/llvm-project/clang-tools-extra/docs/ReleaseNotes.rst:168:unknown
 document: clang-tidy/checks/cppcoreguidelines-virtual-class-destructor

Build bot: https://lab.llvm.org/buildbot#builders/115/builds/29805

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

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 26d99420d3e4..1f1c4c87112a 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,7 +166,7 @@ Changes in existing checks
   the check would try to create another initializer for the same member.
 
 - Fixed a false positive in :doc:`cppcoreguidelines-virtual-class-destructor
-  ` involving
+  ` involving
   ``final`` classes. The check will not diagnose classes marked ``final``, 
since
   those cannot be used as base classes, consequently, they can not violate the
   rule.



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


[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

2022-06-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 438612.

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

https://reviews.llvm.org/D128248

Files:
  clang/include/clang/AST/APValue.h
  clang/test/SemaCXX/constexpr-array-init.cpp


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+struct Foo {
+  int a; // expected-note {{subobject declared here}}
+  constexpr Foo()
+  : a(get_int()) {
+  }
+
+  constexpr int get_int() {
+return 5;
+  }
+};
+
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 
'bar' must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' 
is not initialized}}
+{{}},
+};
Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -508,6 +508,8 @@
 return const_cast(this)->getArrayInitializedElt(I);
   }
   bool hasArrayFiller() const {
+if (!isArray())
+  return false;
 return getArrayInitializedElts() != getArraySize();
   }
   APValue &getArrayFiller() {


Index: clang/test/SemaCXX/constexpr-array-init.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constexpr-array-init.cpp
@@ -0,0 +1,19 @@
+
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+struct Foo {
+  int a; // expected-note {{subobject declared here}}
+  constexpr Foo()
+  : a(get_int()) {
+  }
+
+  constexpr int get_int() {
+return 5;
+  }
+};
+
+
+static constexpr Foo bar[2][1] = { // expected-error {{constexpr variable 'bar' must be initialized by a constant expression}} \
+   // expected-note {{subobject of type 'int' is not initialized}}
+{{}},
+};
Index: clang/include/clang/AST/APValue.h
===
--- clang/include/clang/AST/APValue.h
+++ clang/include/clang/AST/APValue.h
@@ -508,6 +508,8 @@
 return const_cast(this)->getArrayInitializedElt(I);
   }
   bool hasArrayFiller() const {
+if (!isArray())
+  return false;
 return getArrayInitializedElts() != getArraySize();
   }
   APValue &getArrayFiller() {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2022-06-21 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 438622.
pmatos added a comment.

Incorporate @asb semantic restrictions patch. 
Generate test CHECK using update_cc_* script.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp

Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -304,6 +304,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_ExternrefTy(LLVMContext &C) {
+  // opaque pointer in addrspace(10)
+  static PointerType *Ty = PointerType::get(C, 10);
+  return Ty;
+}
+
+Type *Type::getWasm_FuncrefTy(LLVMContext &C) {
+  // opaque pointer in addrspace(20)
+  static PointerType *Ty = PointerType::get(C, 20);
+  return Ty;
+}
+
 //===--===//
 //   IntegerType Implementation
 //===--===//
Index: llvm/lib/CodeGen/ValueTypes.cpp
===
--- llvm/lib/CodeGen/ValueTypes.cpp
+++ llvm/lib/CodeGen/ValueTypes.cpp
@@ -204,12 +204,8 @@
   case MVT::x86mmx:  return Type::getX86_MMXTy(Context);
   case MVT::x86amx:  return Type::getX86_AMXTy(Context);
   case MVT::i64x8:   return IntegerType::get(Context, 512);
-  case MVT::externref:
-// pointer to opaque struct in addrspace(10)
-return PointerType::get(StructType::create(Context), 10);
-  case MVT::funcref:
-// pointer to i8 addrspace(20)
-return PointerType::get(Type::getInt8Ty(Context), 20);
+  case MVT::externref: return Type::getWasm_ExternrefTy(Context);
+  case MVT::funcref: return Type::getWasm_FuncrefTy(Context);
   case MVT::v1i1:
 return FixedVectorType::get(Type::getInt1Ty(Context), 1);
   case MVT::v2i1:
Index: llvm/include/llvm/IR/Type.h
===
--- llvm/include/llvm/IR/Type.h
+++ llvm/include/llvm/IR/Type.h
@@ -468,6 +468,8 @@
   static PointerType *getInt16PtrTy(LLVMContext &C, unsigned AS = 0);
   static PointerType *getInt32PtrTy(LLVMContext &C, unsigned AS = 0);
   static PointerType *getInt64PtrTy(LLVMContext &C, unsigned AS = 0);
+  static Type *getWasm_ExternrefTy(LLVMContext &C);
+  static Type *getWasm_FuncrefTy(LLVMContext &C);
 
   /// Return a pointer to the current type. This is equivalent to
   /// PointerType::get(Foo, AddrSpace).
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1627,6 +1627,8 @@
 #include "clang/Basic/PPCTypes.def"
 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/RISCVVTypes.def"
+#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
 #define BUILTIN_TYPE(Id, SingletonId)
 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
Index: clang/test/SemaCXX/wasm-refs-and-tables.cpp
==

[PATCH] D127762: [Clang][AArch64] Add ACLE attributes for SME.

2022-06-21 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen updated this revision to Diff 438624.
sdesmalen added a comment.

- Increased test-coverage by adding positive tests for:
  - template instantiations
  - function overloading
  - lambda function with attribute
  - (indirect) pointer to pointer to an attributed function type.

- Also added negative tests for:
  - passing an operand to an arm_streaming attribute
  - Adding an arm_streaming attribute to a non-function type.

- Rewritten the CHECK lines for aarch64-sme-attrs.cpp, such that the attributes 
are checked with named labels, e.g. #[[SM_ENABLED_CALL]].


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

https://reviews.llvm.org/D127762

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/aarch64-sme-attrs-no-sme.c
  clang/test/Sema/aarch64-sme-func-attrs.c

Index: clang/test/Sema/aarch64-sme-func-attrs.c
===
--- /dev/null
+++ clang/test/Sema/aarch64-sme-func-attrs.c
@@ -0,0 +1,223 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sme -fsyntax-only -verify=expected-cpp -x c++ %s
+
+// Valid attributes
+
+__attribute__((arm_streaming)) void sme_arm_streaming(void);
+__attribute__((arm_streaming_compatible)) void sme_arm_streaming_compatible(void);
+
+__attribute__((arm_new_za)) void sme_arm_new_za(void);
+__attribute__((arm_shared_za)) void sme_arm_shared_za(void);
+__attribute__((arm_preserves_za)) void sme_arm_preserves_za(void);
+
+__attribute__((arm_streaming, arm_new_za)) void sme_arm_streaming_new_za(void);
+__attribute__((arm_streaming, arm_shared_za)) void sme_arm_streaming_shared_za(void);
+__attribute__((arm_streaming, arm_preserves_za)) void sme_arm_streaming_preserves_za(void);
+
+__attribute__((arm_streaming_compatible, arm_new_za)) void sme_arm_sc_new_za(void);
+__attribute__((arm_streaming_compatible, arm_shared_za)) void sme_arm_sc_shared_za(void);
+__attribute__((arm_streaming_compatible, arm_preserves_za)) void sme_arm_sc_preserves_za(void);
+
+__attribute__((arm_shared_za, arm_preserves_za)) void sme_arm_shared_preserves_za(void);
+
+__attribute__((arm_locally_streaming)) void sme_arm_locally_streaming(void) { }
+__attribute__((arm_locally_streaming, arm_streaming)) void sme_arm_streaming_and_locally_streaming(void) { }
+__attribute__((arm_locally_streaming, arm_streaming_compatible)) void sme_arm_streaming_and_streaming_compatible(void) { }
+
+__attribute__((arm_locally_streaming, arm_new_za)) void sme_arm_ls_new_za(void) { }
+__attribute__((arm_locally_streaming, arm_shared_za)) void sme_arm_ls_shared_za(void) { }
+__attribute__((arm_locally_streaming, arm_preserves_za)) void sme_arm_ls_preserves_za(void) { }
+
+// Valid attributes on function pointers
+
+void __attribute__((arm_streaming)) streaming_ptr(void);
+typedef __attribute__((arm_streaming)) void (*fptrty1) (void);
+fptrty1 call_streaming_func() { return streaming_ptr; }
+
+void __attribute__((arm_streaming_compatible)) streaming_compatible_ptr(void);
+typedef __attribute__((arm_streaming_compatible)) void (*fptrty2) (void);
+fptrty2 call_sc_func() { return streaming_compatible_ptr; }
+
+void __attribute__((arm_new_za)) new_za_ptr(void);
+typedef __attribute__((arm_new_za)) void (*fptrty3) (void);
+fptrty3 call_new_za_func() { return new_za_ptr; }
+
+void __attribute__((arm_shared_za)) shared_za_ptr(void);
+typedef __attribute__((arm_shared_za)) void (*fptrty4) (void);
+fptrty4 call_shared_za_func() { return shared_za_ptr; }
+
+void __attribute__((arm_preserves_za)) preserves_za_ptr(void);
+typedef __attribute__((arm_preserves_za)) void (*fptrty5) (void);
+fptrty5 call_preserve_za_func() { return preserves_za_ptr; }
+
+void __attribute__((arm_shared_za, arm_preserves_za)) shared_preserves_za_ptr(void);
+typedef __attribute__((arm_shared_za, arm_preserves_za)) void (*fptrty6) (void);
+fptrty6 call_shared_preserve_za_func() { return shared_preserves_za_ptr; }
+
+typedef void (*fptrty7) (void);
+fptrty7 cast_ls_func_to_normal() { return sme_arm_locally_streaming; }
+
+// FIXME: Add invalid function pointer assignments such as assigning:
+//   1. A streaming compatible function to a normal function pointer,
+//   2. A locally streaming function to a streaming function pointer,
+// etc.
+
+// Invalid attributes
+
+// expected-cpp-error@+4 {{'arm_streaming_compatible' and 'arm_strea

[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

2022-06-21 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

@ChuanqiXu - have you tried the test example from 10.6 ex1  - I did the impl as 
below, but the behaviour does not seem to be quite correct?
any thoughts?

As for review, I can try to pick up the "nits" but not sure that I know the 
instantiation sub=system too well, so it would be better if @rsmith could cast 
an eye over those parts.

let's discuss the 10.6 example first (I'd guess 10.7 cases will need to be 
reviewed too)

  // RUN: rm -rf %t
  // RUN: split-file %s %t
  // RUN: cd %t
  
  // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header-unit-header 
std-10-6-ex1-decl.h \
  // RUN: -o decl.pcm
  
  // RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-header-unit-header 
std-10-6-ex1-defn.h \
  // RUN: -o defn.pcm
  
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-6-ex1-stuff.cpp \
  // RUN: -o stuff.pcm
  
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-6-ex1-M1.cpp \
  // RUN: -fmodule-file=stuff.pcm -o M1.pcm  -fmodule-file=defn.pcm
  
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-6-ex1-M2.cpp \
  // RUN: -fmodule-file=stuff.pcm -o M2.pcm  -fmodule-file=decl.pcm
  
  // RUN: %clang_cc1 -std=c++20 std-10-6-ex1-use.cpp \
  // RUN: -fmodule-file=M1.pcm -fmodule-file=M2.pcm  -fsyntax-only
  
  //--- std-10-6-ex1-decl.h
  struct X;
  
  //--- std-10-6-ex1-defn.h
  struct X {};
  
  //--- std-10-6-ex1-stuff.cpp
  export module stuff;
  export template void foo(T, U u) { auto v = u; }
  export template void bar(T, U u) { auto v = *u; }
  
  //--- std-10-6-ex1-M1.cpp
  export module M1;
  import "std-10-6-ex1-defn.h"; // provides struct X {};
  import stuff;
  
  export template void f(T t) {
X x;
foo(t, x); 
  }
  
  //--- std-10-6-ex1-M2.cpp
  export module M2;
  import "std-10-6-ex1-decl.h"; // provides struct X; (not a definition)
  
  import stuff;
  export template void g(T t) {
X *x;
bar(t, x); 
  }
  
  //--- std-10-6-ex1-use.cpp
  import M1;
  import M2;
  
  void test() {
f(0);
g(0);
  }

(I think we might also have some issues with poor diagnostics for items in PMF 
(saying that an import is required before use, but of course that import is 
impossible - e.g. 10.5)


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

https://reviews.llvm.org/D113545

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


[PATCH] D128256: [Clang][AArch64] Limit arm_locally_streaming to function definitions only.

2022-06-21 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen created this revision.
sdesmalen added reviewers: aaron.ballman, sunfish.
Herald added subscribers: pmatos, asb, jdoerfert, kristof.beyls, sbc100.
Herald added a project: All.
sdesmalen requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

This requires forcibly toggling the 'willHaveBody' value of the Decl that's
being built up before/after handling the attributes in order to query
this property on the Decl.

This also updates a WASM test that seemed incorrect (the attribute is
only allowed on function declarations, not definitions).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128256

Files:
  clang/include/clang/Basic/Attr.td
  clang/lib/Sema/SemaDecl.cpp
  clang/test/AST/ast-dump-wasm-attr-export.c
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/aarch64-sme-func-attrs.c

Index: clang/test/Sema/aarch64-sme-func-attrs.c
===
--- clang/test/Sema/aarch64-sme-func-attrs.c
+++ clang/test/Sema/aarch64-sme-func-attrs.c
@@ -100,6 +100,10 @@
 // expected-note@+1 {{conflicting attribute is here}}
 __attribute__((arm_preserves_za, arm_new_za)) void preserves_new_za(void);
 
+// expected-cpp-error@+2 {{'arm_locally_streaming' attribute only applies to function definitions}}
+// expected-error@+1 {{'arm_locally_streaming' attribute only applies to function definitions}}
+__attribute__((arm_locally_streaming)) void sme_arm_locally_streaming_on_declaration(void);
+
 // Invalid attributes on function pointers
 
 // expected-cpp-error@+4 {{'arm_streaming_compatible' and 'arm_streaming' attributes are not compatible}}
@@ -138,8 +142,8 @@
 typedef __attribute__((arm_new_za, arm_preserves_za)) void (*fptrty10) (void);
 fptrty10 invalid_preserve_za_func() { return preserves_za_ptr_invalid; }
 
-// expected-cpp-error@+2 {{'arm_locally_streaming' attribute only applies to functions}}
-// expected-error@+1 {{'arm_locally_streaming' attribute only applies to functions}}
+// expected-cpp-error@+2 {{'arm_locally_streaming' attribute only applies to function definitions}}
+// expected-error@+1 {{'arm_locally_streaming' attribute only applies to function definitions}}
 typedef __attribute__((arm_locally_streaming)) void (*fptrty11) (void);
 
 // expected-warning@+2 {{'arm_streaming' attribute ignored}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -18,7 +18,6 @@
 // CHECK-NEXT: AnyX86NoCfCheck (SubjectMatchRule_hasType_functionType)
 // CHECK-NEXT: ArcWeakrefUnavailable (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ArmBuiltinAlias (SubjectMatchRule_function)
-// CHECK-NEXT: ArmLocallyStreaming (SubjectMatchRule_function)
 // CHECK-NEXT: AssumeAligned (SubjectMatchRule_objc_method, SubjectMatchRule_function)
 // CHECK-NEXT: Assumption (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Availability ((SubjectMatchRule_record, SubjectMatchRule_enum, SubjectMatchRule_enum_constant, SubjectMatchRule_field, SubjectMatchRule_function, SubjectMatchRule_namespace, SubjectMatchRule_objc_category, SubjectMatchRule_objc_implementation, SubjectMatchRule_objc_interface, SubjectMatchRule_objc_method, SubjectMatchRule_objc_property, SubjectMatchRule_objc_protocol, SubjectMatchRule_record, SubjectMatchRule_type_alias, SubjectMatchRule_variable))
Index: clang/test/AST/ast-dump-wasm-attr-export.c
===
--- clang/test/AST/ast-dump-wasm-attr-export.c
+++ clang/test/AST/ast-dump-wasm-attr-export.c
@@ -10,24 +10,21 @@
 
 // Test that functions can be redeclared and they retain their attributes.
 
-__attribute__((export_name("export_red"))) void red(void) {}
-__attribute__((export_name("export_orange"))) void orange(void) {}
-__attribute__((export_name("export_yellow"))) void yellow(void) {}
+__attribute__((export_name("export_red"))) void red(void);
+__attribute__((export_name("export_orange"))) void orange(void);
+__attribute__((export_name("export_yellow"))) void yellow(void);
 
 void red(void);
 void orange(void);
 void yellow(void);
 
 // CHECK: |-FunctionDecl {{.+}} used red 'void (void)'
-// CHECK: | |-CompoundStmt {{.+}}
 // CHECK: | |-WebAssemblyExportNameAttr {{.+}} "export_red"
 // CHECK: | `-UsedAttr {{.+}} Implicit
 // CHECK: |-FunctionDecl {{.+}} used orange 'void (void)'
-// CHECK: | |-CompoundStmt {{.+}}
 // CHECK: | |-WebAssemblyExportNameAttr {{.+}} "export_orange"
 // CHECK: | `-UsedAttr {{.+}} Implicit
 // CHECK: |-FunctionDecl {{.+}} used yellow 'void (void)'
-// CHECK: | |-CompoundStmt {{.+}}
 // CHECK: | |-WebAssemblyExportNameAttr {{.+}} "export_yellow"
 // CHECK: | `-UsedAttr {{.+}} Implicit
 // CHECK: |-FunctionDecl {{.+}} used

[PATCH] D127641: [clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default

2022-06-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D127641#3597360 , @steplong wrote:

> It looks like misc-new-delete-overloads.cpp is failing on line 20:
> ..
> On Line 16, it says sized deallocations are not enabled by default, but this 
> patch turns it on by default for MSVC. Should I unsupport this test for 
> windows or is there a way to pass `/Zc:sizedDealloc-` only for windows?

You could add a target to the test so that it doesn't target windows-msvc, e.g. 
`-target x86_64-unknown-linux`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

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


[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

2022-06-21 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

as suspected, we also have a missing diagnostic in 10.7 ex1

  // RUN: rm -rf %t
  // RUN: split-file %s %t
  // RUN: cd %t
  
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-7-ex1-M-A.cpp \
  // RUN: -o M-A.pcm
  
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-7-ex1-M-B.cpp \
  // RUN: -o M-B.pcm
  
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-7-ex1-M-C.cpp \
  // RUN: -fmodule-file=M-A.pcm -verify -fsyntax-only
  
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-7-ex1-M.cpp \
  // RUN: -o M.pcm -fmodule-file=M-A.pcm -fmodule-file=M-B.pcm
  
  // RUN: %clang_cc1 -std=c++20 -emit-module-interface std-10-7-ex1-X.cpp \
  // RUN: -o X.pcm
  
  // RUN: %clang_cc1 -std=c++20 std-10-7-ex1-use.cpp -fsyntax-only \
  // RUN: -fmodule-file=M.pcm -fmodule-file=X.pcm -verify
  
  //--- std-10-7-ex1-M-A.cpp
  export module M:A;
  export struct B;
  
  //--- std-10-7-ex1-M-B.cpp
  module M:B;
  struct B {
operator int();
  };
  
  //--- std-10-7-ex1-M-C.cpp
  module M:C;
  import :A;
  B b1;   // expected-error {{variable has incomplete type 'B'}} 
  // expected-n...@std-10-7-ex1-m-a.cpp:2 {{forward declaration of 'B'}}
  //--- std-10-7-ex1-M.cpp
  export module M;
  export import :A;
  import :B;
  B b2;
  export void f(B b = B());
  
  //--- std-10-7-ex1-X.cpp
  export module X;
  
  //--- std-10-7-ex1-use.cpp
  module X;
  import M;
  B b3; // expected-error 1+{{definition of 'B' must be imported from 
module 'M:B' before it is required}} 
// expected-n...@std-10-7-ex1-m-b.cpp:2 1+{{definition here is not 
reachable}}
  void g() { f(); }  // expected-error {{definition of 'B' must be imported 
from module 'M:B' before it is required}}
// not sure of the actual diagnostic here ^ , it is not emitted.


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

https://reviews.llvm.org/D113545

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


[PATCH] D128257: invalidateCache in addModule and removeModules

2022-06-21 Thread Tapasweni Pathak via Phabricator via cfe-commits
tapaswenipathak created this revision.
tapaswenipathak added a reviewer: v.g.vassilev.
tapaswenipathak added a project: clang.
Herald added a project: All.
tapaswenipathak requested review of this revision.
Herald added a subscriber: cfe-commits.

Ref: https://github.com/vgvassilev/clang/commit/758e42e823.

It can have a test adding `FileManagerTestHelper` as a `friend` function and 
checking on a few variables. Should it be added?

Pre: https://reviews.llvm.org/D126266.

Authored-by: Vassil Vassilev 
Submitted-by: Tapasweni Pathak 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128257

Files:
  clang/lib/Serialization/ModuleManager.cpp


Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -232,9 +232,15 @@
   // Read the signature eagerly now so that we can check it.  Avoid calling
   // ReadSignature unless there's something to check though.
   if (ExpectedSignature && checkSignature(ReadSignature(NewModule->Data),
-  ExpectedSignature, ErrorStr))
+  ExpectedSignature, ErrorStr)) {
+// Try to remove the buffer.  If it can't be removed, then it was already
+// validated by this process.
+if (!getModuleCache().tryToDropPCM(NewModule->FileName)) {
+  const FileEntry *FE = NewModule->File;
+  FileMgr.invalidateCache(const_cast(FE));
+}
 return OutOfDate;
-
+  }
   // We're keeping this module.  Store it everywhere.
   Module = Modules[Entry] = NewModule.get();
 
@@ -284,6 +290,8 @@
   for (ModuleIterator victim = First; victim != Last; ++victim) {
 Modules.erase(victim->File);
 
+const FileEntry *FE = victim->File;
+FileMgr.invalidateCache(const_cast(FE));
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
   if (Module *mod = modMap->findModule(ModuleName)) {


Index: clang/lib/Serialization/ModuleManager.cpp
===
--- clang/lib/Serialization/ModuleManager.cpp
+++ clang/lib/Serialization/ModuleManager.cpp
@@ -232,9 +232,15 @@
   // Read the signature eagerly now so that we can check it.  Avoid calling
   // ReadSignature unless there's something to check though.
   if (ExpectedSignature && checkSignature(ReadSignature(NewModule->Data),
-  ExpectedSignature, ErrorStr))
+  ExpectedSignature, ErrorStr)) {
+// Try to remove the buffer.  If it can't be removed, then it was already
+// validated by this process.
+if (!getModuleCache().tryToDropPCM(NewModule->FileName)) {
+  const FileEntry *FE = NewModule->File;
+  FileMgr.invalidateCache(const_cast(FE));
+}
 return OutOfDate;
-
+  }
   // We're keeping this module.  Store it everywhere.
   Module = Modules[Entry] = NewModule.get();
 
@@ -284,6 +290,8 @@
   for (ModuleIterator victim = First; victim != Last; ++victim) {
 Modules.erase(victim->File);
 
+const FileEntry *FE = victim->File;
+FileMgr.invalidateCache(const_cast(FE));
 if (modMap) {
   StringRef ModuleName = victim->ModuleName;
   if (Module *mod = modMap->findModule(ModuleName)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128249: Adding clone_attrs attribute.

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

Can you add some details to the patch summary as to what problem you're trying 
to solve with these changes?

The idea itself has some interesting edge cases to think about:

  [[some_attr]] void decl();
  [[clone_attrs_from(decl)]] void other();
  [[some_new_attr]] void decl();
  
  int main() {
other(); // Does other see some_new_attr as well?
  }

or

  [[hot]] void decl();
  [[clone_attrs_from(decl), cold]] void other_decl(); // Do you properly catch 
the mutual exclusions?

or

  [[some_attr_requiring_the_func_return_a_pointer]] int *decl();
  [[clone_attrs_from(decl)]] int other(); // Do you properly catch the semantic 
restrictions?

or

  struct [[some_struct_attr]] S { ... };
  [[clone_attrs_from(S)]] void other(); // Do you properly catch the semantic 
restrictions?

or

  [[some_attr]] void decl();
  [[clone_attrs_from(decl)]] void decl(); // Uh oh, recursive.

(I'm sure there are more situations I'm missing, but you get the idea about 
needing to be very careful with the edge cases.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128249

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


[PATCH] D125669: Adding support for target in_reduction

2022-06-21 Thread Ritanya via Phabricator via cfe-commits
RitanyaB updated this revision to Diff 438554.
RitanyaB added a comment.

The if condition in the method EmitOMPTargetTaskBasedDirective in 
CGStmtOpenMP.cpp file was removed since it was unnecessary.


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

https://reviews.llvm.org/D125669

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_in_reduction_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td

Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -582,6 +582,7 @@
 VersionedClause,
 VersionedClause,
 VersionedClause,
+VersionedClause,
 VersionedClause,
 VersionedClause
   ];
Index: clang/test/OpenMP/target_in_reduction_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_in_reduction_codegen.cpp
@@ -0,0 +1,668 @@
+// RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -verify -triple x86_64-apple-darwin10 -fopenmp -x c++ -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -fopenmp -x c++ -triple x86_64-apple-darwin10 -emit-pch -o %t %s
+// RUN: %clang_cc1 -no-opaque-pointers -no-enable-noundef-analysis -fopenmp -x c++ -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s --check-prefix=CHECK1
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+struct S {
+  int a;
+  S() : a(0) {}
+  S(const S &) {}
+  S &operator=(const S &) { return *this; }
+  ~S() {}
+  friend S operator+(const S &a, const S &b) { return a; }
+};
+
+int main(int argc, char **argv) {
+  int a;
+  float b;
+  S c[5];
+  short d[argc];
+#pragma omp taskgroup task_reduction(+ \
+ : a, b, argc)
+  {
+#pragma omp taskgroup task_reduction(- \
+ : c, d)
+#pragma omp parallel
+#pragma omp target in_reduction(+ \
+: a)
+for (int i = 0; i < 5; i++)
+  a += d[a];
+  }
+  return 0;
+}
+
+#endif
+// CHECK1-LABEL: define {{[^@]+}}@main
+// CHECK1-SAME: (i32 [[ARGC:%.*]], i8** [[ARGV:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK1-NEXT:  entry:
+// CHECK1-NEXT:[[RETVAL:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[ARGC_ADDR:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[ARGV_ADDR:%.*]] = alloca i8**, align 8
+// CHECK1-NEXT:[[A:%.*]] = alloca i32, align 4
+// CHECK1-NEXT:[[B:%.*]] = alloca float, align 4
+// CHECK1-NEXT:[[C:%.*]] = alloca [5 x %struct.S], align 16
+// CHECK1-NEXT:[[SAVED_STACK:%.*]] = alloca i8*, align 8
+// CHECK1-NEXT:[[__VLA_EXPR0:%.*]] = alloca i64, align 8
+// CHECK1-NEXT:[[DOTRD_INPUT_:%.*]] = alloca [3 x %struct.kmp_taskred_input_t], align 8
+// CHECK1-NEXT:[[DOTTASK_RED_:%.*]] = alloca i8*, align 8
+// CHECK1-NEXT:[[DOTRD_INPUT_3:%.*]] = alloca [2 x %struct.kmp_taskred_input_t.0], align 8
+// CHECK1-NEXT:[[DOTTASK_RED_6:%.*]] = alloca i8*, align 8
+// CHECK1-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(%struct.ident_t* @[[GLOB1:[0-9]+]])
+// CHECK1-NEXT:store i32 0, i32* [[RETVAL]], align 4
+// CHECK1-NEXT:store i32 [[ARGC]], i32* [[ARGC_ADDR]], align 4
+// CHECK1-NEXT:store i8** [[ARGV]], i8*** [[ARGV_ADDR]], align 8
+// CHECK1-NEXT:[[ARRAY_BEGIN:%.*]] = getelementptr inbounds [5 x %struct.S], [5 x %struct.S]* [[C]], i32 0, i32 0
+// CHECK1-NEXT:[[ARRAYCTOR_END:%.*]] = getelementptr inbounds [[STRUCT_S:%.*]], %struct.S* [[ARRAY_BEGIN]], i64 5
+// CHECK1-NEXT:br label [[ARRAYCTOR_LOOP:%.*]]
+// CHECK1:   arrayctor.loop:
+// CHECK1-NEXT:[[ARRAYCTOR_CUR:%.*]] = phi %struct.S* [ [[ARRAY_BEGIN]], [[ENTRY:%.*]] ], [ [[ARRAYCTOR_NEXT:%.*]], [[ARRAYCTOR_LOOP]] ]
+// CHECK1-NEXT:call void @_ZN1SC1Ev(%struct.S* nonnull align 4 dereferenceable(4) [[ARRAYCTOR_CUR]])
+// CHECK1-NEXT:[[ARRAYCTOR_NEXT]] = getelementptr inbounds [[STRUCT_S]], %struct.S* [[ARRAYCTOR_CUR]], i64 1
+// CHECK1-NEXT:[[ARRAYCTOR_DONE:%.*]] = icmp eq %struct.S* [[ARRAYCTOR_NEXT]], [[ARRAYCTOR_END]]
+// CHECK1-NEXT:br i1 [[ARRAYCTOR_DONE]], label [[ARRAYCTOR_CONT:%.*]], label [[ARRAYCTOR_LOOP]]
+// CHECK1:   arrayctor.cont:
+// CHECK1-NEXT:[[TMP1:%.*]] = load i32, i32* [[ARGC_ADDR]], align 4
+// CHECK1-NEXT:[[TMP2:%.*]] = zext i32 [[TMP1]] to i64
+// CHECK1-NEXT:[[TMP3:%.*]] = call i8* @llvm.stacksave()
+// CHECK1-NEXT:store i8* [[TMP3]], i8** [[SAVED_STACK]], align 8
+// CHECK1-NEXT:[[VLA:%.*]] = alloca i16, i64 [[TMP2]], align 16
+// CHECK1-NEXT:store i64 [[TMP2]], i64* [[__VLA_EXPR0]], align 8
+// CHECK1-NEXT:call void @__kmpc_taskgroup(%struct.ident_t* @[[GLOB1]], i32 [[TMP0]])
+// CHECK1-NEXT:[[D

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

2022-06-21 Thread Nathan Sidwell via Phabricator via cfe-commits
urnathan added a comment.

please sed /initialiser/initializer/, I noticed a few had crept in.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126189

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


[PATCH] D128072: [clang-tidy] Organize test files into subdirectories by module (NFC)

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

This sounds like a sensible direction to me. I spot-checked the changes and 
they all seem reasonable. Giving my LG, but please wait a bit before landing in 
case someone else has the chance to spot check as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128072

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


[PATCH] D127270: [clang-format] Add space in placement new expression

2022-06-21 Thread omar ahmed via Phabricator via cfe-commits
omarahmed updated this revision to Diff 438657.
omarahmed added a comment.

Change the default to APO_Leave


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127270

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10130,6 +10130,42 @@
 "void delete(link p);\n",
 format("void new (link p);\n"
"void delete (link p);\n"));
+
+  FormatStyle AfterPlacementOperator = getLLVMStyle();
+  AfterPlacementOperator.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  EXPECT_EQ(
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Leave);
+  EXPECT_EQ("new (buf) int;", format("new (buf) int;", AfterPlacementOperator));
+  EXPECT_EQ("new(buf) int;", format("new(buf) int;", AfterPlacementOperator));
+
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Never;
+  verifyFormat("struct A {\n"
+   "  int *a;\n"
+   "  A(int *p) : a(new(p) int) {\n"
+   "new(p) int;\n"
+   "int *b = new(p) int;\n"
+   "int *c = new(p) int(3);\n"
+   "delete(b);\n"
+   "  }\n"
+   "};",
+   AfterPlacementOperator);
+  verifyFormat("void operator new(void *foo) ATTRIB;", AfterPlacementOperator);
+
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Always;
+  verifyFormat("struct A {\n"
+   "  int *a;\n"
+   "  A(int *p) : a(new (p) int) {\n"
+   "new (p) int;\n"
+   "int *b = new (p) int;\n"
+   "int *c = new (p) int(3);\n"
+   "delete (b);\n"
+   "  }\n"
+   "};",
+   AfterPlacementOperator);
+  verifyFormat("void operator new(void *foo) ATTRIB;", AfterPlacementOperator);
 }
 
 TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
@@ -20308,6 +20344,24 @@
   SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatementsExceptControlMacros);
 
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  Style.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Always;
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Never",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Never);
+
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Always",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Always);
+
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Leave",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Leave);
+
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3393,6 +3393,18 @@
 if (Left.is(TT_IfMacro))
   return Style.SpaceBeforeParensOptions.AfterIfMacros ||
  spaceRequiredBeforeParens(Right);
+if (Style.SpaceBeforeParens == FormatStyle::SBPO_Custom &&
+Left.isOneOf(tok::kw_new, tok::kw_delete) &&
+Right.isNot(TT_OverloadedOperatorLParen) &&
+!(Line.MightBeFunctionDecl && Left.is(TT_FunctionDeclarationName))) {
+  if (Style.SpaceBeforeParensOptions.AfterPlacementOperator ==
+  FormatStyle::SpaceBeforeParensCustom::APO_Always ||
+  (Style.SpaceBeforeParensOptions.AfterPlacementOperator ==
+   FormatStyle::SpaceBeforeParensCustom::APO_Leave &&
+   Right.hasWhitespaceBefore()))
+return true;
+  return false;
+}
 if (Line.Type == LT_ObjCDecl)
   return true;
 if (Left.is(tok::semi))
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -936,6 +936,7 @@
Spacing.AfterFunctionDeclarationName);
 IO.mapOptional("AfterIfMacros", Spacing.AfterIfMacros);
 IO.mapOptio

[PATCH] D127270: [clang-format] Add space in placement new expression

2022-06-21 Thread omar ahmed via Phabricator via cfe-commits
omarahmed added inline comments.



Comment at: clang/include/clang/Format/Format.h:3559
   AfterFunctionDefinitionName(false), AfterIfMacros(false),
-  AfterOverloadedOperator(false), AfterRequiresInClause(false),
-  AfterRequiresInExpression(false), BeforeNonEmptyParentheses(false) {}
+  AfterOverloadedOperator(false), AfterPlacementOperator(APO_Always),
+  AfterRequiresInClause(false), AfterRequiresInExpression(false),

MyDeveloperDay wrote:
> HazardyKnusperkeks wrote:
> > As said in the other comment, there is code that depends on setting to 
> > never in the default constructor, so please do.
> Why Never and not Leave? basically introducing one or the other as a default 
> won't that causes changes for people who don't want to use this?
I think that's a good point. I changed that to `APO_Leave` and added 
`APO_Never` to the code that depends on it. 

I was guarding the default behavior with `SpaceBeforeParentheses: Custom` 
condition but I think still if someone defined it to be custom and didn't 
specify this option, it should still be leave.



Comment at: clang/lib/Format/Format.cpp:1169
   case FormatStyle::SBPO_Never:
+Expanded.SpaceBeforeParensOptions.AfterPlacementOperator = 
FormatStyle::SpaceBeforeParensCustom::APO_Never;
 break;

The part that depends on it to be `APO_Never` to align with `SBPO_Never` option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127270

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


[PATCH] D128202: [clangd] Include "final" when printing class declaration

2022-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/AST/DeclPrinter.cpp:1010
 
+  if (D->isEffectivelyFinal()) {
+  Out << " final";

tom-anders wrote:
> sammccall wrote:
> > isEffectivelyFinal returns true for
> > `struct X { ~X() final; }`
> > 
> > I don't think we want to print `struct X final {}` in that case.
> > 
> > Probably want to replicate the check for FinalAttr instead?
> Agreed. Would probably make sense to add a `bool hasFinalAttribute() const` 
> to `CXXRecordDecl`?
I'm not sure such a method pays for itself, the abstraction it might provides 
over hasAttr() is:
 - it handles the case where there's no definition... but maybe "return false" 
isn't the right thing to do in all circumstances?
 - a simple hasFinal() could avoid thinking about syntactic details - but here 
we explicitly care about them.
 - it hides the detail that final is stored as an attribute rather than e.g. a 
bit. This is the only piece that seems useful.

Given that, I think it's probably best here just to inline the logic, but I 
don't feel strongly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128202

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


[PATCH] D127114: new clang-tidy checker for assignments within condition clause of if statement

2022-06-21 Thread dodohand via Phabricator via cfe-commits
dodohand added a comment.

@gribozavr2 , have I successfully addressed the points you brought up?


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

https://reviews.llvm.org/D127114

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


[PATCH] D127873: [clang-format] Fix misplacemnt of `*` in declaration of pointer to struct

2022-06-21 Thread Jack Huang via Phabricator via cfe-commits
jackhong12 updated this revision to Diff 438669.
jackhong12 added a comment.

Thanks for your reply! I added comments for each clause.


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

https://reviews.llvm.org/D127873

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp
  clang/unittests/Format/TokenAnnotatorTest.cpp

Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -85,6 +85,32 @@
   Tokens = annotate("case &x:");
   EXPECT_EQ(Tokens.size(), 5u) << Tokens;
   EXPECT_TOKEN(Tokens[1], tok::amp, TT_UnaryOperator);
+
+  Tokens = annotate("struct {\n"
+"} *ptr;");
+  EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+  Tokens = annotate("union {\n"
+"} *ptr;");
+  EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+  Tokens = annotate("class {\n"
+"} *ptr;");
+  EXPECT_EQ(Tokens.size(), 7u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::star, TT_PointerOrReference);
+
+  Tokens = annotate("struct {\n"
+"} &&ptr = {};");
+  EXPECT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
+  Tokens = annotate("union {\n"
+"} &&ptr = {};");
+  EXPECT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
+  Tokens = annotate("class {\n"
+"} &&ptr = {};");
+  EXPECT_EQ(Tokens.size(), 10u) << Tokens;
+  EXPECT_TOKEN(Tokens[3], tok::ampamp, TT_PointerOrReference);
 }
 
 TEST_F(TokenAnnotatorTest, UnderstandsUsesOfPlusAndMinus) {
Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10431,6 +10431,67 @@
   "void F();",
   getGoogleStyleWithColumns(68));
 
+  FormatStyle Style = getLLVMStyle();
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("struct {\n"
+   "}* ptr;",
+   Style);
+  verifyFormat("union {\n"
+   "}* ptr;",
+   Style);
+  verifyFormat("class {\n"
+   "}* ptr;",
+   Style);
+  verifyFormat("struct {\n"
+   "}&& ptr = {};",
+   Style);
+  verifyFormat("union {\n"
+   "}&& ptr = {};",
+   Style);
+  verifyFormat("class {\n"
+   "}&& ptr = {};",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Middle;
+  verifyFormat("struct {\n"
+   "} * ptr;",
+   Style);
+  verifyFormat("union {\n"
+   "} * ptr;",
+   Style);
+  verifyFormat("class {\n"
+   "} * ptr;",
+   Style);
+  verifyFormat("struct {\n"
+   "} && ptr = {};",
+   Style);
+  verifyFormat("union {\n"
+   "} && ptr = {};",
+   Style);
+  verifyFormat("class {\n"
+   "} && ptr = {};",
+   Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  verifyFormat("struct {\n"
+   "} *ptr;",
+   Style);
+  verifyFormat("union {\n"
+   "} *ptr;",
+   Style);
+  verifyFormat("class {\n"
+   "} *ptr;",
+   Style);
+  verifyFormat("struct {\n"
+   "} &&ptr = {};",
+   Style);
+  verifyFormat("union {\n"
+   "} &&ptr = {};",
+   Style);
+  verifyFormat("class {\n"
+   "} &&ptr = {};",
+   Style);
+
   verifyIndependentOfContext("MACRO(int *i);");
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -2304,6 +2304,27 @@
 if (NextToken->isOneOf(tok::comma, tok::semi))
   return TT_PointerOrReference;
 
+// After right braces, star tokens are likely to be pointers to struct,
+// union, or class.
+//   struct {} *ptr;
+if (PrevToken->is(tok::r_brace) && Tok.is(tok::star))
+  return TT_PointerOrReference;
+
+// For "} &&"
+if (PrevToken->is(tok::r_brace) && Tok.is(tok::ampamp)) {
+  const FormatToken *MatchingLBrace = PrevToken->MatchingParen;
+  // We check whether there is a TemplateCloser(">") to indicate it's a
+  // template or not. If it's a template, "&&" is a binary operator.
+  //   enable_if<>{} && ...
+  if (MatchingLBrace && MatchingLBrace->getPreviousNonComment() &&
+  MatchingLBrace->getPreviousNonComment()->is(TT_TemplateC

[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-06-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.



> Ignoring the `pragma alloc_text`, it looks like GCC compiles the following 
> `foo` with C linkage vs LLVM which compiles with C++ linkage (foo's name is 
> mangled):

The mangled name shouldn't matter since it has internal linkage. I tried 
dropping the `static`, and then foo doesn't seem to get mangled: 
https://godbolt.org/z/arzW5TbYz


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126559

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


[PATCH] D127856: [clangd] Support multiline semantic tokens

2022-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:947
+Out->tokenModifiers = Tok.Modifiers;
+Last = Tok;
 

this copy feels gratuitous, can we just use Tokens.back(), or do the copy in 
the rare case?



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:954
+  // line.
+  // This is slow, but code rarely has multiline tokens.
+  // FIXME: There's a client capability for supporting multiline tokens,

This isn't literally true - files with multiline raw strings aren't rare. maybe 
"multiline tokens are rare"?
(even so I wonder if there's a real performance problem here...)



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:960
+  // length.
+  for (int I = Tok.R.start.line; I != Tok.R.end.line; ++I) {
+auto LineEnd = Code.find('\n', TokStartOffset);

can we use < rather than != here? (or an assert)
I realize something has to have gone horribly wrong to infloop here, but it's 
something nonlocal...



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:971
+Out->deltaStart = 0;
+Out->tokenType = static_cast(Tok.Kind);
+Out->tokenModifiers = Tok.Modifiers;

reassigning fields one by one seems fragile, copy the last token and then 
overwrite the fields needed?



Comment at: 
clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:1007
+  llvm::StringRef AnnotatedCode = R"cpp(
+[[fo
+o

please have the first token start somewhere other than column 0


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127856

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


[PATCH] D128095: clang: fix checking parameter packs for expansion

2022-06-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 438680.
mizvekov edited the summary of this revision.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128095

Files:
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/SemaInternal.h
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp

Index: clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
+++ clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp
@@ -469,3 +469,25 @@
   bar(b);
 }
 }
+
+namespace pr56094 {
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+  // expected-error@-1 {{pack expansion contains parameter packs 'T' and 'U' that have different lengths (1 vs. 2)}}
+  template  D(B *);
+  // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
+};
+using t1 = D::B;
+// expected-note@-1 {{in instantiation of template class 'pr56094::D' requested here}}
+
+template  struct F {};
+template  struct G {};
+template  struct E {
+  template  using B = G...>;
+  // expected-error@-1 {{pack expansion contains parameter pack 'U' that has a different length (1 vs. 2) from outer parameter packs}}
+  template  E(B *);
+  // expected-note@-1 {{in instantiation of template type alias 'B' requested here}}
+};
+using t2 = E::B;
+// expected-note@-1 {{in instantiation of template class 'pr56094::E' requested here}}
+} // namespace pr56094
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -88,6 +88,17 @@
   return true;
 }
 
+bool VisitSubstTemplateTypeParmPackType(SubstTemplateTypeParmPackType *T) {
+  Unexpanded.push_back({T, SourceLocation()});
+  return true;
+}
+
+bool
+VisitSubstNonTypeTemplateParmPackExpr(SubstNonTypeTemplateParmPackExpr *E) {
+  Unexpanded.push_back({E, E->getParameterPackLocation()});
+  return true;
+}
+
 /// Record occurrences of function and non-type template
 /// parameter packs in an expression.
 bool VisitDeclRefExpr(DeclRefExpr *E) {
@@ -306,7 +317,8 @@
   auto *TTPD = dyn_cast(LocalPack);
   return TTPD && TTPD->getTypeForDecl() == TTPT;
 }
-return declaresSameEntity(Pack.first.get(), LocalPack);
+return declaresSameEntity(Pack.first.get(),
+  LocalPack);
   };
   if (llvm::any_of(LSI->LocalPacks, DeclaresThisPack))
 LambdaParamPackReferences.push_back(Pack);
@@ -358,7 +370,7 @@
   = Unexpanded[I].first.dyn_cast())
   Name = TTP->getIdentifier();
 else
-  Name = Unexpanded[I].first.get()->getIdentifier();
+  Name = Unexpanded[I].first.get()->getIdentifier();
 
 if (Name && NamesKnown.insert(Name).second)
   Names.push_back(Name);
@@ -421,7 +433,7 @@
   llvm::SmallPtrSet ParmSet(Parms.begin(), Parms.end());
   SmallVector UnexpandedParms;
   for (auto Parm : Unexpanded)
-if (ParmSet.contains(Parm.first.dyn_cast()))
+if (ParmSet.contains(Parm.first.dyn_cast()))
   UnexpandedParms.push_back(Parm);
   if (UnexpandedParms.empty())
 return false;
@@ -681,42 +693,51 @@
 // Compute the depth and index for this parameter pack.
 unsigned Depth = 0, Index = 0;
 IdentifierInfo *Name;
-bool IsVarDeclPack = false;
+unsigned NewPackSize;
+bool NotPack = true;
 
-if (const TemplateTypeParmType *TTP =
+if (const auto *TTP =
 ParmPack.first.dyn_cast()) {
   Depth = TTP->getDepth();
   Index = TTP->getIndex();
   Name = TTP->getIdentifier();
+} else if (const auto *STP =
+   ParmPack.first
+   .dyn_cast()) {
+  NewPackSize = STP->getNumArgs();
+  Name = STP->getIdentifier();
+  NotPack = false;
+} else if (const auto *SEP =
+   ParmPack.first
+   .dyn_cast()) {
+  NewPackSize = SEP->getArgumentPack().pack_size();
+  Name = SEP->getParameterPack()->getIdentifier();
+  NotPack = false;
 } else {
-  NamedDecl *ND = ParmPack.first.get();
-  if (isa(ND))
-IsVarDeclPack = true;
-  else
+  const auto *ND = ParmPack.first.get();
+  if (isa(ND)) {
+// Figure out whether we're instantiating to an argument pack or not.
+using DeclArgumentPack = LocalInstantiationScope::DeclArgumentPack;
+llvm::PointerUnion *Instantiation =
+CurrentInstantiationScope->findInstantiationOf(
+ParmPack.first.get());
+if (Instantiation->is()) {
+  // We could expand this function parameter pack.
+  NewPackSize = Instan

[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-06-21 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

In D126559#3598885 , @hans wrote:

>> Ignoring the `pragma alloc_text`, it looks like GCC compiles the following 
>> `foo` with C linkage vs LLVM which compiles with C++ linkage (foo's name is 
>> mangled):
>
> The mangled name shouldn't matter since it has internal linkage. I tried 
> dropping the `static`, and then foo doesn't seem to get mangled: 
> https://godbolt.org/z/arzW5TbYz

Oh I see, that makes sense. We aren't accepting 
https://godbolt.org/z/9Yej9vhYd. Do you know of a way to get the `NamedDecl` 
with `extern "C"` instead of the second declaration?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126559

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


[PATCH] D127641: [clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default

2022-06-21 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 438682.
steplong added a comment.
Herald added a project: clang-tools-extra.

- Add `-target x86_64-unknown-linux` to `misc-new-delete-overloads.cpp`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-zc.cpp


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck 
-check-prefix=SIZED-DEALLOC-OFF %s
+// SIZED-DEALLOC: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++14 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++20 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++latest -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// ALIGNED-NEW-BEFORE-CPP17-NOT: "-faligned-allocation"
+// ALIGNED-NEW-CPP17ONWARDS: "-faligned-allocation"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck 
-check-prefix=TRIGRAPHS-DEFAULT %s
 // cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
 // isn't explicitly passed.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6470,6 +6470,7 @@
 }
 CmdArgs.push_back(LanguageStandard.data());
   }
+  bool IsCPP17Onwards = false;
   if (ImplyVCPPCXXVer) {
 StringRef LanguageStandard;
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
@@ -6493,6 +6494,9 @@
 }
 
 CmdArgs.push_back(LanguageStandard.data());
+
+IsCPP17Onwards =
+LanguageStandard != "-std=c++11" && LanguageStandard != "-std=c++14";
   }
 
   Args.addOptInFlag(CmdArgs, options::OPT_fborland_extensions,
@@ -6622,9 +6626,15 @@
 options::OPT_fno_relaxed_template_template_args);
 
   // -fsized-deallocation is off by default, as it is an ABI-breaking change 
for
-  // most platforms.
-  Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
-options::OPT_fno_sized_deallocation);
+  // most platforms. MSVC turns on /Zc:sizedDealloc by default, starting in
+  // MSVC 2015.
+  if (IsWindowsMSVC && IsMSVC2015Compatible &&
+  !Args.getLastArg(options::OPT_fsized_deallocation,
+   options::OPT_fno_sized_deallocation))
+CmdArgs.push_back("-fsized-deallocation");
+  else
+Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
+  options::OPT_fno_sized_deallocation);
 
   // -faligned-allocation is on by default in C++17 onwards and otherwise off
   // by default.
@@ -6635,6 +6645,8 @@
   CmdArgs.push_back("-fno-aligned-allocation");
 else
   CmdArgs.push_back("-faligned-allocation");
+  } else if (IsCPP17Onwards) {
+CmdArgs.push_back("-faligned-allocation");
   }
 
   // The default new alignment can be specified using a dedicated option or via
Index: clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-new-delete-overloads %t
+// RUN: %check_clang_tidy -target x86_64-unknown-linux %s 
misc-new-delete-overloads %t
 
 typedef decltype(sizeof(int)) size_t;
 


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-OFF %s
+// SIZED-DEALLOC: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck 

[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-06-21 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

> Oh I see, that makes sense. We aren't accepting 
> https://godbolt.org/z/9Yej9vhYd. Do you know of a way to get the `NamedDecl` 
> with `extern "C"` instead of the second declaration?

I'm not sure I understand the question, but it seems the current code is 
checking `isExternCContext()`. I think instead you want to check 
`FunctionDecl::isExternC()`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126559

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


[PATCH] D128204: [clangd] Add fix-it for inserting IWYU pragma: keep

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

This is a bit tricky - we'd like to offer more fixes in several scenarios (e.g. 
replace a header with the transitive includes you're relying on), but some of 
those require more complex implementation.

On one hand, presenting only one automated fix will bias users towards that 
option.
On the other hand, it's not clear when the more complex fixes will be ready and 
this solves a real problem.

I'm inclined toward landing it, but will leave this up to @kadircet




Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:502
 // including them directly instead.
 // FIXME(kirillbobyrev): Add fix suggestion for adding IWYU pragmas
 // (keep/export) remove the warning once we support IWYU pragmas.

this FIXME is addressed by this change



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:511
+D.Fixes.emplace_back();
+D.Fixes.back().Message = "add pragma keep directive";
+D.Fixes.back().Edits.emplace_back();

"directive" isn't accurate here I think

What about just: "add IWYU pragma: keep"?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128204

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


[PATCH] D128059: [Clang] Add a warning on invalid UTF-8 in comments.

2022-06-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticLexKinds.td:116-117
   "source file is not valid UTF-8">;
+def warn_invalid_utf8_in_comment : Warning<
+  "invalid UTF-8 in comment">, InGroup>, 
DefaultIgnore;
 def err_character_not_allowed : Error<

What would it take to enable the diagnostic by default? We don't typically add 
off-by-default diagnostics because there's evidence that not many folks enable 
them.

Alternatively, would this make sense as a pedantic warning? It's not really an 
extension for us to accept this stuff, but it seems like we can still 
pedantically diagnose the code?



Comment at: clang/lib/Lex/Lexer.cpp:2399
+  getSourceLocation(CurPtr));
+  bool UnicodeDecodeFailed = false;
+

It looks like this can move into the `while` loop and we can remove some `= 
false` from within the loop?



Comment at: clang/lib/Lex/Lexer.cpp:2407
+// diagnostic only once per sequence that cannot be decoded.
+while ((!WarnOnInvalidUtf8 || isASCII(C)) && C != 0 && // Potentially EOF.
+   C != '\n' && C != '\r') { // Newline or DOS-style newline.

Do you have some idea of performance cost for enabling the warning with a large 
TU? Are we talking .5%? 1%? 5%? noise?



Comment at: clang/lib/Lex/Lexer.cpp:2417
+  if (Length == 0) {
+if (!UnicodeDecodeFailed) {
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);

aaron.ballman wrote:
> 
So if unicode decoding didn't fail... diagnose? :-) The naming here seems 
unfortunate.



Comment at: clang/lib/Lex/Lexer.cpp:2417-2419
+if (!UnicodeDecodeFailed) {
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+}





Comment at: clang/lib/Lex/Lexer.cpp:2698
+  getSourceLocation(CurPtr));
+  bool UnicodeDecodeFailed = false;
+

I think this can move into the loop as well.



Comment at: clang/lib/Lex/Lexer.cpp:2764-2766
+if (!UnicodeDecodeFailed) {
+  Diag(CurPtr, diag::warn_invalid_utf8_in_comment);
+}

Same concerns about naming here as above.



Comment at: llvm/lib/Support/ConvertUTF.cpp:426-429
+  if (length > sourceEnd - source) {
+return 0;
+  }
+  return isLegalUTF8(source, length) ? length : 0;




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128059

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


[PATCH] D126859: [clangd] Validate clang-tidy CheckOptions in clangd config

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

FWIW, I think validating the names makes sense but I don't think typo 
correction pays for itself here. @kadircet?




Comment at: clang-tools-extra/clangd/TidyProvider.cpp:291
+  static void *call() {
+return new tidy::NamesAndOptions(tidy::getAllChecksAndOptions(false));
+  }

it seems strange that clang-tidy provides this API to query what checks are 
linked in, but it constructs an expensive object every time rather than just 
creating a static one once and returning a reference to it. (i.e. the 
memoization is on the caller side)
Should we fix that API instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126859

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


[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

2022-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 438693.
sammccall added a comment.

Deeper version of LR0, still prototype-quality

- use hashtables instead of binary search where appropriate
- simplify GLR accordingly
- add fast-path reduce to reclaim some of the performance (though "reclaim" is 
maybe wrong - this optimization can with hindsight apply to SLR1 also)

Numbers to follow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp

Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -108,7 +108,7 @@
   llvm::outs() << G->dump();
 if (PrintGraph)
   llvm::outs() << clang::pseudo::LRGraph::buildLR0(*G).dumpForTests(*G);
-auto LRTable = clang::pseudo::LRTable::buildSLR(*G);
+auto LRTable = clang::pseudo::LRTable::buildLR0(*G);
 if (PrintTable)
   llvm::outs() << LRTable.dumpForTests(*G);
 if (PrintStatistics)
Index: clang-tools-extra/pseudo/test/lr-build-conflicts.test
===
--- clang-tools-extra/pseudo/test/lr-build-conflicts.test
+++ clang-tools-extra/pseudo/test/lr-build-conflicts.test
@@ -35,12 +35,10 @@
 # TABLE-NEXT: State 1
 # TABLE-NEXT: '-': shift state 3
 # TABLE-NEXT: State 2
-# TABLE-NEXT: 'EOF': reduce by rule 1 'expr := IDENTIFIER'
-# TABLE-NEXT: '-': reduce by rule 1 'expr := IDENTIFIER'
+# TABLE-NEXT: 'EOD': reduce by rule 1 'expr := IDENTIFIER'
 # TABLE-NEXT: State 3
 # TABLE-NEXT: 'IDENTIFIER': shift state 2
 # TABLE-NEXT: 'expr': go to state 4
 # TABLE-NEXT: State 4
-# TABLE-NEXT: 'EOF': reduce by rule 0 'expr := expr - expr'
+# TABLE-NEXT: 'EOD': reduce by rule 0 'expr := expr - expr'
 # TABLE-NEXT: '-': shift state 3
-# TABLE-NEXT: '-': reduce by rule 0 'expr := expr - expr'
Index: clang-tools-extra/pseudo/test/lr-build-basic.test
===
--- clang-tools-extra/pseudo/test/lr-build-basic.test
+++ clang-tools-extra/pseudo/test/lr-build-basic.test
@@ -23,6 +23,6 @@
 # TABLE-NEXT: 'id': go to state 2
 # TABLE-NEXT: State 1
 # TABLE-NEXT: State 2
-# TABLE-NEXT: 'EOF': reduce by rule 1 'expr := id'
+# TABLE-NEXT: 'EOD': reduce by rule 1 'expr := id'
 # TABLE-NEXT: State 3
-# TABLE-NEXT: 'EOF': reduce by rule 0 'id := IDENTIFIER'
+# TABLE-NEXT: 'EOD': reduce by rule 0 'id := IDENTIFIER'
Index: clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
===
--- clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
+++ clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
@@ -9,35 +9,12 @@
 #include "clang-pseudo/Grammar.h"
 #include "clang-pseudo/LRGraph.h"
 #include "clang-pseudo/LRTable.h"
-#include "clang/Basic/TokenKinds.h"
 #include 
 
-namespace llvm {
-template <> struct DenseMapInfo {
-  using Entry = clang::pseudo::LRTable::Entry;
-  static inline Entry getEmptyKey() {
-static Entry E{static_cast(-1), 0,
-   clang::pseudo::LRTable::Action::sentinel()};
-return E;
-  }
-  static inline Entry getTombstoneKey() {
-static Entry E{static_cast(-2), 0,
-   clang::pseudo::LRTable::Action::sentinel()};
-return E;
-  }
-  static unsigned getHashValue(const Entry &I) {
-return llvm::hash_combine(I.State, I.Symbol, I.Act.opaque());
-  }
-  static bool isEqual(const Entry &LHS, const Entry &RHS) {
-return LHS.State == RHS.State && LHS.Symbol == RHS.Symbol &&
-   LHS.Act == RHS.Act;
-  }
-};
-} // namespace llvm
-
 namespace clang {
 namespace pseudo {
 
+#if 0
 class LRTable::Builder {
 public:
   Builder(llvm::ArrayRef> StartStates)
@@ -134,6 +111,41 @@
   }
   return std::move(Build).build(G.table(), Graph.states().size());
 }
+#endif
+
+LRTable LRTable::buildLR0(const Grammar &G) {
+  auto Graph = LRGraph::buildLR0(G);
+  assert(Graph.states().size() <= (1 << StateBits) &&
+ "Graph states execceds the maximum limit!");
+
+  std::vector> Reduce;
+  llvm::DenseMap Shift;
+  llvm::DenseMap GoTo;
+
+  for (const auto &T : Graph.edges()) {
+(isToken(T.Label) ? Shift : GoTo)
+.try_emplace(StateSymbol{T.Src, T.Label}, T.Dst);
+  }
+
+  for (StateID SID = 0; SID < Graph.states().size(); ++SID) 

[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

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

In D127357#3569386 , @hokein wrote:

> Thanks for experimenting this!
>
>> the size of the LR table is much smaller (In this patch we go from 340kB => 
>> 120kB, and the encoding isn't efficient)
>
> This is interesting. I'd expect we now add more reduce actions into the 
> LRTable, thus the table size should grow (I guess the saving is because we 
> don't need to store different token kinds, instead just a single `eod` token)?

Yes, before we store (State, Tok) => Reduce(L := R) for every Tok in Follow(L).
Now we only store (State, eod) => Reduce(L := R).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

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


[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-06-21 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

In D126559#3598950 , @hans wrote:

>> Oh I see, that makes sense. We aren't accepting 
>> https://godbolt.org/z/9Yej9vhYd. Do you know of a way to get the `NamedDecl` 
>> with `extern "C"` instead of the second declaration?
>
> I'm not sure I understand the question, but it seems the current code is 
> checking `isExternCContext()`. I think instead you want to check 
> `FunctionDecl::isExternC()`.

Oh, that answers my question. I'll give that a try. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126559

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


[PATCH] D128282: [WebAssembly] Update test to run it in opaque pointers mode

2022-06-21 Thread Paulo Matos via Phabricator via cfe-commits
pmatos created this revision.
pmatos added reviewers: asb, tlively.
Herald added subscribers: StephenFan, wingo, ecnelises, sunfish, 
jgravelle-google, sbc100, dschuff.
Herald added a project: All.
pmatos requested review of this revision.
Herald added subscribers: cfe-commits, aheejin.
Herald added a project: clang.

When opaque pointers was enabled, -no-opaque-pointers were added to some tests 
in order not to change behaviour. We now revert this and fix the test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128282

Files:
  clang/test/CodeGen/builtins-wasm.c


Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -no-opaque-pointers -triple wasm32-unknown-unknown 
-target-feature +simd128 -target-feature +relaxed-simd -target-feature 
+nontrapping-fptoint -target-feature +exception-handling -target-feature 
+bulk-memory -target-feature +atomics -flax-vector-conversions=none -O3 
-emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
-// RUN: %clang_cc1 -no-opaque-pointers -triple wasm64-unknown-unknown 
-target-feature +simd128 -target-feature +relaxed-simd -target-feature 
+nontrapping-fptoint -target-feature +exception-handling -target-feature 
+bulk-memory -target-feature +atomics -flax-vector-conversions=none -O3 
-emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
-// RUN: not %clang_cc1 -no-opaque-pointers -triple wasm64-unknown-unknown 
-target-feature +nontrapping-fptoint -target-feature +exception-handling 
-target-feature +bulk-memory -target-feature +atomics 
-flax-vector-conversions=none -O3 -emit-llvm -o - %s 2>&1 | FileCheck %s 
-check-prefixes MISSING-SIMD
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 
-target-feature +relaxed-simd -target-feature +nontrapping-fptoint 
-target-feature +exception-handling -target-feature +bulk-memory 
-target-feature +atomics -flax-vector-conversions=none -O3 -emit-llvm -o - %s | 
FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown  -target-feature +simd128 
-target-feature +relaxed-simd -target-feature +nontrapping-fptoint 
-target-feature +exception-handling -target-feature +bulk-memory 
-target-feature +atomics -flax-vector-conversions=none -O3 -emit-llvm -o - %s | 
FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: not %clang_cc1 -triple wasm64-unknown-unknown -target-feature 
+nontrapping-fptoint -target-feature +exception-handling -target-feature 
+bulk-memory -target-feature +atomics -flax-vector-conversions=none -O3 
-emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefixes MISSING-SIMD
 
 // SIMD convenience types
 typedef signed char i8x16 __attribute((vector_size(16)));
@@ -40,13 +40,13 @@
 
 void *tls_base(void) {
   return __builtin_wasm_tls_base();
-  // WEBASSEMBLY: call i8* @llvm.wasm.tls.base()
+  // WEBASSEMBLY: call ptr @llvm.wasm.tls.base()
 }
 
 void throw(void *obj) {
   return __builtin_wasm_throw(0, obj);
-  // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 0, i8* %{{.*}})
-  // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 0, i8* %{{.*}})
+  // WEBASSEMBLY32: call void @llvm.wasm.throw(i32 0, ptr %{{.*}})
+  // WEBASSEMBLY64: call void @llvm.wasm.throw(i32 0, ptr %{{.*}})
 }
 
 void rethrow(void) {
@@ -57,20 +57,20 @@
 
 int memory_atomic_wait32(int *addr, int expected, long long timeout) {
   return __builtin_wasm_memory_atomic_wait32(addr, expected, timeout);
-  // WEBASSEMBLY32: call i32 @llvm.wasm.memory.atomic.wait32(i32* %{{.*}}, i32 
%{{.*}}, i64 %{{.*}})
-  // WEBASSEMBLY64: call i32 @llvm.wasm.memory.atomic.wait32(i32* %{{.*}}, i32 
%{{.*}}, i64 %{{.*}})
+  // WEBASSEMBLY32: call i32 @llvm.wasm.memory.atomic.wait32(ptr %{{.*}}, i32 
%{{.*}}, i64 %{{.*}})
+  // WEBASSEMBLY64: call i32 @llvm.wasm.memory.atomic.wait32(ptr %{{.*}}, i32 
%{{.*}}, i64 %{{.*}})
 }
 
 int memory_atomic_wait64(long long *addr, long long expected, long long 
timeout) {
   return __builtin_wasm_memory_atomic_wait64(addr, expected, timeout);
-  // WEBASSEMBLY32: call i32 @llvm.wasm.memory.atomic.wait64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
-  // WEBASSEMBLY64: call i32 @llvm.wasm.memory.atomic.wait64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
+  // WEBASSEMBLY32: call i32 @llvm.wasm.memory.atomic.wait64(ptr %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
+  // WEBASSEMBLY64: call i32 @llvm.wasm.memory.atomic.wait64(ptr %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
 }
 
 unsigned int memory_atomic_notify(int *addr, unsigned int count) {
   return __builtin_wasm_memory_atomic_notify(addr, count);
-  // WEBASSEMBLY32: call i32 @llvm.wasm.memory.atomic.notify(i32* %{{.*}}, i32 
%{{.*}})
-  // WEBASSEMBLY64: call i32 @llvm.wasm.memory.atomic.notify(i32* %{{.*}}, i32 
%{{.*}})
+  // WEBASSEMBLY32: call i32 @llvm.wasm.memory.atomic.notify(ptr %{{.*}}, i32

[PATCH] D126461: [RISCV] Extract and store new vl of vleff/vlsegff iff destination isn't null

2022-06-21 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

In D126461#3597862 , @craig.topper 
wrote:

> `dst` in the patch description is not the pointer being loaded, it's the 
> pointer of where to store the new_vl. That is only thing being checked for 
> null in this patch.

I agree this is a possible interpretation, but it's also inconsistent with some 
of the other review discussion above.

@pcwang-thead Please consider clarifying the patch description a blocking item 
for future review or potential approval.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126461

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


[PATCH] D128012: [HLSL] Add ExternalSemaSource & vector alias

2022-06-21 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added a comment.

In D128012#3598307 , @Anastasia wrote:

> PCH have large in-memory size compared to the sources, but if it's not an 
> issue then it should be reasonable.

Yea... I think we may have some flexibility on memory size. Our current 
on-device source->dxil compiler is a dylib that runs in the user's process. My 
intent for the 2.0 implementation which will based on modern clang is to move 
the compiler out of process, which will give us more flexibility on memory 
usage, especially if the memory is read-only.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128012

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


[PATCH] D125669: Adding support for target in_reduction

2022-06-21 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

What about the description? Shall we still emit ` if(0)`?


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

https://reviews.llvm.org/D125669

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


[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

2022-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 438701.
sammccall added a comment.
Herald added a subscriber: mgrang.

update tests, trim dead code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp

Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -108,7 +108,7 @@
   llvm::outs() << G->dump();
 if (PrintGraph)
   llvm::outs() << clang::pseudo::LRGraph::buildLR0(*G).dumpForTests(*G);
-auto LRTable = clang::pseudo::LRTable::buildSLR(*G);
+auto LRTable = clang::pseudo::LRTable::buildLR0(*G);
 if (PrintTable)
   llvm::outs() << LRTable.dumpForTests(*G);
 if (PrintStatistics)
Index: clang-tools-extra/pseudo/test/lr-build-conflicts.test
===
--- clang-tools-extra/pseudo/test/lr-build-conflicts.test
+++ clang-tools-extra/pseudo/test/lr-build-conflicts.test
@@ -35,12 +35,10 @@
 # TABLE-NEXT: State 1
 # TABLE-NEXT: '-': shift state 3
 # TABLE-NEXT: State 2
-# TABLE-NEXT: 'EOF': reduce by rule 1 'expr := IDENTIFIER'
-# TABLE-NEXT: '-': reduce by rule 1 'expr := IDENTIFIER'
+# TABLE-NEXT: reduce by rule 1 'expr := IDENTIFIER'
 # TABLE-NEXT: State 3
 # TABLE-NEXT: 'IDENTIFIER': shift state 2
 # TABLE-NEXT: 'expr': go to state 4
 # TABLE-NEXT: State 4
-# TABLE-NEXT: 'EOF': reduce by rule 0 'expr := expr - expr'
+# TABLE-NEXT: reduce by rule 0 'expr := expr - expr'
 # TABLE-NEXT: '-': shift state 3
-# TABLE-NEXT: '-': reduce by rule 0 'expr := expr - expr'
Index: clang-tools-extra/pseudo/test/lr-build-basic.test
===
--- clang-tools-extra/pseudo/test/lr-build-basic.test
+++ clang-tools-extra/pseudo/test/lr-build-basic.test
@@ -23,6 +23,6 @@
 # TABLE-NEXT: 'id': go to state 2
 # TABLE-NEXT: State 1
 # TABLE-NEXT: State 2
-# TABLE-NEXT: 'EOF': reduce by rule 1 'expr := id'
+# TABLE-NEXT: reduce by rule 1 'expr := id'
 # TABLE-NEXT: State 3
-# TABLE-NEXT: 'EOF': reduce by rule 0 'id := IDENTIFIER'
+# TABLE-NEXT: reduce by rule 0 'id := IDENTIFIER'
Index: clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
===
--- clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
+++ clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
@@ -9,35 +9,12 @@
 #include "clang-pseudo/Grammar.h"
 #include "clang-pseudo/LRGraph.h"
 #include "clang-pseudo/LRTable.h"
-#include "clang/Basic/TokenKinds.h"
 #include 
 
-namespace llvm {
-template <> struct DenseMapInfo {
-  using Entry = clang::pseudo::LRTable::Entry;
-  static inline Entry getEmptyKey() {
-static Entry E{static_cast(-1), 0,
-   clang::pseudo::LRTable::Action::sentinel()};
-return E;
-  }
-  static inline Entry getTombstoneKey() {
-static Entry E{static_cast(-2), 0,
-   clang::pseudo::LRTable::Action::sentinel()};
-return E;
-  }
-  static unsigned getHashValue(const Entry &I) {
-return llvm::hash_combine(I.State, I.Symbol, I.Act.opaque());
-  }
-  static bool isEqual(const Entry &LHS, const Entry &RHS) {
-return LHS.State == RHS.State && LHS.Symbol == RHS.Symbol &&
-   LHS.Act == RHS.Act;
-  }
-};
-} // namespace llvm
-
 namespace clang {
 namespace pseudo {
 
+#if 0
 class LRTable::Builder {
 public:
   Builder(llvm::ArrayRef> StartStates)
@@ -45,48 +22,6 @@
 
   bool insert(Entry E) { return Entries.insert(std::move(E)).second; }
   LRTable build(const GrammarTable >, unsigned NumStates) && {
-// E.g. given the following parsing table with 3 states and 3 terminals:
-//
-//ab c
-// +---++---+-+
-// |state0 || s0,r0 | |
-// |state1 | acc|   | |
-// |state2 ||  r1   | |
-// +---++---+-+
-//
-// The final LRTable:
-//  - StateOffset: [s0] = 0, [s1] = 2, [s2] = 3, [sentinel] = 4
-//  - Symbols: [ b,   b,   a,  b]
-//Actions: [ s0, r0, acc, r1]
-//   ~~ range for state 0
-//    range for state 1
-//~~ range for state 2
-// First step, we sort all entries by (State, Symbol,

[PATCH] D128112: [NFC] clang: Implement tests for PR56099

2022-06-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 438702.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128112

Files:
  clang/test/AST/ast-dump-template-decls.cpp


Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -127,3 +127,38 @@
 // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent depth 0 index 0
 } // namespace PR55886
+
+namespace PR56099 {
+template  struct Y;
+template  using Z = Y;
+template  struct foo {
+  template  using bind = Z;
+};
+using t1 = foo::bind;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+};
+using t2 = D::B;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar 
alias B
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int 
(*)(char, short))' cdecl
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+} // namespace PR56099


Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -127,3 +127,38 @@
 // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent depth 0 index 0
 } // namespace PR55886
+
+namespace PR56099 {
+template  struct Y;
+template  using Z = Y;
+template  struct foo {
+  template  using bind = Z;
+};
+using t1 = foo::bind;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+};
+using t2 = D::B;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar alias B
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int (*)(char, short))' cdecl
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth

[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

2022-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 438703.
sammccall added a comment.

remove first/follow, also dead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp

Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -142,66 +142,6 @@
  "Unknown attribute 'unknown'"));
 }
 
-TEST_F(GrammarTest, FirstAndFollowSets) {
-  build(
-  R"bnf(
-_ := expr
-expr := expr - term
-expr := term
-term := IDENTIFIER
-term := ( expr )
-)bnf");
-  ASSERT_TRUE(Diags.empty());
-  auto ToPairs = [](std::vector> Input) {
-std::vector>> Sets;
-for (SymbolID ID = 0; ID < Input.size(); ++ID)
-  Sets.emplace_back(ID, std::move(Input[ID]));
-return Sets;
-  };
-
-  EXPECT_THAT(
-  ToPairs(firstSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("IDENTIFIER"), id("("))),
-  Pair(id("expr"), UnorderedElementsAre(id("IDENTIFIER"), id("("))),
-  Pair(id("term"), UnorderedElementsAre(id("IDENTIFIER"), id("(");
-  EXPECT_THAT(
-  ToPairs(followSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("EOF"))),
-  Pair(id("expr"), UnorderedElementsAre(id("-"), id("EOF"), id(")"))),
-  Pair(id("term"), UnorderedElementsAre(id("-"), id("EOF"), id(")");
-
-  build(R"bnf(
-# A simplfied C++ decl-specifier-seq.
-_ := decl-specifier-seq
-decl-specifier-seq := decl-specifier decl-specifier-seq
-decl-specifier-seq := decl-specifier
-decl-specifier := simple-type-specifier
-decl-specifier := INLINE
-simple-type-specifier := INT
-   )bnf");
-  ASSERT_TRUE(Diags.empty());
-  EXPECT_THAT(
-  ToPairs(firstSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("INLINE"), id("INT"))),
-  Pair(id("decl-specifier-seq"),
-   UnorderedElementsAre(id("INLINE"), id("INT"))),
-  Pair(id("simple-type-specifier"), UnorderedElementsAre(id("INT"))),
-  Pair(id("decl-specifier"),
-   UnorderedElementsAre(id("INLINE"), id("INT");
-  EXPECT_THAT(
-  ToPairs(followSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("EOF"))),
-  Pair(id("decl-specifier-seq"), UnorderedElementsAre(id("EOF"))),
-  Pair(id("decl-specifier"),
-   UnorderedElementsAre(id("INLINE"), id("INT"), id("EOF"))),
-  Pair(id("simple-type-specifier"),
-   UnorderedElementsAre(id("INLINE"), id("INT"), id("EOF");
-}
-
 } // namespace
 } // namespace pseudo
 } // namespace clang
Index: clang-tools-extra/pseudo/tool/ClangPseudo.cpp
===
--- clang-tools-extra/pseudo/tool/ClangPseudo.cpp
+++ clang-tools-extra/pseudo/tool/ClangPseudo.cpp
@@ -108,7 +108,7 @@
   llvm::outs() << G->dump();
 if (PrintGraph)
   llvm::outs() << clang::pseudo::LRGraph::buildLR0(*G).dumpForTests(*G);
-auto LRTable = clang::pseudo::LRTable::buildSLR(*G);
+auto LRTable = clang::pseudo::LRTable::buildLR0(*G);
 if (PrintTable)
   llvm::outs() << LRTable.dumpForTests(*G);
 if (PrintStatistics)
Index: clang-tools-extra/pseudo/test/lr-build-conflicts.test
===
--- clang-tools-extra/pseudo/test/lr-build-conflicts.test
+++ clang-tools-extra/pseudo/test/lr-build-conflicts.test
@@ -35,12 +35,10 @@
 # TABLE-NEXT: State 1
 # TABLE-NEXT: '-': shift state 3
 # TABLE-NEXT: State 2
-# TABLE-NEXT: 'EOF': reduce by rule 1 'expr := IDENTIFIER'
-# TABLE-NEXT: '-': reduce by rule 1 'expr := IDENTIFIER'
+# TABLE-NEXT: reduce by rule 1 'expr := IDENTIFIER'
 # TABLE-NEXT: State 3
 # TABLE-NEXT: 'IDENTIFIER': shift state 2
 # TABLE-NEXT: 'expr': go to state 4
 # TABLE-NEXT: State 4
-# TABLE-NEXT: 'EOF': reduce by rule 0 'expr := expr - expr'
+# TABLE-NEXT: reduce by rule 0 'expr := expr - expr'
 # TABLE-NEXT: '-': shift state 3
-# TABLE-NEXT: '-': reduce by rule 0 'expr := expr - expr'
Index: cla

[PATCH] D128072: [clang-tidy] Organize test files into subdirectories by module (NFC)

2022-06-21 Thread Richard via Phabricator via cfe-commits
LegalizeAdulthood added a comment.

In D128072#3598634 , @aaron.ballman 
wrote:

> This sounds like a sensible direction to me. I spot-checked the changes and 
> they all seem reasonable. Giving my LG, but please wait a bit before landing 
> in case someone else has the chance to spot check as well.

Testing was:

- check-clang-extra passed
- add_new_check.py added the boiler plate test code in the correct place


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128072

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


[PATCH] D127142: [HIP] Link with clang_rt.builtins

2022-06-21 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 438709.
yaxunl added a comment.

add -unwindlib=libgcc by default for --hip-link since -rtlib=compiler-rt needs 
it


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

https://reviews.llvm.org/D127142

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/hip-runtime-libs-linux.hip
  clang/test/Driver/hip-runtime-libs-msvc.hip

Index: clang/test/Driver/hip-runtime-libs-msvc.hip
===
--- clang/test/Driver/hip-runtime-libs-msvc.hip
+++ clang/test/Driver/hip-runtime-libs-msvc.hip
@@ -2,9 +2,16 @@
 
 // RUN:  touch %t.o
 
+// Get compiler-rt library full path.
+// RUN: %clang -target x86_64-pc-windows-msvc -rtlib=compiler-rt \
+// RUN:   -print-libgcc-file-name >%t.1
+
 // Test HIP runtime lib args specified by --rocm-path.
 // RUN: %clang -### --hip-link -target x86_64-pc-windows-msvc \
-// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
-// RUN:   | FileCheck %s
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o >%t.2 2>&1
+// RUN: cat %t.1 %t.2 | FileCheck %s
 
+// CHECK: [[COMPILER_RT:.*clang_rt\.builtins.*]]
 // CHECK: "-libpath:{{.*Inputs.*rocm.*lib}}" "amdhip64.lib"
+// CHECK-SAME: "[[COMPILER_RT]]"
+// CHECK-NOT: "-lgcc_{{s|eh}}"
Index: clang/test/Driver/hip-runtime-libs-linux.hip
===
--- clang/test/Driver/hip-runtime-libs-linux.hip
+++ clang/test/Driver/hip-runtime-libs-linux.hip
@@ -2,15 +2,19 @@
 
 // RUN:  touch %t.o
 
+// Get compiler-rt library full path.
+// RUN: %clang -target x86_64-linux-gnu -rtlib=compiler-rt \
+// RUN:   -print-libgcc-file-name >%t.1
+
 // Test HIP runtime lib args specified by --rocm-path.
 // RUN: %clang -### --hip-link -target x86_64-linux-gnu \
-// RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
-// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+// RUN:   --rocm-path=%S/Inputs/rocm %t.o >%t.2 2>&1
+// RUN: cat %t.1 %t.2 | FileCheck -check-prefixes=ROCM-PATH,COMMON %s
 
 // Test HIP runtime lib args specified by environment variable ROCM_PATH.
 // RUN: env ROCM_PATH=%S/Inputs/rocm %clang -### --hip-link \
-// RUN:   -target x86_64-linux-gnu %t.o 2>&1 \
-// RUN:   | FileCheck -check-prefixes=ROCM-PATH %s
+// RUN:   -target x86_64-linux-gnu %t.o >%t.2 2>&1
+// RUN: cat %t.1 %t.2 | FileCheck -check-prefixes=ROCM-PATH,COMMON %s
 
 // Test detecting latest /opt/rocm-{release} directory.
 // RUN: rm -rf %T/opt
@@ -18,26 +22,31 @@
 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.9.0-1234
 // RUN: cp -r %S/Inputs/rocm %T/opt/rocm-3.10.0
 // RUN: %clang -### --hip-link -target x86_64-linux-gnu \
-// RUN:   --sysroot=%T %t.o 2>&1 \
-// RUN:   | FileCheck -check-prefixes=ROCM-REL %s
+// RUN:   --sysroot=%T %t.o >%t.2 2>&1
+// RUN: cat %t.1 %t.2 | FileCheck -check-prefixes=ROCM-REL,COMMON %s
 
 // Test HIP runtime lib is not linked without --hip-link.
 // RUN: %clang -### -target x86_64-linux-gnu \
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefixes=NOHIPRT %s
 
-// Test HIP runtime lib is not linked with -nostdlib.
-// RUN: %clang -### --hip-link -nostdlib -target x86_64-linux-gnu \
+// Test HIP runtime lib is not linked with -rtlib=gcc.
+// RUN: %clang -### --hip-link -rtlib=gcc -target x86_64-linux-gnu \
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
-// RUN:   | FileCheck -check-prefixes=NOHIPRT %s
+// RUN:   | FileCheck -check-prefixes=LIBGCC %s
 
 // Test HIP runtime lib is not linked with -no-hip-rt.
 // RUN: %clang -### --hip-link -no-hip-rt -target x86_64-linux-gnu \
 // RUN:   --rocm-path=%S/Inputs/rocm %t.o 2>&1 \
 // RUN:   | FileCheck -check-prefixes=NOHIPRT %s
 
+// COMMON: [[COMPILER_RT:/.*/libclang_rt\.builtins.*]]
 // ROCM-PATH: "-L[[HIPRT:.*/Inputs/rocm/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
 // ROCM-REL: "-L[[HIPRT:.*/opt/rocm-3.10.0/lib]]" "-rpath" "[[HIPRT]]" "-lamdhip64"
+// COMMON-SAME: "[[COMPILER_RT]]"
+// COMMON-SAME: "-lgcc_{{s|eh}}"
+
 // NOHIPRT-NOT: "-L{{.*/Inputs/rocm/lib}}"
 // NOHIPRT-NOT: "-rpath" "{{.*/Inputs/rocm/lib}}"
 // NOHIPRT-NOT: "-lamdhip64"
+// LIBGCC-NOT: "{{/[^"]*clang_rt\.builtins[^"]*}}"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -832,8 +832,12 @@
   if (runtimeLibType)
 return *runtimeLibType;
 
+  // HIP needs compier-rt for _Float16 conversion functions.
   const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
-  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
+  StringRef LibName =
+  A ? A->getValue()
+: (Args.hasArg(options::OPT_hip_link) ? "compiler-rt"
+  : CLANG_DEFAULT_RTLIB);
 
   // Only use "platform" in tests to override CLANG_DEFAULT_RTLIB!
   if (LibName == "compiler-rt")
@@ -858,8 +862,14 @@
   if (unwindLibType)
 return *unwindLibType;
 
+  // HIP needs compiler-rt for _Float16 conversion function

[PATCH] D127856: [clangd] Support multiline semantic tokens

2022-06-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 438711.
kadircet marked 4 inline comments as done.
kadircet added a comment.

Get rid of the copy in common case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127856

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -944,7 +944,7 @@
   )");
   Tokens.front().Modifiers |= unsigned(HighlightingModifier::Declaration);
   Tokens.front().Modifiers |= unsigned(HighlightingModifier::Readonly);
-  auto Results = toSemanticTokens(Tokens);
+  auto Results = toSemanticTokens(Tokens, /*Code=*/"");
 
   ASSERT_THAT(Results, SizeIs(3));
   EXPECT_EQ(Results[0].tokenType, unsigned(HighlightingKind::Variable));
@@ -972,13 +972,15 @@
   auto Before = toSemanticTokens(tokens(R"(
 [[foo]] [[bar]] [[baz]]
 [[one]] [[two]] [[three]]
-  )"));
+  )"),
+ /*Code=*/"");
   EXPECT_THAT(diffTokens(Before, Before), IsEmpty());
 
   auto After = toSemanticTokens(tokens(R"(
 [[foo]] [[hello]] [[world]] [[baz]]
 [[one]] [[two]] [[three]]
-  )"));
+  )"),
+/*Code=*/"");
 
   // Replace [bar, baz] with [hello, world, baz]
   auto Diff = diffTokens(Before, After);
@@ -1000,6 +1002,30 @@
   EXPECT_EQ(3u, Diff.front().tokens[2].length);
 }
 
+TEST(SemanticHighlighting, MultilineTokens) {
+  llvm::StringRef AnnotatedCode = R"cpp(
+  [[fo
+o
+o]] [[bar]])cpp";
+  auto Toks = toSemanticTokens(tokens(AnnotatedCode),
+   Annotations(AnnotatedCode).code());
+  ASSERT_THAT(Toks, SizeIs(4));
+  // foo
+  EXPECT_EQ(Toks[0].deltaLine, 1u);
+  EXPECT_EQ(Toks[0].deltaStart, 2u);
+  EXPECT_EQ(Toks[0].length, 2u);
+  EXPECT_EQ(Toks[1].deltaLine, 1u);
+  EXPECT_EQ(Toks[1].deltaStart, 0u);
+  EXPECT_EQ(Toks[1].length, 1u);
+  EXPECT_EQ(Toks[2].deltaLine, 1u);
+  EXPECT_EQ(Toks[2].deltaStart, 0u);
+  EXPECT_EQ(Toks[2].length, 1u);
+
+  // bar
+  EXPECT_EQ(Toks[3].deltaLine, 0u);
+  EXPECT_EQ(Toks[3].deltaStart, 2u);
+  EXPECT_EQ(Toks[3].length, 3u);
+}
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -21,6 +21,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_SEMANTICHIGHLIGHTING_H
 
 #include "Protocol.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -101,7 +102,8 @@
 // main AST.
 std::vector getSemanticHighlightings(ParsedAST &AST);
 
-std::vector toSemanticTokens(llvm::ArrayRef);
+std::vector toSemanticTokens(llvm::ArrayRef,
+llvm::StringRef Code);
 llvm::StringRef toSemanticTokenType(HighlightingKind Kind);
 llvm::StringRef toSemanticTokenModifier(HighlightingModifier Modifier);
 std::vector diffTokens(llvm::ArrayRef Before,
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -30,7 +30,9 @@
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Casting.h"
+#include "llvm/Support/Error.h"
 #include 
 
 namespace clang {
@@ -918,33 +920,69 @@
 }
 
 std::vector
-toSemanticTokens(llvm::ArrayRef Tokens) {
+toSemanticTokens(llvm::ArrayRef Tokens,
+ llvm::StringRef Code) {
   assert(std::is_sorted(Tokens.begin(), Tokens.end()));
   std::vector Result;
+  // In case we split a HighlightingToken into multiple tokens (e.g. because it
+  // was spanning multiple lines), this tracks the last one. This prevents
+  // having a copy all the time.
+  HighlightingToken Scratch;
   const HighlightingToken *Last = nullptr;
   for (const HighlightingToken &Tok : Tokens) {
 Result.emplace_back();
-SemanticToken &Out = Result.back();
+SemanticToken *Out = &Result.back();
 // deltaStart/deltaLine are relative if possible.
 if (Last) {
-  assert(Tok.R.start.line >= Last->R.start.line);
-  Out.deltaLine = Tok.R.start.line - Last->R.start.line;
-  if (Out.deltaLine == 0) {
+  assert(Tok.R.start.line >= Last->R.end.line);
+  Out->deltaLine = Tok.R.start.line - Last->R.end.line;
+  if (Out->deltaLine == 0) {
 assert(Tok.R.start.character >=

[PATCH] D127856: [clangd] Support multiline semantic tokens

2022-06-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:947
+Out->tokenModifiers = Tok.Modifiers;
+Last = Tok;
 

sammccall wrote:
> this copy feels gratuitous, can we just use Tokens.back(), or do the copy in 
> the rare case?
unfortunately copy is needed, as the delta needs to be from start of the last 
token :/

changing the logic to do the copy only in the rare case by using a scratch 
element, LMK if you have better ideas here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127856

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


[PATCH] D127976: [IR] Move vector.insert/vector.extract out of experimental namespace

2022-06-21 Thread Bradley Smith via Phabricator via cfe-commits
bsmith updated this revision to Diff 438718.
bsmith added a comment.

- Clarify LangRef slightly to make it clearer that fixed types can be used
- Rebase on top of recent test changes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127976

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vget.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vlmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics-overloaded/vset.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vget.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlmul.c
  clang/test/CodeGen/RISCV/rvv-intrinsics/vset.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
  clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq-bfloat.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_dupq.c
  clang/test/CodeGen/aarch64-sve-vls-arith-ops.c
  clang/test/CodeGen/aarch64-sve-vls-bitwise-ops.c
  clang/test/CodeGen/aarch64-sve-vls-compare-ops.c
  clang/test/CodeGen/aarch64-sve-vls-shift-ops.c
  clang/test/CodeGen/aarch64-sve-vls-subscript-ops.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_dup_neonq.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_get_neonq.c
  
clang/test/CodeGen/aarch64_neon_sve_bridge_intrinsics/acle_neon_sve_bridge_set_neonq.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
  llvm/docs/LangRef.rst
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/BasicTTIImpl.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/include/llvm/IR/Intrinsics.td
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
  llvm/lib/Target/AArch64/SVEIntrinsicOpts.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/Analysis/CostModel/AArch64/sve-intrinsics.ll
  llvm/test/Analysis/CostModel/RISCV/rvv-shuffle.ll
  llvm/test/Bitcode/upgrade-vector-insert-extract-intrinsics.ll
  llvm/test/Bitcode/upgrade-vector-insert-extract-intrinsics.ll.bc
  llvm/test/CodeGen/AArch64/dag-combine-insert-subvector.ll
  llvm/test/CodeGen/AArch64/insert-subvector-res-legalization.ll
  llvm/test/CodeGen/AArch64/split-vector-insert.ll
  llvm/test/CodeGen/AArch64/sve-extract-fixed-from-scalable-vector.ll
  llvm/test/CodeGen/AArch64/sve-extract-fixed-vector.ll
  llvm/test/CodeGen/AArch64/sve-extract-scalable-vector.ll
  llvm/test/CodeGen/AArch64/sve-extract-vector-to-predicate-store.ll
  llvm/test/CodeGen/AArch64/sve-fixed-length-extract-subvector.ll
  llvm/test/CodeGen/AArch64/sve-insert-vector-to-predicate-load.ll
  llvm/test/CodeGen/AArch64/sve-insert-vector.ll
  llvm/test/CodeGen/AArch64/sve-no-typesize-warnings.ll
  llvm/test/CodeGen/AArch64/sve-punpklo-combine.ll
  llvm/test/CodeGen/AArch64/sve-vecreduce-fold.ll
  llvm/test/CodeGen/RISCV/rvv/extract-subvector.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-extract-subvector.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-insert-subvector.ll
  llvm/test/CodeGen/RISCV/rvv/insert-subvector.ll
  llvm/test/CodeGen/RISCV/rvv/mgather-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/mscatter-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/vpload.ll
  llvm/test/Transforms/InstCombine/AArch64/sve-intrinsic-opts-cmpne.ll
  llvm/test/Transforms/InstCombine/canonicalize-vector-extract.ll
  llvm/test/Transforms/InstCombine/canonicalize-vector-insert.ll
  llvm/test/Transforms/InstSimplify/extract-vector.ll
  llvm/test/Transforms/InstSimplify/insert-vector.ll
  llvm/test/Transforms/InterleavedAccess/AArch64/sve-interleaved-accesses.ll
  llvm/test/Verifier/extract-vector-mismatched-element-types.ll
  llvm/test/Verifier/insert-extract-intrinsics-invalid.ll
  llvm/test/Verifier/insert-vector-mismatched-element-types.ll

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


[PATCH] D128204: [clangd] Add fix-it for inserting IWYU pragma: keep

2022-06-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

as discussed offline I agree that we should have this, as no matter how hard we 
try there are going to be cases that we can't get right due to ADL/template 
instantiations or depending on 3rd party code that cannot be edited and also 
doesn't have relevant pragmas inside.

my hesitation about having them at this stage is, we won't be able to:

- get feedback around most of these issues as people will just put a pragma and 
be done with it.
- fix them going forward, even after implementation gets better, we won't be 
able to diagnose these headers and "falsely" issued pragmas will keep includes 
around.

Hence i'd like to hear a little bit more about what kind of false positives 
you're facing often enough to need this as an automated fix at this stage, to 
see if there's something we can do to improve the implementation first.




Comment at: clang-tools-extra/clangd/unittests/DiagnosticsTests.cpp:1795
   Annotations Test(R"cpp(
-$fix[[  $diag[[#include "unused.h"]]
+$fix[[  $diag[[#include "unused.h"]]$insert[[]]
 ]]

can you also have a test with an include that already has a trailing comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128204

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


[PATCH] D127270: [clang-format] Add space in placement new expression

2022-06-21 Thread omar ahmed via Phabricator via cfe-commits
omarahmed updated this revision to Diff 438719.
omarahmed added a comment.

Format files


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127270

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/tools/dump_format_style.py
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10130,6 +10130,42 @@
 "void delete(link p);\n",
 format("void new (link p);\n"
"void delete (link p);\n"));
+
+  FormatStyle AfterPlacementOperator = getLLVMStyle();
+  AfterPlacementOperator.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  EXPECT_EQ(
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Leave);
+  EXPECT_EQ("new (buf) int;", format("new (buf) int;", AfterPlacementOperator));
+  EXPECT_EQ("new(buf) int;", format("new(buf) int;", AfterPlacementOperator));
+
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Never;
+  verifyFormat("struct A {\n"
+   "  int *a;\n"
+   "  A(int *p) : a(new(p) int) {\n"
+   "new(p) int;\n"
+   "int *b = new(p) int;\n"
+   "int *c = new(p) int(3);\n"
+   "delete(b);\n"
+   "  }\n"
+   "};",
+   AfterPlacementOperator);
+  verifyFormat("void operator new(void *foo) ATTRIB;", AfterPlacementOperator);
+
+  AfterPlacementOperator.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Always;
+  verifyFormat("struct A {\n"
+   "  int *a;\n"
+   "  A(int *p) : a(new (p) int) {\n"
+   "new (p) int;\n"
+   "int *b = new (p) int;\n"
+   "int *c = new (p) int(3);\n"
+   "delete (b);\n"
+   "  }\n"
+   "};",
+   AfterPlacementOperator);
+  verifyFormat("void operator new(void *foo) ATTRIB;", AfterPlacementOperator);
 }
 
 TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
@@ -20308,6 +20344,24 @@
   SpaceBeforeParens,
   FormatStyle::SBPO_ControlStatementsExceptControlMacros);
 
+  Style.SpaceBeforeParens = FormatStyle::SBPO_Custom;
+  Style.SpaceBeforeParensOptions.AfterPlacementOperator =
+  FormatStyle::SpaceBeforeParensCustom::APO_Always;
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Never",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Never);
+
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Always",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Always);
+
+  CHECK_PARSE("SpaceBeforeParensOptions:\n"
+  "  AfterPlacementOperator: Leave",
+  SpaceBeforeParensOptions.AfterPlacementOperator,
+  FormatStyle::SpaceBeforeParensCustom::APO_Leave);
+
   Style.ColumnLimit = 123;
   FormatStyle BaseStyle = getLLVMStyle();
   CHECK_PARSE("BasedOnStyle: LLVM", ColumnLimit, BaseStyle.ColumnLimit);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3393,6 +3393,18 @@
 if (Left.is(TT_IfMacro))
   return Style.SpaceBeforeParensOptions.AfterIfMacros ||
  spaceRequiredBeforeParens(Right);
+if (Style.SpaceBeforeParens == FormatStyle::SBPO_Custom &&
+Left.isOneOf(tok::kw_new, tok::kw_delete) &&
+Right.isNot(TT_OverloadedOperatorLParen) &&
+!(Line.MightBeFunctionDecl && Left.is(TT_FunctionDeclarationName))) {
+  if (Style.SpaceBeforeParensOptions.AfterPlacementOperator ==
+  FormatStyle::SpaceBeforeParensCustom::APO_Always ||
+  (Style.SpaceBeforeParensOptions.AfterPlacementOperator ==
+   FormatStyle::SpaceBeforeParensCustom::APO_Leave &&
+   Right.hasWhitespaceBefore()))
+return true;
+  return false;
+}
 if (Line.Type == LT_ObjCDecl)
   return true;
 if (Left.is(tok::semi))
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -936,6 +936,7 @@
Spacing.AfterFunctionDeclarationName);
 IO.mapOptional("AfterIfMacros", Spacing.AfterIfMacros);
 IO.mapOptional("AfterOverloade

[PATCH] D127976: [IR] Move vector.insert/vector.extract out of experimental namespace

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



Comment at: llvm/docs/LangRef.rst:17289
 insert into. Conceptually, this can be used to build a scalable vector out of
-non-scalable vectors.
+non-scalable vectors, however this intrinsic can also be used on purely fixed
+types.

Now this comment makes it seems like you can't use it on purely scalable 
vectors.



Comment at: llvm/docs/LangRef.rst:17329
+specified. Conceptually, this can be used to decompose a scalable vector into
+non-scalable parts, however this intrinsic can also be used on purely fixed
+types.

Same here


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127976

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2022-06-21 Thread Paulo Matos via Phabricator via cfe-commits
pmatos updated this revision to Diff 438722.
pmatos added a comment.

rebase on top of D128282 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Builtins.def
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs-and-tables.c
  clang/test/SemaCXX/wasm-refs-and-tables.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp

Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -304,6 +304,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_ExternrefTy(LLVMContext &C) {
+  // opaque pointer in addrspace(10)
+  static PointerType *Ty = PointerType::get(C, 10);
+  return Ty;
+}
+
+Type *Type::getWasm_FuncrefTy(LLVMContext &C) {
+  // opaque pointer in addrspace(20)
+  static PointerType *Ty = PointerType::get(C, 20);
+  return Ty;
+}
+
 //===--===//
 //   IntegerType Implementation
 //===--===//
Index: llvm/lib/CodeGen/ValueTypes.cpp
===
--- llvm/lib/CodeGen/ValueTypes.cpp
+++ llvm/lib/CodeGen/ValueTypes.cpp
@@ -204,12 +204,8 @@
   case MVT::x86mmx:  return Type::getX86_MMXTy(Context);
   case MVT::x86amx:  return Type::getX86_AMXTy(Context);
   case MVT::i64x8:   return IntegerType::get(Context, 512);
-  case MVT::externref:
-// pointer to opaque struct in addrspace(10)
-return PointerType::get(StructType::create(Context), 10);
-  case MVT::funcref:
-// pointer to i8 addrspace(20)
-return PointerType::get(Type::getInt8Ty(Context), 20);
+  case MVT::externref: return Type::getWasm_ExternrefTy(Context);
+  case MVT::funcref: return Type::getWasm_FuncrefTy(Context);
   case MVT::v1i1:
 return FixedVectorType::get(Type::getInt1Ty(Context), 1);
   case MVT::v2i1:
Index: llvm/include/llvm/IR/Type.h
===
--- llvm/include/llvm/IR/Type.h
+++ llvm/include/llvm/IR/Type.h
@@ -468,6 +468,8 @@
   static PointerType *getInt16PtrTy(LLVMContext &C, unsigned AS = 0);
   static PointerType *getInt32PtrTy(LLVMContext &C, unsigned AS = 0);
   static PointerType *getInt64PtrTy(LLVMContext &C, unsigned AS = 0);
+  static Type *getWasm_ExternrefTy(LLVMContext &C);
+  static Type *getWasm_FuncrefTy(LLVMContext &C);
 
   /// Return a pointer to the current type. This is equivalent to
   /// PointerType::get(Foo, AddrSpace).
Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -1627,6 +1627,8 @@
 #include "clang/Basic/PPCTypes.def"
 #define RVV_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/RISCVVTypes.def"
+#define WASM_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
+#include "clang/Basic/WebAssemblyReferenceTypes.def"
 #define BUILTIN_TYPE(Id, SingletonId)
 #define SIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
 #define UNSIGNED_TYPE(Id, SingletonId) case BuiltinType::Id:
Index: clang/test/SemaCXX/wasm-refs-and-tables.cpp
===

[PATCH] D128112: [NFC] clang: Implement tests for PR56099

2022-06-21 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 438723.
mizvekov added a comment.

.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128112

Files:
  clang/test/AST/ast-dump-template-decls.cpp


Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -127,3 +127,38 @@
 // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent depth 0 index 0
 } // namespace PR55886
+
+namespace PR56099 {
+template  struct Y;
+template  using Z = Y;
+template  struct foo {
+  template  using bind = Z;
+};
+using t1 = foo::bind;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+};
+using t2 = D::B;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar 
alias B
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int 
(*)(char, short))' cdecl
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+} // namespace PR56099


Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -127,3 +127,38 @@
 // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent depth 0 index 0
 } // namespace PR55886
+
+namespace PR56099 {
+template  struct Y;
+template  using Z = Y;
+template  struct foo {
+  template  using bind = Z;
+};
+using t1 = foo::bind;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+};
+using t2 = D::B;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar alias B
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int (*)(char, short))' cdecl
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth

[PATCH] D127898: [clang][dataflow] Find unsafe locs after fixpoint

2022-06-21 Thread Sam Estep via Phabricator via cfe-commits
samestep added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp:66
+  SourceLocations Locs;
+  for (const CFGBlock *Block : Context->getCFG()) {
+// Skip blocks that were not evaluated.

xazax.hun wrote:
> While doing yet another iteration after we reached the fixed point is a valid 
> approach, many analyses have a monotonic property when it comes to emitting 
> diagnostics. In this case, when the analysis discovered that an optional 
> access is unsafe in one of the iterations I would not expect it to become 
> safe in subsequent iterations. In most of the cases this makes collecting 
> diagnostics eagerly a viable option and saves us from doing one more 
> traversal of the CFG. On the other hand, we need to be careful to not to emit 
> duplicate diagnostics.
> 
> I wonder whether, from a user point of view, not having to do one more 
> iteration is a more ergonomic interface. 
@xazax.hun Agreed, I don't think for this particular analysis there's a risk of 
diagnostics being prematurely added and then becoming invalid as the analysis 
progresses. However, the broader goal of this patch is to separate the 
information-gathering part of the analysis to the diagnostic-flagging part of 
the analysis, with the hope that we can maybe derive the former automatically 
while still allowing the latter to be written manually. It seems to me that it 
would be infeasible to automatically derive both.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127898

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


[PATCH] D126859: [clangd] Validate clang-tidy CheckOptions in clangd config

2022-06-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

I also agree with the typo correction verdict. In theory there'll be two cases:

- typo correction helps,  in which case it'll be obvious from the warning 
itself.
- typo correction doesn't help, because the option doesn't exist at all, we'll 
be just showing a random option. I don't think how this'll be helpful.

So I don't think this is providing much of a value compared to the extra logic.




Comment at: clang-tools-extra/clangd/TidyProvider.cpp:291
+  static void *call() {
+return new tidy::NamesAndOptions(tidy::getAllChecksAndOptions(false));
+  }

sammccall wrote:
> it seems strange that clang-tidy provides this API to query what checks are 
> linked in, but it constructs an expensive object every time rather than just 
> creating a static one once and returning a reference to it. (i.e. the 
> memoization is on the caller side)
> Should we fix that API instead?
+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126859

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


[PATCH] D128282: [WebAssembly] Update test to run it in opaque pointers mode

2022-06-21 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.

LGTM. Though it also looks like all the WEBASSEMBLY32/WEBASSEMBLY64 lines 
you're modifying match each other, so could be combined to single 
`WEBASSEMBLY:` lines. It might be worth doing that while you're touching this 
test?




Comment at: clang/test/CodeGen/builtins-wasm.c:2
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128 
-target-feature +relaxed-simd -target-feature +nontrapping-fptoint 
-target-feature +exception-handling -target-feature +bulk-memory 
-target-feature +atomics -flax-vector-conversions=none -O3 -emit-llvm -o - %s | 
FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown  -target-feature +simd128 
-target-feature +relaxed-simd -target-feature +nontrapping-fptoint 
-target-feature +exception-handling -target-feature +bulk-memory 
-target-feature +atomics -flax-vector-conversions=none -O3 -emit-llvm -o - %s | 
FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: not %clang_cc1 -triple wasm64-unknown-unknown -target-feature 
+nontrapping-fptoint -target-feature +exception-handling -target-feature 
+bulk-memory -target-feature +atomics -flax-vector-conversions=none -O3 
-emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefixes MISSING-SIMD

Nit: whitespace.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128282

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


[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

2022-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 438727.
sammccall added a comment.

update test/binaries, tests now all pass


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp
  clang-tools-extra/pseudo/unittests/LRTableTest.cpp

Index: clang-tools-extra/pseudo/unittests/LRTableTest.cpp
===
--- clang-tools-extra/pseudo/unittests/LRTableTest.cpp
+++ clang-tools-extra/pseudo/unittests/LRTableTest.cpp
@@ -17,36 +17,33 @@
 namespace pseudo {
 namespace {
 
+using testing::ElementsAre;
 using testing::IsEmpty;
 using testing::UnorderedElementsAre;
-using Action = LRTable::Action;
 
 TEST(LRTable, Builder) {
-  GrammarTable GTable;
-
+  GrammarTable GT;
   //   eof   semi  ...
   // +---++---+---
   // |state0 || s0,r0 |...
   // |state1 | acc|   |...
   // |state2 ||  r1   |...
   // +---++---+---
-  std::vector Entries = {
-  {/* State */ 0, tokenSymbol(tok::semi), Action::shift(0)},
-  {/* State */ 0, tokenSymbol(tok::semi), Action::reduce(0)},
-  {/* State */ 1, tokenSymbol(tok::eof), Action::reduce(2)},
-  {/* State */ 2, tokenSymbol(tok::semi), Action::reduce(1)}};
-  GrammarTable GT;
-  LRTable T = LRTable::buildForTests(GT, Entries);
-  EXPECT_THAT(T.find(0, tokenSymbol(tok::eof)), IsEmpty());
-  EXPECT_THAT(T.find(0, tokenSymbol(tok::semi)),
-  UnorderedElementsAre(Action::shift(0), Action::reduce(0)));
-  EXPECT_THAT(T.find(1, tokenSymbol(tok::eof)),
-  UnorderedElementsAre(Action::reduce(2)));
-  EXPECT_THAT(T.find(1, tokenSymbol(tok::semi)), IsEmpty());
-  EXPECT_THAT(T.find(2, tokenSymbol(tok::semi)),
-  UnorderedElementsAre(Action::reduce(1)));
+  LRTable::Builder Builder;
+  Builder.StateCount = 3;
+  Builder.Shift[{/*State=*/0, tokenSymbol(tok::semi)}] = 0;
+  Builder.Reduce.push_back({/*State=*/0, /*Rule=*/0});
+  Builder.Reduce.push_back({/*State=*/1, /*Rule=*/2});
+  Builder.Reduce.push_back({/*State=*/2, /*Rule=*/1});
+  LRTable T = std::move(Builder).build();
+  EXPECT_EQ(T.getShiftState(0, tokenSymbol(tok::eof)), llvm::None);
+  EXPECT_EQ(T.getShiftState(0, tokenSymbol(tok::semi)), LRTable::StateID{0});
+  EXPECT_THAT(T.getReduceRules(0), ElementsAre(0));
+  EXPECT_EQ(T.getShiftState(1, tokenSymbol(tok::semi)), llvm::None);
+  EXPECT_THAT(T.getReduceRules(1), ElementsAre(2));
+  EXPECT_THAT(T.getReduceRules(2), ElementsAre(1));
   // Verify the behaivor for other non-available-actions terminals.
-  EXPECT_THAT(T.find(2, tokenSymbol(tok::kw_int)), IsEmpty());
+  EXPECT_EQ(T.getShiftState(2, tokenSymbol(tok::kw_int)), llvm::None);
 }
 
 } // namespace
Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -142,66 +142,6 @@
  "Unknown attribute 'unknown'"));
 }
 
-TEST_F(GrammarTest, FirstAndFollowSets) {
-  build(
-  R"bnf(
-_ := expr
-expr := expr - term
-expr := term
-term := IDENTIFIER
-term := ( expr )
-)bnf");
-  ASSERT_TRUE(Diags.empty());
-  auto ToPairs = [](std::vector> Input) {
-std::vector>> Sets;
-for (SymbolID ID = 0; ID < Input.size(); ++ID)
-  Sets.emplace_back(ID, std::move(Input[ID]));
-return Sets;
-  };
-
-  EXPECT_THAT(
-  ToPairs(firstSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("IDENTIFIER"), id("("))),
-  Pair(id("expr"), UnorderedElementsAre(id("IDENTIFIER"), id("("))),
-  Pair(id("term"), UnorderedElementsAre(id("IDENTIFIER"), id("(");
-  EXPECT_THAT(
-  ToPairs(followSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("EOF"))),
-  Pair(id("expr"), UnorderedElementsAre(id("-"), id("EOF"), id(")"))),
-  Pair(id("term"), UnorderedElementsAre(id("-"), id("EOF"), id(")");
-
-  build(R"bnf(
-# A simplfied C++ decl-specifier-seq.
-_ := decl-specifier-seq
-decl-specifier-seq := decl-specifier decl-specifier-seq
-decl-specifier-se

[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

2022-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 438732.
sammccall added a comment.

tweak & document fast-path


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/Grammar.h
  clang-tools-extra/pseudo/include/clang-pseudo/LRTable.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp
  clang-tools-extra/pseudo/unittests/LRTableTest.cpp

Index: clang-tools-extra/pseudo/unittests/LRTableTest.cpp
===
--- clang-tools-extra/pseudo/unittests/LRTableTest.cpp
+++ clang-tools-extra/pseudo/unittests/LRTableTest.cpp
@@ -17,36 +17,33 @@
 namespace pseudo {
 namespace {
 
+using testing::ElementsAre;
 using testing::IsEmpty;
 using testing::UnorderedElementsAre;
-using Action = LRTable::Action;
 
 TEST(LRTable, Builder) {
-  GrammarTable GTable;
-
+  GrammarTable GT;
   //   eof   semi  ...
   // +---++---+---
   // |state0 || s0,r0 |...
   // |state1 | acc|   |...
   // |state2 ||  r1   |...
   // +---++---+---
-  std::vector Entries = {
-  {/* State */ 0, tokenSymbol(tok::semi), Action::shift(0)},
-  {/* State */ 0, tokenSymbol(tok::semi), Action::reduce(0)},
-  {/* State */ 1, tokenSymbol(tok::eof), Action::reduce(2)},
-  {/* State */ 2, tokenSymbol(tok::semi), Action::reduce(1)}};
-  GrammarTable GT;
-  LRTable T = LRTable::buildForTests(GT, Entries);
-  EXPECT_THAT(T.find(0, tokenSymbol(tok::eof)), IsEmpty());
-  EXPECT_THAT(T.find(0, tokenSymbol(tok::semi)),
-  UnorderedElementsAre(Action::shift(0), Action::reduce(0)));
-  EXPECT_THAT(T.find(1, tokenSymbol(tok::eof)),
-  UnorderedElementsAre(Action::reduce(2)));
-  EXPECT_THAT(T.find(1, tokenSymbol(tok::semi)), IsEmpty());
-  EXPECT_THAT(T.find(2, tokenSymbol(tok::semi)),
-  UnorderedElementsAre(Action::reduce(1)));
+  LRTable::Builder Builder;
+  Builder.StateCount = 3;
+  Builder.Shift[{/*State=*/0, tokenSymbol(tok::semi)}] = 0;
+  Builder.Reduce.push_back({/*State=*/0, /*Rule=*/0});
+  Builder.Reduce.push_back({/*State=*/1, /*Rule=*/2});
+  Builder.Reduce.push_back({/*State=*/2, /*Rule=*/1});
+  LRTable T = std::move(Builder).build();
+  EXPECT_EQ(T.getShiftState(0, tokenSymbol(tok::eof)), llvm::None);
+  EXPECT_EQ(T.getShiftState(0, tokenSymbol(tok::semi)), LRTable::StateID{0});
+  EXPECT_THAT(T.getReduceRules(0), ElementsAre(0));
+  EXPECT_EQ(T.getShiftState(1, tokenSymbol(tok::semi)), llvm::None);
+  EXPECT_THAT(T.getReduceRules(1), ElementsAre(2));
+  EXPECT_THAT(T.getReduceRules(2), ElementsAre(1));
   // Verify the behaivor for other non-available-actions terminals.
-  EXPECT_THAT(T.find(2, tokenSymbol(tok::kw_int)), IsEmpty());
+  EXPECT_EQ(T.getShiftState(2, tokenSymbol(tok::kw_int)), llvm::None);
 }
 
 } // namespace
Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -142,66 +142,6 @@
  "Unknown attribute 'unknown'"));
 }
 
-TEST_F(GrammarTest, FirstAndFollowSets) {
-  build(
-  R"bnf(
-_ := expr
-expr := expr - term
-expr := term
-term := IDENTIFIER
-term := ( expr )
-)bnf");
-  ASSERT_TRUE(Diags.empty());
-  auto ToPairs = [](std::vector> Input) {
-std::vector>> Sets;
-for (SymbolID ID = 0; ID < Input.size(); ++ID)
-  Sets.emplace_back(ID, std::move(Input[ID]));
-return Sets;
-  };
-
-  EXPECT_THAT(
-  ToPairs(firstSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("IDENTIFIER"), id("("))),
-  Pair(id("expr"), UnorderedElementsAre(id("IDENTIFIER"), id("("))),
-  Pair(id("term"), UnorderedElementsAre(id("IDENTIFIER"), id("(");
-  EXPECT_THAT(
-  ToPairs(followSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("EOF"))),
-  Pair(id("expr"), UnorderedElementsAre(id("-"), id("EOF"), id(")"))),
-  Pair(id("term"), UnorderedElementsAre(id("-"), id("EOF"), id(")");
-
-  build(R"bnf(
-# A simplfied C++ decl-specifier-seq.
-_ := decl-specifier-seq
-decl-specifier-seq := decl-specifier decl-specifier-seq
-decl-specifier-seq := decl-spec

[PATCH] D127802: [HLSL] Support HLSL vector initializers

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127802

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


[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

2022-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 438735.
sammccall added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTable.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang-tools-extra/pseudo/test/lr-build-basic.test
  clang-tools-extra/pseudo/test/lr-build-conflicts.test
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp
  clang-tools-extra/pseudo/unittests/GrammarTest.cpp
  clang-tools-extra/pseudo/unittests/LRTableTest.cpp

Index: clang-tools-extra/pseudo/unittests/LRTableTest.cpp
===
--- clang-tools-extra/pseudo/unittests/LRTableTest.cpp
+++ clang-tools-extra/pseudo/unittests/LRTableTest.cpp
@@ -17,36 +17,33 @@
 namespace pseudo {
 namespace {
 
+using testing::ElementsAre;
 using testing::IsEmpty;
 using testing::UnorderedElementsAre;
-using Action = LRTable::Action;
 
 TEST(LRTable, Builder) {
-  GrammarTable GTable;
-
+  GrammarTable GT;
   //   eof   semi  ...
   // +---++---+---
   // |state0 || s0,r0 |...
   // |state1 | acc|   |...
   // |state2 ||  r1   |...
   // +---++---+---
-  std::vector Entries = {
-  {/* State */ 0, tokenSymbol(tok::semi), Action::shift(0)},
-  {/* State */ 0, tokenSymbol(tok::semi), Action::reduce(0)},
-  {/* State */ 1, tokenSymbol(tok::eof), Action::reduce(2)},
-  {/* State */ 2, tokenSymbol(tok::semi), Action::reduce(1)}};
-  GrammarTable GT;
-  LRTable T = LRTable::buildForTests(GT, Entries);
-  EXPECT_THAT(T.find(0, tokenSymbol(tok::eof)), IsEmpty());
-  EXPECT_THAT(T.find(0, tokenSymbol(tok::semi)),
-  UnorderedElementsAre(Action::shift(0), Action::reduce(0)));
-  EXPECT_THAT(T.find(1, tokenSymbol(tok::eof)),
-  UnorderedElementsAre(Action::reduce(2)));
-  EXPECT_THAT(T.find(1, tokenSymbol(tok::semi)), IsEmpty());
-  EXPECT_THAT(T.find(2, tokenSymbol(tok::semi)),
-  UnorderedElementsAre(Action::reduce(1)));
+  LRTable::Builder Builder;
+  Builder.StateCount = 3;
+  Builder.Shift[{/*State=*/0, tokenSymbol(tok::semi)}] = 0;
+  Builder.Reduce.push_back({/*State=*/0, /*Rule=*/0});
+  Builder.Reduce.push_back({/*State=*/1, /*Rule=*/2});
+  Builder.Reduce.push_back({/*State=*/2, /*Rule=*/1});
+  LRTable T = std::move(Builder).build();
+  EXPECT_EQ(T.getShiftState(0, tokenSymbol(tok::eof)), llvm::None);
+  EXPECT_EQ(T.getShiftState(0, tokenSymbol(tok::semi)), LRTable::StateID{0});
+  EXPECT_THAT(T.getReduceRules(0), ElementsAre(0));
+  EXPECT_EQ(T.getShiftState(1, tokenSymbol(tok::semi)), llvm::None);
+  EXPECT_THAT(T.getReduceRules(1), ElementsAre(2));
+  EXPECT_THAT(T.getReduceRules(2), ElementsAre(1));
   // Verify the behaivor for other non-available-actions terminals.
-  EXPECT_THAT(T.find(2, tokenSymbol(tok::kw_int)), IsEmpty());
+  EXPECT_EQ(T.getShiftState(2, tokenSymbol(tok::kw_int)), llvm::None);
 }
 
 } // namespace
Index: clang-tools-extra/pseudo/unittests/GrammarTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GrammarTest.cpp
+++ clang-tools-extra/pseudo/unittests/GrammarTest.cpp
@@ -142,66 +142,6 @@
  "Unknown attribute 'unknown'"));
 }
 
-TEST_F(GrammarTest, FirstAndFollowSets) {
-  build(
-  R"bnf(
-_ := expr
-expr := expr - term
-expr := term
-term := IDENTIFIER
-term := ( expr )
-)bnf");
-  ASSERT_TRUE(Diags.empty());
-  auto ToPairs = [](std::vector> Input) {
-std::vector>> Sets;
-for (SymbolID ID = 0; ID < Input.size(); ++ID)
-  Sets.emplace_back(ID, std::move(Input[ID]));
-return Sets;
-  };
-
-  EXPECT_THAT(
-  ToPairs(firstSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("IDENTIFIER"), id("("))),
-  Pair(id("expr"), UnorderedElementsAre(id("IDENTIFIER"), id("("))),
-  Pair(id("term"), UnorderedElementsAre(id("IDENTIFIER"), id("(");
-  EXPECT_THAT(
-  ToPairs(followSets(*G)),
-  UnorderedElementsAre(
-  Pair(id("_"), UnorderedElementsAre(id("EOF"))),
-  Pair(id("expr"), UnorderedElementsAre(id("-"), id("EOF"), id(")"))),
-  Pair(id("term"), UnorderedElementsAre(id("-"), id("EOF"), id(")");
-
-  build(R"bnf(
-# A simplfied C++ decl-specifier-seq.
-_ := decl-specifier-seq
-decl-specifier-seq := decl-specifier decl-specifier-seq
-decl-specifier-seq := decl-specifie

[PATCH] D127446: [clang-tidy] Add `-verify-config` command line argument

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

Thanks for this, it seems like an interesting feature!




Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:263
+Check the config files to ensure each check and
+option is recognised.
+)"),





Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:436
+llvm::WithColor::error(llvm::errs(), Source)
+<< "building CheckGlob '" << Cur << "' " << Error << "'\n";
+continue;

`Building check glob` instead?



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:450
+  llvm::raw_ostream &Output = llvm::WithColor::warning(llvm::errs(), 
Source)
+  << "Unknown Check '" << Cur << '\'';
+  llvm::StringRef Closest = closest(Cur, AllChecks);

`Unknown check` instead?



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:573
+llvm::WithColor::warning(llvm::errs(), OptionWithSource.second)
+<< "Unknown Check Option '" << Key << '\'';
+llvm::StringRef Closest = closest(Key, Valid.Options);

`Unknown check option` instead?



Comment at: 
clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp:12
+
+// CHECK-VERIFY-DAG: command-line option '-config': warning: Unknown Check 
'readability-else-after-ret'; did you mean 'readability-else-after-return'
+// CHECK-VERIFY-DAG: command-line option '-config': warning: Unknown Check 
Option 'modernize-lop-convert.UseCxx20ReverseRanges'; did you mean 
'modernize-loop-convert.UseCxx20ReverseRanges'

It's unfortunate that `warning: ` appears in the middle of the diagnostic as 
opposed to at the start. I wonder if this can be reworked to say: `warning: 
Unknown check 'whatever'; did you mean 'whatever'? [-verify-config]` or 
something?

Also, no test coverage for the error case and for the unknown check case where 
there's no closest match worth talking about.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127446

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


[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

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

Current numbers from my machine:

Parse time (`ClangPseudoBenchmark SemaCodeComplete.cpp 
--benchmark_filter=glrParse --benchmark_min_time=10`)

  old: glrParse167033209 ns167026892 ns   84 
bytes_per_second=2.24031M/s
  new: glrParse192320371 ns192305530 ns   72 
bytes_per_second=1.94582M/s

13% slowdown

LR Table  (`clang-pseudo -source SemaCodeComplete.cpp -strip-directives 
-print-statistics`):

  old:
  Statistics of the LR parsing table:
  number of states: 1480
  number of actions: 84136
  size of the table (bytes): 342564
  new: 
  Statistics of the LR parsing table:
  number of actions: shift=13741 reduce=1115 goto=14789
  size of the table (bytes): 401538

20% increase presumably due to sparseness of the shift/goto hashtables, i'll 
dig into it

Forest (`clang-pseudo -source SemaCodeComplete.cpp -strip-directives 
-print-statistics`):

  old:
  Forest bytes: 11055328 nodes: 651678
  GSS bytes: 20640 nodes: 574449
  new:
  Forest bytes: 16747864 nodes: 989322
  GSS bytes: 28832 nodes: 882916

52% increase due to incorrect reductions performed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

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


[clang] 271cc58 - [NFC] clang: Implement tests for PR56099

2022-06-21 Thread Matheus Izvekov via cfe-commits

Author: Matheus Izvekov
Date: 2022-06-21T18:35:17+02:00
New Revision: 271cc588054a90abf0d82f57af272c3db749ff56

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

LOG: [NFC] clang: Implement tests for PR56099

Signed-off-by: Matheus Izvekov 

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

Added: 


Modified: 
clang/test/AST/ast-dump-template-decls.cpp

Removed: 




diff  --git a/clang/test/AST/ast-dump-template-decls.cpp 
b/clang/test/AST/ast-dump-template-decls.cpp
index 616a96902eff4..13050eee7aeda 100644
--- a/clang/test/AST/ast-dump-template-decls.cpp
+++ b/clang/test/AST/ast-dump-template-decls.cpp
@@ -127,3 +127,38 @@ using type2 = typename C::type1;
 // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent depth 0 index 0
 } // namespace PR55886
+
+namespace PR56099 {
+template  struct Y;
+template  using Z = Y;
+template  struct foo {
+  template  using bind = Z;
+};
+using t1 = foo::bind;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+};
+using t2 = D::B;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar 
alias B
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int 
(*)(char, short))' cdecl
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+} // namespace PR56099



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


[PATCH] D128112: [NFC] clang: Implement tests for PR56099

2022-06-21 Thread Matheus Izvekov via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG271cc588054a: [NFC] clang: Implement tests for PR56099 
(authored by mizvekov).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128112

Files:
  clang/test/AST/ast-dump-template-decls.cpp


Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -127,3 +127,38 @@
 // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent depth 0 index 0
 } // namespace PR55886
+
+namespace PR56099 {
+template  struct Y;
+template  using Z = Y;
+template  struct foo {
+  template  using bind = Z;
+};
+using t1 = foo::bind;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+};
+using t2 = D::B;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar 
alias B
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int 
(*)(char, short))' cdecl
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (char, short)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent 
contains_unexpanded_pack depth 0 index 0 pack
+} // namespace PR56099


Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -127,3 +127,38 @@
 // CHECK-NEXT: SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
 // CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent depth 0 index 0
 } // namespace PR55886
+
+namespace PR56099 {
+template  struct Y;
+template  using Z = Y;
+template  struct foo {
+  template  using bind = Z;
+};
+using t1 = foo::bind;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'Bs' dependent contains_unexpanded_pack depth 0 index 0 pack
+
+template  struct D {
+  template  using B = int(int (*...p)(T, U));
+};
+using t2 = D::B;
+// CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar alias B
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int (*)(char, short))' cdecl
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'T' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar
+// CHECK-NEXT: TemplateTypeParmType 0x{{[^ ]*}} 'U' dependent contains_unexpanded_pack depth 0 index 0 pack
+// CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (c

[PATCH] D127923: [Diagnostics] Accept newline and format diag opts on first line

2022-06-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a subscriber: beanz.
aaron.ballman added a comment.

I'm a bit uncomfortable with this as we (at least currently) want to discourage 
non-terse diagnostics, and allowing newlines encourages longer diagnostics. 
There's an RFC kicking around about making more expressive diagnostics and so 
this discomfort may pass with time. (The only three uses of \n in our current 
Clang diagnostics are all driver diagnostics and all three of them are new for 
the HLSL stuff, wrong, and need to be reworded. CC @beanz to look into fixing 
up 
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/DiagnosticDriverKinds.td#L674).

Is there a reason the remarks can't use individual diagnostic emissions to 
simulate newlines? Or is this perhaps a demonstration that the remarks should 
not be using the diagnostic engine at all and should be emitting their output 
to a user-controllable stream (or file)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127923

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


[PATCH] D128097: [Clang] Fix compile time regression caused by D126061.

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

LGTM, great catch! That's not something I would have expected to be at the root 
of this performance issue. Thank you for the quick turnaround on the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128097

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


[PATCH] D127363: [Lex] Fix for char32_t literal truncation on 16 bit architectures

2022-06-21 Thread Tom Honermann via Phabricator via cfe-commits
tahonermann added inline comments.



Comment at: clang/lib/Lex/LiteralSupport.cpp:1600
 
-  llvm::APInt LitVal(PP.getTargetInfo().getIntWidth(), 0);
+  llvm::APInt LitVal(PP.getTargetInfo().getChar32Width(), 0);
 

sammccall wrote:
> tahonermann wrote:
> > I don't think this is quite right. For the code that follows this change to 
> > work as intended and issue the "Character constant too long for its type" 
> > diagnostic, the width needs to match that of `int`. This is required for 
> > multicharacter literals (they have type `int`) so that an appropriate 
> > diagnostic is issued for `'x'` for targets that have a 32-bit int (or 
> > for `'xxx'` for targets that have a 16-bit int)`.
> > 
> > Additionally, the type of a character constant in C is `int`.
> > 
> > I think what is needed is something like:
> >   unsigned BitWidth = getCharWidth(Kind, PP.getTargetInfo());
> >   if (IsMultiChar || !PP.getLangOpts().CPlusPlus)
> > BitWidth = PP.getTargetInfo().getIntWidth();
> >   llvm::APInt LitVal(BitWidth, 0);
> Thanks for pointing this out.
> 
> My reading of https://eel.is/c++draft/lex.ccon#2 is that a multi-char char 
> literal with a L/u8/u/U prefix is not `int` but the respective character 
> types, so the conditions here are even a little *more* complicated than you 
> suggest :-(
That is partially correct. Per [[ https://eel.is/c++draft/lex.ccon#1.sentence-3 
| (lex.ccon)p1 sentence 3 ]], multicharacter literals are not allowed to have a 
`u8`, `u`, or `U` prefix. A multicharacter literal with a `L` prefix does have 
a `wchar_t` type, but Clang does not currently support `L` prefixed 
multicharacter literals (multicharacter literals are conditionally-supported 
per [[ https://eel.is/c++draft/lex.ccon#1.sentence-4 | (lex.ccon)p1 sentence 4 
]])

All that being said, I would not be surprised if some additional conditions are 
needed. I don't recall where Clang diagnoses the ill-formed and unsupported 
cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127363

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


[PATCH] D127593: [clang] Fix trivially copyable for copy constructor and copy assignment operator

2022-06-21 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added subscribers: thakis, rsmith.
royjacobson added a comment.

In D127593#3598234 , @sberg wrote:

> In general, there's still a handful of `__has_trivial_*` calls across 
> Abseil's recent master branch `absl/meta/type_traits.h`.

Breaking abseil seems pretty bad indeed :/ @rsmith do you think we should 
revert this?
Pinging @thakis as well for chrome.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127593

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


[PATCH] D128288: [PowerPC] Fix signatures for vec_replace_unaligned builtin

2022-06-21 Thread Lei Huang via Phabricator via cfe-commits
lei created this revision.
lei added reviewers: amyk, quinnp, power-llvm-team.
Herald added subscribers: shchenz, nemanjai.
Herald added a project: All.
lei requested review of this revision.
Herald added a project: clang.

``vec_replace_unaligned`` is meant to return vuc to emphasize that elements
are being inserted on unnatural boundaries.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128288

Files:
  clang/lib/Headers/altivec.h
  clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
  clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c

Index: clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c
===
--- clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c
+++ clang/test/CodeGen/PowerPC/builtins-ppc-vec-ins-error.c
@@ -49,12 +49,12 @@
 }
 
 #elif defined(__TEST_UNALIGNED_UI)
-vector unsigned int test_vec_replace_unaligned_ui(void) {
+vector unsigned char test_vec_replace_unaligned_ui(void) {
   return vec_replace_unaligned(vuia, uia, 16); // expected-error {{byte number 16 is outside of the valid range [0, 12]}}
 }
 
 #else
-vector unsigned long long test_vec_replace_unaligned_ull(void) {
+vector unsigned char test_vec_replace_unaligned_ull(void) {
   return vec_replace_unaligned(vulla, ulla, 12); // expected-error {{byte number 12 is outside of the valid range [0, 8]}}
 }
 #endif
Index: clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
===
--- clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
+++ clang/test/CodeGen/PowerPC/builtins-ppc-p10vector.c
@@ -1183,8 +1183,7 @@
 // CHECK-BE-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
 // CHECK-BE-NEXT:[[TMP4:%.*]] = call <4 x i32> @llvm.ppc.altivec.vinsw(<4 x i32> [[TMP3]], i32 [[TMP2]], i32 6)
 // CHECK-BE-NEXT:[[TMP5:%.*]] = bitcast <4 x i32> [[TMP4]] to <16 x i8>
-// CHECK-BE-NEXT:[[TMP6:%.*]] = bitcast <16 x i8> [[TMP5]] to <4 x i32>
-// CHECK-BE-NEXT:ret <4 x i32> [[TMP6]]
+// CHECK-BE-NEXT:ret <16 x i8> [[TMP5]]
 //
 // CHECK-LE-LABEL: @test_vec_replace_unaligned_si(
 // CHECK-LE-NEXT:  entry:
@@ -1194,10 +1193,9 @@
 // CHECK-LE-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
 // CHECK-LE-NEXT:[[TMP4:%.*]] = call <4 x i32> @llvm.ppc.altivec.vinsw(<4 x i32> [[TMP3]], i32 [[TMP2]], i32 6)
 // CHECK-LE-NEXT:[[TMP5:%.*]] = bitcast <4 x i32> [[TMP4]] to <16 x i8>
-// CHECK-LE-NEXT:[[TMP6:%.*]] = bitcast <16 x i8> [[TMP5]] to <4 x i32>
-// CHECK-LE-NEXT:ret <4 x i32> [[TMP6]]
+// CHECK-LE-NEXT:ret <16 x i8> [[TMP5]]
 //
-vector signed int test_vec_replace_unaligned_si(void) {
+vector unsigned char test_vec_replace_unaligned_si(void) {
   return vec_replace_unaligned(vsia, sia, 6);
 }
 
@@ -1209,8 +1207,7 @@
 // CHECK-BE-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
 // CHECK-BE-NEXT:[[TMP4:%.*]] = call <4 x i32> @llvm.ppc.altivec.vinsw(<4 x i32> [[TMP3]], i32 [[TMP2]], i32 8)
 // CHECK-BE-NEXT:[[TMP5:%.*]] = bitcast <4 x i32> [[TMP4]] to <16 x i8>
-// CHECK-BE-NEXT:[[TMP6:%.*]] = bitcast <16 x i8> [[TMP5]] to <4 x i32>
-// CHECK-BE-NEXT:ret <4 x i32> [[TMP6]]
+// CHECK-BE-NEXT:ret <16 x i8> [[TMP5]]
 //
 // CHECK-LE-LABEL: @test_vec_replace_unaligned_ui(
 // CHECK-LE-NEXT:  entry:
@@ -1220,10 +1217,9 @@
 // CHECK-LE-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
 // CHECK-LE-NEXT:[[TMP4:%.*]] = call <4 x i32> @llvm.ppc.altivec.vinsw(<4 x i32> [[TMP3]], i32 [[TMP2]], i32 8)
 // CHECK-LE-NEXT:[[TMP5:%.*]] = bitcast <4 x i32> [[TMP4]] to <16 x i8>
-// CHECK-LE-NEXT:[[TMP6:%.*]] = bitcast <16 x i8> [[TMP5]] to <4 x i32>
-// CHECK-LE-NEXT:ret <4 x i32> [[TMP6]]
+// CHECK-LE-NEXT:ret <16 x i8> [[TMP5]]
 //
-vector unsigned int test_vec_replace_unaligned_ui(void) {
+vector unsigned char test_vec_replace_unaligned_ui(void) {
   return vec_replace_unaligned(vuia, uia, 8);
 }
 
@@ -1236,8 +1232,7 @@
 // CHECK-BE-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
 // CHECK-BE-NEXT:[[TMP4:%.*]] = call <4 x i32> @llvm.ppc.altivec.vinsw(<4 x i32> [[TMP3]], i32 [[CONV]], i32 12)
 // CHECK-BE-NEXT:[[TMP5:%.*]] = bitcast <4 x i32> [[TMP4]] to <16 x i8>
-// CHECK-BE-NEXT:[[TMP6:%.*]] = bitcast <16 x i8> [[TMP5]] to <4 x float>
-// CHECK-BE-NEXT:ret <4 x float> [[TMP6]]
+// CHECK-BE-NEXT:ret <16 x i8> [[TMP5]]
 //
 // CHECK-LE-LABEL: @test_vec_replace_unaligned_f(
 // CHECK-LE-NEXT:  entry:
@@ -1248,10 +1243,9 @@
 // CHECK-LE-NEXT:[[TMP3:%.*]] = bitcast <16 x i8> [[TMP1]] to <4 x i32>
 // CHECK-LE-NEXT:[[TMP4:%.*]] = call <4 x i32> @llvm.ppc.altivec.vinsw(<4 x i32> [[TMP3]], i32 [[CONV]], i32 12)
 // CHECK-LE-NEXT:[[TMP5:%.*]] = bitcast <4 x i32> [[TMP4]] to <16 x i8>
-// CHECK-LE-NEXT:[[TMP6:%.*]] = bitcast <16 x i8> [[TMP5]] to <4 x float>
-// CHECK-LE-NEXT:ret <4 x float> [[TMP6]]
+// CHECK-LE-NEXT:ret <16 x i8> [[T

[PATCH] D127812: [AArch64] Function multiversioning support added.

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

In D127812#3587223 , @ilinpv wrote:

> In D127812#3585249 , @erichkeane 
> wrote:
>
>> I'm concerned as to the design of this addition, I don't particularly 
>> appreciate the reasons for making 'target_clones' different, nor the purpose 
>> for adding a new attribute instead of using 'target' for what seems like 
>> exactly that?  IF the new spelling is THAT necessary, we perhaps don't need 
>> a whole new attribute for it either.
>
> Thank you for fair concern, "target_clones" for AArch64 has different format, 
> semantic, e.g. "default" is not required.  Therefore it diverges with X86 in 
> these parts.

Is it *necessary* that it diverges like this? (Is there some published 
standards document you're trying to conform to, is there an implementation 
difficulty with not diverging, something else?)

> "target" attribute has been already used and supported on AArch64 in a 
> different sense, like target("arm"), target("dotprod"), 
> target("branch-protection=bti"). The intention of creating new 
> "target_version" attribute is not to overlap with that. It also has different 
> format, mangling and semantic, e.g. treating function without attribute as 
> "default", and option to disable attribute droping function multi versions. 
> Do these explanations dispel your concern?

Do I understand correctly that AArch64 was using an attribute named `target` 
which does not behave like the attribute with the same name in GCC and Clang on 
other architectures, and now you'd like to introduce a new attribute which does 
behave like `target` but under a different name? If I have that correct, I 
don't think that's reasonable -- there's far too much possibility for confusion 
with that situation already, and adding a new attribute only increases the 
confusion. I'm not certain where the technical debt came from, but we shouldn't 
increase the burden on users here; I think `target` and `target_clones` should 
be made to work consistently across architectures if at all possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D127357: [pseudo] wip/prototype: use LR0 instead of SLR1 table

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

My current thinking is this is too much overhead to accept.

I'm going to try to take some of these ideas and apply them to our SLR(1) 
implementation, in particular store heads as nodes rather than pending actions.
I think it's worth accepting some slowdown for this, which the fast-path might 
pay for.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127357

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


[PATCH] D127976: [IR] Move vector.insert/vector.extract out of experimental namespace

2022-06-21 Thread Javier Setoain via Phabricator via cfe-commits
jsetoain added inline comments.



Comment at: llvm/docs/LangRef.rst:17292-17294
+``llvm.vector.insert`` can be used to insert a fixed-width vector into a
+scalable vector, but not the other way around.
 

To answer Craig's point, I don't think it was clear before that you could use 
this intrinsic with purely scalable vectors before, either. I believe the 
confusion comes from these clarifications. If instead of explicitly stating 
valid options you exclude the invalid ones, there's no room for ambiguity. 
Something like:

//"Scalable vectors can only be inserted/extracted into/out of other scalable 
vectors"//. Examples of all other possible combinations might help to nail down 
this point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127976

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


[PATCH] D128249: Adding clone_attrs attribute.

2022-06-21 Thread Puyan Lotfi via Phabricator via cfe-commits
plotfi added a comment.

Thanks for the feedback on corner cases @aaron.ballman, this will give me more 
concrete things to think about here.

At the moment I mainly thinking about a case:

  typedef int foo;
  enum : foo {} __attribute__((__clone_attrs_from__(foo)));

This is mostly because of how NS_OPTIONS enums on Darwin are defined through a 
macro.
We have been looking into breaking up how the typedef and the enum are defined 
for better behavior with C++.
The only challenge is that if an NS_OPTIONS macro is used to declare an enum 
and an attribute is specified either before or after, it will then only apply 
to either the typedef or the enum.

Thats the reason for a clone_attrs attribute.

I'll update description soon.

In D128249#3598507 , @aaron.ballman 
wrote:

> Can you add some details to the patch summary as to what problem you're 
> trying to solve with these changes?
>
> The idea itself has some interesting edge cases to think about:
>
>   [[some_attr]] void decl();
>   [[clone_attrs_from(decl)]] void other();
>   [[some_new_attr]] void decl();
>   
>   int main() {
> other(); // Does other see some_new_attr as well?
>   }
>
> or
>
>   [[hot]] void decl();
>   [[clone_attrs_from(decl), cold]] void other_decl(); // Do you properly 
> catch the mutual exclusions?
>
> or
>
>   [[some_attr_requiring_the_func_return_a_pointer]] int *decl();
>   [[clone_attrs_from(decl)]] int other(); // Do you properly catch the 
> semantic restrictions?
>
> or
>
>   struct [[some_struct_attr]] S { ... };
>   [[clone_attrs_from(S)]] void other(); // Do you properly catch the semantic 
> restrictions?
>
> or
>
>   [[some_attr]] void decl();
>   [[clone_attrs_from(decl)]] void decl(); // Uh oh, recursive.
>
> (I'm sure there are more situations I'm missing, but you get the idea about 
> needing to be very careful with the edge cases.)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128249

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


[clang] 9f499d9 - [HLSL] Support HLSL vector initializers

2022-06-21 Thread Chris Bieneman via cfe-commits

Author: Chris Bieneman
Date: 2022-06-21T12:33:42-05:00
New Revision: 9f499d9d73edfc818978c64eb24b8d2d34995d76

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

LOG: [HLSL] Support HLSL vector initializers

In HLSL vectors are ext_vectors in all respects except that they
support a constructor style syntax for initializing vectors. This
change adds a translation of vector constructor arguments into
initializer lists.

This supports two oddities of HLSL syntax:
(1) HLSL vectors support constructor syntax
(2) HLSL vectors are expanded to constituate components in constructors

Reviewed By: aaron.ballman

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

Added: 
clang/test/AST/HLSL/vector-constructors.hlsl
clang/test/SemaHLSL/BuiltIns/vector-constructors-erros.hlsl

Modified: 
clang/lib/Sema/SemaInit.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index c7e068046d7fd..f4cd45ad6c922 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -1696,7 +1696,7 @@ void InitListChecker::CheckVectorType(const 
InitializedEntity &Entity,
 return;
   }
 
-  if (!SemaRef.getLangOpts().OpenCL) {
+  if (!SemaRef.getLangOpts().OpenCL && !SemaRef.getLangOpts().HLSL ) {
 // If the initializing element is a vector, try to copy-initialize
 // instead of breaking it apart (which is doomed to failure anyway).
 Expr *Init = IList->getInit(Index);
@@ -1790,7 +1790,7 @@ void InitListChecker::CheckVectorType(const 
InitializedEntity &Entity,
   InitializedEntity ElementEntity =
 InitializedEntity::InitializeElement(SemaRef.Context, 0, Entity);
 
-  // OpenCL initializers allows vectors to be constructed from vectors.
+  // OpenCL and HLSL initializers allow vectors to be constructed from vectors.
   for (unsigned i = 0; i < maxElements; ++i) {
 // Don't attempt to go past the end of the init list
 if (Index >= IList->getNumInits())
@@ -1819,7 +1819,7 @@ void InitListChecker::CheckVectorType(const 
InitializedEntity &Entity,
 }
   }
 
-  // OpenCL requires all elements to be initialized.
+  // OpenCL and HLSL require all elements to be initialized.
   if (numEltsInit != maxElements) {
 if (!VerifyOnly)
   SemaRef.Diag(IList->getBeginLoc(),
@@ -5969,6 +5969,37 @@ void InitializationSequence::InitializeFrom(Sema &S,
 
   assert(Args.size() >= 1 && "Zero-argument case handled above");
 
+  // For HLSL ext vector types we allow list initialization behavior for C++
+  // constructor syntax. This is accomplished by converting initialization
+  // arguments an InitListExpr late.
+  if (S.getLangOpts().HLSL && DestType->isExtVectorType() &&
+  (SourceType.isNull() ||
+   !Context.hasSameUnqualifiedType(SourceType, DestType))) {
+
+llvm::SmallVector InitArgs;
+for (auto Arg : Args) {
+  if (Arg->getType()->isExtVectorType()) {
+const auto *VTy = Arg->getType()->castAs();
+unsigned Elm = VTy->getNumElements();
+for (unsigned Idx = 0; Idx < Elm; ++Idx) {
+  InitArgs.emplace_back(new (Context) ArraySubscriptExpr(
+  Arg,
+  IntegerLiteral::Create(
+  Context, llvm::APInt(Context.getIntWidth(Context.IntTy), 
Idx),
+  Context.IntTy, SourceLocation()),
+  VTy->getElementType(), Arg->getValueKind(), Arg->getObjectKind(),
+  SourceLocation()));
+}
+  } else
+InitArgs.emplace_back(Arg);
+}
+InitListExpr *ILE = new (Context) InitListExpr(
+S.getASTContext(), SourceLocation(), InitArgs, SourceLocation());
+Args[0] = ILE;
+AddListInitializationStep(DestType);
+return;
+  }
+
   // The remaining cases all need a source type.
   if (Args.size() > 1) {
 SetFailed(FK_TooManyInitsForScalar);
@@ -8129,6 +8160,11 @@ ExprResult InitializationSequence::Perform(Sema &S,
   ExprResult CurInit((Expr *)nullptr);
   SmallVector ArrayLoopCommonExprs;
 
+  // HLSL allows vector initialization to function like list initialization, 
but
+  // use the syntax of a C++-like constructor.
+  bool IsHLSLVectorInit = S.getLangOpts().HLSL && DestType->isExtVectorType() 
&&
+  isa(Args[0]);
+
   // For initialization steps that start with a single initializer,
   // grab the only argument out the Args and place it into the "current"
   // initializer.
@@ -8166,7 +8202,7 @@ ExprResult InitializationSequence::Perform(Sema &S,
   case SK_StdInitializerList:
   case SK_OCLSamplerInit:
   case SK_OCLZeroOpaqueType: {
-assert(Args.size() == 1);
+assert(Args.size() == 1 || IsHLSLVectorInit);
 CurInit = Args[0];
 if (!CurInit.get()) return ExprError();
 break;

diff  --git a/clang/test/AST/HLSL/vector-constructors.hlsl 
b/clang

[PATCH] D127802: [HLSL] Support HLSL vector initializers

2022-06-21 Thread Chris Bieneman 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 rG9f499d9d73ed: [HLSL] Support HLSL vector initializers 
(authored by beanz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127802

Files:
  clang/lib/Sema/SemaInit.cpp
  clang/test/AST/HLSL/vector-constructors.hlsl
  clang/test/SemaHLSL/BuiltIns/vector-constructors-erros.hlsl

Index: clang/test/SemaHLSL/BuiltIns/vector-constructors-erros.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/BuiltIns/vector-constructors-erros.hlsl
@@ -0,0 +1,22 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s
+
+typedef float float2 __attribute__((ext_vector_type(2)));
+typedef float float3 __attribute__((ext_vector_type(3)));
+
+struct S { float f; };
+struct S2 { float f; int i; };
+
+[numthreads(1,1,1)]
+void entry() {
+  float2 LilVec = float2(1.0, 2.0);
+  float2 BrokenVec = float2(1.0, 2.0, 3.0); // expected-error{{excess elements in vector initializer}}
+  float3 NormieVec = float3(LilVec, 3.0, 4.0); // expected-error{{excess elements in vector initializer}}
+  float3 BrokenNormie = float3(3.0, 4.0); // expected-error{{too few elements in vector initialization (expected 3 elements, have 2)}}
+  float3 OverwhemledNormie = float3(3.0, 4.0, 5.0, 6.0); // expected-error{{excess elements in vector initializer}}
+
+  // These _should_ work in HLSL but aren't yet supported.
+  S s;
+  float2 GettingStrange = float2(s, s); // expected-error{{no viable conversion from 'S' to 'float'}} expected-error{{no viable conversion from 'S' to 'float'}}
+  S2 s2;
+  float2 EvenStranger = float2(s2); // expected-error{{no viable conversion from 'S2' to 'float'}} expected-error{{too few elements in vector initialization (expected 2 elements, have 1)}}
+}
Index: clang/test/AST/HLSL/vector-constructors.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/vector-constructors.hlsl
@@ -0,0 +1,143 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -ast-dump -o - %s | FileCheck %s 
+
+typedef float float2 __attribute__((ext_vector_type(2)));
+typedef float float3 __attribute__((ext_vector_type(3)));
+
+[numthreads(1,1,1)]
+void entry() {
+  float2 Vec2 = float2(1.0, 2.0);
+  float3 Vec3 = float3(Vec2, 3.0);
+  float3 Vec3b = float3(1.0, 2.0, 3.0);
+
+// For the float2 vector, we just expect a conversion from constructor
+// parameters to an initialization list
+// CHECK: VarDecl 0x{{[0-9a-fA-F]+}}  col:10 used Vec2 'float2':'float __attribute__((ext_vector_type(2)))' cinit
+// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}}  'float2':'float __attribute__((ext_vector_type(2)))' functional cast to float2 
+// CHECK-NEXT: InitListExpr 0x{{[0-9a-fA-F]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-fA-F]+}}  'float' 
+// CHECK-NEXT: FloatingLiteral 0x{{[0-9a-fA-F]+}}  'double' 1.00e+00
+// CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-fA-F]+}}  'float' 
+// CHECK-NEXT: FloatingLiteral 0x{{[0-9a-fA-F]+}}  'double' 2.00e+00
+
+
+// For the float 3 things get fun...
+// Here we expect accesses to the vec2 to provide the first and second
+// components using ArraySubscriptExpr
+// CHECK: VarDecl 0x{{[0-9a-fA-F]+}}  col:10 Vec3 'float3':'float __attribute__((ext_vector_type(3)))' cinit
+// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}}  'float3':'float __attribute__((ext_vector_type(3)))' functional cast to float3 
+// CHECK-NEXT: InitListExpr 0x{{[0-9a-fA-F]+}}  'float3':'float __attribute__((ext_vector_type(3)))'
+// CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-fA-F]+}} > 'float' 
+// CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9a-fA-F]+}} > 'float' lvalue
+// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-fA-F]+}}  'float2':'float __attribute__((ext_vector_type(2)))' lvalue Var 0x{{[0-9a-fA-F]+}} 'Vec2' 'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT: IntegerLiteral 0x{{[0-9a-fA-F]+}} <> 'int' 0
+// CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-fA-F]+}} > 'float' 
+// CHECK-NEXT: ArraySubscriptExpr 0x{{[0-9a-fA-F]+}} > 'float' lvalue
+// CHECK-NEXT: DeclRefExpr 0x{{[0-9a-fA-F]+}}  'float2':'float __attribute__((ext_vector_type(2)))' lvalue Var 0x{{[0-9a-fA-F]+}} 'Vec2' 'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT: IntegerLiteral 0x{{[0-9a-fA-F]+}} <> 'int' 1
+// CHECK-NEXT: ImplicitCastExpr 0x{{[0-9a-fA-F]+}}  'float' 
+// CHECK-NEXT: FloatingLiteral 0x{{[0-9a-fA-F]+}}  'double' 3.00e+00
+
+// CHECK: VarDecl 0x{{[0-9a-fA-F]+}}  col:10 Vec3b 'float3':'float __attribute__((ext_vector_type(3)))' cinit
+// CHECK-NEXT: CXXFunctionalCastExpr 0x{{[0-9a-fA-F]+}}  'float3':'float __attribute__((ext_vector_type(3)))' functional cast to float3 
+// CHECK-NEXT: InitListExpr 0x{{

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

2022-06-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGExprComplex.cpp:896
+
+ComplexPairTy ComplexExprEmitter::EmitPromoted(const Expr *E) {
+  if (auto *BinOp = dyn_cast(E->IgnoreParens())) {

pengfei wrote:
> rjmccall wrote:
> > zahiraam wrote:
> > > rjmccall wrote:
> > > > `EmitPromoted` should take the promotion type.
> > > > 
> > > > You are missing the logic in this file which handles *unpromoted* 
> > > > emission (where you have a binary operator but the context wants an 
> > > > unpromoted value) by recognizing that you need to do a promoted 
> > > > operation and then truncate.
> > > Sorry but not sure what you mean here. A case where we don't want any 
> > > promotion would be:
> > > 
> > > float _Complex add(float _Complex a, float _Complex b) {
> > >   return a + b;
> > > }
> > > 
> > > In this case, getPromotionType would return the null type and EmitBinOps 
> > > would just go through the  "older" control path where there is no 
> > > promotion.
> > > Unless I misunderstood your comment?
> > > 
> > > 
> > I'm talking about the unpromoted emission path for an operation that we 
> > want to *internally* promote.  So like your example but using `_Float16` — 
> > we want to emit the binary `+` as a `float` operation, but the context 
> > needs an unpromoted value because it's going to be returned.
> > 
> > The promoted emission path (the various `EmitPromoted` methods) represents 
> > a request by the caller to produce a result that doesn't match the formal 
> > type of the expression.  The normal emission path `Visit` etc.) represents 
> > a request by the caller to produce a result normally, i.e. one that matches 
> > the formal type.  In general, we always start in the latter because 
> > arbitrary contexts always expect a value of the formal type; it's only 
> > these recursive calls within promoted emitters that contextually want a 
> > promoted value.
> > 
> > In your current patch, you're entering the promoted path by special-casing 
> > one context that frequently terminates promoted emission: 
> > `EmitComplexExprIntoLValue`, which is used for things like assignment.  
> > That's not the right way to handle it, though.  Instead, you should do like 
> > I asked you to do with the scalar emitter, which is to recognize in the 
> > normal emission path for a promotable operation (like binary `+`) that you 
> > need to promote the operation and then unpromote the result.  Then things 
> > like `EmitComplexExprIntoLValue` will continue to simply enter the normal 
> > path because that's the kind of value they need, and the promotion logic 
> > will do the right thing from there to ensure we don't emit a `_Float16` 
> > operation in LLVM IR.
> > 
> > Incidentally, I thought of another context that you ought to do promotion 
> > for: when we're converting a promotable value to a larger floating-point 
> > type, we should presumably convert the promoted value directly rather than 
> > truncating it to the unpromoted type before the conversion.
> I'm not familiar with the FE details, but I understand the background is just 
> to promote expressions that have more than one operation. So I agree with 
> @zahiraam, and
> > to ensure we don't emit a _Float16 operation in LLVM IR
> is not what we expected here.
> 
> `_Float16` is a ABI type for which a target supported has to lower any 
> `_Float16` operations in LLVM IR. See what we have done on X86 backend by 
> D107082.
> 
> That said, a single `a + b` can be and should be emitted as `%c = fadd half 
> %a, %b`.
Well, you can provide operation-by-operation lowering support if you want to, 
but what's going to come out of Clang IRGen in this mode is not going to rely 
on it.  It's far easier to just emit these operations differently, always using 
`float`, than to try to recognize the special cases where all the inputs are 
naturally `half` and so you might as well emit a `half` operation.

And I think the postcondition that `half` operations don't come out of IRGen is 
a generally useful property even if you've already written this lowering code.  
Among other things, it makes it easy to test that you haven't missed a case 
where you should be doing promoted emission.


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

https://reviews.llvm.org/D113107

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


[PATCH] D127246: [LinkerWrapper] Rework the linker wrapper and use owning binaries

2022-06-21 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 438758.
jhuber6 added a comment.

Adding a test to ensure we no longer write temporary files for unused inputs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127246

Files:
  clang/test/Driver/linker-wrapper.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -28,6 +28,7 @@
 #include "llvm/Object/Archive.h"
 #include "llvm/Object/ArchiveWriter.h"
 #include "llvm/Object/Binary.h"
+#include "llvm/Object/IRObjectFile.h"
 #include "llvm/Object/ObjectFile.h"
 #include "llvm/Object/OffloadBinary.h"
 #include "llvm/Support/CommandLine.h"
@@ -68,8 +69,7 @@
cl::cat(ClangLinkerWrapperCategory));
 
 static cl::opt
-TargetFeatures("target-feature",
-   cl::desc("Target features for triple"),
+TargetFeatures("target-feature", cl::desc("Target features for triple"),
cl::cat(ClangLinkerWrapperCategory));
 
 static cl::opt OptLevel("opt-level",
@@ -114,9 +114,8 @@
cl::value_desc(" or ="),
cl::cat(ClangLinkerWrapperCategory));
 
-static cl::opt Verbose("v",
- cl::desc("Verbose output from tools"),
- 
+static cl::opt Verbose("v", cl::desc("Verbose output from tools"),
+
  cl::cat(ClangLinkerWrapperCategory));
 
 static cl::opt DebugInfo(
@@ -165,63 +164,43 @@
 /// different but it should work for what is passed here.
 static constexpr unsigned FatbinaryOffset = 0x50;
 
-/// Information for a device offloading file extracted from the host.
-struct DeviceFile {
-  DeviceFile(OffloadKind Kind, StringRef TheTriple, StringRef Arch,
- StringRef Filename)
-  : Kind(Kind), TheTriple(TheTriple), Arch(Arch), Filename(Filename) {}
+using OffloadingImage = OffloadBinary::OffloadingImage;
+
+/// A class to contain the binary information for a single OffloadBinary.
+class OffloadFile : public OwningBinary {
+public:
+  using TargetID = std::pair;
+
+  OffloadFile(std::unique_ptr Binary,
+  std::unique_ptr Buffer)
+  : OwningBinary(std::move(Binary), std::move(Buffer)) {}
 
-  OffloadKind Kind;
-  std::string TheTriple;
-  std::string Arch;
-  std::string Filename;
+  /// We use the Triple and Architecture pair to group linker inputs together.
+  /// This conversion function lets us use these files in a hash-map.
+  operator TargetID() const {
+return std::make_pair(getBinary()->getTriple(), getBinary()->getArch());
+  }
 };
 
 namespace llvm {
-/// Helper that allows DeviceFile to be used as a key in a DenseMap. For now we
-/// assume device files with matching architectures and triples but different
-/// offloading kinds should be handlded together, this may not be true in the
-/// future.
-
-// Provide DenseMapInfo for OffloadKind.
+// Provide DenseMapInfo so that OffloadKind can be used in a DenseMap.
 template <> struct DenseMapInfo {
   static inline OffloadKind getEmptyKey() { return OFK_LAST; }
   static inline OffloadKind getTombstoneKey() {
 return static_cast(OFK_LAST + 1);
   }
-  static unsigned getHashValue(const OffloadKind &Val) { return Val * 37U; }
+  static unsigned getHashValue(const OffloadKind &Val) { return Val; }
 
   static bool isEqual(const OffloadKind &LHS, const OffloadKind &RHS) {
 return LHS == RHS;
   }
 };
-template <> struct DenseMapInfo {
-  static DeviceFile getEmptyKey() {
-return {DenseMapInfo::getEmptyKey(),
-DenseMapInfo::getEmptyKey(),
-DenseMapInfo::getEmptyKey(),
-DenseMapInfo::getEmptyKey()};
-  }
-  static DeviceFile getTombstoneKey() {
-return {DenseMapInfo::getTombstoneKey(),
-DenseMapInfo::getTombstoneKey(),
-DenseMapInfo::getTombstoneKey(),
-DenseMapInfo::getTombstoneKey()};
-  }
-  static unsigned getHashValue(const DeviceFile &I) {
-return DenseMapInfo::getHashValue(I.TheTriple) ^
-   DenseMapInfo::getHashValue(I.Arch);
-  }
-  static bool isEqual(const DeviceFile &LHS, const DeviceFile &RHS) {
-return LHS.TheTriple == RHS.TheTriple && LHS.Arch == RHS.Arch;
-  }
-};
 } // namespace llvm
 
 namespace {
 
 Error extractFromBuffer(std::unique_ptr Buffer,
-SmallVectorImpl &DeviceFiles);
+SmallVectorImpl &DeviceFiles);
 
 void printCommands(ArrayRef CmdArgs) {
   if (CmdArgs.empty())
@@ -232,7 +211,7 @@
 llvm::errs() << *IC << (std::next(IC) != IE ? " " : "\n");
 }
 
-// Forward user requested arguments to the device linking job.
+/// Forward user requested arguments to the device linking job.
 void renderXLinkerArgs(SmallV

[PATCH] D128249: Adding clone_attrs attribute.

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

In D128249#3599551 , @plotfi wrote:

> Thanks for the feedback on corner cases @aaron.ballman, this will give me 
> more concrete things to think about here.
>
> At the moment I mainly thinking about a case:
>
>   typedef int foo;
>   enum : foo {} __attribute__((__clone_attrs_from__(foo)));
>
> This is mostly because of how NS_OPTIONS enums on Darwin are defined through 
> a macro.
> We have been looking into breaking up how the typedef and the enum are 
> defined for better behavior with C++.
> The only challenge is that if an NS_OPTIONS macro is used to declare an enum 
> and an attribute is specified either before or after, it will then only apply 
> to either the typedef or the enum.
>
> Thats the reason for a clone_attrs attribute.

Ah, thank you for the explanation. That is an interesting case. Another 
potential idea to consider is the idea of "inheriting" attributes from a 
related interface. e.g., a derived class which inherits attributes from the 
base, or an enum with a fixed underlying type inheriting attributes from the 
fixed type, etc. I've not given it a lot of thought, but it seems like there's 
a relationship there that might make sense for attributes in general. As an 
example:

  struct [[gnu::packed]] S {
char c;
int i;
  };
  
  struct T {
char c;
int i;
  };
  
  template 
  struct [[inherits_attributes]] V : U {
double d;
  };

Where instantiating `V` would result in both `V` and `S` being packed, but 
instantiating `V` would not pack either. (Again, I've not put a ton of 
thought into it, but it's a possible alternative design worth considering.)

> I'll update description soon.
>
> In D128249#3598507 , @aaron.ballman 
> wrote:
>
>> Can you add some details to the patch summary as to what problem you're 
>> trying to solve with these changes?
>>
>> The idea itself has some interesting edge cases to think about:
>>
>>   [[some_attr]] void decl();
>>   [[clone_attrs_from(decl)]] void other();
>>   [[some_new_attr]] void decl();
>>   
>>   int main() {
>> other(); // Does other see some_new_attr as well?
>>   }
>>
>> or
>>
>>   [[hot]] void decl();
>>   [[clone_attrs_from(decl), cold]] void other_decl(); // Do you properly 
>> catch the mutual exclusions?
>>
>> or
>>
>>   [[some_attr_requiring_the_func_return_a_pointer]] int *decl();
>>   [[clone_attrs_from(decl)]] int other(); // Do you properly catch the 
>> semantic restrictions?
>>
>> or
>>
>>   struct [[some_struct_attr]] S { ... };
>>   [[clone_attrs_from(S)]] void other(); // Do you properly catch the 
>> semantic restrictions?
>>
>> or
>>
>>   [[some_attr]] void decl();
>>   [[clone_attrs_from(decl)]] void decl(); // Uh oh, recursive.
>>
>> (I'm sure there are more situations I'm missing, but you get the idea about 
>> needing to be very careful with the edge cases.)




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128249

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


[PATCH] D126559: [MSVC] Fix pragma alloc_text failing for C files

2022-06-21 Thread Stephen Long via Phabricator via cfe-commits
steplong added a comment.

I tried the following:

  FunctionDecl *FD = ND->getAsFunction();
  DeclContext *DC = ND->getDeclContext();
  DEBUG_WITH_TYPE("foo", llvm::dbgs() << "[FOO] DC->isExternCContext() 
: " << DC->isExternCContext() << "\n");
  DEBUG_WITH_TYPE("foo", llvm::dbgs() << "[FOO] FD->isExternC()
: " << FD->isExternC()<< "\n");
  DEBUG_WITH_TYPE("foo", llvm::dbgs() << "[FOO] FD->isInExternCContext()   
: " << FD->isInExternCContext()   << "\n");
  llvm::dbgs() << "[FOO] "; ND->dump();
  if (getLangOpts().CPlusPlus && !DC->isExternCContext()) {
Diag(Loc, diag::err_pragma_alloc_text_c_linkage);
return;
  }

and I'm getting the following output:

  [FOO] DC->isExternCContext() : 0
  [FOO] FD->isExternC(): 0
  [FOO] FD->isInExternCContext()   : 0
  [FOO] FunctionDecl 0x10ec0250 prev 0x10ec0148  col:13 
foo 'void ()' static

The C file is:

  1 extern "C" {
  2 static void foo();
  3 }
  4 static void foo();
  5 #pragma alloc_text("s", foo)
  6 static void foo() {}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126559

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


[PATCH] D126461: [RISCV] Extract and store new vl of vleff/vlsegff iff destination isn't null

2022-06-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D126461#3599122 , @reames wrote:

> In D126461#3597862 , @craig.topper 
> wrote:
>
>> `dst` in the patch description is not the pointer being loaded, it's the 
>> pointer of where to store the new_vl. That is only thing being checked for 
>> null in this patch.
>
> I agree this is a possible interpretation, but it's also inconsistent with 
> some of the other review discussion above.
>
> @pcwang-thead Please consider clarifying the patch description a blocking 
> item for future review or potential approval.

I don't believe it was meant to be inconsistent, but I agree it could be 
confusing. All of the prior discussion is talking about the C intrinsic 
interface which has two pointers, the pointer to load from, and the outparam 
pointer for new_vl. All mentions of a pointer being null were only ever meant 
to refer to the outparam pointer.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126461

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


[PATCH] D126461: [RISCV] Extract and store new vl of vleff/vlsegff iff new_vl output pointer isn't null

2022-06-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

I have attempted to revise the title and description. Please take a look 
@pcwang-thead and @reames


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126461

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


[PATCH] D127641: [clang-cl][MSVC] Enable /Zc:alignedNew for C++17 and /Zc:sizedDealloc by default

2022-06-21 Thread Stephen Long via Phabricator via cfe-commits
steplong updated this revision to Diff 438778.
steplong added a comment.

Whoops, this is a clang-tidy test, so `-target` won't work here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127641

Files:
  clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-zc.cpp


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck 
-check-prefix=SIZED-DEALLOC-OFF %s
+// SIZED-DEALLOC: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++14 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-BEFORE-CPP17 %s
+// RUN: %clang_cl /c /std:c++17 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++20 -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// RUN: %clang_cl /c /std:c++latest -### -- %s 2>&1 | FileCheck 
-check-prefix=ALIGNED-NEW-CPP17ONWARDS %s
+// ALIGNED-NEW-BEFORE-CPP17-NOT: "-faligned-allocation"
+// ALIGNED-NEW-CPP17ONWARDS: "-faligned-allocation"
+
 // RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck 
-check-prefix=TRIGRAPHS-DEFAULT %s
 // cc1 will disable trigraphs for -fms-compatibility as long as -ftrigraphs
 // isn't explicitly passed.
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6470,6 +6470,7 @@
 }
 CmdArgs.push_back(LanguageStandard.data());
   }
+  bool IsCPP17Onwards = false;
   if (ImplyVCPPCXXVer) {
 StringRef LanguageStandard;
 if (const Arg *StdArg = Args.getLastArg(options::OPT__SLASH_std)) {
@@ -6493,6 +6494,9 @@
 }
 
 CmdArgs.push_back(LanguageStandard.data());
+
+IsCPP17Onwards =
+LanguageStandard != "-std=c++11" && LanguageStandard != "-std=c++14";
   }
 
   Args.addOptInFlag(CmdArgs, options::OPT_fborland_extensions,
@@ -6622,9 +6626,15 @@
 options::OPT_fno_relaxed_template_template_args);
 
   // -fsized-deallocation is off by default, as it is an ABI-breaking change 
for
-  // most platforms.
-  Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
-options::OPT_fno_sized_deallocation);
+  // most platforms. MSVC turns on /Zc:sizedDealloc by default, starting in
+  // MSVC 2015.
+  if (IsWindowsMSVC && IsMSVC2015Compatible &&
+  !Args.getLastArg(options::OPT_fsized_deallocation,
+   options::OPT_fno_sized_deallocation))
+CmdArgs.push_back("-fsized-deallocation");
+  else
+Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
+  options::OPT_fno_sized_deallocation);
 
   // -faligned-allocation is on by default in C++17 onwards and otherwise off
   // by default.
@@ -6635,6 +6645,8 @@
   CmdArgs.push_back("-fno-aligned-allocation");
 else
   CmdArgs.push_back("-faligned-allocation");
+  } else if (IsCPP17Onwards) {
+CmdArgs.push_back("-faligned-allocation");
   }
 
   // The default new alignment can be specified using a dedicated option or via
Index: clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc-new-delete-overloads.cpp
@@ -1,5 +1,10 @@
 // RUN: %check_clang_tidy %s misc-new-delete-overloads %t
 
+// MSVC turns on sized deallocations by default, so we unsupport this test
+// for windows.
+
+// UNSUPPORTED: system-windows
+
 typedef decltype(sizeof(int)) size_t;
 
 struct S {


Index: clang/test/Driver/cl-zc.cpp
===
--- clang/test/Driver/cl-zc.cpp
+++ clang/test/Driver/cl-zc.cpp
@@ -1,6 +1,19 @@
 // Note: %s must be preceded by --, otherwise it may be interpreted as a
 // command-line option, e.g. on Mac where %s is commonly under /Users.
 
+// RUN: %clang_cl /c -### -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC %s
+// RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=SIZED-DEALLOC-OFF %s
+// SIZED-DEALLOC: "-fsized-deallocation"
+// SIZED-DEALLOC-OFF-NOT: "-fsized-deallocation"
+
+// RUN: %clang_cl /c /std:c++11 -### -- %s 2>&1 | FileChe

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 438781.
erichkeane added a comment.

As promised, got it down to the 1 failure, and added tests for @ChuanqiXu and 
the std::vector example.  That all seems to work, just a problem with the 
CXX/temp/temp.arg/temp.arg.template/p3-2a.cpp test left.


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

https://reviews.llvm.org/D126907

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/Template.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
  
clang/test/CXX/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
  
clang/test/CXX/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
  clang/test/Driver/crash-report.cpp
  clang/test/SemaTemplate/concepts-friends.cpp
  clang/test/SemaTemplate/concepts.cpp
  clang/test/SemaTemplate/deferred-concept-inst.cpp
  clang/test/SemaTemplate/instantiate-requires-clause.cpp
  clang/test/SemaTemplate/trailing-return-short-circuit.cpp

Index: clang/test/SemaTemplate/trailing-return-short-circuit.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/trailing-return-short-circuit.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template 
+  requires(sizeof(T) > 2) || T::value // #FOO_REQ
+void Foo(T){};// #FOO
+
+template 
+void TrailingReturn(T)   // #TRAILING
+  requires(sizeof(T) > 2) || // #TRAILING_REQ
+  T::value   // #TRAILING_REQ_VAL
+{};
+template 
+struct HasValue {
+  static constexpr bool value = B;
+};
+static_assert(sizeof(HasValue) <= 2);
+
+template 
+struct HasValueLarge {
+  static constexpr bool value = B;
+  int I;
+};
+static_assert(sizeof(HasValueLarge) > 2);
+
+void usage() {
+  // Passes the 1st check, short-circuit so the 2nd ::value is not evaluated.
+  Foo(1.0);
+  TrailingReturn(1.0);
+
+  // Fails the 1st check, but has a ::value, so the check happens correctly.
+  Foo(HasValue{});
+  TrailingReturn(HasValue{});
+
+  // Passes the 1st check, but would have passed the 2nd one.
+  Foo(HasValueLarge{});
+  TrailingReturn(HasValueLarge{});
+
+  // Fails the 1st check, fails 2nd because there is no ::value.
+  Foo(true);
+  // expected-error@-1{{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  TrailingReturn(true);
+  // expected-error@-1{{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  // Fails the 1st check, fails 2nd because ::value is false.
+  Foo(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{and 'HasValue::value' evaluated to false}}
+  TrailingReturn(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{and 'HasValue::value' evaluated to false}}
+}
Index: clang/test/SemaTemplate/instantiate-requires-clause.cpp
===
--- clang/test/SemaTemplate/instantiate-requires-clause.cpp
+++ clang/test/SemaTemplate/instantiate-requires-clause.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
+// RUN: %clang_cc1 -std=c++2a -x c++ %s -Wno-unused-value -verify
 
 template  requires ((sizeof(Args) == 1), ...)
 // exp

[PATCH] D127246: [LinkerWrapper] Rework the linker wrapper and use owning binaries

2022-06-21 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

I've read it but can't promise it's correct -  the diff is large and has some 
spurious noise in it which distracts significantly from the functional changes.

Would you be willing to split this into two patches, one which renames 
variables and moves blocks of code around without changing them and a second 
that has the functional changes?




Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:338
+Contents.getBufferIdentifier());
+auto NewBinaryOrErr = OffloadBinary::create(*BufferCopy);
+if (!NewBinaryOrErr)

This is syntactically a bit weird: `std::move(*NewBinaryOrErr)`

Could you spell out the type? I think based on the previous version it's 
probably an Expected> but my first thought was whether a 
unique_ptr was being heap allocated by ::create



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:784
 };
-Conf.PostInternalizeModuleHook = [&](size_t, const Module &M) {
+Conf.PostInternalizeModuleHook = [&, Arch](size_t, const Module &M) {
   SmallString<128> TempFile;

Why call out Arch here? Passing a StringRef by reference via the & should be 
fine



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:903
 
   // We assume visibility of the whole program if every input file was bitcode.
+  bool WholeProgram = InputFiles.empty();

Existing comment I see, but what justifies that assumption?



Comment at: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp:1136
+
+  Triple TheTriple = Triple(Images.front().StringData.lookup("triple"));
+  auto FileOrErr = nvptx::fatbinary(InputFiles, TheTriple);

This is close but not quite a copy of existing code, moving it around in the 
file at the same time as changing it makes the diff significantly harder to 
follow


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127246

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


[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

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

Note that the failure comes down to:

  template concept C = T::f();
  template class P> struct S1{};
  template struct X{};
  S1 s11;

and requires the -frelaxed-template-template-args flag:

  [ekeane1@scsel-clx-24 build]$  ./bin/clang -cc1 -std=c++20 temp.cpp 
-frelaxed-template-template-args
  temp.cpp:5:4: error: template template argument 'X' is more constrained than 
template template parameter 'P'
  S1 s11;
 ^
  temp.cpp:3:29: note: 'P' declared here
  template  class P> struct S1{};
  ^
  temp.cpp:4:20: note: 'X' declared here
  template struct X{};
 ^
  1 error generated.




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

https://reviews.llvm.org/D126907

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


[PATCH] D126461: [RISCV] Extract and store new vl of vleff/vlsegff iff new_vl output pointer isn't null

2022-06-21 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

@craig.topper Much clearer, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126461

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


  1   2   >