[PATCH] D132831: [clang][Interp] Handle SubstNonTypeTemplateParmExprs

2022-09-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 457766.
tbaeder marked 2 inline comments as done.

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

https://reviews.llvm.org/D132831

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/test/AST/Interp/functions.cpp


Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -65,3 +65,11 @@
   return recursion(i);
 }
 static_assert(recursion(10) == 0, "");
+
+template
+constexpr decltype(N) getNum() {
+  return N;
+}
+static_assert(getNum<-2>() == -2, "");
+static_assert(getNum<10>() == 10, "");
+static_assert(getNum() == 5, "");
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -76,6 +76,7 @@
   bool VisitUnaryOperator(const UnaryOperator *E);
   bool VisitDeclRefExpr(const DeclRefExpr *E);
   bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E);
+  bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr 
*E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -231,6 +231,12 @@
   return false;
 }
 
+template 
+bool ByteCodeExprGen::VisitSubstNonTypeTemplateParmExpr(
+const SubstNonTypeTemplateParmExpr *E) {
+  return this->visit(E->getReplacement());
+}
+
 template 
 bool ByteCodeExprGen::discard(const Expr *E) {
   OptionScope Scope(this, /*NewDiscardResult=*/true);


Index: clang/test/AST/Interp/functions.cpp
===
--- clang/test/AST/Interp/functions.cpp
+++ clang/test/AST/Interp/functions.cpp
@@ -65,3 +65,11 @@
   return recursion(i);
 }
 static_assert(recursion(10) == 0, "");
+
+template
+constexpr decltype(N) getNum() {
+  return N;
+}
+static_assert(getNum<-2>() == -2, "");
+static_assert(getNum<10>() == 10, "");
+static_assert(getNum() == 5, "");
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -76,6 +76,7 @@
   bool VisitUnaryOperator(const UnaryOperator *E);
   bool VisitDeclRefExpr(const DeclRefExpr *E);
   bool VisitImplicitValueInitExpr(const ImplicitValueInitExpr *E);
+  bool VisitSubstNonTypeTemplateParmExpr(const SubstNonTypeTemplateParmExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -231,6 +231,12 @@
   return false;
 }
 
+template 
+bool ByteCodeExprGen::VisitSubstNonTypeTemplateParmExpr(
+const SubstNonTypeTemplateParmExpr *E) {
+  return this->visit(E->getReplacement());
+}
+
 template 
 bool ByteCodeExprGen::discard(const Expr *E) {
   OptionScope Scope(this, /*NewDiscardResult=*/true);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132727: [clang][Interp] Implement array initializers and subscript expressions

2022-09-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 457767.
tbaeder marked 6 inline comments as done.

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

https://reviews.llvm.org/D132727

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/ByteCodeStmtGen.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Pointer.cpp
  clang/lib/AST/Interp/Program.cpp
  clang/test/AST/Interp/arrays.cpp

Index: clang/test/AST/Interp/arrays.cpp
===
--- clang/test/AST/Interp/arrays.cpp
+++ clang/test/AST/Interp/arrays.cpp
@@ -1,13 +1,85 @@
 // RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
 // RUN: %clang_cc1 -verify=ref %s
 
+constexpr int m = 3;
+constexpr const int *foo[][5] = {
+  {nullptr, &m, nullptr, nullptr, nullptr},
+  {nullptr, nullptr, &m, nullptr, nullptr},
+  {nullptr, nullptr, nullptr, &m, nullptr},
+};
+
+static_assert(foo[0][0] == nullptr, "");
+static_assert(foo[0][1] == &m, "");
+static_assert(foo[0][2] == nullptr, "");
+static_assert(foo[0][3] == nullptr, "");
+static_assert(foo[0][4] == nullptr, "");
+static_assert(foo[1][0] == nullptr, "");
+static_assert(foo[1][1] == nullptr, "");
+static_assert(foo[1][2] == &m, "");
+static_assert(foo[1][3] == nullptr, "");
+static_assert(foo[1][4] == nullptr, "");
+static_assert(foo[2][0] == nullptr, "");
+static_assert(foo[2][1] == nullptr, "");
+static_assert(foo[2][2] == nullptr, "");
+static_assert(foo[2][3] == &m, "");
+static_assert(foo[2][4] == nullptr, "");
+
+
+/// A init list for a primitive value.
+constexpr int f{5};
+static_assert(f == 5, "");
+
+
+constexpr int getElement(int i) {
+  int values[] = {1, 4, 9, 16, 25, 36};
+  return values[i];
+}
+static_assert(getElement(1) == 4, "");
+static_assert(getElement(5) == 36, "");
+
+
+template
+constexpr T getElementOf(T* array, int i) {
+  return array[i];
+}
+static_assert(getElementOf(foo[0], 1) == &m, "");
+
 
-/// expected-no-diagnostics
-/// ref-no-diagnostics
+constexpr int data[] = {5, 4, 3, 2, 1};
+static_assert(data[0] == 4, ""); // expected-error{{failed}} \
+ // expected-note{{5 == 4}} \
+ // ref-error{{failed}} \
+ // ref-note{{5 == 4}}
+
+
+constexpr int dynamic[] = {
+  f, 3, 2 + 5, data[3], *getElementOf(foo[2], 3)
+};
+static_assert(dynamic[0] == f, "");
+static_assert(dynamic[3] == 2, "");
+
+
+constexpr int dependent[4] = {
+  0, 1, dependent[0], dependent[1]
+};
+static_assert(dependent[2] == dependent[0], "");
+static_assert(dependent[3] == dependent[1], "");
 
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Wc99-extensions"
 #pragma clang diagnostic ignored "-Winitializer-overrides"
+constexpr int DI[] = {
+  [0] = 10,
+  [1] = 20,
+  30,
+  40,
+  [1] = 50
+};
+static_assert(DI[0] == 10, "");
+static_assert(DI[1] == 50, "");
+static_assert(DI[2] == 30, "");
+static_assert(DI[3] == 40, "");
+
 /// FIXME: The example below tests ImplicitValueInitExprs, but we can't
 ///   currently evaluate other parts of it.
 #if 0
Index: clang/lib/AST/Interp/Program.cpp
===
--- clang/lib/AST/Interp/Program.cpp
+++ clang/lib/AST/Interp/Program.cpp
@@ -334,14 +334,15 @@
   } else {
 // Arrays of composites. In this case, the array is a list of pointers,
 // followed by the actual elements.
-Descriptor *Desc =
+Descriptor *ElemDesc =
 createDescriptor(D, ElemTy.getTypePtr(), IsConst, IsTemporary);
-if (!Desc)
+if (!ElemDesc)
   return nullptr;
-InterpSize ElemSize = Desc->getAllocSize() + sizeof(InlineDescriptor);
+InterpSize ElemSize =
+ElemDesc->getAllocSize() + sizeof(InlineDescriptor);
 if (std::numeric_limits::max() / ElemSize <= NumElems)
   return {};
-return allocateDescriptor(D, Desc, NumElems, IsConst, IsTemporary,
+return allocateDescriptor(D, ElemDesc, NumElems, IsConst, IsTemporary,
   IsMutable);
   }
 }
Index: clang/lib/AST/Interp/Pointer.cpp
===
--- clang/lib/AST/Interp/Pointer.cpp
+++ clang/lib/AST/Interp/Pointer.cpp
@@ -106,7 +106,7 @@
 
   // Build the path into the object.
   Pointer Ptr = *this;
-  while (Ptr.isField()) {
+  while (Ptr.isField() || Ptr.isArrayElement()) {
 if (Ptr.isArrayElement()) {
   Path.push_back(APValue::LValuePathEntry::ArrayIndex(Ptr.getIndex()));
   Ptr = Ptr.getArray();
@@ -154,7 +154,8 @@
 void Pointer::initialize() const {
   assert(Pointee && "Cannot initialize null pointer");
   Descriptor *Desc = getFieldDesc();
-  if (Desc->isPrimitiveArray()) {
+
+  if (Desc->isArray()) {
 if (!Pointee->IsStatic) {
   // Primitive array initializer.
   InitMa

[PATCH] D132829: [clang][Interp] Handle ImplictValueInitExprs

2022-09-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder marked an inline comment as done.
tbaeder added inline comments.



Comment at: clang/test/AST/Interp/arrays.cpp:13
+///   currently evaluate other parts of it.
+#if 0
+struct fred {

aaron.ballman wrote:
> I wish we could find some solution that didn't require this so that the test 
> case breaks when we do get around to implementing support for the other bits. 
> But this is at least a good start!
Usually we could just keep it enabled and add the appropriate `expected-error` 
parts, but in this case we run into an assertion later on and that doesn't work.


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

https://reviews.llvm.org/D132829

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


[PATCH] D133249: [libc++] Documents details of the pre-commit CI.

2022-09-03 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added reviewers: aaron.ballman, ldionne.
Herald added subscribers: mstorsjo, arphaman.
Herald added a project: All.
Mordante requested review of this revision.
Herald added projects: clang, libc++.
Herald added subscribers: libcxx-commits, cfe-commits.
Herald added a reviewer: libc++.

This documentation aims to make it cleare how the libc++ pre-commit CI
works. For libc++ developers and other LLVM projects whose changes can
affect libc++.

This was discusses with @aaron.ballman as a follow on some unclearities
for the Clang communitee how the libc++ pre-commit CI works.

Note some parts depend on patches under review as commented in the
documentation.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133249

Files:
  clang/www/hacking.html
  libcxx/docs/Contributing.rst
  libcxx/docs/index.rst

Index: libcxx/docs/index.rst
===
--- libcxx/docs/index.rst
+++ libcxx/docs/index.rst
@@ -93,6 +93,7 @@
   Further, both projects are apparently abandoned: STLport 5.2.1 was
   released in Oct'08, and STDCXX 4.2.1 in May'08.
 
+.. _SupportedPlatforms:
 
 Platform and Compiler Support
 =
Index: libcxx/docs/Contributing.rst
===
--- libcxx/docs/Contributing.rst
+++ libcxx/docs/Contributing.rst
@@ -84,5 +84,158 @@
 Look for the failed build and select the ``artifacts`` tab. There, download the
 abilist for the platform, e.g.:
 
-* C++20 for the Linux platform.
-* MacOS C++20 for the Apple platform.
+* C++XX for the Linux platform (where XX is the latest C++ version).
+* MacOS X86_64 and MacOS arm64 for the Apple platform.
+
+
+.. comments The new part got longer than expected, would it make sense to move
+   it to its own page?
+
+
+Pre-commit CI
+=
+
+Introduction
+
+
+Unlike eost parts of the LLVM project, libc++ uses a pre-commit CI [#]_. This
+CI is hosted on `Buildkite `__ and
+the build results are visible in the review on Phabricator. Before committing a
+patch please make sure the CI is green.
+
+
+The CI tests libc++ for all :ref:`supported platforms `.
+The build is started for every diff uploaded. A complete CI run takes
+approximately one hour. To reduce the load:
+
+* The build is cancelled when a new diff for the same revision is uploaded.
+* The build is done in several stages and cancelled when a stage fails.
+
+Typically the libc++ jobs use a Ubuntu Docker image. This image contains
+recent `nightly builds `__ of all supported versions of
+Clang and the current version of the ``main`` branch. These versions of Clang
+are used to build libc++ and execute its tests.
+
+Unless specified otherwise the ``main`` version of Clang is used.
+
+Unless specified otherwise the tests are executed for the latest C++
+version; this is the version being "developed" by the C++ committee. CI runners
+using this language version will produce an artifact with a graphviz dot file
+containing the internal dependencies of the Standard headers in libc++.
+
+.. comments D133127 adds the artifact
+
+
+.. note:: Updating the Clang nightly builds in the Docker image is a manual
+   process and is done at an irregular interval. When you need to have the
+   latest nightly build to test recent Clang changes best ask at the
+   ``#libcxx`` channel on
+   `LLVM's Discord server `__.
+
+.. comments ``irregular`` is used on purpose. Committing to a schedule seems
+   unwanted; people might be unavailable to update the image, the nightly
+   builds fail and are not uploaded for multiple days (this is not uncommon).
+
+.. [#] There's `Dev meeting talk `__
+   explaining the benefits of libc++'s pre-commit CI.
+
+Builds
+--
+
+Below a short description of the most interesting CI builds [#]_:
+
+* ``Format`` runs ``clang-format`` and uploads its output as an artifact. At the
+  moment this build is a soft error and doesn't fail the build.
+* ``Generated output`` runs the ``libcxx-generate-files`` build target and
+  tests for non-ASCII characters in libcxx. Some files are excluded since they
+  use Unicode, mainly tests. The output of these commands are uploaded as
+  artifact.
+* ``Documentation`` builds the documentation. (This is done early in the build
+  process since it is cheap to run.)
+* ``C++XX`` these build steps test the various C++ versions, making sure all
+  C++ language versions work with the changes made.
+* ``Clang XX`` these build steps test whether the changes work with all
+  supported Clang versions.
+* ``Booststrapping build`` builds Clang using the revision of the patch and
+  uses that Clang version to build and test libc++. This validates the current
+  Clang and lib++ are compatible. When making changes in Clang that affect
+  libc++ t

[clang] 4ff2250 - Revert "[driver][clang] remove the check-time-trace test on the platform "PS4/PS5/Hexagon""

2022-09-03 Thread Junduo Dong via cfe-commits

Author: Junduo Dong
Date: 2022-09-03T01:37:55-07:00
New Revision: 4ff2250a22ed651facf6dad8f379a3fd24a8f6b1

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

LOG: Revert "[driver][clang] remove the check-time-trace test on the platform 
"PS4/PS5/Hexagon""

This reverts commit 39221ad55752c246bb8448a181847103432e12b2.

Added: 


Modified: 
clang/test/Driver/check-time-trace.cpp

Removed: 




diff  --git a/clang/test/Driver/check-time-trace.cpp 
b/clang/test/Driver/check-time-trace.cpp
index 3ff12981a97c..e0d1e935a733 100644
--- a/clang/test/Driver/check-time-trace.cpp
+++ b/clang/test/Driver/check-time-trace.cpp
@@ -1,5 +1,3 @@
-// UNSUPPORTED: ps4, ps5, hexagon
-
 // RUN: rm -rf %T/exe && mkdir %T/exe
 // RUN: %clangxx -ftime-trace -ftime-trace-granularity=0 -o 
%T/exe/check-time-trace %s
 // RUN: cat %T/exe/check-time-trace*.json \



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


[clang] 5e4f69e - Revert "[Clang] change default storing path of `-ftime-trace`"

2022-09-03 Thread Junduo Dong via cfe-commits

Author: Junduo Dong
Date: 2022-09-03T01:38:37-07:00
New Revision: 5e4f69edbc1e36c47c62a2c522e9a8a6e7b86d06

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

LOG: Revert "[Clang] change default storing path of `-ftime-trace`"

This reverts commit 38941da066a7b785ba4771710189172e94e37824.

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/check-time-trace.cpp
clang/tools/driver/cc1_main.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 5f5655fbc34a8..ba359a1d31a53 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -4510,102 +4510,6 @@ Action *Driver::ConstructPhaseAction(
   llvm_unreachable("invalid phase in ConstructPhaseAction");
 }
 
-// Infer data storing path of the options `-ftime-trace`, `-ftime-trace=`
-void InferTimeTracePath(Compilation &C) {
-  bool HasTimeTrace =
-  C.getArgs().getLastArg(options::OPT_ftime_trace) != nullptr;
-  bool HasTimeTraceFile =
-  C.getArgs().getLastArg(options::OPT_ftime_trace_EQ) != nullptr;
-  // Whether `-ftime-trace` or `-ftime-trace=` are specified
-  if (!HasTimeTrace && !HasTimeTraceFile)
-return;
-
-  // If `-ftime-trace=` is specified, TracePath is the .
-  // Else if there is a linking job, TracePath is the parent path of .exe,
-  // then the OutputFile's name may be appended to it.
-  // Else, TracePath is "",
-  // then the full OutputFile's path may be appended to it.
-  SmallString<128> TracePath("");
-
-  if (HasTimeTraceFile) {
-TracePath = SmallString<128>(
-C.getArgs().getLastArg(options::OPT_ftime_trace_EQ)->getValue());
-  } else {
-// Get linking executable file's parent path as TracePath's parent path,
-// default is ".". Filename may be determined and added into TracePath 
then.
-//
-// e.g. executable file's path: /usr/local/a.out
-//  its parent's path:  /usr/local
-for (auto &J : C.getJobs()) {
-  if (J.getSource().getKind() == Action::LinkJobClass) {
-assert(!J.getOutputFilenames().empty() &&
-   "linking output filename is empty");
-auto OutputFilePath =
-SmallString<128>(J.getOutputFilenames()[0].c_str());
-if (llvm::sys::path::has_parent_path(OutputFilePath)) {
-  TracePath = llvm::sys::path::parent_path(OutputFilePath);
-} else {
-  TracePath = SmallString<128>(".");
-}
-break;
-  }
-}
-  }
-
-  // Add or replace the modified -ftime-trace=` to all clang jobs
-  for (auto &J : C.getJobs()) {
-if (J.getSource().getKind() == Action::AssembleJobClass ||
-J.getSource().getKind() == Action::BackendJobClass ||
-J.getSource().getKind() == Action::CompileJobClass) {
-  SmallString<128> TracePathReal = TracePath;
-  SmallString<128> OutputPath(J.getOutputFilenames()[0].c_str());
-  std::string arg = std::string("-ftime-trace=");
-  if (!HasTimeTraceFile) {
-if (TracePathReal.empty()) {
-  // /xxx/yyy.o => /xxx/yyy.json
-  llvm::sys::path::replace_extension(OutputPath, "json");
-  arg += std::string(OutputPath.c_str());
-} else {
-  // /xxx/yyy.o => /executable_file_parent_path/yyy.json
-  llvm::sys::path::append(TracePathReal,
-  llvm::sys::path::filename(OutputPath));
-  llvm::sys::path::replace_extension(TracePathReal, "json");
-  arg += std::string(TracePathReal.c_str());
-}
-  } else {
-// /full_file_path_specified or /path_specified/yyy.json
-if (llvm::sys::fs::is_directory(TracePathReal))
-  llvm::sys::path::append(TracePathReal,
-  llvm::sys::path::filename(OutputPath));
-llvm::sys::path::replace_extension(TracePathReal, "json");
-arg += std::string(TracePathReal.c_str());
-  }
-
-  assert(arg.size() > strlen("-ftime-trace") &&
- arg.find("-ftime-trace=") == 0 && arg[arg.size() - 1] != '=' &&
- "invalid `-ftime-trace=`");
-
-  const std::string::size_type size = arg.size();
-  char *buffer = new char[size + 1];
-  memcpy(buffer, arg.c_str(), size + 1);
-
-  // Replace `-ftime-trace` or `-ftime-trace=` with the modified
-  // `-ftime-trace=`.
-  auto &JArgs = J.getArguments();
-  for (unsigned I = 0; I < JArgs.size(); ++I) {
-if (StringRef(JArgs[I]).startswith("-ftime-trace=") ||
-(StringRef(JArgs[I]).equals("-ftime-trace") && !HasTimeTraceFile)) 
{
-  ArgStringList NewArgs(JArgs.begin(), JArgs.begin() + I);
-  NewArgs.push_back(buffer);
-  NewArgs.append(JArgs.begin() + I + 1, JArgs.end());
-  J.replaceArguments(NewArg

[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-03 Thread dongjunduo via Phabricator via cfe-commits
dongjunduo added a comment.

These related commits have been reverted temporarily.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D130888: [Clang] Introduce -fexperimental-sanitize-metadata=

2022-09-03 Thread Marco Elver via Phabricator via cfe-commits
melver added inline comments.



Comment at: clang/test/Driver/fsanitize-metadata.c:1
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all 
-fno-experimental-sanitize-metadata=all %s -### 2>&1 | FileCheck %s
+// CHECK-NOT: -fexperimental-sanitize-metadata

MaskRay wrote:
>  -fno-experimental-sanitize-metadata= works on bitmasks. You can change this 
> run line to remove one bit instead of all.
Added more tests to check removing one bit after =all, but left this in place 
for the extra coverage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130888

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


[PATCH] D130888: [Clang] Introduce -fexperimental-sanitize-metadata=

2022-09-03 Thread Marco Elver via Phabricator via cfe-commits
melver updated this revision to Diff 457779.
melver marked 3 inline comments as done.
melver added a comment.

- Options.td: s/f_clang_Group/f_Group/, remove NoXarchOption
- Driver test: also test -fexperimental-sanitize-metadata=all 
-fno-experimental-metadata=


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130888

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/sanitize-metadata.c
  clang/test/Driver/fsanitize-metadata.c

Index: clang/test/Driver/fsanitize-metadata.c
===
--- /dev/null
+++ clang/test/Driver/fsanitize-metadata.c
@@ -0,0 +1,23 @@
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all -fno-experimental-sanitize-metadata=all %s -### 2>&1 | FileCheck %s
+// CHECK-NOT: -fexperimental-sanitize-metadata
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=bad_arg %s -### 2>&1 | FileCheck -check-prefix=CHECK-INVALID %s
+// CHECK-INVALID: error: unsupported argument 'bad_arg' to option '-fexperimental-sanitize-metadata='
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered %s -### 2>&1 | FileCheck -check-prefix=CHECK-COVERED %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=atomics -fno-experimental-sanitize-metadata=atomics -fexperimental-sanitize-metadata=covered %s -### 2>&1 | FileCheck -check-prefix=CHECK-COVERED %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all -fno-experimental-sanitize-metadata=atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-COVERED %s
+// CHECK-COVERED: "-fexperimental-sanitize-metadata=covered"
+// CHECK-COVERED-NOT: "-fexperimental-sanitize-metadata=atomics"
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ATOMICS %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered -fno-experimental-sanitize-metadata=covered -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ATOMICS %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all -fno-experimental-sanitize-metadata=covered %s -### 2>&1 | FileCheck -check-prefix=CHECK-ATOMICS %s
+// CHECK-ATOMICS: "-fexperimental-sanitize-metadata=atomics"
+// CHECK-ATOMICS-NOT: "-fexperimental-sanitize-metadata=covered"
+
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered,atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=covered -fexperimental-sanitize-metadata=atomics %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// RUN: %clang --target=x86_64-linux-gnu -fexperimental-sanitize-metadata=all %s -### 2>&1 | FileCheck -check-prefix=CHECK-ALL %s
+// CHECK-ALL: "-fexperimental-sanitize-metadata=covered"
+// CHECK-ALL: "-fexperimental-sanitize-metadata=atomics"
Index: clang/test/CodeGen/sanitize-metadata.c
===
--- /dev/null
+++ clang/test/CodeGen/sanitize-metadata.c
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple x86_64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,ATOMICS
+// RUN: %clang_cc1 -O -fexperimental-sanitize-metadata=atomics -triple aarch64-gnu-linux -x c -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,ATOMICS
+
+int x, y;
+
+void empty() {
+// CHECK-NOT: define dso_local void @empty() {{.*}} !pcsections
+}
+
+int atomics() {
+// ATOMICS-LABEL: define dso_local i32 @atomics()
+// ATOMICS-SAME:  !pcsections ![[ATOMICS_COVERED:[0-9]+]]
+// ATOMICS-NEXT:  entry:
+// ATOMICS-NEXT:atomicrmw add {{.*}} !pcsections ![[ATOMIC_OP:[0-9]+]]
+// ATOMICS-NOT: load {{.*}} !pcsections
+  __atomic_fetch_add(&x, 1, __ATOMIC_RELAXED);
+  return y;
+}
+// ATOMICS-LABEL: __sanitizer_metadata_atomics.module_ctor
+// ATOMICS: call void @__sanitizer_metadata_atomics_add(i32 1, ptr @__start_sanmd_atomics, ptr @__stop_sanmd_atomics)
+// ATOMICS-LABEL: __sanitizer_metadata_atomics.module_dtor
+// ATOMICS: call void @__sanitizer_metadata_atomics_del(i32 1, ptr @__start_sanmd_atomics, ptr @__stop_sanmd_atomics)
+
+// CHECK-LABEL: __sanitizer_metadata_covered.module_ctor
+// CHECK: call void @__sanitizer_metadata_covered_add(i32 1, ptr @__start_sanmd_covered, ptr @__stop_sanmd_covered)
+// CHECK-LABEL: __sanitizer_metadata_covered.module_dtor
+// CHECK: call void @__sanitizer_metadata_covered_del(i32 1, ptr @__start_sanmd_covered, ptr @__stop_sanmd_covered)
+
+// ATOMICS: ![[ATO

[PATCH] D132990: [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:310-316
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}

I think the issue might not be tested in this file since we do not run it with 
the `-Wpre-c++17-compat` flag


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

https://reviews.llvm.org/D132990

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


[PATCH] D133244: [clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

2022-09-03 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please mention changes in Release Notes and add test case.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133244

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


[PATCH] D130513: [Flang] Add -fconvert option to swap endianness for unformatted files

2022-09-03 Thread Peixin Qiao via Phabricator via cfe-commits
peixin added inline comments.



Comment at: flang/runtime/environment.cpp:77
+#else
+  envp = environ;
+#endif

What is `environ` used for? Should we try to keep as less extern variable as 
possible in runtime for security.



Comment at: flang/test/Driver/emit-mlir.f90:16
 ! CHECK-NEXT: }
+! CHECK-NEXT: fir.global @_QQEnvironmentDefaults constant : 
!fir.ref, 
!fir.ref> {
+! CHECK-NEXT:  %[[VAL_0:.*]] = fir.zero_bits !fir.ref, !fir.ref>

jpenix-quic wrote:
> peixin wrote:
> > Is it possible not to generated this global variable if `fconvert=` is not 
> > specified?
> I'm not entirely sure--the issue I was running into was how to handle this in 
> Fortran_main.c in a way which worked for all of GCC/Clang/Visual Studio (and 
> maybe others?). I was originally thinking of doing this by using a weak 
> definition of _QQEnvironmentDefaults set to nullptr so fconvert, etc. could 
> override this definition without explicitly generating the fallback case. For 
> GCC/clang, I think I could use __attribute__((weak)), but I wasn't sure how 
> to handle this if someone tried to build with Visual Studio (or maybe another 
> toolchain). I saw a few workarounds (ex: 
> https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024) but I shied 
> away from this since it seems to be an undocumented feature (and presumably 
> only helps with Visual Studio). 
> 
> Do you know of a better or more general way I could do this? (Or, is there 
> non-weak symbol approach that might be better that I'm missing?)
How about generate one runtime function with the argument of 
`EnvironmentDefaultList`? This will avoid this and using one extern variable?

If users use one variable with bind C name `_QQEnvironmentDefaults` in fortran 
or one variable with name `_QQEnvironmentDefaults` in C, it is risky. Would 
using the runtime function and static variable with the type 
`EnvironmentDefaultList` in runtime be safer?


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

https://reviews.llvm.org/D130513

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


[clang] 3ad2fe9 - [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-03 Thread via cfe-commits

Author: yronglin
Date: 2022-09-03T23:26:01+08:00
New Revision: 3ad2fe913ae08ca062105731ad2da2eae825c731

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

LOG: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is 
array type

Avoid __builtin_assume_aligned crash when the 1st arg is array type(or string 
literal).

Open issue: https://github.com/llvm/llvm-project/issues/57169

Reviewed By: rjmccall

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

Added: 
clang/test/CodeGen/catch-alignment-assumption-array.c

Modified: 
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
clang/test/Sema/builtin-assume-aligned.c

Removed: 




diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 249a3913dc0b6..dc7671ed16cec 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -546,7 +546,7 @@ BUILTIN(__builtin_va_start, "vA.", "nt")
 BUILTIN(__builtin_va_end, "vA", "n")
 BUILTIN(__builtin_va_copy, "vAA", "n")
 BUILTIN(__builtin_stdarg_start, "vA.", "nt")
-BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nc")
+BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nct")
 BUILTIN(__builtin_bcmp, "ivC*vC*z", "Fn")
 BUILTIN(__builtin_bcopy, "vv*v*z", "n")
 BUILTIN(__builtin_bzero, "vv*z", "nF")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index cc3cf9ab46b5e..7bde3fd8a9868 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2781,6 +2781,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_assume_aligned: {
 const Expr *Ptr = E->getArg(0);
 Value *PtrValue = EmitScalarExpr(Ptr);
+if (PtrValue->getType() != VoidPtrTy)
+  PtrValue = EmitCastToVoidPtr(PtrValue);
 Value *OffsetValue =
   (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : nullptr;
 

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 81c687e4530f4..0b75f034739dd 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2443,8 +2443,6 @@ void CodeGenFunction::emitAlignmentAssumption(llvm::Value 
*PtrValue,
   SourceLocation AssumptionLoc,
   llvm::Value *Alignment,
   llvm::Value *OffsetValue) {
-  if (auto *CE = dyn_cast(E))
-E = CE->getSubExprAsWritten();
   QualType Ty = E->getType();
   SourceLocation Loc = E->getExprLoc();
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 897ab701493c2..de132b8300a1f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -128,6 +128,28 @@ static bool checkArgCountAtLeast(Sema &S, CallExpr *Call,
  << Call->getSourceRange();
 }
 
+/// Checks that a call expression's argument count is at most the desired
+/// number. This is useful when doing custom type-checking on a variadic
+/// function. Returns true on error.
+static bool checkArgCountAtMost(Sema &S, CallExpr *Call, unsigned MaxArgCount) 
{
+  unsigned ArgCount = Call->getNumArgs();
+  if (ArgCount <= MaxArgCount)
+return false;
+  return S.Diag(Call->getEndLoc(),
+diag::err_typecheck_call_too_many_args_at_most)
+ << 0 /*function call*/ << MaxArgCount << ArgCount
+ << Call->getSourceRange();
+}
+
+/// Checks that a call expression's argument count is in the desired range. 
This
+/// is useful when doing custom type-checking on a variadic function. Returns
+/// true on error.
+static bool checkArgCountRange(Sema &S, CallExpr *Call, unsigned MinArgCount,
+   unsigned MaxArgCount) {
+  return checkArgCountAtLeast(S, Call, MinArgCount) ||
+ checkArgCountAtMost(S, Call, MaxArgCount);
+}
+
 /// Checks that a call expression's argument count is the desired number.
 /// This is useful when doing custom type-checking.  Returns true on error.
 static bool checkArgCount(Sema &S, CallExpr *Call, unsigned DesiredArgCount) {
@@ -148,6 +170,20 @@ static bool checkArgCount(Sema &S, CallExpr *Call, 
unsigned DesiredArgCount) {
  << Call->getArg(1)->getSourceRange();
 }
 
+static bool convertArgumentToType(Sema &S, Expr *&Value, QualType Ty) {
+  if (Value->isTypeDependent())
+return false;
+
+  InitializedEntity Entity =
+  InitializedEntity::InitializeParameter(S.Context, Ty, false);
+  ExprResult Result =
+  S.PerformCopyInitialization(Entity, 

[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-03 Thread Lin Yurong via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3ad2fe913ae0: [Clang][CodeGen] Avoid 
__builtin_assume_aligned crash when the 1st arg is array… (authored by 
yronglin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

Files:
  clang/include/clang/Basic/Builtins.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/catch-alignment-assumption-array.c
  clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
  clang/test/Sema/builtin-assume-aligned.c

Index: clang/test/Sema/builtin-assume-aligned.c
===
--- clang/test/Sema/builtin-assume-aligned.c
+++ clang/test/Sema/builtin-assume-aligned.c
@@ -66,6 +66,11 @@
 }
 #endif
 
+int test13(int *a) {
+  a = (int *)__builtin_assume_aligned(a, 2 * 2.0); // expected-error {{argument to '__builtin_assume_aligned' must be a constant integer}}
+  return a[0];
+}
+
 void test_void_assume_aligned(void) __attribute__((assume_aligned(32))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 int test_int_assume_aligned(void) __attribute__((assume_aligned(16))); // expected-warning {{'assume_aligned' attribute only applies to return values that are pointers}}
 void *test_ptr_assume_aligned(void) __attribute__((assume_aligned(64))); // no-warning
Index: clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
===
--- clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
+++ clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
@@ -26,3 +26,9 @@
 void *ignore_volatiles(volatile void * x) {
   return __builtin_assume_aligned(x, 1);
 }
+
+// CHECK-LABEL: ignore_array_volatiles
+void *ignore_array_volatiles() {
+  volatile int arr[] = {1};
+  return __builtin_assume_aligned(arr, 4);
+}
Index: clang/test/CodeGen/catch-alignment-assumption-array.c
===
--- /dev/null
+++ clang/test/CodeGen/catch-alignment-assumption-array.c
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -no-opaque-pointers -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fno-sanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-NORECOVER,CHECK-SANITIZE-UNREACHABLE
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-recover=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-ANYRECOVER,CHECK-SANITIZE-RECOVER
+// RUN: %clang_cc1 -no-opaque-pointers -fsanitize=alignment -fsanitize-trap=alignment -emit-llvm %s -o - -triple x86_64-linux-gnu | FileCheck %s -implicit-check-not="call void @__ubsan_handle_alignment_assumption" --check-prefixes=CHECK,CHECK-SANITIZE,CHECK-SANITIZE-TRAP,CHECK-SANITIZE-UNREACHABLE
+
+// CHECK-SANITIZE-ANYRECOVER: @[[CHAR:.*]] = {{.*}} c"'char *'\00" }
+// CHECK-SANITIZE-ANYRECOVER: @[[ALIGNMENT_ASSUMPTION:.*]] = {{.*}}, i32 31, i32 35 }, {{.*}}* @[[CHAR]] }
+
+void *caller(void) {
+  char str[] = "";
+  // CHECK:   define{{.*}}
+  // CHECK-NEXT:  entry:
+  // CHECK-NEXT:%[[STR:.*]] = alloca [1 x i8], align 1
+  // CHECK-NEXT:%[[BITCAST:.*]] = bitcast [1 x i8]* %[[STR]] to i8*
+  // CHECK-NEXT:call void @llvm.memset.p0i8.i64(i8* align 1 %[[BITCAST]], i8 0, i64 1, i1 false)
+  // CHECK-NEXT:%[[ARRAYDECAY:.*]] = getelementptr inbounds [1 x i8], [1 x i8]* %[[STR]], i64 0, i64 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64
+  // CHECK-SANITIZE-NEXT:   %[[MASKEDPTR:.*]] = and i64 %[[PTRINT]], 0
+  // CHECK-SANITIZE-NEXT:   %[[MASKCOND:.*]] = icmp eq i64 %[[MASKEDPTR]], 0
+  // CHECK-SANITIZE-NEXT:   %[[PTRINT_DUP:.*]] = ptrtoint i8* %[[ARRAYDECAY]] to i64, !nosanitize
+  // CHECK-SANITIZE-NEXT:   br i1 %[[MASKCOND]], label %[[CONT:.*]], label %[[HANDLER_ALIGNMENT_ASSUMPTION:[^,]+]],{{.*}} !nosanitize
+  // CHECK-SANITIZE:  [[HANDLER_ALIGNMENT_ASSUMPTION]]:
+  // CHECK-SANITIZE-NORECOVER-NEXT: call void @__ubsan_handle_alignment_assumption_abort(i8* bitcast ({ {{{.*}}}, {{{.*}}}, {{{.*}}}* }* @[[ALIGNMENT_ASSUMPTION]] to i8*), i64 %[[PTRINT_DUP]], i64 1, i64 0){{.*}}, !nosanitize
+  // CHECK-SANITIZE-RECOVER-NEXT:   call void @__ubsan_handle_alignment_assumption(i8* bitcast ({ {{{.*}}}, {{{.*}}

[PATCH] D131750: [clang-format] Distinguish logical and after bracket from reference

2022-09-03 Thread Jack Huang via Phabricator via cfe-commits
jackhong12 added a comment.

Is there any chance we also add this patch to version 15?

https://github.com/llvm/llvm-project/issues/57534#issuecomment-1236132578


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131750

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


[clang] a2ef765 - [Driver] Change some cc1 only JoinedOrSeparate long options to Separate

2022-09-03 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-03T10:45:30-07:00
New Revision: a2ef7654ec2e907f84a876b1cf5d37fc87754de7

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

LOG: [Driver] Change some cc1 only JoinedOrSeparate long options to Separate

They are error-prone as they do not end with `=`.
Note: for driver -isystem/etc, we have to support the Joined form.

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index a3134fdae87cd..d03336f32b968 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -4275,7 +4275,7 @@ def : Flag<["-"], "integrated-as">, 
Alias, Flags<[NoXarchOption]
 def : Flag<["-"], "no-integrated-as">, Alias,
   Flags<[CC1Option, FlangOption, NoXarchOption]>;
 
-def working_directory : JoinedOrSeparate<["-"], "working-directory">, 
Flags<[CC1Option]>,
+def working_directory : Separate<["-"], "working-directory">, 
Flags<[CC1Option]>,
   HelpText<"Resolve file paths relative to the specified directory">,
   MarshallingInfoString>;
 def working_directory_EQ : Joined<["-"], "working-directory=">, 
Flags<[CC1Option]>,
@@ -6204,20 +6204,20 @@ def fmodules_strict_context_hash : Flag<["-"], 
"fmodules-strict-context-hash">,
   HelpText<"Enable hashing of all compiler options that could impact the "
"semantics of a module in an implicit build">,
   MarshallingInfoFlag>;
-def c_isystem : JoinedOrSeparate<["-"], "c-isystem">, 
MetaVarName<"">,
+def c_isystem : Separate<["-"], "c-isystem">, MetaVarName<"">,
   HelpText<"Add directory to the C SYSTEM include search path">;
-def objc_isystem : JoinedOrSeparate<["-"], "objc-isystem">,
+def objc_isystem : Separate<["-"], "objc-isystem">,
   MetaVarName<"">,
   HelpText<"Add directory to the ObjC SYSTEM include search path">;
-def objcxx_isystem : JoinedOrSeparate<["-"], "objcxx-isystem">,
+def objcxx_isystem : Separate<["-"], "objcxx-isystem">,
   MetaVarName<"">,
   HelpText<"Add directory to the ObjC++ SYSTEM include search path">;
-def internal_isystem : JoinedOrSeparate<["-"], "internal-isystem">,
+def internal_isystem : Separate<["-"], "internal-isystem">,
   MetaVarName<"">,
   HelpText<"Add directory to the internal system include search path; these "
"are assumed to not be user-provided and are used to model system "
"and standard headers' paths.">;
-def internal_externc_isystem : JoinedOrSeparate<["-"], 
"internal-externc-isystem">,
+def internal_externc_isystem : Separate<["-"], "internal-externc-isystem">,
   MetaVarName<"">,
   HelpText<"Add directory to the internal system include search path with "
"implicit extern \"C\" semantics; these are assumed to not be "



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


[clang] 89df4e4 - [Driver] Remove unused -Ttext -Tdata -Tbss

2022-09-03 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-03T10:57:29-07:00
New Revision: 89df4e4825ee6136bebbe5f70de29eb80456aaa4

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

LOG: [Driver] Remove unused -Ttext -Tdata -Tbss

They lead to -Wunused-command-line-argument and should be written as -Ttext=
instead, but the driver options end with a space. -Ttext=0 can be accepted by
the JoinedOrSeparate -T, so the JoinedOrSeparate -Ttext/etc are unneeded.

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/test/Driver/hexagon-toolchain-elf.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d03336f32b968..c7c34f072ba23 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -764,12 +764,6 @@ def R_Joined : Joined<["-"], "R">, Group, 
Flags<[CC1Option, CoreOption]
   MetaVarName<"">, HelpText<"Enable the specified remark">;
 def S : Flag<["-"], "S">, 
Flags<[NoXarchOption,CC1Option,FlangOption,FC1Option]>, Group,
   HelpText<"Only run preprocess and compilation steps">;
-def Tbss : JoinedOrSeparate<["-"], "Tbss">, Group,
-  MetaVarName<"">, HelpText<"Set starting address of BSS to ">;
-def Tdata : JoinedOrSeparate<["-"], "Tdata">, Group,
-  MetaVarName<"">, HelpText<"Set starting address of DATA to ">;
-def Ttext : JoinedOrSeparate<["-"], "Ttext">, Group,
-  MetaVarName<"">, HelpText<"Set starting address of TEXT to ">;
 def T : JoinedOrSeparate<["-"], "T">, Group,
   MetaVarName<"

[PATCH] D133202: [Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type

2022-09-03 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Broken by the patch https://lab.llvm.org/buildbot/#/builders/127/builds/35304


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133202

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


[PATCH] D131469: [Clang] change default storing path of `-ftime-trace`

2022-09-03 Thread Steven Wu via Phabricator via cfe-commits
steven_wu added a comment.

In D131469#3768500 , @dongjunduo 
wrote:

> These related commits have been reverted temporarily.

Thanks. Another way to do this is that as you don't really care what linker 
does in this test case, you just need to fake a linker with a shell script then 
let the clang driver to invoke that script as a linker.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131469

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


[PATCH] D131750: [clang-format] Distinguish logical and after bracket from reference

2022-09-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a subscriber: tstellar.
HazardyKnusperkeks added a comment.

You have to ask @tstellar to cherry-pick it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131750

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


[clang] 9905dae - Revert "[Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st arg is array type"

2022-09-03 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-09-03T13:12:49-07:00
New Revision: 9905dae5e18cd55ee6bb8678c95fed940ded1ef9

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

LOG: Revert "[Clang][CodeGen] Avoid __builtin_assume_aligned crash when the 1st 
arg is array type"

Breakes windows bot.

This reverts commit 3ad2fe913ae08ca062105731ad2da2eae825c731.

Added: 


Modified: 
clang/include/clang/Basic/Builtins.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/catch-alignment-assumption-ignorelist.c
clang/test/Sema/builtin-assume-aligned.c

Removed: 
clang/test/CodeGen/catch-alignment-assumption-array.c



diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index dc7671ed16ce..249a3913dc0b 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -546,7 +546,7 @@ BUILTIN(__builtin_va_start, "vA.", "nt")
 BUILTIN(__builtin_va_end, "vA", "n")
 BUILTIN(__builtin_va_copy, "vAA", "n")
 BUILTIN(__builtin_stdarg_start, "vA.", "nt")
-BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nct")
+BUILTIN(__builtin_assume_aligned, "v*vC*z.", "nc")
 BUILTIN(__builtin_bcmp, "ivC*vC*z", "Fn")
 BUILTIN(__builtin_bcopy, "vv*v*z", "n")
 BUILTIN(__builtin_bzero, "vv*z", "nF")

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 5af3811988e1..d5b504949447 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -2781,8 +2781,6 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BI__builtin_assume_aligned: {
 const Expr *Ptr = E->getArg(0);
 Value *PtrValue = EmitScalarExpr(Ptr);
-if (PtrValue->getType() != VoidPtrTy)
-  PtrValue = EmitCastToVoidPtr(PtrValue);
 Value *OffsetValue =
   (E->getNumArgs() > 2) ? EmitScalarExpr(E->getArg(2)) : nullptr;
 

diff  --git a/clang/lib/CodeGen/CodeGenFunction.cpp 
b/clang/lib/CodeGen/CodeGenFunction.cpp
index 0b75f034739d..81c687e4530f 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -2443,6 +2443,8 @@ void CodeGenFunction::emitAlignmentAssumption(llvm::Value 
*PtrValue,
   SourceLocation AssumptionLoc,
   llvm::Value *Alignment,
   llvm::Value *OffsetValue) {
+  if (auto *CE = dyn_cast(E))
+E = CE->getSubExprAsWritten();
   QualType Ty = E->getType();
   SourceLocation Loc = E->getExprLoc();
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index de132b8300a1..897ab701493c 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -128,28 +128,6 @@ static bool checkArgCountAtLeast(Sema &S, CallExpr *Call,
  << Call->getSourceRange();
 }
 
-/// Checks that a call expression's argument count is at most the desired
-/// number. This is useful when doing custom type-checking on a variadic
-/// function. Returns true on error.
-static bool checkArgCountAtMost(Sema &S, CallExpr *Call, unsigned MaxArgCount) 
{
-  unsigned ArgCount = Call->getNumArgs();
-  if (ArgCount <= MaxArgCount)
-return false;
-  return S.Diag(Call->getEndLoc(),
-diag::err_typecheck_call_too_many_args_at_most)
- << 0 /*function call*/ << MaxArgCount << ArgCount
- << Call->getSourceRange();
-}
-
-/// Checks that a call expression's argument count is in the desired range. 
This
-/// is useful when doing custom type-checking on a variadic function. Returns
-/// true on error.
-static bool checkArgCountRange(Sema &S, CallExpr *Call, unsigned MinArgCount,
-   unsigned MaxArgCount) {
-  return checkArgCountAtLeast(S, Call, MinArgCount) ||
- checkArgCountAtMost(S, Call, MaxArgCount);
-}
-
 /// Checks that a call expression's argument count is the desired number.
 /// This is useful when doing custom type-checking.  Returns true on error.
 static bool checkArgCount(Sema &S, CallExpr *Call, unsigned DesiredArgCount) {
@@ -170,20 +148,6 @@ static bool checkArgCount(Sema &S, CallExpr *Call, 
unsigned DesiredArgCount) {
  << Call->getArg(1)->getSourceRange();
 }
 
-static bool convertArgumentToType(Sema &S, Expr *&Value, QualType Ty) {
-  if (Value->isTypeDependent())
-return false;
-
-  InitializedEntity Entity =
-  InitializedEntity::InitializeParameter(S.Context, Ty, false);
-  ExprResult Result =
-  S.PerformCopyInitialization(Entity, SourceLocation(), Value);
-  if (Result.isInvalid())
-return true;
-  Value = Result.get();
-  return false;
-}
-
 /// Check that the first 

[PATCH] D133249: [libc++] Documents details of the pre-commit CI.

2022-09-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/www/hacking.html:302
+
+  For most builds, the pre-commit CI uses a recent
+  https://apt.llvm.org/";>nightly build of Clang from LLVM's main

I'm wondering if there's a better synonym for "builds" here which would be 
clearer? Initially I read this as if "most times a patch is run through the 
CI", not "most of the configurations in the CI run". So maybe "configurations"?



Comment at: libcxx/docs/Contributing.rst:101
+
+Unlike eost parts of the LLVM project, libc++ uses a pre-commit CI [#]_. This
+CI is hosted on `Buildkite `__ 
and

Typo `eost` - I presume you mean "most"?



Comment at: libcxx/docs/Contributing.rst:119
+
+Unless specified otherwise the ``main`` version of Clang is used.
+

I don't understand this paragraph - each CI run is run through the configured 
set of supported Clang versions - not only `main`? Or does this talk about 
specifics about manually running tests with the Docker image?



Comment at: libcxx/docs/Contributing.rst:158
+* ``Clang XX`` these build steps test whether the changes work with all
+  supported Clang versions.
+* ``Booststrapping build`` builds Clang using the revision of the patch and

Side note - these tests only test one specific version of C++ with these 
versions of Clang - we don't have fully coverage of all standard versions with 
all supported versions of Clang. (Not really sure if that's worth mentioning 
though. Also I do see this kinda hinted at at the end of the file.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133249

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


[PATCH] D133261: NFC: [clang] add template substitution AST test for make_integer_seq

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a project: All.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Depends on D133072 

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133261

Files:
  clang/test/SemaTemplate/make_integer_seq.cpp


Index: clang/test/SemaTemplate/make_integer_seq.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/make_integer_seq.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -ast-dump -xc++ < %s | FileCheck %s
+
+template  struct A {};
+
+using test1 = __make_integer_seq;
+//  CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 
test1 '__make_integer_seq':'A'
+// CHECK-NEXT: | `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar
+// CHECK-NEXT: |   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 
'__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT: | |-TemplateArgument template A
+// CHECK-NEXT: | |-TemplateArgument type 'int'
+// CHECK-NEXT: | | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT: | |-TemplateArgument expr
+// CHECK-NEXT: | | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT: | |   |-value: Int 1
+// CHECK-NEXT: | |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
+// CHECK-NEXT: | `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: |   `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
+
+template  using B = __make_integer_seq;
+using test2 = B;
+//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 
test2 'B':'A'
+// CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 'B' sugar
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'B' 
sugar alias B
+// CHECK-NEXT:   |-TemplateArgument type 'int'
+// CHECK-NEXT:   | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT:   |-TemplateArgument expr
+// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT:   |   |-value: Int 1
+// CHECK-NEXT:   |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
+// CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 
'__make_integer_seq' sugar
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 
'__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT:   |-TemplateArgument template A
+// CHECK-NEXT:   |-TemplateArgument type 'int':'int'
+// CHECK-NEXT:   | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 
'int' sugar
+// CHECK-NEXT:   |   |-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'B1' 
dependent depth 0 index 0
+// CHECK-NEXT:   |   | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'B1'
+// CHECK-NEXT:   |   `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT:   |-TemplateArgument expr
+// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT:   |   |-value: Int 1
+// CHECK-NEXT:   |   `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}} 
 'int'
+// CHECK-NEXT:   | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}} 
 col:24 referenced 'B1' depth 0 index 1 B2
+// CHECK-NEXT:   | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  
'int' 1
+// CHECK-NEXT:   `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'


Index: clang/test/SemaTemplate/make_integer_seq.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/make_integer_seq.cpp
@@ -0,0 +1,45 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -ast-dump -xc++ < %s | FileCheck %s
+
+template  struct A {};
+
+using test1 = __make_integer_seq;
+//  CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test1 '__make_integer_seq':'A'
+// CHECK-NEXT: | `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar
+// CHECK-NEXT: |   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT: | |-TemplateArgument template A
+// CHECK-NEXT: | |-TemplateArgument type 'int'
+// CHECK-NEXT: | | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT: | |-TemplateArgument expr
+// CHECK-NEXT: | | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT: | |   |-value: Int 1
+// CHECK-NEXT: | |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
+// CHECK-NEXT: | `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: |   `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
+
+template  using B = __make_integer_seq;
+using test2 = B;
+//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test2 'B':'A'
+// CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 'B' sugar
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'B' sugar alias B
+// CHECK-NEXT:   |-TemplateArgument type 'int'
+// CHECK-NEXT:   | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT: 

[PATCH] D133262: [clang] Represent __make_integer_seq as alias template in the AST

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov created this revision.
Herald added a subscriber: jeroen.dobbelaere.
Herald added a project: All.
mizvekov requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

We change the template specialization of __make_integer_seq to
be an alias to a synthesized template specialization type of the
underlying template, making the resulting type correctly represent
the template arguments used to specialize the underlying template.

When performing member access on the resulting type, it's now
possible to map from a Subst* node to the template argument
as-written used in a regular fashion, without special casing.

Depends on D133261 

Signed-off-by: Matheus Izvekov 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133262

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/make_integer_seq.cpp

Index: clang/test/SemaTemplate/make_integer_seq.cpp
===
--- clang/test/SemaTemplate/make_integer_seq.cpp
+++ clang/test/SemaTemplate/make_integer_seq.cpp
@@ -5,7 +5,7 @@
 using test1 = __make_integer_seq;
 //  CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test1 '__make_integer_seq':'A'
 // CHECK-NEXT: | `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar
-// CHECK-NEXT: |   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT: |   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar alias __make_integer_seq
 // CHECK-NEXT: | |-TemplateArgument template A
 // CHECK-NEXT: | |-TemplateArgument type 'int'
 // CHECK-NEXT: | | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
@@ -13,12 +13,22 @@
 // CHECK-NEXT: | | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT: | |   |-value: Int 1
 // CHECK-NEXT: | |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
-// CHECK-NEXT: | `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
-// CHECK-NEXT: |   `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: | `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A' sugar A
+// CHECK-NEXT: |   |-TemplateArgument type 'int':'int'
+// CHECK-NEXT: |   | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
+// CHECK-NEXT: |   |   |-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'auto' dependent depth 0 index 1
+// CHECK-NEXT: |   |   | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
+// CHECK-NEXT: |   |   `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT: |   |-TemplateArgument expr
+// CHECK-NEXT: |   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT: |   |   |-value: Int 0
+// CHECK-NEXT: |   |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 0
+// CHECK-NEXT: |   `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: | `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
 
 template  using B = __make_integer_seq;
 using test2 = B;
-//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test2 'B':'A'
+//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test2 'B':'A'
 // CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 'B' sugar
 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'B' sugar alias B
 // CHECK-NEXT:   |-TemplateArgument type 'int'
@@ -28,7 +38,7 @@
 // CHECK-NEXT:   |   |-value: Int 1
 // CHECK-NEXT:   |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
 // CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar
-// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar alias __make_integer_seq
 // CHECK-NEXT:   |-TemplateArgument template A
 // CHECK-NEXT:   |-TemplateArgument type 'int':'int'
 // CHECK-NEXT:   | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
@@ -36,10 +46,20 @@
 // CHECK-NEXT:   |   | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'B1'
 // CHECK-NEXT:   |   `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
 // CHECK-NEXT:   |-TemplateArgument expr
-// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT:   |   |-value: Int 1
 // CHECK-NEXT:   |   `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT:   | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}}  col:24 referenced 'B1' depth 0 index 1 B2
 // CHECK-NEXT:   | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
-// CHECK-NEXT:   `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
-// CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}

[PATCH] D133262: [clang] Represent __make_integer_seq as alias template in the AST

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 457816.
Herald added a project: libc++.
Herald added a subscriber: libcxx-commits.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133262

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/make_integer_seq.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D133072
+D133262
Index: clang/test/SemaTemplate/make_integer_seq.cpp
===
--- clang/test/SemaTemplate/make_integer_seq.cpp
+++ clang/test/SemaTemplate/make_integer_seq.cpp
@@ -5,7 +5,7 @@
 using test1 = __make_integer_seq;
 //  CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test1 '__make_integer_seq':'A'
 // CHECK-NEXT: | `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar
-// CHECK-NEXT: |   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT: |   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar alias __make_integer_seq
 // CHECK-NEXT: | |-TemplateArgument template A
 // CHECK-NEXT: | |-TemplateArgument type 'int'
 // CHECK-NEXT: | | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
@@ -13,12 +13,22 @@
 // CHECK-NEXT: | | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT: | |   |-value: Int 1
 // CHECK-NEXT: | |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
-// CHECK-NEXT: | `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
-// CHECK-NEXT: |   `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: | `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A' sugar A
+// CHECK-NEXT: |   |-TemplateArgument type 'int':'int'
+// CHECK-NEXT: |   | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
+// CHECK-NEXT: |   |   |-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'auto' dependent depth 0 index 1
+// CHECK-NEXT: |   |   | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
+// CHECK-NEXT: |   |   `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT: |   |-TemplateArgument expr
+// CHECK-NEXT: |   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT: |   |   |-value: Int 0
+// CHECK-NEXT: |   |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 0
+// CHECK-NEXT: |   `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: | `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
 
 template  using B = __make_integer_seq;
 using test2 = B;
-//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test2 'B':'A'
+//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test2 'B':'A'
 // CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 'B' sugar
 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'B' sugar alias B
 // CHECK-NEXT:   |-TemplateArgument type 'int'
@@ -28,7 +38,7 @@
 // CHECK-NEXT:   |   |-value: Int 1
 // CHECK-NEXT:   |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
 // CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar
-// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar alias __make_integer_seq
 // CHECK-NEXT:   |-TemplateArgument template A
 // CHECK-NEXT:   |-TemplateArgument type 'int':'int'
 // CHECK-NEXT:   | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
@@ -36,10 +46,20 @@
 // CHECK-NEXT:   |   | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'B1'
 // CHECK-NEXT:   |   `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
 // CHECK-NEXT:   |-TemplateArgument expr
-// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT:   |   |-value: Int 1
 // CHECK-NEXT:   |   `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT:   | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}}  col:24 referenced 'B1' depth 0 index 1 B2
 // CHECK-NEXT:   | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
-// CHECK-NEXT:   `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
-// CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT:   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A' sugar A
+// CHECK-NEXT: |-TemplateArgument type 'int':'int'
+// CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
+// CHECK-NEXT: |   |-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'auto' dependent depth 0 index 1

[PATCH] D133157: Add -sanitizer-coverage-control-flow

2022-09-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/docs/SanitizerCoverage.rst:338
+
+With ``-fsanitize-coverage=control-flow`` the compiler will create a table to 
collect
+control flow for each function. More specifically, for each basic block in the 
function,

This paragraph doesn't describe how the table is encoded.

The description about null-separated is incorrect as it is actually null-ended.



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1048
+
+void ModuleSanitizerCoverage::CollectFunctionControlFlow(Function &F) {
+  SmallVector CFs;

Use `collectFunctionControlFlow` for new functions. `CamelCaseFunction` is 
legacy.

I'd prefer `createXXX` since `collectXXX` implies returning the object while 
the function actually creates the needed metadata.



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1080
+
+  size_t N = CFs.size();
+  auto CFArray = CreateFunctionLocalArrayInSection(CFs.size(), F, IntptrPtrTy, 
SanCovCFsSectionName);

-Wunused-variable



Comment at: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp:1081
+  size_t N = CFs.size();
+  auto CFArray = CreateFunctionLocalArrayInSection(CFs.size(), F, IntptrPtrTy, 
SanCovCFsSectionName);
+  CFArray->setInitializer(ConstantArray::get(ArrayType::get(IntptrPtrTy, 
CFs.size()), CFs));

I'd avoid the variable in favor of `FunctionCFsArray`



Comment at: llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll:1
+; Test -sanitizer-coverage-control-flow
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 
-sanitizer-coverage-control-flow -S | FileCheck %s

End complete sentences in comments with `.`



Comment at: llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll:6
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo(i32* %a) sanitize_address {
+entry:

Avoid `i32*`. Use opaque pointers `ptr` for new tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D133157: Add -sanitizer-coverage-control-flow

2022-09-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> Add -sanitizer-coverage-control-flow

Add -fsanitizer-coverage=control-flow


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D133262: [clang] Represent __make_integer_seq as alias template in the AST

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 457817.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133262

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclTemplate.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/make_integer_seq.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- libcxx/DELETE.ME
+++ libcxx/DELETE.ME
@@ -1 +1,2 @@
 D133072
+D133262
Index: clang/test/SemaTemplate/make_integer_seq.cpp
===
--- clang/test/SemaTemplate/make_integer_seq.cpp
+++ clang/test/SemaTemplate/make_integer_seq.cpp
@@ -5,7 +5,7 @@
 using test1 = __make_integer_seq;
 //  CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test1 '__make_integer_seq':'A'
 // CHECK-NEXT: | `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar
-// CHECK-NEXT: |   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT: |   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar alias __make_integer_seq
 // CHECK-NEXT: | |-TemplateArgument template A
 // CHECK-NEXT: | |-TemplateArgument type 'int'
 // CHECK-NEXT: | | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
@@ -13,12 +13,22 @@
 // CHECK-NEXT: | | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT: | |   |-value: Int 1
 // CHECK-NEXT: | |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
-// CHECK-NEXT: | `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
-// CHECK-NEXT: |   `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: | `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A' sugar A
+// CHECK-NEXT: |   |-TemplateArgument type 'int':'int'
+// CHECK-NEXT: |   | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
+// CHECK-NEXT: |   |   |-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'auto' dependent depth 0 index 1
+// CHECK-NEXT: |   |   | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
+// CHECK-NEXT: |   |   `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT: |   |-TemplateArgument expr
+// CHECK-NEXT: |   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT: |   |   |-value: Int 0
+// CHECK-NEXT: |   |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 0
+// CHECK-NEXT: |   `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT: | `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
 
 template  using B = __make_integer_seq;
 using test2 = B;
-//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test2 'B':'A'
+//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:7 test2 'B':'A'
 // CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} 'B' sugar
 // CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'B' sugar alias B
 // CHECK-NEXT:   |-TemplateArgument type 'int'
@@ -28,7 +38,7 @@
 // CHECK-NEXT:   |   |-value: Int 1
 // CHECK-NEXT:   |   `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
 // CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar
-// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar __make_integer_seq
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__make_integer_seq' sugar alias __make_integer_seq
 // CHECK-NEXT:   |-TemplateArgument template A
 // CHECK-NEXT:   |-TemplateArgument type 'int':'int'
 // CHECK-NEXT:   | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
@@ -36,10 +46,20 @@
 // CHECK-NEXT:   |   | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'B1'
 // CHECK-NEXT:   |   `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
 // CHECK-NEXT:   |-TemplateArgument expr
-// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
+// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT:   |   |-value: Int 1
 // CHECK-NEXT:   |   `-SubstNonTypeTemplateParmExpr 0x{{[0-9A-Fa-f]+}}  'int'
 // CHECK-NEXT:   | |-NonTypeTemplateParmDecl 0x{{[0-9A-Fa-f]+}}  col:24 referenced 'B1' depth 0 index 1 B2
 // CHECK-NEXT:   | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 1
-// CHECK-NEXT:   `-RecordType 0x{{[0-9A-Fa-f]+}} 'A'
-// CHECK-NEXT: `-ClassTemplateSpecialization 0x{{[0-9A-Fa-f]+}} 'A'
+// CHECK-NEXT:   `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} 'A' sugar A
+// CHECK-NEXT: |-TemplateArgument type 'int':'int'
+// CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar
+// CHECK-NEXT: |   |-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'auto' dependent depth 0 index 1
+// CHECK-NEXT: |   | `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} ''
+// CHECK-NEXT: |   `

[PATCH] D133082: [clang] Implement setting crash_diagnostics_dir through env variable

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 457818.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133082

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UsersManual.rst
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/crash-diagnostics-dir-3.c
  libcxx/utils/ci/buildkite-pipeline.yml


Index: libcxx/utils/ci/buildkite-pipeline.yml
===
--- libcxx/utils/ci/buildkite-pipeline.yml
+++ libcxx/utils/ci/buildkite-pipeline.yml
@@ -369,10 +369,12 @@
 artifact_paths:
   - "**/test-results.xml"
   - "**/*.abilist"
+  - "**/crash_diagnostics/*"
 env:
 CC: "clang-${LLVM_HEAD_VERSION}"
 CXX: "clang++-${LLVM_HEAD_VERSION}"
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}"
+CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
   queue: "libcxx-builders"
   os: "linux"
Index: clang/test/Driver/crash-diagnostics-dir-3.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir-3.c
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: not env CLANG_CRASH_DIAGNOSTICS_DIR=%t %clang -c %s -o - 2>&1 | 
FileCheck %s
+#pragma clang __debug parser_crash
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK: diagnostic msg: 
{{.*}}{{/|\\}}crash-diagnostics-dir-3.c.tmp{{(/|\\).*}}.c
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -5413,15 +5413,18 @@
StringRef BoundArch) const {
   SmallString<128> TmpName;
   Arg *A = C.getArgs().getLastArg(options::OPT_fcrash_diagnostics_dir);
-  if (CCGenDiagnostics && A) {
-SmallString<128> CrashDirectory(A->getValue());
-if (!getVFS().exists(CrashDirectory))
-  llvm::sys::fs::create_directories(CrashDirectory);
-llvm::sys::path::append(CrashDirectory, Prefix);
+  Optional CrashDirectory =
+  CCGenDiagnostics && A
+  ? std::string(A->getValue())
+  : llvm::sys::Process::GetEnv("CLANG_CRASH_DIAGNOSTICS_DIR");
+  if (CrashDirectory) {
+if (!getVFS().exists(*CrashDirectory))
+  llvm::sys::fs::create_directories(*CrashDirectory);
+SmallString<128> Path(*CrashDirectory);
+llvm::sys::path::append(Path, Prefix);
 const char *Middle = !Suffix.empty() ? "-%%." : "-%%";
-std::error_code EC = llvm::sys::fs::createUniqueFile(
-CrashDirectory + Middle + Suffix, TmpName);
-if (EC) {
+if (std::error_code EC =
+llvm::sys::fs::createUniqueFile(Path + Middle + Suffix, TmpName)) {
   Diag(clang::diag::err_unable_to_make_temp) << EC.message();
   return "";
 }
Index: clang/docs/UsersManual.rst
===
--- clang/docs/UsersManual.rst
+++ clang/docs/UsersManual.rst
@@ -687,6 +687,11 @@
   Specify where to write the crash diagnostics files; defaults to the
   usual location for temporary files.
 
+.. envvar:: CLANG_CRASH_DIAGNOSTICS_DIR=
+
+   Like :option:`-fcrash-diagnostics-dir=`, specifies where to write the
+   crash diagnostics files, but with lower precedence than the option.
+
 Clang is also capable of generating preprocessed source file(s) and associated
 run script(s) even without a crash. This is specially useful when trying to
 generate a reproducer for warnings or errors while using modules.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -135,6 +135,9 @@
 
 Non-comprehensive list of changes in this release
 -
+- It's now possible to set the crash diagnostics directory through
+  the environment variable ``CLANG_CRASH_DIAGNOSTICS_DIR``.
+  The ``-fcrash-diagnostics-dir`` flag takes precedence.
 
 New Compiler Flags
 --


Index: libcxx/utils/ci/buildkite-pipeline.yml
===
--- libcxx/utils/ci/buildkite-pipeline.yml
+++ libcxx/utils/ci/buildkite-pipeline.yml
@@ -369,10 +369,12 @@
 artifact_paths:
   - "**/test-results.xml"
   - "**/*.abilist"
+  - "**/crash_diagnostics/*"
 env:
 CC: "clang-${LLVM_HEAD_VERSION}"
 CXX: "clang++-${LLVM_HEAD_VERSION}"
 LLVM_SYMBOLIZER_PATH: "/usr/bin/llvm-symbolizer-${LLVM_HEAD_VERSION}"
+CLANG_CRASH_DIAGNOSTICS_DIR: "crash_diagnostics"
 agents:
   queue: "libcxx-builders"
   os: "linux"
Index: clang/test/Driver/crash-diagnostics-dir-3.c
===
--- /dev/null
+++ clang/test/Driver/crash-diagnostics-dir-3.c
@@ -0,0 +1,5 @@
+// RUN: rm -rf %t
+// RUN: not env CLANG_CRASH

[PATCH] D133072: [clang] fix profiling of template arguments of template and declaration kind

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 457819.
mizvekov marked 2 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133072

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/TemplateBase.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/concepts.cpp
  libcxx/DELETE.ME

Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D133072
Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -256,3 +256,9 @@
 C auto **&j2 = g();  // expected-error {{deduced type 'int' does not satisfy 'C'}}
 C auto **&&j3 = g(); // expected-error {{deduced type 'int' does not satisfy 'C'}}
 }
+
+namespace GH55567 {
+template class> concept C = true;
+template  struct S {};
+void f(C auto);
+} // namespace GH55567
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -5643,7 +5643,8 @@
 if (CheckTemplateTemplateArgument(TempParm, Params, Arg))
   return true;
 
-Converted.push_back(Arg.getArgument());
+Converted.push_back(
+Context.getCanonicalTemplateArgument(Arg.getArgument()));
 break;
 
   case TemplateArgument::Expression:
@@ -5813,13 +5814,14 @@
 if (!ArgumentPack.empty()) {
   // If we were part way through filling in an expanded parameter pack,
   // fall back to just producing individual arguments.
-  Converted.insert(Converted.end(),
-   ArgumentPack.begin(), ArgumentPack.end());
+  for (const TemplateArgument &I : ArgumentPack)
+Converted.push_back(Context.getCanonicalTemplateArgument(I));
   ArgumentPack.clear();
 }
 
 while (ArgIdx < NumArgs) {
-  Converted.push_back(NewArgs[ArgIdx].getArgument());
+  Converted.push_back(Context.getCanonicalTemplateArgument(
+  NewArgs[ArgIdx].getArgument()));
   ++ArgIdx;
 }
 
@@ -5952,7 +5954,8 @@
   if (ArgIdx < NumArgs && CurrentInstantiationScope &&
   CurrentInstantiationScope->getPartiallySubstitutedPack()) {
 while (ArgIdx < NumArgs && NewArgs[ArgIdx].getArgument().isPackExpansion())
-  Converted.push_back(NewArgs[ArgIdx++].getArgument());
+  Converted.push_back(Context.getCanonicalTemplateArgument(
+  NewArgs[ArgIdx++].getArgument()));
   }
 
   // If we have any leftover arguments, then there were too many arguments.
Index: clang/lib/AST/TemplateBase.cpp
===
--- clang/lib/AST/TemplateBase.cpp
+++ clang/lib/AST/TemplateBase.cpp
@@ -321,26 +321,15 @@
 
   case Declaration:
 getParamTypeForDecl().Profile(ID);
-ID.AddPointer(getAsDecl()? getAsDecl()->getCanonicalDecl() : nullptr);
+ID.AddPointer(getAsDecl());
 break;
 
+  case TemplateExpansion:
+ID.AddInteger(TemplateArg.NumExpansions);
+LLVM_FALLTHROUGH;
   case Template:
-  case TemplateExpansion: {
-TemplateName Template = getAsTemplateOrTemplatePattern();
-if (TemplateTemplateParmDecl *TTP
-  = dyn_cast_or_null(
-Template.getAsTemplateDecl())) {
-  ID.AddBoolean(true);
-  ID.AddInteger(TTP->getDepth());
-  ID.AddInteger(TTP->getPosition());
-  ID.AddBoolean(TTP->isParameterPack());
-} else {
-  ID.AddBoolean(false);
-  ID.AddPointer(Context.getCanonicalTemplateName(Template)
-  .getAsVoidPointer());
-}
+getAsTemplateOrTemplatePattern().Profile(ID);
 break;
-  }
 
   case Integral:
 getAsIntegral().Profile(ID);
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -5116,7 +5116,9 @@
CanonArgs);
 
 // Find the insert position again.
-DependentTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
+[[maybe_unused]] auto *Nothing =
+DependentTemplateSpecializationTypes.FindNodeOrInsertPos(ID, InsertPos);
+assert(!Nothing && "canonical type broken");
   }
 
   void *Mem = Allocate((sizeof(DependentTemplateSpecializationType) +
@@ -5731,7 +5733,9 @@
 Canon = getAutoTypeInternal(QualType(), Keyword, IsDependent, IsPack,
 TypeConstraintConcept, CanonArgs, true);
 // Find the insert position again.
-AutoTypes.FindNodeOrInsertPos(ID, InsertPos);
+[[maybe_unused]] auto *Nothing =
+AutoTypes.FindNode

[PATCH] D133262: [clang] Represent __make_integer_seq as alias template in the AST

2022-09-03 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

There are some known bugs about how we handle this built-in in the AST- #42102, 
#51928, #54993. Is it possible that your patch solves them? It would be great 
if it does, I hit one of them in the wild a while back.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133262

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


[PATCH] D133262: [clang] Represent __make_integer_seq as alias template in the AST

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added a comment.

In D133262#3768883 , @royjacobson 
wrote:

> There are some known bugs about how we handle this built-in in the AST- 
> #42102, #51928, #54993. Is it possible that your patch solves them? It would 
> be great if it does, I hit one of them in the wild a while back.

I think not, these look like deduction problems, and what is done in this patch 
should not affect deduction.

The TemplateSpecializationTypes we are changing in this patch are all sugar, 
and these should not affect it.

Dependence can create canonical TST, which does affect it, but 
`checkBuiltinTemplateIdType` is not even called if there is any dependence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133262

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


[PATCH] D133087: [clang-format][NFC][Docs] fix wrong example of warping class definitions

2022-09-03 Thread passw_passw via Phabricator via cfe-commits
Passw added a comment.

I do not have commit access, please help to commit this change. 
Thanks.


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

https://reviews.llvm.org/D133087

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


[PATCH] D133244: [clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

2022-09-03 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 updated this revision to Diff 457828.
felix642 added a comment.

+ Added test case and updated ReleaseNotes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133244

Files:
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- 
-config="{CheckOptions: [{key: 
readability-container-data-pointer.IgnoredContainers, value: '::arrayType'}]}" 
-- -fno-delayed-template-parsing
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -155,3 +155,25 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for 
accessing the data pointer instead of taking the address of the 0-th element 
[readability-container-data-pointer]
   // CHECK-FIXES: {{^  }}return holder.v.data();{{$}}
 }
+
+template
+struct ArrayType {
+  using size_type = size_t;
+
+  arrayType();
+
+  T *data();
+  const T *data() const;
+
+  T &operator[](size_type);
+  const T &operator[](size_type) const;
+
+private:
+  T _value[N];
+};
+
+// Don't issue a warning because of the config above.
+int *s() {
+  arrayType s;
+  return &s[0];
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -141,6 +141,10 @@
   The check now skips unions since in this case a default constructor with 
empty body
   is not equivalent to the explicitly defaulted one.
 
+- Improved `readability-container-data-pointer 
` check.
+
+  The check now skips containers that are defined in the option 
IgnoredContainers.  The default value is ::std::array.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
@@ -37,6 +37,9 @@
   llvm::Optional getCheckTraversalKind() const override {
 return TK_IgnoreUnlessSpelledInSource;
   }
+
+private:
+  const std::vector IgnoredContainers;
 };
 } // namespace readability
 } // namespace tidy
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "ContainerDataPointerCheck.h"
 
+#include "../utils/OptionsUtils.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -22,14 +23,18 @@
 constexpr llvm::StringLiteral AddrOfContainerExprName =
 "addr-of-container-expr";
 constexpr llvm::StringLiteral AddressOfName = "address-of";
+const auto DefaultIgnoredContainers = "::std::array";
 
 ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
  ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context) {}
+: ClangTidyCheck(Name, Context),
+  IgnoredContainers(utils::options::parseStringList(
+  Options.get("IgnoredContainers", DefaultIgnoredContainers))) {}
 
 void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
   const auto Record =
   cxxRecordDecl(
+  unless(hasAnyName(IgnoredContainers)),
   isSameOrDerivedFrom(
   namedDecl(
   has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))


Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -config="{CheckOptions: [{key: readability-container-data-pointer.IgnoredContainers, value: '::arrayType'}]}" -- -fno-delayed-template-parsing
 
 typedef __SIZE_TYPE__ size_t

[PATCH] D133244: [clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

2022-09-03 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:146
+
+  The check now skips containers that are defined in the option 
IgnoredContainers.  The default value is ::std::array.
+

Please highlight option name and value with single back-tick.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp:1
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- 
-config="{CheckOptions: [{key: 
readability-container-data-pointer.IgnoredContainers, value: '::arrayType'}]}" 
-- -fno-delayed-template-parsing
 

I think test should be separated to handle situations with and without option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133244

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


[PATCH] D133244: [clang-tidy] Readability-container-data-pointer adds new option to ignore Containers

2022-09-03 Thread Félix-Antoine Constantin via Phabricator via cfe-commits
felix642 updated this revision to Diff 457829.
felix642 added a comment.

Fixed compilation issues


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133244

Files:
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
  clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- 
-config="{CheckOptions: [{key: 
readability-container-data-pointer.IgnoredContainers, value: '::ArrayType'}]}" 
-- -fno-delayed-template-parsing
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -155,3 +155,25 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: 'data' should be used for 
accessing the data pointer instead of taking the address of the 0-th element 
[readability-container-data-pointer]
   // CHECK-FIXES: {{^  }}return holder.v.data();{{$}}
 }
+
+template
+struct ArrayType {
+  using size_type = size_t;
+
+  ArrayType();
+
+  T *data();
+  const T *data() const;
+
+  T &operator[](size_type);
+  const T &operator[](size_type) const;
+
+private:
+  T _value[N];
+};
+
+// Don't issue a warning because of the config above.
+int *s() {
+  ArrayType s;
+  return &s[0];
+}
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -141,6 +141,10 @@
   The check now skips unions since in this case a default constructor with 
empty body
   is not equivalent to the explicitly defaulted one.
 
+- Improved `readability-container-data-pointer 
` check.
+
+  The check now skips containers that are defined in the option 
IgnoredContainers.  The default value is ::std::array.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.h
@@ -37,6 +37,9 @@
   llvm::Optional getCheckTraversalKind() const override {
 return TK_IgnoreUnlessSpelledInSource;
   }
+
+private:
+  const std::vector IgnoredContainers;
 };
 } // namespace readability
 } // namespace tidy
Index: clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerDataPointerCheck.cpp
@@ -8,6 +8,7 @@
 
 #include "ContainerDataPointerCheck.h"
 
+#include "../utils/OptionsUtils.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/StringRef.h"
 
@@ -22,14 +23,18 @@
 constexpr llvm::StringLiteral AddrOfContainerExprName =
 "addr-of-container-expr";
 constexpr llvm::StringLiteral AddressOfName = "address-of";
+const auto DefaultIgnoredContainers = "::std::array";
 
 ContainerDataPointerCheck::ContainerDataPointerCheck(StringRef Name,
  ClangTidyContext *Context)
-: ClangTidyCheck(Name, Context) {}
+: ClangTidyCheck(Name, Context),
+  IgnoredContainers(utils::options::parseStringList(
+  Options.get("IgnoredContainers", DefaultIgnoredContainers))) {}
 
 void ContainerDataPointerCheck::registerMatchers(MatchFinder *Finder) {
   const auto Record =
   cxxRecordDecl(
+  unless(hasAnyName(IgnoredContainers)),
   isSameOrDerivedFrom(
   namedDecl(
   has(cxxMethodDecl(isPublic(), hasName("data")).bind("data")))


Index: clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability/container-data-pointer.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s readability-container-data-pointer %t -- -config="{CheckOptions: [{key: readability-container-data-pointer.IgnoredContainers, value: '::ArrayType'}]}" -- -fno-delayed-template-parsing
 
 typedef __SIZE_TYPE__ size_t;
 
@@ -155,3 +155

[PATCH] D133249: [libc++] Documents details of the pre-commit CI.

2022-09-03 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov added inline comments.



Comment at: libcxx/docs/Contributing.rst:164-165
+
+  When this buld fails with an LLVM assertion, the crash diagnostics are
+  available as an artifact.
+




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133249

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


[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-09-03 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev updated this revision to Diff 457830.
v.g.vassilev marked 9 inline comments as done.
v.g.vassilev added a comment.

Address review comments


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

https://reviews.llvm.org/D127284

Files:
  clang/include/clang/AST/ASTConsumer.h
  clang/include/clang/Parse/Parser.h
  clang/lib/CodeGen/CodeGenAction.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/CodeGen/ModuleBuilder.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Parse/Parser.cpp
  clang/test/Interpreter/disambiguate-decl-stmt.cpp
  clang/test/Interpreter/execute-stmts.cpp
  clang/unittests/Interpreter/InterpreterTest.cpp

Index: clang/unittests/Interpreter/InterpreterTest.cpp
===
--- clang/unittests/Interpreter/InterpreterTest.cpp
+++ clang/unittests/Interpreter/InterpreterTest.cpp
@@ -120,12 +120,7 @@
 
   // FIXME: Add support for wrapping and running statements.
   auto R2 = Interp->Parse("var1++; printf(\"var1 value %d\\n\", var1);");
-  EXPECT_FALSE(!!R2);
-  using ::testing::HasSubstr;
-  EXPECT_THAT(DiagnosticsOS.str(),
-  HasSubstr("error: unknown type name 'var1'"));
-  auto Err = R2.takeError();
-  EXPECT_EQ("Parsing failed.", llvm::toString(std::move(Err)));
+  EXPECT_TRUE(!!R2);
 }
 
 TEST(InterpreterTest, UndoCommand) {
Index: clang/test/Interpreter/execute-stmts.cpp
===
--- /dev/null
+++ clang/test/Interpreter/execute-stmts.cpp
@@ -0,0 +1,35 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc  -verify | FileCheck %s
+
+// expected-no-diagnostics
+
+extern "C" int printf(const char*,...);
+
+// FIXME: Support template instantiation calls.
+//template  T call() { printf("call\n"); return T(); }
+//call();
+ C: call
+
+int i = 1;
+++i;
+printf("i = %d\n", i);
+// CHECK: i = 2
+
+namespace Ns { void f(){ i++; } }
+Ns::f();
+
+void g() { ++i; }
+g();
+::g();
+
+printf("i = %d\n", i);
+// CHECK-NEXT: i = 5
+
+for (; i > 4; --i) printf("i = %d\n", i);
+// CHECK-NEXT: i = 5
+
+int j = i; printf("j = %d\n", j);
+// CHECK-NEXT: j = 4
+
+%quit
Index: clang/test/Interpreter/disambiguate-decl-stmt.cpp
===
--- /dev/null
+++ clang/test/Interpreter/disambiguate-decl-stmt.cpp
@@ -0,0 +1,53 @@
+// REQUIRES: host-supports-jit
+// UNSUPPORTED: system-aix
+// RUN: cat %s | clang-repl -Xcc -Xclang -Xcc -verify | FileCheck %s
+
+// expected-no-diagnostics
+
+extern "C" int printf(const char*,...);
+
+// Decls which are hard to disambiguate
+
+// FIXME: Support operators.
+// struct S1 { operator int(); };
+// S1::operator int() { return 0; }
+
+
+// Dtors
+using I = int;
+I x = 10;
+x.I::~I();
+x = 20;
+
+// Ctors
+
+// FIXME: Support deduction guide
+// template struct A { A(); A(T); };
+// A() -> A;
+
+struct S2 { S2(); };
+S2::S2() = default;
+
+namespace N { struct S { S(); }; }
+N::S::S() { printf("N::S::S()\n"); }
+N::S s;
+// CHECK: N::S::S()
+
+namespace Ns {namespace Ns { void Ns(); void Fs();}}
+void Ns::Ns::Ns() { printf("void Ns::Ns::Ns()\n"); }
+void Ns::Ns::Fs() {}
+
+Ns::Ns::Fs();
+Ns::Ns::Ns();
+// CHECK-NEXT: void Ns::Ns::Ns()
+
+struct Attrs1 { Attrs1(); };
+Attrs1::Attrs1() __attribute((pure)) = default;
+
+struct Attrs2 { Attrs2(); };
+__attribute((pure)) Attrs2::Attrs2() = default;
+
+// Extra semicolon
+namespace N {};
+
+%quit
Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -582,13 +582,14 @@
 ///
 /// Note that in C, it is an error if there is no first declaration.
 bool Parser::ParseFirstTopLevelDecl(DeclGroupPtrTy &Result,
-Sema::ModuleImportState &ImportState) {
+Sema::ModuleImportState &ImportState,
+StmtVector *Stmts) {
   Actions.ActOnStartOfTranslationUnit();
 
   // For C++20 modules, a module decl must be the first in the TU.  We also
   // need to track module imports.
   ImportState = Sema::ModuleImportState::FirstDecl;
-  bool NoTopLevelDecls = ParseTopLevelDecl(Result, ImportState);
+  bool NoTopLevelDecls = ParseTopLevelDecl(Result, ImportState, Stmts);
 
   // C11 6.9p1 says translation units must have at least one top-level
   // declaration. C++ doesn't have this restriction. We also don't want to
@@ -609,7 +610,8 @@
 ///   declaration
 /// [C++20]   module-import-declaration
 bool Parser::ParseTopLevelDecl(DeclGroupPtrTy &Result,
-   Sema::ModuleImportState &ImportState) {
+   Sema::ModuleImportState &ImportState,
+   StmtVector *Stmts /*=nullptr*/) {
 

[PATCH] D127284: [clang-repl] Support statements on global scope in incremental mode.

2022-09-03 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a subscriber: sunho.
v.g.vassilev added inline comments.



Comment at: clang/include/clang/AST/ASTConsumer.h:54-59
+  /// HandleTopLevelStmts - Handle the specified top-level statements. This is
+  /// called by the parser to process every top-level Stmt* in incremental
+  /// compilation mode.
+  ///
+  /// \returns true to continue parsing, or false to abort parsing.
+  virtual bool HandleTopLevelStmts(const llvm::SmallVectorImpl &Stmts) 
{

aaron.ballman wrote:
> In C and C++, the only thing that's at file scope (that the parser sees) are 
> declarations, not statements, so the phrasing here seems off. I suspect this 
> is because you don't *know* you're only going to get declarations (because it 
> could be that we're trying to parse in the context of an imaginary function 
> body)? If so, perhaps the comments could be updated to clarify that.
I am a bit confused. Could you clarify what wording changes you had in mind?



Comment at: clang/include/clang/Parse/Parser.h:466
+  /// A SmallVector of statements, with stack size 32 (as that is the only one
+  /// used.)
+  typedef SmallVector StmtVector;

aaron.ballman wrote:
> Drive by punctuation fix. I'm not certain I understand "as that is the only 
> one used", but that's from the original comment. It's possible the comment 
> holds no real weight any longer?
It does not indeed carry weight. Let me try to improve it.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:5107-5111
+  static unsigned id = 0;
+  ASTContext &C = getContext();
+  TranslationUnitDecl *TUDecl = C.getTranslationUnitDecl();
+
+  IdentifierInfo *name = &C.Idents.get("_stmts" + std::to_string(id++));

aaron.ballman wrote:
> You should fix the other identifiers in this function to match the usual 
> coding style.
I have not paid too much attention in the coding style here as it was mostly 
for initiating a design discussion.

The body of this function breaks the design of clang which assumes AST to be 
created by the frontend and be essentially immutable in `CodeGen`. This 
`FunctionDecl` needs to be treated as a global initializer. That is, it needs 
to be run in a particular order to the other initializer following the lexical 
occurrence of the statement block. That leaves us with two options, either to 
expose the registration of global initializers outside of CodeGen, or we need 
to create that here.

Alternatively, we could make `HandleTopLevelStmts` take a `FunctionDecl` and we 
can create it in the `IncrementalParser`. That blurs the responsibility and 
coherence of the interfaces. We will have public interface 
`HandleTopLevelStmts` (or similar) which handles top-level statements but take 
a `FunctionDecl` as a parameter which is created by the user...



Comment at: clang/lib/Parse/ParseDecl.cpp:5514-5521
+  // FIXME: this returns true for NS::f();
   // A right parenthesis, or ellipsis followed by a right parenthesis signals
   // that we have a constructor.
   if (Tok.is(tok::r_paren) ||
   (Tok.is(tok::ellipsis) && NextToken().is(tok::r_paren))) {
 TPA.Revert();
 return true;

aaron.ballman wrote:
> rsmith wrote:
> > I think we'll need to work out whether we're disambiguating versus a 
> > statement here. I think the key observation is that either:
> > 
> > 1) We know we're parsing a declaration, because we're inside a class body 
> > or parsing after `template` or `template<...>` or similar.
> > 2) A constructor declaration must be a definition, so if we don't see a 
> > `{`, `:`, or `try` after the declarator then it's an expression, not a 
> > declaration.
> > 
> > I'd suggest passing in a flag to say whether we know we're parsing a 
> > declaration, which is true unless we're disambiguating against a top-level 
> > statement; in that case, don't return here and instead keep going until we 
> > hit one of the relevant cases below.
> > A constructor declaration must be a definition, so if we don't see a {, :, 
> > or try after the declarator then it's an expression, not a declaration.
> 
> Consider: 
> ```
> struct S {
>   S();
> };
> 
> S::S() = default;
> ```
> The out-of-line constructor definition is still a kind of declaration despite 
> not ending in `{`, `:`, or `try`.
That came up a lot in the testsuite but I've added a test for it.



Comment at: clang/lib/Parse/ParseTentative.cpp:54
+case tok::semi:
+  return true; // Not a stmt but can be extra terminator in `namespace{};`
+case tok::kw_template:

aaron.ballman wrote:
> http://eel.is/c++draft/dcl.dcl#nt:empty-declaration
IIUC, clang models the `;` as a `NullStmt`.



Comment at: clang/lib/Parse/ParseTentative.cpp:60
+case tok::identifier:
+  if (getLangOpts().CPlusPlus) {
+if (isConstructorDeclarator(/*Unqualified=*/false,

aaron.ballman wrote:
> You should asse

[PATCH] D133266: [MinGW] Reject explicit non-default visibility applied to dllexport/dllimport declaration

2022-09-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay created this revision.
MaskRay added reviewers: mstorsjo, mati865, rnk.
Herald added a subscriber: StephenFan.
Herald added a project: All.
MaskRay requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

dllimport/dllexport is incompatible with protected/hidden visibilities.
(Arguably dllexport is compatible with protected but we can reject it
for simplicity.)

When an explicit visibility attribute applies on a dllexport/dllimport
declaration, report a Frontend error (Sema does not compute visibility).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133266

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGenCXX/dllstorage-visibility.cpp


Index: clang/test/CodeGenCXX/dllstorage-visibility.cpp
===
--- clang/test/CodeGenCXX/dllstorage-visibility.cpp
+++ clang/test/CodeGenCXX/dllstorage-visibility.cpp
@@ -4,10 +4,18 @@
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility-inlines-hidden -o - %s | FileCheck %s --check-prefix=GNU
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-windows-gnu -fdeclspec 
-fvisibility=hidden -o - %s | FileCheck %s --check-prefix=GNU
 
+// RUN: %clang_cc1 -emit-llvm-only -verify -triple x86_64-windows-gnu 
-fdeclspec -DERR1 -o - %s
+// RUN: %clang_cc1 -emit-llvm-only -verify -triple x86_64-windows-gnu 
-fdeclspec -fvisibility=hidden -DERR1 -o - %s
+// RUN: %clang_cc1 -emit-llvm-only -verify -triple x86_64-windows-gnu 
-fdeclspec -DERR2 -o - %s
+
 #define CONCAT2(x, y) x##y
 #define CONCAT(x, y) CONCAT2(x, y)
 #define USE(func) void CONCAT(use, __LINE__)() { func(); }
 
+#define HIDDEN __attribute__((visibility("hidden")))
+#define PROTECTED __attribute__((visibility("protected")))
+#define DEFAULT __attribute__((visibility("default")))
+
 // MSVC-DAG: declare dllimport void @"?bar@foo@@QEAAXXZ"(
 // GNU-DAG: define linkonce_odr hidden void @_ZN3foo3barEv(
 
@@ -24,3 +32,17 @@
 // GNU-DAG: define weak_odr dso_local dllexport void @_Z15exported_inlinev(
 __declspec(dllexport) inline void exported_inline() {}
 USE(exported_inline)
+
+#if defined(ERR1)
+// expected-error@+1 {{non-default visibility cannot be applied to 'dllimport' 
declaration}}
+__attribute__((dllimport)) HIDDEN void imported_hidden();
+
+__attribute__((dllexport)) DEFAULT void exported_default() {}
+// expected-error@+1 {{non-default visibility cannot be applied to 'dllexport' 
declaration}}
+__attribute__((dllexport)) HIDDEN void exported_hidden() { imported_hidden(); }
+#elif defined(ERR2)
+struct PROTECTED C {
+  // expected-error@+1 {{non-default visibility cannot be applied to 
'dllexport' declaration}}
+  __attribute__((dllexport)) void exported_protected() {}
+};
+#endif
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -1099,8 +1099,6 @@
 
 void CodeGenModule::setGlobalVisibility(llvm::GlobalValue *GV,
 const NamedDecl *D) const {
-  if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass())
-return;
   // Internal definitions always have default visibility.
   if (GV->hasLocalLinkage()) {
 GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
@@ -,6 +1109,14 @@
   // Set visibility for definitions, and for declarations if requested globally
   // or set explicitly.
   LinkageInfo LV = D->getLinkageAndVisibility();
+  if (GV->hasDLLExportStorageClass() || GV->hasDLLImportStorageClass()) {
+// Reject explicit non-default visibility on dllexport/dllimport.
+if (LV.isVisibilityExplicit() && LV.getVisibility() != DefaultVisibility)
+  getDiags().Report(D->getLocation(),
+diag::err_non_default_visibility_dllstorage)
+  << (GV->hasDLLExportStorageClass() ? "dllexport" : "dllimport");
+return;
+  }
   if (LV.isVisibilityExplicit() || getLangOpts().SetVisibilityForExternDecls ||
   !GV->isDeclarationForLinker())
 GV->setVisibility(GetLLVMVisibility(LV.getVisibility()));
Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -282,6 +282,8 @@
   "definition with same mangled name '%0' as another definition">;
 def err_cyclic_alias : Error<
   "%select{alias|ifunc}0 definition is part of a cycle">;
+def err_non_default_visibility_dllstorage : Error<
+  "non-default visibility cannot be applied to '%0' declaration">;
 def err_ifunc_resolver_return : Error<
   "ifunc resolver function must return a pointer">;
 


Index: clang/test/CodeGenCXX/dllstorage-visibility.cpp
===
--- clang

[PATCH] D131464: [test] Make tests pass regardless of gnu++14/gnu++17 default

2022-09-03 Thread Fangrui Song 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 rG83ea47acd711: [test] Make tests pass regardless of 
gnu++14/gnu++17 default (authored by MaskRay).

Changed prior to commit:
  https://reviews.llvm.org/D131464?vs=457367&id=457836#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131464

Files:
  clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c
  clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
  clang/test/AST/ast-dump-undeduced-expr.cpp
  clang/test/AST/sourceranges.cpp
  clang/test/Analysis/blocks.m
  clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
  clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
  clang/test/CXX/class.access/class.friend/p1.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
  clang/test/CXX/except/except.spec/p2-dynamic-types.cpp
  clang/test/CXX/except/except.spec/p9-dynamic.cpp
  clang/test/CXX/stmt.stmt/stmt.select/p3.cpp
  clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  clang/test/CXX/temp/temp.res/temp.local/p3.cpp
  clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
  clang/test/CodeGenCXX/align-avx-complete-objects.cpp
  clang/test/CodeGenCXX/copy-constructor-elim-2.cpp
  clang/test/CodeGenCXX/debug-info-template-parameter.cpp
  clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp
  clang/test/CodeGenCXX/exception-spec-decay.cpp
  clang/test/CodeGenCXX/exceptions-cxx-ehsc.cpp
  clang/test/CodeGenCXX/exceptions-no-rtti.cpp
  clang/test/CodeGenCXX/global-init.cpp
  clang/test/CodeGenCXX/no-exceptions.cpp
  clang/test/CodeGenCXX/override-bit-field-layout.cpp
  clang/test/CodeGenCXX/override-layout.cpp
  clang/test/CodeGenCXX/reference-temporary-ms.cpp
  clang/test/CodeGenCXX/rtti-linkage.cpp
  clang/test/Layout/ms-x86-vtordisp.cpp
  clang/test/Modules/update-exception-spec.cpp
  clang/test/OpenMP/declare_mapper_messages.cpp
  clang/test/PCH/cxx-functions.cpp
  clang/test/Parser/cxx-casting.cpp
  clang/test/Parser/cxx-class.cpp
  clang/test/Parser/cxx-template-argument.cpp
  clang/test/Parser/cxx-template-decl.cpp
  clang/test/Parser/cxx1z-nested-namespace-definition.cpp
  clang/test/Sema/ms_class_layout.cpp
  clang/test/SemaCXX/MicrosoftExtensions.cpp
  clang/test/SemaCXX/PR12778.cpp
  clang/test/SemaCXX/altivec.cpp
  clang/test/SemaCXX/bool.cpp
  clang/test/SemaCXX/default2.cpp
  clang/test/SemaCXX/exception-spec-no-exceptions.cpp
  clang/test/SemaCXX/exceptions.cpp
  clang/test/SemaCXX/expressions.cpp
  clang/test/SemaCXX/inline.cpp
  clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
  clang/test/SemaCXX/linkage2.cpp
  clang/test/SemaCXX/member-pointer.cpp
  clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
  clang/test/SemaCXX/new-delete.cpp
  clang/test/SemaCXX/static-data-member.cpp
  clang/test/SemaCXX/type-definition-in-specifier.cpp
  clang/test/SemaCXX/user-defined-conversions.cpp
  clang/test/SemaCXX/warn-new-overaligned-3.cpp
  clang/test/SemaCXX/warn-new-overaligned.cpp
  clang/test/SemaCXX/writable-strings-deprecated.cpp
  clang/test/SemaSYCL/zero-length-arrays.cpp
  clang/test/SemaTemplate/class-template-id.cpp
  clang/test/SemaTemplate/constructor-template.cpp
  clang/test/SemaTemplate/explicit-instantiation.cpp
  clang/test/SemaTemplate/instantiate-exception-spec.cpp
  clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
  clang/test/SemaTemplate/instantiation-default-2.cpp
  clang/test/SemaTemplate/temp_arg.cpp
  clang/test/SemaTemplate/temp_arg_template.cpp
  clang/test/SemaTemplate/typename-specifier-3.cpp
  clang/unittests/AST/ASTTraverserTest.cpp
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -567,6 +567,32 @@
 self.config.substitutions.append(
 ('%target_itanium_abi_host_triple', ''))
 
+# TODO: Many tests work across many language standards. Before
+# https://discourse.llvm.org/t/lit-run-a-run-line-multiple-times-with-different-replacements/64932
+# has a solution, provide substitutions to conveniently try every standard with LIT_CLANG_STD_GROUP.
+clang_std_group = int(os.environ.get('LIT_CLANG_STD_GROUP', '0'))
+clang_std_values = ('98', '11', '14', '17', '20', '2b')
+def add_std_cxx(s):
+t = s[8:]
+if t.endswith('-'):
+t += clang_std_values[-1]
+l = clang_std_values.index(t[0:2] if t[0:2] != '23' else '2b')
+h = clang_std_values.index(t[3:5])
+# Let LIT_CLANG_STD_GROUP=0 pick the highest value (likely the most relevant
+# standard).
+l = h - clang_std_group % (h-l+1)
+self.config.substitutions.append((s

[clang] 83ea47a - [test] Make tests pass regardless of gnu++14/gnu++17 default

2022-09-03 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-09-04T05:29:32Z
New Revision: 83ea47acd7116bf50274534ba9b3bd3035c01da6

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

LOG: [test] Make tests pass regardless of gnu++14/gnu++17 default

GCC from 11 onwards defaults to -std=gnu++17 for C++ source files. We want to 
do the same
(https://discourse.llvm.org/t/c-objc-switch-to-gnu-17-as-the-default-dialect/64360).
Split RUN lines, adjust `-verify`, or add `__cplusplus < 201703L` or 
`-Wno-dynamic-exception-spec`,
so that tests will pass regardless of gnu++14/gnu++17 default.

We have a desire to mark a test compatible with multiple language standards.
There are ongoing discussions how to add markers in the long term:

* https://discourse.llvm.org/t/iterating-lit-run-lines/62596
* 
https://discourse.llvm.org/t/lit-run-a-run-line-multiple-times-with-different-replacements/64932

As a workaround in the short term, add lit substitutions `%std_cxx98-`,
`%std_cxx11-14`, etc. They can be used for tests which work across multiple
language standards. If a range has `n` standards, run lit multiple times, with
`LIT_CLANG_STD_GROUP=0`, `LIT_CLANG_STD_GROUP=1`, etc to cover all `n` 
standards.

Reviewed By: #clang-language-wg, aaron.ballman

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

Added: 


Modified: 
clang/test/AST/ast-dump-openmp-begin-declare-variant_11.c
clang/test/AST/ast-dump-openmp-begin-declare-variant_template_3.cpp
clang/test/AST/ast-dump-undeduced-expr.cpp
clang/test/AST/sourceranges.cpp
clang/test/Analysis/blocks.m
clang/test/Analysis/exploded-graph-rewriter/objects_under_construction.cpp
clang/test/CXX/basic/basic.stc/basic.stc.dynamic/p2.cpp
clang/test/CXX/class.access/class.friend/p1.cpp
clang/test/CXX/dcl.dcl/dcl.spec/dcl.stc/p2.cpp
clang/test/CXX/except/except.spec/p2-dynamic-types.cpp
clang/test/CXX/except/except.spec/p9-dynamic.cpp
clang/test/CXX/stmt.stmt/stmt.select/p3.cpp
clang/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
clang/test/CXX/temp/temp.res/temp.local/p3.cpp
clang/test/CodeGen/typedef_alignment_mismatch_warning.cpp
clang/test/CodeGenCXX/align-avx-complete-objects.cpp
clang/test/CodeGenCXX/copy-constructor-elim-2.cpp
clang/test/CodeGenCXX/debug-info-template-parameter.cpp
clang/test/CodeGenCXX/debug-info-template-partial-specialization.cpp
clang/test/CodeGenCXX/exception-spec-decay.cpp
clang/test/CodeGenCXX/exceptions-cxx-ehsc.cpp
clang/test/CodeGenCXX/exceptions-no-rtti.cpp
clang/test/CodeGenCXX/global-init.cpp
clang/test/CodeGenCXX/no-exceptions.cpp
clang/test/CodeGenCXX/override-bit-field-layout.cpp
clang/test/CodeGenCXX/override-layout.cpp
clang/test/CodeGenCXX/reference-temporary-ms.cpp
clang/test/CodeGenCXX/rtti-linkage.cpp
clang/test/Layout/ms-x86-vtordisp.cpp
clang/test/Modules/update-exception-spec.cpp
clang/test/OpenMP/declare_mapper_messages.cpp
clang/test/PCH/cxx-functions.cpp
clang/test/Parser/cxx-casting.cpp
clang/test/Parser/cxx-class.cpp
clang/test/Parser/cxx-template-argument.cpp
clang/test/Parser/cxx-template-decl.cpp
clang/test/Parser/cxx1z-nested-namespace-definition.cpp
clang/test/Sema/ms_class_layout.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp
clang/test/SemaCXX/PR12778.cpp
clang/test/SemaCXX/altivec.cpp
clang/test/SemaCXX/bool.cpp
clang/test/SemaCXX/default2.cpp
clang/test/SemaCXX/exception-spec-no-exceptions.cpp
clang/test/SemaCXX/exceptions.cpp
clang/test/SemaCXX/expressions.cpp
clang/test/SemaCXX/inline.cpp
clang/test/SemaCXX/libstdcxx_is_pod_hack.cpp
clang/test/SemaCXX/linkage2.cpp
clang/test/SemaCXX/member-pointer.cpp
clang/test/SemaCXX/missing-namespace-qualifier-typo-corrections.cpp
clang/test/SemaCXX/new-delete.cpp
clang/test/SemaCXX/static-data-member.cpp
clang/test/SemaCXX/type-definition-in-specifier.cpp
clang/test/SemaCXX/user-defined-conversions.cpp
clang/test/SemaCXX/warn-new-overaligned-3.cpp
clang/test/SemaCXX/warn-new-overaligned.cpp
clang/test/SemaCXX/writable-strings-deprecated.cpp
clang/test/SemaSYCL/zero-length-arrays.cpp
clang/test/SemaTemplate/class-template-id.cpp
clang/test/SemaTemplate/constructor-template.cpp
clang/test/SemaTemplate/explicit-instantiation.cpp
clang/test/SemaTemplate/instantiate-exception-spec.cpp
clang/test/SemaTemplate/instantiate-non-dependent-types.cpp
clang/test/SemaTemplate/instantiation-default-2.cpp
clang/test/SemaTemplate/temp_arg.cpp
clang/test/SemaTemplate/temp_arg_template.cpp
clang/test/SemaTemplate/typename-specifier-3.cpp
clang/unittests/AST/ASTTraverserTest.cpp
llvm/utils/lit/lit/llvm/config.py

Removed: 




[PATCH] D111367: [Driver] Change -dumpmachine to respect --target/LLVM_DEFAULT_TARGET_TRIPLE verbatim

2022-09-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay abandoned this revision.
MaskRay added a comment.
Herald added a subscriber: StephenFan.
Herald added a project: All.

Abandon since we decide to try using normalized target triple and just hard 
code the Debian multiarch (omitted 'vendor') in few places.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111367

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


[PATCH] D132136: [clang] Perform implicit lvalue-to-rvalue cast with new interpreter

2022-09-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

In D132136#3766958 , @aaron.ballman 
wrote:

> On the one hand, I'm not comfortable landing this without adequate testing, 
> especially because you want to build more stuff on top of it. I think we need 
> to make sure the foundational bits of evaluation are rock solid before 
> building things on top of them. However, on the other hand, this is 
> foundational enough that it's hard to test this bit without other parts of 
> the interpreter being ready. So my preference is to try to add test coverage 
> even if it's failing currently because other parts of the interpreter aren't 
> ready yet. e.g., (imaginary test case, feel free to use better ones)
>
>   template 
>   struct is_same { static constexpr bool value = false; };
>   
>   template 
>   struct is_same { static constexpr bool value = true; };
>   
>   const volatile int i = 0;
>   // Test that lvalue to rvalue conversion ends up stripping top-level 
> qualifiers.
>   // FIXME: this isn't correct yet because we don't have support for 
> qualifier conversions yet.
>   static_assert(is_same::value, "oh no!"); // 
> expected-error {{static assertion failed: oh no!}}
>
> This way, we can start getting extensive test cases written while thinking 
> about the situations specific to lvalue to rvalue conversion (or whatever 
> else is being implemented at the moment) instead of trying to come back and 
> remember to write them later.
>
> Is that reasonable, or is the interpreter in such a state where even this 
> kind of testing is basically impossible to come up with?

Soo... I was gonna tell you that the test case is obviously not going to work 
right now, since record types aren't implemented at all.  //But// the test case 
actually works just fine. However, it also works without the lvalue-to-rvalue 
conversion in `EvaluteAsRValue`. Both with the old and the new interpreter.

I'm going to add an actual unit test that fails without the conversion. But it 
only checks a very simple case, i.e. that a `DeclRefExpr` is returned as an 
integer and not the lvalue.


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

https://reviews.llvm.org/D132136

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


[PATCH] D132975: [clang][BOLT] Add clang-bolt target

2022-09-03 Thread Amir Ayupov via Phabricator via cfe-commits
Amir added a comment.

In D132975#3768391 , @tschuett wrote:

> Will there be eventually a way to build a fully optimised clang/lld with 
> ThinLTO, PGO, and Bolt?

Short answer is likely yes.
For clang, I think this diff should be compatible with PGO, with a caveat that 
BOLT should be applied to stage-2 clang built with PGO, which means that 
`BOOTSTRAP_` options should be set carefully. And for sure it's compatible with 
ThinLTO - this one is completely orthogonal. 
For lld, I can envision a similar fully automated optimized build, but likely 
in a future separate diff.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132975

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


[PATCH] D132136: [clang] Perform implicit lvalue-to-rvalue cast with new interpreter

2022-09-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 457838.
tbaeder added a comment.

Add a unit test.


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

https://reviews.llvm.org/D132136

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/AST/Interp/literals.cpp
  clang/unittests/AST/EvaluateAsRValueTest.cpp

Index: clang/unittests/AST/EvaluateAsRValueTest.cpp
===
--- clang/unittests/AST/EvaluateAsRValueTest.cpp
+++ clang/unittests/AST/EvaluateAsRValueTest.cpp
@@ -107,3 +107,50 @@
 Args));
   }
 }
+
+class CheckLValueToRValueConversionVisitor
+: public clang::RecursiveASTVisitor {
+public:
+  bool VisitDeclRefExpr(const clang::DeclRefExpr *E) {
+clang::Expr::EvalResult Result;
+E->EvaluateAsRValue(Result, E->getDecl()->getASTContext(), true);
+
+EXPECT_TRUE(Result.Val.hasValue());
+// Since EvaluateAsRValue does an implicit lvalue-to-rvalue conversion,
+// the result cannot be a LValue.
+EXPECT_FALSE(Result.Val.isLValue());
+
+return true;
+  }
+};
+
+class CheckConversionAction : public clang::ASTFrontendAction {
+public:
+  std::unique_ptr
+  CreateASTConsumer(clang::CompilerInstance &Compiler,
+llvm::StringRef FilePath) override {
+return std::make_unique();
+  }
+
+private:
+  class Consumer : public clang::ASTConsumer {
+  public:
+~Consumer() override {}
+
+void HandleTranslationUnit(clang::ASTContext &Ctx) override {
+  CheckLValueToRValueConversionVisitor Evaluator;
+  Evaluator.TraverseDecl(Ctx.getTranslationUnitDecl());
+}
+  };
+};
+
+TEST(EvaluateAsRValue, LValueToRValueConversionWorks) {
+  std::string ModesToTest[] = {"", "-fexperimental-new-constant-interpreter"};
+  for (std::string const &Mode : ModesToTest) {
+std::vector Args(1, Mode);
+ASSERT_TRUE(runToolOnCodeWithArgs(std::make_unique(),
+  "constexpr int a = 20;\n"
+  "static_assert(a == 20, \"\");\n",
+  Args));
+  }
+}
Index: clang/test/AST/Interp/literals.cpp
===
--- clang/test/AST/Interp/literals.cpp
+++ clang/test/AST/Interp/literals.cpp
@@ -11,6 +11,7 @@
 static_assert(number == 10, "");
 static_assert(number != 10, ""); // expected-error{{failed}} \
  // ref-error{{failed}} \
+ // expected-note{{evaluates to}} \
  // ref-note{{evaluates to}}
 
 constexpr bool getTrue() { return true; }
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -14934,25 +14934,27 @@
 /// lvalue-to-rvalue cast if it is an lvalue.
 static bool EvaluateAsRValue(EvalInfo &Info, const Expr *E, APValue &Result) {
   assert(!E->isValueDependent());
+
+  if (E->getType().isNull())
+return false;
+
+  if (!CheckLiteralType(Info, E))
+return false;
+
   if (Info.EnableNewConstInterp) {
 if (!Info.Ctx.getInterpContext().evaluateAsRValue(Info, E, Result))
   return false;
   } else {
-if (E->getType().isNull())
-  return false;
-
-if (!CheckLiteralType(Info, E))
-  return false;
-
 if (!::Evaluate(Result, Info, E))
   return false;
+  }
 
-if (E->isGLValue()) {
-  LValue LV;
-  LV.setFrom(Info.Ctx, Result);
-  if (!handleLValueToRValueConversion(Info, E, E->getType(), LV, Result))
-return false;
-}
+  // Implicit lvalue-to-rvalue cast.
+  if (E->isGLValue()) {
+LValue LV;
+LV.setFrom(Info.Ctx, Result);
+if (!handleLValueToRValueConversion(Info, E, E->getType(), LV, Result))
+  return false;
   }
 
   // Check this core constant expression is a constant expression.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] b7a7aee - [clang] Qualify auto in range-based for loops (NFC)

2022-09-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2022-09-03T23:27:27-07:00
New Revision: b7a7aeee90cffefd0f73b8d9f44ab4d1d5123d05

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

LOG: [clang] Qualify auto in range-based for loops (NFC)

Added: 


Modified: 
clang/lib/ARCMigrate/ObjCMT.cpp
clang/lib/ARCMigrate/TransGCAttrs.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/StmtProfile.cpp
clang/lib/AST/Type.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/ThreadSafetyCommon.cpp
clang/lib/CodeGen/CGBlocks.cpp
clang/lib/CodeGen/CGCall.cpp
clang/lib/CodeGen/CGClass.cpp
clang/lib/CodeGen/CGDebugInfo.cpp
clang/lib/CodeGen/CGDeclCXX.cpp
clang/lib/CodeGen/CGExpr.cpp
clang/lib/CodeGen/CGObjCGNU.cpp
clang/lib/CodeGen/CGObjCMac.cpp
clang/lib/CodeGen/CodeGenFunction.cpp
clang/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
clang/lib/CodeGen/SwiftCallingConv.cpp
clang/lib/Driver/Compilation.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/HIPAMD.cpp
clang/lib/Format/Format.cpp
clang/lib/Frontend/FrontendActions.cpp
clang/lib/Index/USRGeneration.cpp
clang/lib/Sema/IdentifierResolver.cpp
clang/lib/Sema/Sema.cpp
clang/lib/Sema/SemaCodeComplete.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaDeclObjC.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaInit.cpp
clang/lib/Sema/SemaLambda.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaObjCProperty.cpp
clang/lib/Sema/SemaOpenMP.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/lib/StaticAnalyzer/Checkers/NSErrorChecker.cpp
clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
clang/lib/StaticAnalyzer/Checkers/UndefinedAssignmentChecker.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/NoUncountedMembersChecker.cpp
clang/lib/StaticAnalyzer/Core/CallEvent.cpp
clang/lib/StaticAnalyzer/Core/CoreEngine.cpp
clang/lib/StaticAnalyzer/Core/ExprEngineObjC.cpp
clang/lib/Tooling/Tooling.cpp

Removed: 




diff  --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index 26f751b77f86a..fe0ce4c5cdc3a 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -792,7 +792,7 @@ static bool UseNSOptionsMacro(Preprocessor &PP, ASTContext 
&Ctx,
   bool PowerOfTwo = true;
   bool AllHexdecimalEnumerator = true;
   uint64_t MaxPowerOfTwoVal = 0;
-  for (auto Enumerator : EnumDcl->enumerators()) {
+  for (auto *Enumerator : EnumDcl->enumerators()) {
 const Expr *InitExpr = Enumerator->getInitExpr();
 if (!InitExpr) {
   PowerOfTwo = false;

diff  --git a/clang/lib/ARCMigrate/TransGCAttrs.cpp 
b/clang/lib/ARCMigrate/TransGCAttrs.cpp
index 99a61e0842a76..b94aee2de573e 100644
--- a/clang/lib/ARCMigrate/TransGCAttrs.cpp
+++ b/clang/lib/ARCMigrate/TransGCAttrs.cpp
@@ -158,7 +158,7 @@ class GCAttrsCollector : public 
RecursiveASTVisitor {
 if (!D)
   return false;
 
-for (auto I : D->redecls())
+for (auto *I : D->redecls())
   if (!isInMainFile(I->getLocation()))
 return false;
 

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 52e7eeca665ab..20fcc8fea4b79 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -7568,7 +7568,7 @@ std::string ASTContext::getObjCEncodingForBlock(const 
BlockExpr *Expr) const {
   // FIXME: There might(should) be a better way of doing this computation!
   CharUnits PtrSize = getTypeSizeInChars(VoidPtrTy);
   CharUnits ParmOffset = PtrSize;
-  for (auto PI : Decl->parameters()) {
+  for (auto *PI : Decl->parameters()) {
 QualType PType = PI->getType();
 CharUnits sz = getObjCEncodingTypeSize(PType);
 if (sz.isZero())
@@ -7583,7 +7583,7 @@ std::string ASTContext::getObjCEncodingForBlock(const 
BlockExpr *Expr) const {
 
   // Argument types.
   ParmOffset = PtrSize;
-  for (auto PVDecl : Decl->parameters()) {
+  for (auto *PVDecl : Decl->parameters()) {
 QualType PType = PVDecl->getOriginalType();
 if (const auto *AT =
 dyn_cast(PType->getCanonicalTypeInternal())) {
@@ -7612,7 +7612,7 @@ ASTContext::ge