[PATCH] D143560: clang-format.el: fix warnings

2023-02-27 Thread Augustin Fabre via Phabricator via cfe-commits
augfab marked 5 inline comments as done.
augfab added a comment.

All comments were addressed, marking them as Done.

I don't have commit access, here's my name and email: Augustin Fabre 
.

Thanks!


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

https://reviews.llvm.org/D143560

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


[PATCH] D144844: [C++20] [Modules] Offer -fno-import-inter-module-function-defs to avoid duplicated compilation in modules

2023-02-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: iains, Bigcheese, dblaikie.
ChuanqiXu added a project: clang-modules.
Herald added a project: All.
ChuanqiXu requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Close https://github.com/llvm/llvm-project/issues/61015
Close https://github.com/llvm/llvm-project/issues/60996

Clang will import the function definitions from other module unit within
optimizations by default to get the best performance. But there are
cases users prefer faster compilation speed than the best performance.

Although we may not agree such ideas, we should offer an option for the
users to give them the right to choose.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144844

Files:
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/module-no-import-from-other-tu.cppm
  clang/test/Modules/inter-module-imports-function-defs.cppm

Index: clang/test/Modules/inter-module-imports-function-defs.cppm
===
--- /dev/null
+++ clang/test/Modules/inter-module-imports-function-defs.cppm
@@ -0,0 +1,57 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: cd %t
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/a.cppm \
+// RUN: -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/b.cppm \
+// RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/b.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.cppm \
+// RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple %t/c.pcm -S \
+// RUN: -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cppm --check-prefix=NO-IMPORT
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/a.cppm \
+// RUN: -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/b.cppm \
+// RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/b.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/c.cppm \
+// RUN: -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 %t/c.pcm \
+// RUN: -S -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cppm --check-prefix=IMPORT
+//
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 \
+// RUN: %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 \
+// RUN: %t/b.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/b.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 \
+// RUN: %t/c.cppm -emit-module-interface -fprebuilt-module-path=%t -o %t/c.pcm
+// RUN: %clang_cc1 -std=c++20 -triple %itanium_abi_triple -O3 \
+// RUN: -fno-import-inter-module-function-defs %t/c.pcm \
+// RUN: -S -emit-llvm -disable-llvm-passes -o - | FileCheck %t/c.cppm --check-prefix=NO-IMPORT
+
+//--- a.cppm
+export module a;
+export int a() {
+return 43;
+}
+
+//--- b.cppm
+export module b;
+export import a;
+export int b() {
+return 43 + a();
+}
+
+//--- c.cppm
+export module c;
+export import b;
+export int c() {
+return 43 + b() + a();
+}
+
+// NO-IMPORT: declare{{.*}}@_ZW1b1bv
+// NO-IMPORT: declare{{.*}}@_ZW1a1av
+
+// IMPORT: define available_externally{{.*}}@_ZW1b1bv
+// IMPORT: define available_externally{{.*}}@_ZW1a1av
Index: clang/test/Driver/module-no-import-from-other-tu.cppm
===
--- /dev/null
+++ clang/test/Driver/module-no-import-from-other-tu.cppm
@@ -0,0 +1,6 @@
+// RUN: %clang -O3 -fno-import-inter-module-function-defs -std=c++20 \
+// RUN: %s -### 2>&1 | FileCheck %s
+
+export module x;
+
+// CHECK: -fno-import-inter-module-function-defs
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -3850,6 +3850,10 @@
   Args.ClaimAllArgs(options::OPT_fmodule_output);
   Args.ClaimAllArgs(options::OPT_fmodule_output_EQ);
 
+  if (Args.hasFlag(options::OPT_fno_import_inter_module_function_defs,
+   options::OPT_fimport_inter_module_function_defs, false))
+CmdArgs.push_back("-fno-import-inter-module-function-defs");
+
   return HaveModules;
 }
 
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -3541,7 +3541,8 @@
   if (getFunctionLinkage(GD) != llvm::Function::AvailableExternallyLinkage)
 return true;
   const auto *F = cast(GD.getDecl());
-  if (CodeGen

[PATCH] D144780: Explicit cast on customized offsetof should not be ignored when evaluating as const

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

I love it. Short, to the point. Thanks.
I think this is the right way to fix this.
Good job.
Can you merge the change? Or should I do it on you behalf?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144780

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


[clang-tools-extra] b6f4834 - [include-cleaner] Fix an unintended early return when checking the

2023-02-27 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2023-02-27T10:09:40+01:00
New Revision: b6f48341c5956a5b1d60ceb9963a2a9e5937788d

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

LOG: [include-cleaner] Fix an unintended early return when checking the
incompatible flags in the CLI tool.

Added: 


Modified: 
clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp

Removed: 




diff  --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index f45a54b5ee9a3..918f7c968ef90 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -187,9 +187,10 @@ int main(int argc, const char **argv) {
   if (OptionsParser->getSourcePathList().size() != 1) {
 std::vector IncompatibleFlags = {&HTMLReportPath, &Print};
 for (const auto *Flag : IncompatibleFlags) {
-  if (Flag->getNumOccurrences())
+  if (Flag->getNumOccurrences()) {
 llvm::errs() << "-" << Flag->ArgStr << " requires a single input file";
-  return 1;
+return 1;
+  }
 }
   }
   auto Factory = clang::tooling::newFrontendActionFactory();



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


[PATCH] D144709: [clang-format] Improve left to right const

2023-02-27 Thread Alexander Hederstaf via Phabricator via cfe-commits
AlexanderHederstaf updated this revision to Diff 500697.
AlexanderHederstaf added a comment.

Rebase after change to pointer to member was merged.
Add case for typename used for nested dependent names.
Add assertions for template closers/openers.

Add commented-out tests for two cases where right to left
produces code that does not compile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

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

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -303,6 +303,11 @@
   verifyFormat("void foo() const final;", Style);
   verifyFormat("void foo() const final LLVM_READONLY;", Style);
   verifyFormat("void foo() const LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile override;", Style);
+  verifyFormat("void foo() const volatile override LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile final;", Style);
+  verifyFormat("void foo() const volatile final LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile LLVM_READONLY;", Style);
 
   verifyFormat(
   "template  explicit Action(Action const &action);",
@@ -353,6 +358,10 @@
   verifyFormat("static int const bat;", "static const int bat;", Style);
   verifyFormat("static int const bat;", "static int const bat;", Style);
 
+  verifyFormat("Foo::Bar const volatile A::*;",
+   "volatile const Foo::Bar A::*;",
+   Style);
+
   verifyFormat("int const Foo::bat = 0;", "const int Foo::bat = 0;",
Style);
   verifyFormat("int const Foo::bat = 0;", "int const Foo::bat = 0;",
@@ -418,6 +427,15 @@
   verifyFormat("unsigned long long const a;", "const unsigned long long a;",
Style);
 
+  // Multiple template parameters.
+  verifyFormat("Bar", "Bar", Style);
+  // Variable declaration based on template type.
+  verifyFormat("Bar bar", "Bar bar", Style);
+
+  // Using typename for a nested dependent type name
+  verifyFormat("typename Foo::iterator const;", "const typename Foo::iterator;",
+   Style);
+
   // don't adjust macros
   verifyFormat("const INTPTR a;", "const INTPTR a;", Style);
 
@@ -573,6 +591,20 @@
   verifyFormat("const std::Foo < int", "const std::Foo", "const std::Foo", Style);
 
+  // TODO: Fails to move const past std::Foo as it's not the last template
+  // parameter.
+  // Multiple template parameters.
+  // verifyFormat("Bar", "Bar", Style);
+
+  // TODO: Fails with "std::const Foo" when going left.
+  // Variable declaration based on template type.
+  // verifyFormat("Bar bar", "Bar bar", Style);
+
+  // TODO: Fails to move const past typename "typename const Foo::iterator".
+  // Using typename for a dependent name
+  // verifyFormat("const typename Foo::iterator", "typename Foo::iterator
+  // const", Style);
+
   // don't adjust macros
   verifyFormat("INTPTR const a;", "INTPTR const a;", Style);
 
@@ -601,6 +633,13 @@
   verifyFormat("const volatile int a;", "int volatile const a;", Style);
   verifyFormat("const volatile int a;", "const int volatile a;", Style);
 
+  // TODO: Left style can not move qualifiers past Foo.
+  // verifyFormat("const volatile Foo a;", "const volatile Foo a;", Style);
+  // verifyFormat("const volatile Foo a;", "volatile const Foo a;", Style);
+  // verifyFormat("const volatile Foo a;", "Foo const volatile a;", Style);
+  // verifyFormat("const volatile Foo a;", "Foo volatile const a;", Style);
+  // verifyFormat("const volatile Foo a;", "const Foo volatile a;", Style);
+
   Style.QualifierAlignment = FormatStyle::QAS_Right;
   Style.QualifierOrder = {"type", "const", "volatile"};
 
@@ -610,6 +649,12 @@
   verifyFormat("int const volatile a;", "int volatile const a;", Style);
   verifyFormat("int const volatile a;", "const int volatile a;", Style);
 
+  verifyFormat("Foo const volatile a;", "const volatile Foo a;", Style);
+  verifyFormat("Foo const volatile a;", "volatile const Foo a;", Style);
+  verifyFormat("Foo const volatile a;", "Foo const volatile a;", Style);
+  verifyFormat("Foo const volatile a;", "Foo volatile const a;", Style);
+  verifyFormat("Foo const volatile a;", "const Foo volatile a;", Style);
+
   Style.QualifierAlignment = FormatStyle::QAS_Left;
   Style.QualifierOrder = {"volatile", "const", "type"};
 
@@ -619,6 +664,13 @@
   verifyFormat("volatile const int a;", "int volatile const a;", Style);
   verifyFormat("volatile const int a;", "const int volatile a;", Style);
 
+  // TODO: Left style can not move qualifiers past Foo.
+  // verifyFormat("volatile const Foo a;", "const volatile Foo a;", Style);
+  // verifyFormat("volatile const Foo a;", "volatile const Foo a;", Style);
+  // verifyFormat("volatile const Foo a;", "Foo cons

[PATCH] D144709: [clang-format] Improve left to right const

2023-02-27 Thread Alexander Hederstaf via Phabricator via cfe-commits
AlexanderHederstaf marked 6 inline comments as done.
AlexanderHederstaf added a comment.

Fixed comments and rebased. Tested right to left on the output of left to right 
and discovered two cases where the output code would not compile. Added new 
tests for those cases and I am working on improvements for right to left.




Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:231-232
+// The case  `Foo() const volatile override` -> `Foo() const volatile
+// override` The case  `Foo() volatile const final` -> `Foo() const 
volatile
+// final`
+if (PreviousCheck->is(tok::r_paren))

HazardyKnusperkeks wrote:
> `clang-format` did wrap your comment ;)
Re-arranged the comments.



Comment at: clang/lib/Format/QualifierAlignmentFixer.cpp:230
+} else if (PreviousCheck->is(TT_TemplateCloser)) {
+  return PreviousCheck->MatchingParen->Previous->isNot(tok::kw_template);
+} else if (PreviousCheck->isOneOf(TT_PointerOrReference, tok::identifier,

HazardyKnusperkeks wrote:
> AlexanderHederstaf wrote:
> > HazardyKnusperkeks wrote:
> > > That may be null, or not?
> > I assumed that if the token is identified as a template closer then there 
> > will exist an opener. As far as I am aware, something must preceed that 
> > opener.
> Then please add an assertion. So we would get a nice message if your 
> assumption is wrong.
Added assertions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

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


[PATCH] D144622: [clang[[ASTImporter] Import TemplateName correctly

2023-02-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

I think these patches are fix for separate problems and can be applied 
independently. It is not better if these are moved into one change. The other 
patch D144273  is not finished (it can get 
bigger), and a test for this change is needed. I try still to discover what the 
exact problem is here, then I can add an unit test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144622

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


[PATCH] D125402: [clang][diag] warn if function returns class type by-const-value

2023-02-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

This has been sitting in the queue for a while, sorry about that.
I think this makes sense in its current iteration, with the warning always on. 
Have you tried to build a large project like chrome with it?




Comment at: clang/lib/Sema/SemaChecking.cpp:16843
+
+  RHSExpr = RHSExpr->IgnoreImplicit();
+

Maybe we should ignore parentheses too?



Comment at: clang/lib/Sema/SemaChecking.cpp:16850-16856
+  const Decl *CD = CE->getCalleeDecl();
+  if (!CD)
+return;
+
+  const FunctionDecl *FD = dyn_cast(CD);
+  if (!FD)
+return;

you can use `CE->getDirectCallee()` here



Comment at: clang/lib/Sema/SemaChecking.cpp:16874
+const SourceRange ReturnTypeLoc = FD->getReturnTypeSourceRange();
+Diag(ReturnTypeLoc.getBegin(), diag::warn_pessimizing_return_by_const);
+Diag(OpLoc, diag::note_pessimizing_return_by_const)

I think a fixit to remove the const would be nice.


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

https://reviews.llvm.org/D125402

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


[PATCH] D144626: [C++20] [Modules] Trying to compare the trailing require clause of the primary template when performing ODR checking

2023-02-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D144626#4154122 , @ChuanqiXu wrote:

> In D144626#4150378 , @erichkeane 
> wrote:
>
>> That looks reasonable to me, though I fear all the libcxx failures are going 
>> to be related to this, please make sure to check them out!
>
> I tested locally that the libcxx failures are not related to  this patch 
> after I reverted this change.

Maybe you can rebase and push a change to trigger the bots again.


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

https://reviews.llvm.org/D144626

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


[PATCH] D144853: [Clang][RISCV] Add CMake options to configure default CPU

2023-02-27 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead created this revision.
pcwang-thead added reviewers: asb, jrtc27, kito-cheng, craig.topper, reames, 
eopXD.
Herald added subscribers: luke, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, 
shiva0217, niosHD, sabuasal, simoncook, johnrusso, rbar, arichardson.
Herald added a project: All.
pcwang-thead requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

For GCC, we can configure default target with `with-{tune/arch/abi}`
options. While for Clang, we don't have the similar way to configure.

Here we add two CMake options `CLANG_RISCV32_DEFAULT_CPU` and
`CLANG_RISCV64_DEFAULT_CPU` to configure default CPU for riscv32
and riscv64.

By specifying these two options when compiling Clang/LLVM, we can
achieve the same goal just like GCC's `with-{tune/arch/abi}`:

- Tune/arch info can be inferred from CPU info.
- Default ABI can be computed from arch string.

And we can do native detection via specifying default CPU to `native`.

Test `clang/test/Driver/riscv-march-mcpu-mtune.c` will failed if we
specify different default CPU.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144853

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


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -10,6 +10,7 @@
 #include "../Clang.h"
 #include "ToolChains/CommonArgs.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -320,5 +321,11 @@
   if (!CPU.empty())
 return CPU;
 
-  return Triple.isRISCV64() ? "generic-rv64" : "generic-rv32";
+  std::string DefaultCPU = Triple.isRISCV64() ? CLANG_RISCV64_DEFAULT_CPU
+  : CLANG_RISCV32_DEFAULT_CPU;
+  // Handle default CPU name is 'native'.
+  if (DefaultCPU == "native")
+DefaultCPU = llvm::sys::getHostCPUName();
+
+  return DefaultCPU;
 }
Index: clang/include/clang/Config/config.h.cmake
===
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -32,6 +32,10 @@
 /* Default architecture for SystemZ. */
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}"
 
+/* Default CPU for RISCV. */
+#define CLANG_RISCV32_DEFAULT_CPU "${CLANG_RISCV32_DEFAULT_CPU}"
+#define CLANG_RISCV64_DEFAULT_CPU "${CLANG_RISCV64_DEFAULT_CPU}"
+
 /* Multilib basename for libdir. */
 #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}"
 
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -247,6 +247,9 @@
 
 set(CLANG_SYSTEMZ_DEFAULT_ARCH "z10" CACHE STRING "SystemZ Default Arch")
 
+set(CLANG_RISCV32_DEFAULT_CPU "generic-rv32" CACHE STRING "RISCV32 Default 
CPU")
+set(CLANG_RISCV64_DEFAULT_CPU "generic-rv64" CACHE STRING "RISCV64 Default 
CPU")
+
 set(CLANG_VENDOR ${PACKAGE_VENDOR} CACHE STRING
   "Vendor-specific text for showing with version information.")
 


Index: clang/lib/Driver/ToolChains/Arch/RISCV.cpp
===
--- clang/lib/Driver/ToolChains/Arch/RISCV.cpp
+++ clang/lib/Driver/ToolChains/Arch/RISCV.cpp
@@ -10,6 +10,7 @@
 #include "../Clang.h"
 #include "ToolChains/CommonArgs.h"
 #include "clang/Basic/CharInfo.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/DriverDiagnostic.h"
 #include "clang/Driver/Options.h"
@@ -320,5 +321,11 @@
   if (!CPU.empty())
 return CPU;
 
-  return Triple.isRISCV64() ? "generic-rv64" : "generic-rv32";
+  std::string DefaultCPU = Triple.isRISCV64() ? CLANG_RISCV64_DEFAULT_CPU
+  : CLANG_RISCV32_DEFAULT_CPU;
+  // Handle default CPU name is 'native'.
+  if (DefaultCPU == "native")
+DefaultCPU = llvm::sys::getHostCPUName();
+
+  return DefaultCPU;
 }
Index: clang/include/clang/Config/config.h.cmake
===
--- clang/include/clang/Config/config.h.cmake
+++ clang/include/clang/Config/config.h.cmake
@@ -32,6 +32,10 @@
 /* Default architecture for SystemZ. */
 #define CLANG_SYSTEMZ_DEFAULT_ARCH "${CLANG_SYSTEMZ_DEFAULT_ARCH}"
 
+/* Default CPU for RISCV. */
+#define CLANG_RISCV32_DEFAULT_CPU "${CLANG_RISCV32_DEFAULT_CPU}"
+#define CLANG_RISCV64_DEFAULT_CPU "${CLANG_RISCV64_DEFAULT_CPU}"
+
 /* Multilib basename for libdir. */
 #define CLANG_INSTALL_LIBDIR_BASENAME "${CLANG_INSTALL_LIBDIR_BASENAME}"
 
I

[PATCH] D144626: [C++20] [Modules] Trying to compare the trailing require clause of the primary template when performing ODR checking

2023-02-27 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 500703.
ChuanqiXu added a comment.

Rebase and push again to trigger the bot.


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

https://reviews.llvm.org/D144626

Files:
  clang/lib/AST/ASTContext.cpp
  clang/test/Modules/pr60890.cppm

Index: clang/test/Modules/pr60890.cppm
===
--- /dev/null
+++ clang/test/Modules/pr60890.cppm
@@ -0,0 +1,82 @@
+// https://github.com/llvm/llvm-project/issues/60890
+//
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/a.cppm -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/b.cppm -fprebuilt-module-path=%t -o %t/b.pcm
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/c.cppm -fprebuilt-module-path=%t -o %t/c.pcm
+// RUN: %clang_cc1 -std=c++20 %t/d.cpp -fprebuilt-module-path=%t -S -emit-llvm -o -
+
+//--- a.cppm
+export module a;
+ 
+export template
+struct a {
+	friend void aa(a x) requires(true) {}
+	void aaa() requires(true) {}
+};
+
+export template struct a;
+
+export template
+void foo(T) requires(true) {}
+
+export template void foo(double);
+
+export template 
+class A {
+	friend void foo<>(A);
+};
+
+//--- b.cppm
+export module b;
+
+import a;
+
+void b() {
+a _;
+	a __;
+}
+
+//--- c.cppm
+export module c;
+
+import a;
+
+struct c {
+	void f() const {
+		a _;
+		aa(_);
+		_.aaa();
+
+		a __;
+		aa(__);
+		__.aaa();
+
+		foo(5);
+		foo(3.0);
+		foo(A());
+	}
+};
+
+//--- d.cpp
+// expected-no-diagnostics
+import a;
+import b;
+import c;
+
+void d() {
+	a _;
+	aa(_);
+	_.aaa();
+
+	a __;
+	aa(__);
+	__.aaa();
+
+	foo(5);
+	foo(3.0);
+	foo(A());
+}
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -6683,8 +6683,28 @@
 return false;
 }
 
-if (!isSameConstraintExpr(FuncX->getTrailingRequiresClause(),
-  FuncY->getTrailingRequiresClause()))
+// The trailing require clause of instantiated function may change during
+// the semantic analysis. Trying to get the primary template function (if
+// exists) to compare the primary trailing require clause.
+auto TryToGetPrimaryTemplatedFunction =
+[](const FunctionDecl *FD) -> const FunctionDecl * {
+  switch (FD->getTemplatedKind()) {
+  case FunctionDecl::TK_DependentNonTemplate:
+return FD->getInstantiatedFromDecl();
+  case FunctionDecl::TK_FunctionTemplate:
+return FD->getDescribedFunctionTemplate()->getTemplatedDecl();
+  case FunctionDecl::TK_MemberSpecialization:
+return FD->getInstantiatedFromMemberFunction();
+  case FunctionDecl::TK_FunctionTemplateSpecialization:
+return FD->getPrimaryTemplate()->getTemplatedDecl();
+  default:
+return FD;
+  }
+};
+const FunctionDecl *PrimaryX = TryToGetPrimaryTemplatedFunction(FuncX);
+const FunctionDecl *PrimaryY = TryToGetPrimaryTemplatedFunction(FuncY);
+if (!isSameConstraintExpr(PrimaryX->getTrailingRequiresClause(),
+  PrimaryY->getTrailingRequiresClause()))
   return false;
 
 auto GetTypeAsWritten = [](const FunctionDecl *FD) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144780: Explicit cast on customized offsetof should not be ignored when evaluating as const

2023-02-27 Thread Ding Fei via Phabricator via cfe-commits
danix800 added a comment.

In D144780#4154487 , @steakhal wrote:

> I love it. Short, to the point. Thanks.
> I think this is the right way to fix this.
> Good job.
> Can you merge the change? Or should I do it on you behalf?

I've no permission to merge, please do it for me. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144780

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


[PATCH] D144709: [clang-format] Improve left to right const

2023-02-27 Thread Alexander Hederstaf via Phabricator via cfe-commits
AlexanderHederstaf updated this revision to Diff 500710.
AlexanderHederstaf added a comment.

Fix simple types not moving all the way right.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

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

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -303,6 +303,11 @@
   verifyFormat("void foo() const final;", Style);
   verifyFormat("void foo() const final LLVM_READONLY;", Style);
   verifyFormat("void foo() const LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile override;", Style);
+  verifyFormat("void foo() const volatile override LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile final;", Style);
+  verifyFormat("void foo() const volatile final LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile LLVM_READONLY;", Style);
 
   verifyFormat(
   "template  explicit Action(Action const &action);",
@@ -350,9 +355,24 @@
   verifyFormat("int const volatile *restrict;", "const int volatile *restrict;",
Style);
 
+  verifyFormat("long long int const volatile;", "const long long int volatile;",
+   Style);
+  verifyFormat("long long int const volatile;", "long const long int volatile;",
+   Style);
+  verifyFormat("long long int const volatile;", "long long volatile int const;",
+   Style);
+  verifyFormat("long long int const volatile;", "long volatile long const int;",
+   Style);
+  verifyFormat("long long int const volatile;", "const long long volatile int;",
+   Style);
+
   verifyFormat("static int const bat;", "static const int bat;", Style);
   verifyFormat("static int const bat;", "static int const bat;", Style);
 
+  verifyFormat("Foo::Bar const volatile A::*;",
+   "volatile const Foo::Bar A::*;",
+   Style);
+
   verifyFormat("int const Foo::bat = 0;", "const int Foo::bat = 0;",
Style);
   verifyFormat("int const Foo::bat = 0;", "int const Foo::bat = 0;",
@@ -418,6 +438,15 @@
   verifyFormat("unsigned long long const a;", "const unsigned long long a;",
Style);
 
+  // Multiple template parameters.
+  verifyFormat("Bar", "Bar", Style);
+  // Variable declaration based on template type.
+  verifyFormat("Bar bar", "Bar bar", Style);
+
+  // Using typename for a nested dependent type name
+  verifyFormat("typename Foo::iterator const;", "const typename Foo::iterator;",
+   Style);
+
   // don't adjust macros
   verifyFormat("const INTPTR a;", "const INTPTR a;", Style);
 
@@ -573,6 +602,20 @@
   verifyFormat("const std::Foo < int", "const std::Foo", "const std::Foo", Style);
 
+  // TODO: Fails to move const past std::Foo as it's not the last template
+  // parameter.
+  // Multiple template parameters.
+  // verifyFormat("Bar", "Bar", Style);
+
+  // TODO: Fails with "std::const Foo" when going left.
+  // Variable declaration based on template type.
+  // verifyFormat("Bar bar", "Bar bar", Style);
+
+  // TODO: Fails to move const past typename "typename const Foo::iterator".
+  // Using typename for a dependent name
+  // verifyFormat("const typename Foo::iterator", "typename Foo::iterator
+  // const", Style);
+
   // don't adjust macros
   verifyFormat("INTPTR const a;", "INTPTR const a;", Style);
 
@@ -601,6 +644,13 @@
   verifyFormat("const volatile int a;", "int volatile const a;", Style);
   verifyFormat("const volatile int a;", "const int volatile a;", Style);
 
+  // TODO: Left style can not move qualifiers past Foo.
+  // verifyFormat("const volatile Foo a;", "const volatile Foo a;", Style);
+  // verifyFormat("const volatile Foo a;", "volatile const Foo a;", Style);
+  // verifyFormat("const volatile Foo a;", "Foo const volatile a;", Style);
+  // verifyFormat("const volatile Foo a;", "Foo volatile const a;", Style);
+  // verifyFormat("const volatile Foo a;", "const Foo volatile a;", Style);
+
   Style.QualifierAlignment = FormatStyle::QAS_Right;
   Style.QualifierOrder = {"type", "const", "volatile"};
 
@@ -610,6 +660,12 @@
   verifyFormat("int const volatile a;", "int volatile const a;", Style);
   verifyFormat("int const volatile a;", "const int volatile a;", Style);
 
+  verifyFormat("Foo const volatile a;", "const volatile Foo a;", Style);
+  verifyFormat("Foo const volatile a;", "volatile const Foo a;", Style);
+  verifyFormat("Foo const volatile a;", "Foo const volatile a;", Style);
+  verifyFormat("Foo const volatile a;", "Foo volatile const a;", Style);
+  verifyFormat("Foo const volatile a;", "const Foo volatile a;", Style);
+
   Style.QualifierAlignment = FormatStyle::QAS_Left;
   Style.QualifierOrder = {"volatile", "const", "type"};

[clang] 95c3c2b - [clang-format] clang-format.el: fix warnings

2023-02-27 Thread Owen Pan via cfe-commits

Author: Augustin Fabre
Date: 2023-02-27T01:56:24-08:00
New Revision: 95c3c2b8570d307ad91c603856336acf32e5021f

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

LOG: [clang-format] clang-format.el: fix warnings

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

Added: 


Modified: 
clang/tools/clang-format/clang-format.el

Removed: 




diff  --git a/clang/tools/clang-format/clang-format.el 
b/clang/tools/clang-format/clang-format.el
index 4e6daa82d4ade..30ac7501afcb6 100644
--- a/clang/tools/clang-format/clang-format.el
+++ b/clang/tools/clang-format/clang-format.el
@@ -82,7 +82,7 @@ in such buffers."
 (let* ((children (xml-node-children node))
(text (car children)))
   (cl-case (xml-node-name node)
-('replacement
+(replacement
  (let* ((offset (xml-get-attribute-or-nil node 'offset))
 (length (xml-get-attribute-or-nil node 'length)))
(when (or (null offset) (null length))
@@ -93,7 +93,7 @@ in such buffers."
(setq offset (string-to-number offset))
(setq length (string-to-number length))
(push (list offset length text) replacements)))
-('cursor
+(cursor
  (setq cursor (string-to-number text)))
 
 ;; Sort by decreasing offset, length.



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


[PATCH] D143560: clang-format.el: fix warnings

2023-02-27 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95c3c2b8570d: [clang-format] clang-format.el: fix warnings 
(authored by augfab, committed by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143560

Files:
  clang/tools/clang-format/clang-format.el


Index: clang/tools/clang-format/clang-format.el
===
--- clang/tools/clang-format/clang-format.el
+++ clang/tools/clang-format/clang-format.el
@@ -82,7 +82,7 @@
 (let* ((children (xml-node-children node))
(text (car children)))
   (cl-case (xml-node-name node)
-('replacement
+(replacement
  (let* ((offset (xml-get-attribute-or-nil node 'offset))
 (length (xml-get-attribute-or-nil node 'length)))
(when (or (null offset) (null length))
@@ -93,7 +93,7 @@
(setq offset (string-to-number offset))
(setq length (string-to-number length))
(push (list offset length text) replacements)))
-('cursor
+(cursor
  (setq cursor (string-to-number text)))
 
 ;; Sort by decreasing offset, length.


Index: clang/tools/clang-format/clang-format.el
===
--- clang/tools/clang-format/clang-format.el
+++ clang/tools/clang-format/clang-format.el
@@ -82,7 +82,7 @@
 (let* ((children (xml-node-children node))
(text (car children)))
   (cl-case (xml-node-name node)
-('replacement
+(replacement
  (let* ((offset (xml-get-attribute-or-nil node 'offset))
 (length (xml-get-attribute-or-nil node 'length)))
(when (or (null offset) (null length))
@@ -93,7 +93,7 @@
(setq offset (string-to-number offset))
(setq length (string-to-number length))
(push (list offset length text) replacements)))
-('cursor
+(cursor
  (setq cursor (string-to-number text)))
 
 ;; Sort by decreasing offset, length.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143436: [clangd] Move standard options adaptor to CommandMangler

2023-02-27 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@kadircet friendly ping, could you please take a look to this diff?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D136497: [Clang] support for outputs along indirect edges of asm goto

2023-02-27 Thread Mikael Holmén via Phabricator via cfe-commits
uabelho added a comment.

I noticed that gvn-hoist doesn't handle this very nicely, I just wrote 
https://github.com/llvm/llvm-project/issues/61023


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136497

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


[PATCH] D143260: [clangd] Add semantic token for labels

2023-02-27 Thread Christian Kandeler via Phabricator via cfe-commits
ckandeler added a comment.

ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143260

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


[PATCH] D144638: [lit] Detect Consistent File Access Times

2023-02-27 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added a comment.

Thanks very much for looking into this, the flakiness of these tests has been 
bugging me for ages.




Comment at: llvm/utils/lit/lit/llvm/config.py:171
+# in the tests that do the same thing.
+(_, try_touch_err) = self.get_process_output(["touch", "-a", "-t", 
"199505050555.55", f.name])
+if try_touch_err != "":

It looks like this command will be run on Windows. I think it will fail and 
cause False to be returned, which is the desired result, but this appears to be 
by accident rather than design. Therefore I'm inclined to agree with @int3 that 
a hard-coded check would be preferable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144638

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


[PATCH] D143803: [clang][alias|ifunc]: Add a diagnostic for mangled names

2023-02-27 Thread Dhruv Chawla via Phabricator via cfe-commits
0xdc03 updated this revision to Diff 500715.
0xdc03 edited the summary of this revision.
0xdc03 added a comment.

- Update to address reviewer comments
- Add release note
- Redo notes to match reviewer comments
- Make the fix-it highlight the whole attribute
- Update tests to check new diagnostics


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143803

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/alias.cpp
  clang/test/CodeGen/attr-ifunc.c
  clang/test/CodeGen/attr-ifunc.cpp
  clang/test/Sema/attr-alias-elf.c

Index: clang/test/Sema/attr-alias-elf.c
===
--- clang/test/Sema/attr-alias-elf.c
+++ clang/test/Sema/attr-alias-elf.c
@@ -5,9 +5,10 @@
 }
 
 void f2(void) __attribute__((alias("g2"))); // expected-error {{alias must point to a defined variable or function}}
-
+// expected-note@-1 {{must refer to the mangled name}}
 
 void f3(void) __attribute__((alias("g3"))); // expected-error {{alias must point to a defined variable or function}}
+// expected-note@-1 {{must refer to the mangled name}}
 void g3(void);
 
 
@@ -46,11 +47,14 @@
 int b1 = 42;
 
 extern int a2 __attribute__((alias("b2"))); // expected-error {{alias must point to a defined variable or function}}
+// expected-note@-1 {{must refer to the mangled name}}
 
 extern int a3 __attribute__((alias("b3"))); // expected-error {{alias must point to a defined variable or function}}
+// expected-note@-1 {{must refer to the mangled name}}
 extern int b3;
 
 extern int a4 __attribute__((alias("b4"))); // expected-error {{alias must point to a defined variable or function}}
+// expected-note@-1 {{must refer to the mangled name}}
 typedef int b4;
 
 void test2_bar() {}
Index: clang/test/CodeGen/attr-ifunc.cpp
===
--- /dev/null
+++ clang/test/CodeGen/attr-ifunc.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+
+void *f1_ifunc(void) { return nullptr; }
+void f1(void) __attribute__((ifunc("f1_ifunc")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+// expected-note@-2 {{must refer to the mangled name}}
+// expected-note@-3 {{function by that name is mangled as}}
+
+void *f6_resolver_resolver(void) { return 0; }
+void *f6_resolver(void) __attribute__((ifunc("f6_resolver_resolver")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+// expected-note@-2 {{must refer to the mangled name}}
+// expected-note@-3 {{function by that name is mangled as}}
+void f6(void) __attribute__((ifunc("f6_resolver")));
+// expected-error@-1 {{ifunc must point to a defined function}}
+// expected-note@-2 {{must refer to the mangled name}}
+// expected-note@-3 {{function by that name is mangled as}}
+
+__attribute__((unused, ifunc("resolver"), deprecated("hahahaha, isn't C great?")))
+void func();
+// expected-error@-2 {{ifunc must point to a defined function}}
+// expected-note@-3 {{must refer to the mangled name}}
+
Index: clang/test/CodeGen/attr-ifunc.c
===
--- clang/test/CodeGen/attr-ifunc.c
+++ clang/test/CodeGen/attr-ifunc.c
@@ -12,6 +12,7 @@
 void *f1_ifunc(void);
 void f1(void) __attribute__((ifunc("f1_ifunc")));
 // expected-error@-1 {{ifunc must point to a defined function}}
+// expected-note@-2 {{must refer to the mangled name}}
 
 void *f2_a(void) __attribute__((alias("f2_b")));
 void *f2_b(void) __attribute__((ifunc("f2_a")));
Index: clang/test/CodeGen/alias.cpp
===
--- /dev/null
+++ clang/test/CodeGen/alias.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+
+void *f1_ifunc(void) { return nullptr; }
+void f1(void) __attribute__((alias("f1_ifunc")));
+// expected-error@-1 {{alias must point to a defined variable or function}}
+// expected-note@-2 {{must refer to the mangled name}}
+// expected-note@-3 {{function by that name is mangled as}}
+
+void *f6_resolver_resolver(void) { return 0; }
+void *f6_resolver(void) __attribute__((alias("f6_resolver_resolver")));
+// expected-error@-1 {{alias must point to a defined variable or function}}
+// expected-note@-2 {{must refer to the mangled name}}
+// expected-note@-3 {{function by that name is mangled as}}
+void f6(void) __attribute__((alias("f6_resolver")));
+// expected-error@-1 {{alias must point to a defined variable or function}}
+// expected-note@-2 {{must refer to the mangled name}}
+// expected-note@-3 {{function by that name is mangled as}}
+
+__attribute__((unused, alias("resolver"), deprecated("hahahaha, isn't C great?")))
+void func();
+// expected-error@-2 {{alias must point to a defined variable or function}}
+// expected-note@-3 

[PATCH] D143375: clang-tidy: Count template constructors in modernize-use-default-member-init

2023-02-27 Thread Marco Falke via Phabricator via cfe-commits
MarcoFalke updated this revision to Diff 500716.
MarcoFalke added a comment.

Thanks. Added release note. Lmk if I should go ahead and merge this.


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

https://reviews.llvm.org/D143375

Files:
  clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
@@ -60,6 +60,12 @@
 int i;
 };
 
+struct TwoConstructorsTpl {
+  TwoConstructorsTpl() : i{7} {}
+  template  TwoConstructorsTpl(T, int) : i(8) {}
+  int i;
+};
+
 struct PositiveNotDefaultOOLInt {
   PositiveNotDefaultOOLInt(int);
   int i;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,6 +98,9 @@
   `ImplementationFileExtensions`, replacing the check-local options of the
   same name.
 
+- In `modernize-use-default-member-init` count template constructors toward
+  hand written constructors so that they are skipped if more than one exists.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -246,8 +246,12 @@
   // Check whether we have multiple hand-written constructors and bomb out, as
   // it is hard to reconcile their sets of member initializers.
   const auto *ClassDecl = cast(Field->getParent());
-  if (llvm::count_if(ClassDecl->ctors(), [](const CXXConstructorDecl *Ctor) {
-return !Ctor->isCopyOrMoveConstructor();
+  if (llvm::count_if(ClassDecl->decls(), [](const Decl *D) {
+if (const auto *FTD = dyn_cast(D))
+  D = FTD->getTemplatedDecl();
+if (const auto *Ctor = dyn_cast(D))
+  return !Ctor->isCopyOrMoveConstructor();
+return false;
   }) > 1)
 return;
 


Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-default-member-init.cpp
@@ -60,6 +60,12 @@
 int i;
 };
 
+struct TwoConstructorsTpl {
+  TwoConstructorsTpl() : i{7} {}
+  template  TwoConstructorsTpl(T, int) : i(8) {}
+  int i;
+};
+
 struct PositiveNotDefaultOOLInt {
   PositiveNotDefaultOOLInt(int);
   int i;
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -98,6 +98,9 @@
   `ImplementationFileExtensions`, replacing the check-local options of the
   same name.
 
+- In `modernize-use-default-member-init` count template constructors toward
+  hand written constructors so that they are skipped if more than one exists.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/UseDefaultMemberInitCheck.cpp
@@ -246,8 +246,12 @@
   // Check whether we have multiple hand-written constructors and bomb out, as
   // it is hard to reconcile their sets of member initializers.
   const auto *ClassDecl = cast(Field->getParent());
-  if (llvm::count_if(ClassDecl->ctors(), [](const CXXConstructorDecl *Ctor) {
-return !Ctor->isCopyOrMoveConstructor();
+  if (llvm::count_if(ClassDecl->decls(), [](const Decl *D) {
+if (const auto *FTD = dyn_cast(D))
+  D = FTD->getTemplatedDecl();
+if (const auto *Ctor = dyn_cast(D))
+  return !Ctor->isCopyOrMoveConstructor();
+return false;
   }) > 1)
 return;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143803: [clang][alias|ifunc]: Add a diagnostic for mangled names

2023-02-27 Thread Dhruv Chawla via Phabricator via cfe-commits
0xdc03 added a comment.

Okay, I have now modified the diagnostic to look something like (as per the 
discussion at 
https://discord.com/channels/636084430946959380/636732781086638081/1079356357024694363):

  ../../bug/ifunc-#59164.cpp:17:16: error: ifunc must point to a defined 
function
  __attribute__((ifunc("resolver")))
 ^
  ../../bug/ifunc-#59164.cpp:17:16: note: the name specified in an ifunc must 
refer to the mangled name
  ../../bug/ifunc-#59164.cpp:17:16: note: function by that name is mangled as 
"_ZL8resolverv"
  __attribute__((ifunc("resolver")))
 ^
 ifunc("_ZL8resolverv")
  ../../bug/ifunc-#59164.cpp:20:16: error: alias must point to a defined 
variable or function
  __attribute__((alias("resolver")))
 ^
  ../../bug/ifunc-#59164.cpp:20:16: note: the name specified in an alias must 
refer to the mangled name
  ../../bug/ifunc-#59164.cpp:20:16: note: function by that name is mangled as 
"_ZL8resolverv"
  __attribute__((alias("resolver")))
 ^
 alias("_ZL8resolverv")
  ../../bug/ifunc-#59164.cpp:23:24: error: ifunc must point to a defined 
function
  __attribute__((unused, ifunc("resolver"), deprecated("hahahaha, isn't C 
great?"))) void func();
 ^
  ../../bug/ifunc-#59164.cpp:23:24: note: the name specified in an ifunc must 
refer to the mangled name
  ../../bug/ifunc-#59164.cpp:23:24: note: function by that name is mangled as 
"_ZL8resolverv"
  __attribute__((unused, ifunc("resolver"), deprecated("hahahaha, isn't C 
great?"))) void func();
 ^
 ifunc("_ZL8resolverv")
  3 errors generated.

However, `clang/test/SemaCXX/externc-ifunc-resolver.cpp` still fails, and I am 
not entirely sure what to do with it. Should I update it to check the 
diagnostic? Also, it seems that the code I wrote prints "must refer to the 
mangled name" everywhere, even when the resolver or aliasee is not a function. 
Should I try to fix this? Or is it OK as it is?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143803

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


[clang] f600a5a - [clang-format] Add macro replacement to fuzzing.

2023-02-27 Thread Manuel Klimek via cfe-commits

Author: Manuel Klimek
Date: 2023-02-27T10:40:22Z
New Revision: f600a5aec52c0aa56e4e47c992b6f10e5cd7b7af

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

LOG: [clang-format] Add macro replacement to fuzzing.

Added: 


Modified: 
clang/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp

Removed: 




diff  --git a/clang/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp 
b/clang/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp
index f90cdf5ab60db..a8a783ba1a53e 100644
--- a/clang/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp
+++ b/clang/tools/clang-format/fuzzer/ClangFormatFuzzer.cpp
@@ -19,6 +19,9 @@ extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t 
size) {
   std::string s((const char *)data, size);
   auto Style = getGoogleStyle(clang::format::FormatStyle::LK_Cpp);
   Style.ColumnLimit = 60;
+  Style.Macros.push_back("ASSIGN_OR_RETURN(a, b)=a = (b)");
+  Style.Macros.push_back("ASSIGN_OR_RETURN(a, b, c)=a = (b); if (x) return c");
+  Style.Macros.push_back("MOCK_METHOD(r, n, a, s)=r n a s");
   auto Replaces = reformat(Style, s, clang::tooling::Range(0, s.size()));
   auto Result = applyAllReplacements(s, Replaces);
 



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


[clang] ec67d70 - [SVE] Add intrinsics for uniform dsp operations that explicitly undefine the result for inactive lanes.

2023-02-27 Thread via cfe-commits

Author: chendewen
Date: 2023-02-27T18:44:55+08:00
New Revision: ec67d703cfb021c705510f9d626e2b800b155b79

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

LOG: [SVE] Add intrinsics for uniform dsp operations that explicitly undefine 
the result for inactive lanes.

This patch adds new intrinsics for uniform dsp operations and changes the 
lowering for the following builtins to emit calls to the new aarch64.sve.###.u 
intrinsics.
  svsqsub_x
  svsqsub_n_x
  svuqsub_x
  svuqsub_n_x
  svsqsubr_x
  svsqsubr_n_x
  svuqsubr_x
  svuqsubr_n_x

Reviewed By: Paul Walker
Differential Revision: https://reviews.llvm.org/D144704

Added: 
llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp-undef.ll

Modified: 
clang/include/clang/Basic/arm_sve.td
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qsub.c
clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qsubr.c
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 8fe0ea7119032..d13ba0590b353 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1521,10 +1521,10 @@ defm SVHADD_U  : SInstZPZZ<"svhadd",  "UcUsUiUl", 
"aarch64_sve_uhadd",  "aarch64
 defm SVRHADD_S : SInstZPZZ<"svrhadd", "csli", "aarch64_sve_srhadd", 
"aarch64_sve_srhadd">;
 defm SVRHADD_U : SInstZPZZ<"svrhadd", "UcUsUiUl", "aarch64_sve_urhadd", 
"aarch64_sve_urhadd">;
 
-defm SVQSUB_S  : SInstZPZZ<"svqsub",  "csli", "aarch64_sve_sqsub",  
"aarch64_sve_sqsub">;
-defm SVQSUB_U  : SInstZPZZ<"svqsub",  "UcUsUiUl", "aarch64_sve_uqsub",  
"aarch64_sve_uqsub">;
-defm SVQSUBR_S : SInstZPZZ<"svqsubr", "csli", "aarch64_sve_sqsubr", 
"aarch64_sve_sqsubr">;
-defm SVQSUBR_U : SInstZPZZ<"svqsubr", "UcUsUiUl", "aarch64_sve_uqsubr", 
"aarch64_sve_uqsubr">;
+defm SVQSUB_S  : SInstZPZZ<"svqsub",  "csli", "aarch64_sve_sqsub",  
"aarch64_sve_sqsub_u">;
+defm SVQSUB_U  : SInstZPZZ<"svqsub",  "UcUsUiUl", "aarch64_sve_uqsub",  
"aarch64_sve_uqsub_u">;
+defm SVQSUBR_S : SInstZPZZ<"svqsubr", "csli", "aarch64_sve_sqsubr", 
"aarch64_sve_sqsub_u", [ReverseMergeAnyBinOp]>;
+defm SVQSUBR_U : SInstZPZZ<"svqsubr", "UcUsUiUl", "aarch64_sve_uqsubr", 
"aarch64_sve_uqsub_u", [ReverseMergeAnyBinOp]>;
 defm SVHSUB_S  : SInstZPZZ<"svhsub",  "csli", "aarch64_sve_shsub",  
"aarch64_sve_shsub">;
 defm SVHSUB_U  : SInstZPZZ<"svhsub",  "UcUsUiUl", "aarch64_sve_uhsub",  
"aarch64_sve_uhsub">;
 defm SVHSUBR_S : SInstZPZZ<"svhsubr", "csli", "aarch64_sve_shsubr", 
"aarch64_sve_shsubr">;

diff  --git a/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qsub.c 
b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qsub.c
index 534e2369d83eb..aad06b79a5f5f 100644
--- a/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qsub.c
+++ b/clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qsub.c
@@ -297,12 +297,12 @@ svuint64_t test_svqsub_u64_m(svbool_t pg, svuint64_t op1, 
svuint64_t op2)
 
 // CHECK-LABEL: @test_svqsub_s8_x(
 // CHECK-NEXT:  entry:
-// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.sqsub.nxv16i8( [[PG:%.*]],  [[OP1:%.*]],  [[OP2:%.*]])
+// CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.sqsub.u.nxv16i8( [[PG:%.*]],  [[OP1:%.*]],  [[OP2:%.*]])
 // CHECK-NEXT:ret  [[TMP0]]
 //
 // CPP-CHECK-LABEL: 
@_Z16test_svqsub_s8_xu10__SVBool_tu10__SVInt8_tu10__SVInt8_t(
 // CPP-CHECK-NEXT:  entry:
-// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.sqsub.nxv16i8( [[PG:%.*]],  [[OP1:%.*]],  [[OP2:%.*]])
+// CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.sqsub.u.nxv16i8( [[PG:%.*]],  [[OP1:%.*]],  [[OP2:%.*]])
 // CPP-CHECK-NEXT:ret  [[TMP0]]
 //
 svint8_t test_svqsub_s8_x(svbool_t pg, svint8_t op1, svint8_t op2)
@@ -313,13 +313,13 @@ svint8_t test_svqsub_s8_x(svbool_t pg, svint8_t op1, 
svint8_t op2)
 // CHECK-LABEL: @test_svqsub_s16_x(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PG:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.aarch64.sve.sqsub.nxv8i16( [[TMP0]],  
[[OP1:%.*]],  [[OP2:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.aarch64.sve.sqsub.u.nxv8i16( [[TMP0]],  [[OP1:%.*]],  [[OP2:%.*]])
 // CHECK-NEXT:ret  [[TMP1]]
 //
 // CPP-CHECK-LABEL: 
@_Z17test_svqsub_s16_xu10__SVBool_tu11__SVInt16_tu11__SVInt16_t(
 // CPP-CHECK-NEXT:  entry:
 // CPP-CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PG:%.*]])
-// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  
@llvm.aarch64.sve.sqsub.nxv8i16( [[TMP0]],  
[[OP1:%.*]],  [[OP2:%.*]])
+// CPP-CHECK-NEXT:[[TMP1:%.*]] = tail call  
@ll

[PATCH] D144704: [SVE] Add intrinsics for uniform dsp operations that explicitly undefine the result for inactive lanes.

2023-02-27 Thread Allen zhong 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 rGec67d703cfb0: [SVE] Add intrinsics for uniform dsp 
operations that explicitly undefine the… (authored by dewen, committed by 
Allen).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144704

Files:
  clang/include/clang/Basic/arm_sve.td
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qsub.c
  clang/test/CodeGen/aarch64-sve2-intrinsics/acle_sve2_qsubr.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp-undef.ll

Index: llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp-undef.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve2-intrinsics-uniform-dsp-undef.ll
@@ -0,0 +1,108 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve2 < %s | FileCheck %s
+
+;
+; SQSUB
+;
+
+define  @sqsub_i8_u( %pg,  %a,  %b) {
+; CHECK-LABEL: sqsub_i8_u:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sqsub z0.b, z0.b, z1.b
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.sqsub.u.nxv16i8( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @sqsub_i16_u( %pg,  %a,  %b) {
+; CHECK-LABEL: sqsub_i16_u:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sqsub z0.h, z0.h, z1.h
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.sqsub.u.nxv8i16( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @sqsub_i32_u( %pg,  %a,  %b) {
+; CHECK-LABEL: sqsub_i32_u:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sqsub z0.s, z0.s, z1.s
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.sqsub.u.nxv4i32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @sqsub_i64_u( %pg,  %a,  %b) {
+; CHECK-LABEL: sqsub_i64_u:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:sqsub z0.d, z0.d, z1.d
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.sqsub.u.nxv2i64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+;
+; UQSUB
+;
+
+define  @uqsub_i8_u( %pg,  %a,  %b) {
+; CHECK-LABEL: uqsub_i8_u:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uqsub z0.b, z0.b, z1.b
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.uqsub.u.nxv16i8( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @uqsub_i16_u( %pg,  %a,  %b) {
+; CHECK-LABEL: uqsub_i16_u:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uqsub z0.h, z0.h, z1.h
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.uqsub.u.nxv8i16( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @uqsub_i32_u( %pg,  %a,  %b) {
+; CHECK-LABEL: uqsub_i32_u:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uqsub z0.s, z0.s, z1.s
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.uqsub.u.nxv4i32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @uqsub_i64_u( %pg,  %a,  %b) {
+; CHECK-LABEL: uqsub_i64_u:
+; CHECK:   // %bb.0:
+; CHECK-NEXT:uqsub z0.d, z0.d, z1.d
+; CHECK-NEXT:ret
+  %out = call  @llvm.aarch64.sve.uqsub.u.nxv2i64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+declare  @llvm.aarch64.sve.uqsub.u.nxv16i8(, , )
+declare  @llvm.aarch64.sve.uqsub.u.nxv8i16(, , )
+declare  @llvm.aarch64.sve.uqsub.u.nxv4i32(, , )
+declare  @llvm.aarch64.sve.uqsub.u.nxv2i64(, , )
+
+declare  @llvm.aarch64.sve.sqsub.u.nxv16i8(, , )
+declare  @llvm.aarch64.sve.sqsub.u.nxv8i16(, , )
+declare  @llvm.aarch64.sve.sqsub.u.nxv4i32(, , )
+declare  @llvm.aarch64.sve.sqsub.u.nxv2i64(, , )
\ No newline at end of file
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -18449,10 +18449,16 @@
 return convertMergedOpToPredOp(N, ISD::S

[PATCH] D144638: [lit] Detect Consistent File Access Times

2023-02-27 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Updates incoming to add a specific check for netbsd and windows, which are 
currently excluding the affected tests anyway.




Comment at: llvm/utils/lit/lit/llvm/config.py:165
+#
+# This check hopefully detects both cases, and disables tests that require
+# consistent atime.

int3 wrote:
> lenary wrote:
> > jhenderson wrote:
> > > Is "hopefully" really needed here?
> > I'm hedging in this comment, in part because we're trying to find a race 
> > condition experimentally, and also because this will cause lit to fatal 
> > error before running any tests if `touch` exits non-zero for any reason. 
> if we know for sure that NetBSD and Windows don't support this, why not 
> hardcode those values in, and only try the experimental check otherwise?
Yeah, this seems pragmatic, I will add it back in again - excluding NetBSD and 
Windows.



Comment at: llvm/utils/lit/lit/llvm/config.py:171
+# in the tests that do the same thing.
+(_, try_touch_err) = self.get_process_output(["touch", "-a", "-t", 
"199505050555.55", f.name])
+if try_touch_err != "":

michaelplatings wrote:
> It looks like this command will be run on Windows. I think it will fail and 
> cause False to be returned, which is the desired result, but this appears to 
> be by accident rather than design. Therefore I'm inclined to agree with @int3 
> that a hard-coded check would be preferable.
I am going to add the hardcoded checks, but I think `touch` is available in 
windows, it should be in the same directory as all the git binaries.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144638

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


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-02-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

First and foremost, I want to deeply apologize about my rushed response. When I 
say that the `Taint originated here` note remained, I **wrongly** draw 
conclusions. Won't happen again.

__Taint-flow IDs__:
I would challenge that we need a flow ID (number) because for me the tainted 
symbol already has a unique ID which should be suitable for this purpose.
What I can see is that it would be useful to know directly what was the first 
tainted symbols of any given tainted symbol. (`SymbolData -> SymbolData` 
mapping)
This is pretty much analog with what you implemented by piggybacking on the 
taint kind. Although, I'd argue that having an explicit mapping would be 
cleaner, but I can see that it's more on personal preference.
In addition to that, I think there is value in minimizing the number of places 
where we introduce such static counters, so I would adwise against that unless 
we have a good reason for doing so.

I'm thinking that although it's handy to have the originally tainted symbol 
directly at the error-node at hand, I'm still not sure if that couldn't be 
calculated and tracked back to the place where we introduced taint.

  int n;
  scanf("%d", &n); // binds $1, not important
  int v = mytaintsource(n); // taint originated here, returns $2
  int z = taintprop(v); // taint propagated here, returns $3
  int x = 42 / z; // 42 div $3

__Soundness of the back-propagation__:
The back-propagation is always in-sync **given that** the state-transition of 
introducing taint **also attaches** the `NoteTag` explaining what it did and 
why.
This basically means that after we call `addTaint()` we must also add a 
`NoteTag` when we call `addTransition()`. Under these circumstances I find it 
easier to argue that the back-propagation is consistent (sound). If a specific 
checker (other than the `GenericTaintChecker`) models taint, it should stick to 
the rules described and emit the right `NoteTag`. That way even downstream 
checkers would play nicely with the taint-tracking and benefit from it.

__Interestingness__:
The concerns seem valid about that the set of interesting symbols could be 
larger than the actually required (and desired) set. However, I wouldn't 
worried about this much unless we have an example on which we can continue 
discussing that this is a real concern.
What I can see is that as-of-now we use the interestingness notion for this, 
and deviating or introducing something else would introduce complexity. So, I'm 
not strictly against having something else, but I would lean towards using 
interestingness here as well, unless we have clear-cut examples demonstrating 
the need for something more sophisticated.

Finally, I'd like to thank you for investing your time into this subject. We 
really should have done it much earlier. Without these similar improvements 
like this one, it's just half way done. Thank you.


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

https://reviews.llvm.org/D144269

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


[clang] 398cddf - [clang-format] Fix assertion that doesn't hold under fuzzing.

2023-02-27 Thread Manuel Klimek via cfe-commits

Author: Manuel Klimek
Date: 2023-02-27T10:50:42Z
New Revision: 398cddf6acecfb12b5997c2d639ee3cf31b787ad

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

LOG: [clang-format] Fix assertion that doesn't hold under fuzzing.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index b0314d6cfa75f..c789f2907dac9 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -511,12 +511,11 @@ class LineJoiner {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (NextLine.First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
-  } else {
+  } if(TheLine->InPPDirective ||
+   !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
+tok::kw_struct)) {
 // Try to merge a block with left brace unwrapped that wasn't yet
 // covered.
-assert(TheLine->InPPDirective ||
-   !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
-tok::kw_struct));
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
   (NextLine.First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyFunction);



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


[PATCH] D144780: Explicit cast on customized offsetof should not be ignored when evaluating as const

2023-02-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

In D144780#4154619 , @danix800 wrote:

> In D144780#4154487 , @steakhal 
> wrote:
>
>> I love it. Short, to the point. Thanks.
>> I think this is the right way to fix this.
>> Good job.
>> Can you merge the change? Or should I do it on you behalf?
>
> I've no permission to merge, please do it for me. Thanks!

In that case please tell me what should I set as the commit-author?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144780

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


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-02-27 Thread Balázs Benics via Phabricator via cfe-commits
steakhal added a comment.

If we worry about having taint-related reports without a Note message 
explaining where the taint was introduced, we could just assert that in a 
`BugReportVisitor` at the `finalizeVisitor()` callback. I think such an 
assertion would make a lot of sense.
To achieve this, we could take the `R.getNotes()` and check if any of them 
refers to a specific one produced by the `NoteTag` callback for taint sources, 
let's say `TaintSourceTag` for that `PathDiagnosticNotePiece`.

  void MyVisitor::finalizeVisitor(BugReporterContext &, const ExplodedNode *, 
PathSensitiveBugReport &R) {
assert(llvm::any_of(R.getNotes(),
[](const auto &Piece) { return Piece->getTag() == 
TaintSourceTag; }) &&
   "Each taint report should have at least one taint-source");
  }

With this assertion, we would gain confidence that the taint reports are 
complete, or at least they all have at least one taint source.


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

https://reviews.llvm.org/D144269

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


[PATCH] D53953: [clang-tidy] Get ClangTidyContext out of the business of storing diagnostics. NFC

2023-02-27 Thread Milly Menson via Phabricator via cfe-commits
MillyMe added a comment.

Thank you!


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D53953

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


[PATCH] D144780: Explicit cast on customized offsetof should not be ignored when evaluating as const

2023-02-27 Thread Ding Fei via Phabricator via cfe-commits
danix800 added a comment.

danix800 (danix...@gmail.com) is OK, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144780

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


[PATCH] D144179: [Clang] Added functionality to provide config file name via env variable

2023-02-27 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen added a comment.

In D144179#4146599 , @MaskRay wrote:

> This looks like introducing a footgun (when something behaves differently 
> from an upstream Clang, it would be difficult for toolchain maintainers to 
> know why).
> Why can't your user specify `CLANG_CONFIG_FILE_SYSTEM_DIR`?

Because I don't want the user to be specifying any flags compiling. The feature 
is intended to be used by a system administrator who will configure the system 
for the user so no compile flags are necessary. That way the machines can be 
configured the same way for all users.
Since there were concerns about visibility of what configuration is used, I 
checked the driver crash report generated when a configuration file set via an 
environmental variable is used. The crash report will print the configuration 
file used and the flags specified in the configuration file will be appended to 
the driver args in the crash reproducer.
And finally, you already use an env variable, CLANG_NO_DEFAULT_CONFIG, to 
disable use of default configuration so it isn't really an introduction but 
rather an extension of what is already used.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144179

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


[PATCH] D144638: [lit] Detect Consistent File Access Times

2023-02-27 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:171
+# in the tests that do the same thing.
+(_, try_touch_err) = self.get_process_output(["touch", "-a", "-t", 
"199505050555.55", f.name])
+if try_touch_err != "":

lenary wrote:
> michaelplatings wrote:
> > It looks like this command will be run on Windows. I think it will fail and 
> > cause False to be returned, which is the desired result, but this appears 
> > to be by accident rather than design. Therefore I'm inclined to agree with 
> > @int3 that a hard-coded check would be preferable.
> I am going to add the hardcoded checks, but I think `touch` is available in 
> windows, it should be in the same directory as all the git binaries.
This is definitely tangential to the change, but in case it's useful to know: 
conventionally only `C:\Program Files\Git\bin` is added to the path on Windows, 
not `C:\Program Files\Git\usr\bin`. `C:\Program Files\Git\bin` only contains 
`bash.exe`, `git.exe` and `sh.exe`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144638

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


[PATCH] D144371: [LLVM-COV] Fix an issue: a statement after calling 'assert()' function is wrongly marked as 'not executed'

2023-02-27 Thread Ying Yi via Phabricator via cfe-commits
MaggieYi added a comment.

Gentle ping ...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144371

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


[PATCH] D144638: [lit] Detect Consistent File Access Times

2023-02-27 Thread Sam Elliott via Phabricator via cfe-commits
lenary added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:171
+# in the tests that do the same thing.
+(_, try_touch_err) = self.get_process_output(["touch", "-a", "-t", 
"199505050555.55", f.name])
+if try_touch_err != "":

michaelplatings wrote:
> lenary wrote:
> > michaelplatings wrote:
> > > It looks like this command will be run on Windows. I think it will fail 
> > > and cause False to be returned, which is the desired result, but this 
> > > appears to be by accident rather than design. Therefore I'm inclined to 
> > > agree with @int3 that a hard-coded check would be preferable.
> > I am going to add the hardcoded checks, but I think `touch` is available in 
> > windows, it should be in the same directory as all the git binaries.
> This is definitely tangential to the change, but in case it's useful to know: 
> conventionally only `C:\Program Files\Git\bin` is added to the path on 
> Windows, not `C:\Program Files\Git\usr\bin`. `C:\Program Files\Git\bin` only 
> contains `bash.exe`, `git.exe` and `sh.exe`.
Something weirder is happening in `_find_git_windows_unix_tools` (from 
https://reviews.llvm.org/D84380), but I think it's probably right just to early 
exit with false on Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144638

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


[PATCH] D144862: Include highlighed, include on hover, code lense for used symbols

2023-02-27 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo created this revision.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
VitaNuo requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144862

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdLSPServer.h
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Protocol.cpp
  clang-tools-extra/clangd/Protocol.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h

Index: clang-tools-extra/clangd/XRefs.h
===
--- clang-tools-extra/clangd/XRefs.h
+++ clang-tools-extra/clangd/XRefs.h
@@ -32,6 +32,8 @@
 namespace clangd {
 class ParsedAST;
 
+std::vector findCodeLens(ParsedAST &AST);
+
 // Describes where a symbol is declared and defined (as far as clangd knows).
 // There are three cases:
 //  - a declaration only, no definition is known (e.g. only header seen)
Index: clang-tools-extra/clangd/XRefs.cpp
===
--- clang-tools-extra/clangd/XRefs.cpp
+++ clang-tools-extra/clangd/XRefs.cpp
@@ -16,6 +16,8 @@
 #include "Selection.h"
 #include "SourceCode.h"
 #include "URI.h"
+#include "clang-include-cleaner/Analysis.h"
+#include "clang-include-cleaner/Types.h"
 #include "index/Index.h"
 #include "index/Merge.h"
 #include "index/Relation.h"
@@ -62,9 +64,11 @@
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
+#include  
 
 namespace clang {
 namespace clangd {
+std::string HelloString = "Hello";
 namespace {
 
 // Returns the single definition of the entity declared by D, if visible.
@@ -74,6 +78,7 @@
 // Kinds of nodes that always return nullptr here will not have definitions
 // reported by locateSymbolAt().
 const NamedDecl *getDefinition(const NamedDecl *D) {
+  std::string AnotherString;
   assert(D);
   // Decl has one definition that we can find.
   if (const auto *TD = dyn_cast(D))
@@ -118,6 +123,7 @@
 // FindSymbols.
 std::optional toLSPLocation(const SymbolLocation &Loc,
   llvm::StringRef TUPath) {
+  std::string ThirdString;
   if (!Loc)
 return std::nullopt;
   auto Uri = URI::parse(Loc.FileURI);
@@ -1213,8 +1219,50 @@
   return std::nullopt;
 }
 
+std::vector
+collectMacroReferences(ParsedAST &AST) {
+  const auto &SM = AST.getSourceManager();
+  //  FIXME: !!this is a hacky way to collect macro references.
+  std::vector Macros;
+  auto &PP = AST.getPreprocessor();
+  for (const syntax::Token &Tok :
+   AST.getTokens().spelledTokens(SM.getMainFileID())) {
+auto Macro = locateMacroAt(Tok, PP);
+if (!Macro)
+  continue;
+if (auto DefLoc = Macro->Info->getDefinitionLoc(); DefLoc.isValid())
+  Macros.push_back(
+  {Tok.location(),
+   include_cleaner::Macro{/*Name=*/PP.getIdentifierInfo(Tok.text(SM)),
+  DefLoc},
+   include_cleaner::RefType::Explicit});
+  }
+  return Macros;
+}
+
 } // namespace
 
+include_cleaner::Includes
+convertIncludes(const SourceManager &SM,
+const llvm::ArrayRef MainFileIncludes) {
+  include_cleaner::Includes Includes;
+  for (const Inclusion &Inc : MainFileIncludes) {
+include_cleaner::Include TransformedInc;
+llvm::StringRef WrittenRef = llvm::StringRef(Inc.Written);
+TransformedInc.Spelled = WrittenRef.trim("\"<>");
+TransformedInc.HashLocation =
+SM.getComposedLoc(SM.getMainFileID(), Inc.HashOffset);
+TransformedInc.Line = Inc.HashLine + 1;
+TransformedInc.Angled = WrittenRef.starts_with("<");
+auto FE = SM.getFileManager().getFile(Inc.Resolved);
+if (!FE)
+  continue;
+TransformedInc.Resolved = *FE;
+Includes.add(std::move(TransformedInc));
+  }
+  return Includes;
+}
+
 std::vector findDocumentHighlights(ParsedAST &AST,
   Position Pos) {
   const SourceManager &SM = AST.getSourceManager();
@@ -1231,11 +1279,96 @@
   DeclRelation::TemplatePattern | DeclRelation::Alias;
   auto TargetDecls =
   targetDecl(N->ASTNode, Relations, AST.getHeuristicResolver());
+
+  const IncludeStructure &Includes = AST.getIncludeStructure();
+  include_cleaner::Includes ConvertedIncludes =
+  convertIncludes(AST.getSourceManager(), Includes.MainFileIncludes);
+  include_cleaner::walkUsed(
+AST.getLocalTopLevelDecls(),
+collectMacroReferences(AST),
+AST.getPragmaIncludes(),
+AST.getSourceManager(),
+[&](const include_cleaner::SymbolReference &Ref,
+llvm::ArrayRef Providers) {
+// std::string SymbolName;
+// switch (Ref.Target.kind()) {
+// case include_cleaner::Symbol::Macro:
+//   break;
+

[PATCH] D140794: [ASTMatcher] Add coroutineBodyStmt matcher

2023-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

> Hmmm, I'm coming around to reusing hasBody() like you've done here. I think 
> it's pretty weird to read: 
> functionDecl(hasBody(coroutineBodyStmt(hasBody(stmt().bind(...))) because of 
> the duplicated calls to hasBody, but I think it's more defensible now than I 
> was originally thinking. I'm still curious if other folks who care about AST 
> matchers have an opinion given that this is a bit trickier than usual.

I think I'm okay with this direction, but one last try at pinging @klimek and 
@sammccall in case they've got an opinion. If we don't hear from them by Thur 
of this week, I'd say it's fine to move forward with the patch as-is.




Comment at: clang/docs/ReleaseNotes.rst:871
 
+- Add ``coroutineBodyStmt`` matcher.
+

You should also mention that the `hasBody` matcher now works with coroutine 
bodies.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140794

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


[PATCH] D144864: [Flang][Driver][MLIR] Add -fopenmp-is-device to Flang and link to an omp.is_device attribute

2023-02-27 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon created this revision.
Herald added subscribers: sunshaoce, Moerafaat, zero9178, bzcheeseman, 
sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, thopre, guansong, yaxunl.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
Herald added projects: Flang, All.
agozillon requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, stephenneuendorffer, 
nicolasvasilache, jdoerfert, MaskRay.
Herald added a reviewer: jdoerfert.
Herald added a reviewer: nicolasvasilache.
Herald added projects: clang, MLIR.

This patch adds the -fopenmp-is-device flag to Flang's FC1 and also
links it up to the application of an attribute to the mlir builtin.module
on lowering. Indiciating whether the module is for host or device.

This omp.is_device module attribute is a light weight adhoc attribute
with noconcrete ODS or class specification, similar to FIR and LLVM's
data_layout, defaultkind and kindmap's. Its intent is simply to carry
information for the moment, it affects transformations (or will in the
future) but does no transformations itself.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144864

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/include/flang/Frontend/LangOptions.def
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help.f90
  flang/tools/bbc/bbc.cpp
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -1417,6 +1417,26 @@
   return success();
 }
 
+//===--===//
+// OpenMPDialect helper functions
+//===--===//
+
+// Set the omp.is_device attribute on the module with the specified boolean
+void OpenMPDialect::setIsDevice(mlir::ModuleOp module, bool isDevice) {
+  module->setAttr(
+  mlir::StringAttr::get(module->getContext(), llvm::Twine{"omp.is_device"}),
+  mlir::BoolAttr::get(module->getContext(), isDevice));
+}
+
+// Return the value of the omp.is_device attribute stored in the module if it
+// exists, otherwise return false by default
+bool OpenMPDialect::getIsDevice(mlir::ModuleOp module) {
+  if (Attribute isDevice = module->getAttr("omp.is_device"))
+if (isDevice.isa())
+  return isDevice.dyn_cast().getValue();
+  return false;
+}
+
 #define GET_ATTRDEF_CLASSES
 #include "mlir/Dialect/OpenMP/OpenMPOpsAttributes.cpp.inc"
 
Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -28,6 +28,15 @@
   let cppNamespace = "::mlir::omp";
   let dependentDialects = ["::mlir::LLVM::LLVMDialect"];
   let useDefaultAttributePrinterParser = 1;
+
+  let extraClassDeclaration = [{
+// Set the omp.is_device attribute on the module with the specified boolean
+static void setIsDevice(mlir::ModuleOp module, bool isDevice);
+
+// Return the value of the omp.is_device attribute stored in the module if it
+// exists, otherwise return false by default
+static bool getIsDevice(mlir::ModuleOp module);
+  }];
 }
 
 // OmpCommon requires definition of OpenACC_Dialect.
Index: flang/tools/bbc/bbc.cpp
===
--- flang/tools/bbc/bbc.cpp
+++ flang/tools/bbc/bbc.cpp
@@ -38,6 +38,7 @@
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/unparse-with-symbols.h"
 #include "flang/Version.inc"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/IR/AsmState.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/MLIRContext.h"
@@ -122,6 +123,11 @@
 llvm::cl::desc("enable openmp"),
 llvm::cl::init(false));
 
+static llvm::cl::opt
+enableOpenMPDevice("fopenmp-is-device",
+   llvm::cl::desc("enable openmp device compilation"),
+   llvm::cl::init(false));
+
 static llvm::cl::opt enableOpenACC("fopenacc",
  llvm::cl::desc("enable openacc"),
  llvm::cl::init(false));
@@ -238,6 +244,8 @@
   kindMap, loweringOptions, {});
   burnside.lower(parseTree, semanticsContext);
   mlir::ModuleOp mlirModule = burnside.getModule();
+  if (enableOpenMP)
+mlir::omp::OpenMPDialect::setIsDevice(mlirModule, enabl

[PATCH] D143751: [clang][analyzer][NFC] Refactor code of StdLibraryFunctionsChecker.

2023-02-27 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

A high level comment before getting into (even more) nitty gritty stuff. But 
shut me down if I misunderstood whats happening.




Comment at: 
clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:124-125
   // requirement would render the initialization of the Summary map infeasible.
+  // A new value constraint is created furthermore by the negate functionality
+  // of the constraint and returned as pointer.
   using ValueConstraintPtr = std::shared_ptr;

balazske wrote:
> Szelethus wrote:
> > Is this what you meant?
> Probably this is better:
> ```
>   // Mind that a pointer to a new value constraint can be created by negating 
> an existing
>   // constraint.
> ```
> The important thing is that one reason for the shared pointer is the negate 
> function that returns a pointer.
Can be, or //will// be? But otherwise, sure.



Comment at: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:271
+
+  private:
+using RangeApplyFunction =

balazske wrote:
> This new private section is the new added code.
While generalizing code is great, whenever its done by introducing function 
arguments / lambdas, the code becomes harder to understand. This is fine, as 
long as this complexity is justified, but I really needed to see what happened 
in the followup patch to see whats the gain behind this.

The gain is that you can capture a stream and construct a helpful message as 
the range is applied. 

Question: couldn't you just expose a lambda for the specific purpose for string 
smithing, and only that? Seems like all lambdas contain kind of the same thing: 
a call to `ConstraintManager::assumeInclusiveRange`. 

Maybe this design (for the above reasons) is worth documenting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143751

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


[PATCH] D144638: [lit] Detect Inconsistent File Access Times

2023-02-27 Thread Sam Elliott via Phabricator via cfe-commits
lenary retitled this revision from "[lit] Detect Consistent File Access Times" 
to "[lit] Detect Inconsistent File Access Times".
lenary edited the summary of this revision.
lenary updated this revision to Diff 500742.
Herald added a subscriber: krytarowski.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144638

Files:
  clang/test/Modules/prune.m
  lld/test/COFF/lto-cache.ll
  lld/test/ELF/lto/cache.ll
  lld/test/MachO/lto-cache.ll
  lld/test/wasm/lto/cache.ll
  llvm/test/ThinLTO/X86/cache.ll
  llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
  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
@@ -5,6 +5,7 @@
 import subprocess
 import sys
 import errno
+import tempfile
 
 import lit.util
 from lit.llvm.subst import FindTool
@@ -155,6 +156,42 @@
 self.with_environment(
 'DYLD_INSERT_LIBRARIES', gmalloc_path_str)
 
+if self._has_consistent_atime():
+features.add('consistent-atime')
+
+# Some tests use `touch` to set the access time for a file, and expect no
+# other processes to change this during the test run. This is not always the
+# case, so we have a way to disable these tests on systems where the access
+# might not be preserved.
+def _has_consistent_atime(self):
+# NetBSD: noatime mounts currently inhibit 'touch -a' updates.
+if platform.system() == 'NetBSD':
+return False
+
+# Windows: the last access time is disabled by default in the OS, and
+# the check below is written in terms of unix utilities (touch, ls),
+# which will not work on this platform.
+if platform.system() == 'Windows':
+return False
+
+# Other Platforms: Try to use `touch -a` to set the atime, and then to
+# read it with `ls`. If they don't match, or either process errors, then
+# don't claim that atime is consistent.
+with tempfile.NamedTemporaryFile() as f:
+# Specific date in the past on purpose, based on what is attempted
+# in the tests that do the same thing.
+(_, try_touch_err) = self.get_process_output(["touch", "-a", "-t", "199505050555.55", f.name])
+if try_touch_err != "":
+return False
+
+(touch_res_out, touch_res_err) = self.get_process_output(["ls", "-lu", f.name])
+if touch_res_err != "":
+return False
+if "1995" not in touch_res_out:
+return False
+
+return True
+
 def _find_git_windows_unix_tools(self, tools_needed):
 assert(sys.platform == 'win32')
 if sys.version_info.major >= 3:
Index: llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
===
--- llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
+++ llvm/test/tools/llvm-objcopy/ELF/strip-preserve-atime.test
@@ -1,7 +1,5 @@
 # Note: ls -lu prints the accessed timestamp
-# NetBSD: noatime mounts currently inhibit 'touch -a' updates
-# Windows: the last access time is disabled by default in the OS
-# UNSUPPORTED: system-netbsd, system-windows
+# REQUIRES: consistent-atime
 
 # Preserve dates when stripping to an output file.
 # RUN: yaml2obj %s -o %t.1.o
Index: llvm/test/ThinLTO/X86/cache.ll
===
--- llvm/test/ThinLTO/X86/cache.ll
+++ llvm/test/ThinLTO/X86/cache.ll
@@ -1,5 +1,4 @@
-; NetBSD: noatime mounts currently inhibit 'touch -a' updates
-; UNSUPPORTED: system-netbsd
+; REQUIRES: consistent-atime
 
 ; The .noindex suffix for output dir is to prevent Spotlight on macOS from
 ; indexing it.
Index: lld/test/wasm/lto/cache.ll
===
--- lld/test/wasm/lto/cache.ll
+++ lld/test/wasm/lto/cache.ll
@@ -1,8 +1,6 @@
 ; RUN: opt -module-hash -module-summary %s -o %t.o
 ; RUN: opt -module-hash -module-summary %p/Inputs/cache.ll -o %t2.o
-; NetBSD: noatime mounts currently inhibit 'touch' from updating atime
-; Windows: no 'touch' command.
-; UNSUPPORTED: system-netbsd, system-windows
+; REQUIRES: consistent-atime
 
 ; RUN: rm -Rf %t.cache && mkdir %t.cache
 ; Create two files that would be removed by cache pruning due to age.
Index: lld/test/MachO/lto-cache.ll
===
--- lld/test/MachO/lto-cache.ll
+++ lld/test/MachO/lto-cache.ll
@@ -1,6 +1,5 @@
 ; REQUIRES: x86
-; NetBSD: noatime mounts currently inhibit 'touch' from updating atime
-; UNSUPPORTED: system-netbsd
+; REQUIRES: consistent-atime
 
 ; RUN: rm -rf %t; split-file %s %t
 ; RUN: opt -module-hash -module-summary %t/foo.ll -o %t/foo.o
Index: lld/test/ELF/lto/

[PATCH] D144638: [lit] Detect Inconsistent File Access Times

2023-02-27 Thread Sam Elliott via Phabricator via cfe-commits
lenary marked 2 inline comments as done.
lenary added a comment.

Hopefully this addresses the feedback so far.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144638

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


[PATCH] D144864: [Flang][Driver][MLIR] Add -fopenmp-is-device to Flang and link to an omp.is_device attribute

2023-02-27 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon updated this revision to Diff 500744.
agozillon added a comment.

Forgot to add an additional test in initial patch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144864

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/include/flang/Frontend/LangOptions.def
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help.f90
  flang/test/Lower/OpenMP/omp-is-device.f90
  flang/tools/bbc/bbc.cpp
  mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
  mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp

Index: mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
===
--- mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
+++ mlir/lib/Dialect/OpenMP/IR/OpenMPDialect.cpp
@@ -1417,6 +1417,26 @@
   return success();
 }
 
+//===--===//
+// OpenMPDialect helper functions
+//===--===//
+
+// Set the omp.is_device attribute on the module with the specified boolean
+void OpenMPDialect::setIsDevice(mlir::ModuleOp module, bool isDevice) {
+  module->setAttr(
+  mlir::StringAttr::get(module->getContext(), llvm::Twine{"omp.is_device"}),
+  mlir::BoolAttr::get(module->getContext(), isDevice));
+}
+
+// Return the value of the omp.is_device attribute stored in the module if it
+// exists, otherwise return false by default
+bool OpenMPDialect::getIsDevice(mlir::ModuleOp module) {
+  if (Attribute isDevice = module->getAttr("omp.is_device"))
+if (isDevice.isa())
+  return isDevice.dyn_cast().getValue();
+  return false;
+}
+
 #define GET_ATTRDEF_CLASSES
 #include "mlir/Dialect/OpenMP/OpenMPOpsAttributes.cpp.inc"
 
Index: mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
===
--- mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
+++ mlir/include/mlir/Dialect/OpenMP/OpenMPOps.td
@@ -28,6 +28,15 @@
   let cppNamespace = "::mlir::omp";
   let dependentDialects = ["::mlir::LLVM::LLVMDialect"];
   let useDefaultAttributePrinterParser = 1;
+
+  let extraClassDeclaration = [{
+// Set the omp.is_device attribute on the module with the specified boolean
+static void setIsDevice(mlir::ModuleOp module, bool isDevice);
+
+// Return the value of the omp.is_device attribute stored in the module if it
+// exists, otherwise return false by default
+static bool getIsDevice(mlir::ModuleOp module);
+  }];
 }
 
 // OmpCommon requires definition of OpenACC_Dialect.
Index: flang/tools/bbc/bbc.cpp
===
--- flang/tools/bbc/bbc.cpp
+++ flang/tools/bbc/bbc.cpp
@@ -38,6 +38,7 @@
 #include "flang/Semantics/semantics.h"
 #include "flang/Semantics/unparse-with-symbols.h"
 #include "flang/Version.inc"
+#include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/IR/AsmState.h"
 #include "mlir/IR/BuiltinOps.h"
 #include "mlir/IR/MLIRContext.h"
@@ -122,6 +123,11 @@
 llvm::cl::desc("enable openmp"),
 llvm::cl::init(false));
 
+static llvm::cl::opt
+enableOpenMPDevice("fopenmp-is-device",
+   llvm::cl::desc("enable openmp device compilation"),
+   llvm::cl::init(false));
+
 static llvm::cl::opt enableOpenACC("fopenacc",
  llvm::cl::desc("enable openacc"),
  llvm::cl::init(false));
@@ -238,6 +244,8 @@
   kindMap, loweringOptions, {});
   burnside.lower(parseTree, semanticsContext);
   mlir::ModuleOp mlirModule = burnside.getModule();
+  if (enableOpenMP)
+mlir::omp::OpenMPDialect::setIsDevice(mlirModule, enableOpenMPDevice);
   std::error_code ec;
   std::string outputName = outputFilename;
   if (!outputName.size())
Index: flang/test/Lower/OpenMP/omp-is-device.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/omp-is-device.f90
@@ -0,0 +1,7 @@
+!RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s --check-prefix=DEVICE
+!RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s --check-prefix=HOST
+
+!DEVICE: module attributes {{{.*}}, omp.is_device = true{{.*}}}
+!HOST: module attributes {{{.*}}, omp.is_device = false{{.*}}}
+subroutine omp_subroutine()
+end subroutine omp_subroutine
\ No newline at end of file
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -138,6 +138,7 @@
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zero

[PATCH] D144866: [clang] Fix aggregate initialization inside lambda constexpr

2023-02-27 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon created this revision.
Herald added a project: All.
Fznamznon requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Constant evaluator only considered access to `this` pointer to be
possible if `this` poitners was captured. However `this` can also appear if
there was a default member initializer.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144866

Files:
  clang/lib/AST/ExprConstant.cpp
  clang/test/SemaCXX/lambda-expressions.cpp


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -665,3 +665,17 @@
 // expected-note@-2 2 {{default capture by}}
 }
 };
+
+#if __cplusplus > 201402L
+namespace GH60936 {
+struct S {
+int i;
+int *p = &i;
+};
+
+static_assert([]() constexpr {
+  S r = S{2};
+  return r.p != nullptr;
+}());
+} // namespace GH60936
+#endif
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -8758,16 +8758,19 @@
   return false;
 }
 Result = *Info.CurrentCall->This;
-// If we are inside a lambda's call operator, the 'this' expression refers
-// to the enclosing '*this' object (either by value or reference) which is
-// either copied into the closure object's field that represents the 
'*this'
-// or refers to '*this'.
+
 if (isLambdaCallOperator(Info.CurrentCall->Callee)) {
-  // Ensure we actually have captured 'this'. (an error will have
-  // been previously reported if not).
+  // Ensure we actually have captured 'this'. If something was wrong with
+  // 'this' capture, the error would have been previously reported.
+  // Otherwise we can be inside of a default initialization of an object
+  // declared by lambda's body, so no need to return false.
   if (!Info.CurrentCall->LambdaThisCaptureField)
-return false;
+return true;
 
+  // If we have captured 'this',  the 'this' expression refers
+  // to the enclosing '*this' object (either by value or reference) which 
is
+  // either copied into the closure object's field that represents the
+  // '*this' or refers to '*this'.
   // Update 'Result' to refer to the data member/field of the closure 
object
   // that represents the '*this' capture.
   if (!HandleLValueMember(Info, E, Result,


Index: clang/test/SemaCXX/lambda-expressions.cpp
===
--- clang/test/SemaCXX/lambda-expressions.cpp
+++ clang/test/SemaCXX/lambda-expressions.cpp
@@ -665,3 +665,17 @@
 // expected-note@-2 2 {{default capture by}}
 }
 };
+
+#if __cplusplus > 201402L
+namespace GH60936 {
+struct S {
+int i;
+int *p = &i;
+};
+
+static_assert([]() constexpr {
+  S r = S{2};
+  return r.p != nullptr;
+}());
+} // namespace GH60936
+#endif
Index: clang/lib/AST/ExprConstant.cpp
===
--- clang/lib/AST/ExprConstant.cpp
+++ clang/lib/AST/ExprConstant.cpp
@@ -8758,16 +8758,19 @@
   return false;
 }
 Result = *Info.CurrentCall->This;
-// If we are inside a lambda's call operator, the 'this' expression refers
-// to the enclosing '*this' object (either by value or reference) which is
-// either copied into the closure object's field that represents the '*this'
-// or refers to '*this'.
+
 if (isLambdaCallOperator(Info.CurrentCall->Callee)) {
-  // Ensure we actually have captured 'this'. (an error will have
-  // been previously reported if not).
+  // Ensure we actually have captured 'this'. If something was wrong with
+  // 'this' capture, the error would have been previously reported.
+  // Otherwise we can be inside of a default initialization of an object
+  // declared by lambda's body, so no need to return false.
   if (!Info.CurrentCall->LambdaThisCaptureField)
-return false;
+return true;
 
+  // If we have captured 'this',  the 'this' expression refers
+  // to the enclosing '*this' object (either by value or reference) which is
+  // either copied into the closure object's field that represents the
+  // '*this' or refers to '*this'.
   // Update 'Result' to refer to the data member/field of the closure object
   // that represents the '*this' capture.
   if (!HandleLValueMember(Info, E, Result,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144179: [Clang] Added functionality to provide config file name via env variable

2023-02-27 Thread Jolanta Jensen via Phabricator via cfe-commits
jolanta.jensen updated this revision to Diff 500747.
jolanta.jensen added a comment.

Adjusting the test for Windows. Setting the read bits only for the config file 
as Windows does not have full support for chmod.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144179

Files:
  clang/include/clang/Config/config.h.cmake
  clang/include/clang/Driver/Driver.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/config-file-from-env.c

Index: clang/test/Driver/config-file-from-env.c
===
--- /dev/null
+++ clang/test/Driver/config-file-from-env.c
@@ -0,0 +1,51 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+// RUN: mkdir %t/empty_dir
+// RUN: echo "-Wall" > %t/c.cfg
+// RUN: echo "-ffast-math" > %t/cxx.cfg
+// RUN: touch %t/unreadable.cfg
+// RUN: chmod a-r %t/unreadable.cfg
+// RUN: touch %t/test.c
+// RUN: touch %t/test.cpp
+
+// RUN: env CONFIG_FILE=%t/c.cfg %clang -S %t/test.c -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C1
+// CHECK-C1: Configuration file: {{.*[\/\\]}}c.cfg
+// CHECK-C1: -Wall
+
+// RUN: env CONFIG_FILE=%t/unreadable.cfg not %clang -S %t/test.c -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C2
+// CHECK-C2: error: cannot read configuration file '{{.*[\/\\]}}unreadable.cfg'
+
+// RUN: env CONFIG_FILE=%t/c.cfg %clang -S %t/test.c --config %S/Inputs/config-1.cfg -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C3
+// CHECK-C3: Configuration file: {{.*[\/\\]}}config-1.cfg
+// CHECK-C3: -Werror
+// CHECK-C3-NOT: -Wall
+
+// RUN: env CONFIG_FILE= not %clang -S %t/test.c -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C4
+// CHECK-C4: error: cannot read configuration file ''
+
+// RUN: env CONFIG_FILE=%t/empty_dir not %clang -S %t/test.c -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-C5
+// CHECK-C5: error: configuration file '{{.*[\/\\]}}empty_dir' cannot be opened: not a regular file
+
+// RUN: env CONFIG_FILE=%t/cxx.cfg %clang++ -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX1
+// CHECK-CXX1: Configuration file: {{.*[\/\\]}}cxx.cfg
+// CHECK-CXX1: -ffast-math
+
+// RUN: env CONFIG_FILE=%t/unreadable.cfg not %clang++ -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX2
+// CHECK-CXX2: error: cannot read configuration file '{{.*[\/\\]}}unreadable.cfg'
+
+// RUN: env CONFIG_FILE=%t/cxx.cfg %clang++ -S %t/test.cpp --config %S/Inputs/config-1.cfg -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX3
+// CHECK-CXX3: Configuration file: {{.*[\/\\]}}config-1.cfg
+// CHECK-CXX3: -Werror
+// CHECK-CXX3-NOT: -ffast-math
+
+// RUN: env CONFIG_FILE= not %clang++ -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX4
+// CHECK-CXX4: error: cannot read configuration file ''
+
+// RUN: env CONFIG_FILE=%t/empty_dir not %clang++ -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX5
+// CHECK-CXX5: error: configuration file '{{.*[\/\\]}}empty_dir' cannot be opened: not a regular file
+
+// RUN: env CONFIG_FILE=%t/c.cfg %clang++ --config=%t/cxx.cfg -S %t/test.cpp -o /dev/null -### 2>&1 | FileCheck %s -check-prefix CHECK-CXX6
+// CHECK-CXX6-NOT: Configuration file: {{.*[\/\\]}}c.cfg
+// CHECK-CXX6-NOT: -Wall
+
+// RUN: rm -rf %t
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1034,6 +1034,35 @@
   return false;
 }
 
+bool Driver::readConfigFileFromEnv() {
+  llvm::cl::ExpansionContext ExpCtx(Saver.getAllocator(),
+llvm::cl::tokenizeConfigFile);
+  ExpCtx.setVFS(&getVFS());
+  std::string EnvCfgName = "CONFIG_FILE";
+
+#if defined(ENV_CONFIG_FILE_NAME)
+  EnvCfgName = ENV_CONFIG_FILE_NAME;
+#endif
+  const char *EnvCfgFileName = getenv(EnvCfgName.c_str());
+
+  if (!EnvCfgFileName)
+return false;
+
+  std::string CfgFileName = EnvCfgFileName;
+  if (CfgFileName.empty()) {
+Diag(diag::err_drv_cannot_read_config_file) << CfgFileName << "";
+return true;
+  }
+
+  // If argument contains directory separator, treat it as a path to
+  // configuration file.
+  SmallString<128> CfgFilePath;
+  if (llvm::sys::path::is_relative(CfgFileName))
+llvm::sys::fs::current_path(CfgFilePath);
+  llvm::sys::path::append(CfgFilePath, CfgFileName);
+  return readConfigFile(CfgFilePath, ExpCtx);
+}
+
 bool Driver::loadConfigFiles() {
   llvm::cl::ExpansionContext ExpCtx(Saver.getAllocator(),
 llvm::cl::tokenizeConfigFile);
@@ -1099,6 +1128,9 @@
 }
   }
 
+  if (ConfigFiles.empty())
+return readConfigFileFromEnv();
+
   // No error occurred.
   return false;
 }
Index: clang/include/clang/Driver/Driver.h
===
--- clang/include/clang/Driver/Driver.h
+++ clang/incl

[PATCH] D140996: [c++20] P1907R1: Support for generalized non-type template arguments of scalar type.

2023-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/include/clang/AST/ASTContext.h:3036
 if (!std::is_trivially_destructible::value) {
-  auto DestroyPtr = [](void *V) { static_cast(V)->~T(); };
-  AddDeallocation(DestroyPtr, Ptr);
+  auto DestroyPtr = [](void *V) { ((T *)V)->~T(); };
+  AddDeallocation(DestroyPtr, (void *)Ptr);

bolshakov-a wrote:
> erichkeane wrote:
> > This change is weird... what is going on here?
> Here is not very beautiful attempt to workaround const-ness of 
> `TemplateArgument::V::Value` pointer passed here from the added 
> `TemplateArgument` constructor. The change in this line isn't acually needed 
> and made only for consistence with the next line, I think. Alternatively, I 
> can
> 1) refactor `addDestruction` and `AddDeallocation` to work with pointers to 
> constants, or
> 2) add `const_cast` to `AddDeallocation` call in the next line, or
> 3) make `TemplateArgument::V::Value` pointer non-const.
> 
> I'm biased to the first variant.
I'd lean towards #3, it ends up being consistent with the rest of the things 
here.  #1 is interesting, but that results in these functions violating 
const-correctness.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140996

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


[PATCH] D144870: [Clang][DebugInfo] Emit zero size bitfields in the debug info to delimit bitfields in different allocation units.

2023-02-27 Thread Juan Manuel Martinez Caamaño via Phabricator via cfe-commits
jmmartinez created this revision.
jmmartinez added reviewers: dblaikie, probinson.
Herald added subscribers: kosarev, tpr.
Herald added a project: All.
jmmartinez requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I'm looking for some feedback, this is definitively not the final solution.
I was wondering if there was an alternative to pass this information in the 
dwarf debug-info.

Consider the following sturctures when targetting:

  struct foo {
int space[4];
char a : 8;
char b : 8;
char x : 8;
char y : 8;
  };
  
  struct bar {
int space[4];
char a : 8;
char b : 8;
char : 0;
char x : 8;
char y : 8;
  };

Even if both structs have the same layout in memory, they are handled
differenlty by the AMDGPU ABI.

With the following code:

// clang --target=amdgcn-amd-amdhsa -g -O1 example.c -S
char use_foo(struct foo f) { return f.y; }
char use_bar(struct bar b) { return b.y; }

For use_foo, the 'y' field is passed in v4
; v_ashrrev_i32_e32 v0, 24, v4
; s_setpc_b64 s[30:31]

For use_bar, the 'y' field is passed in v5
; v_bfe_i32 v0, v5, 8, 8
; s_setpc_b64 s[30:31]

To make this distinction, we record a single 0-size bitfield for every member 
that is preceded
by it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144870

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CGRecordLayout.h
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/test/CodeGen/debug-info-bitfield-0-struct.c

Index: clang/test/CodeGen/debug-info-bitfield-0-struct.c
===
--- /dev/null
+++ clang/test/CodeGen/debug-info-bitfield-0-struct.c
@@ -0,0 +1,97 @@
+// RUN: %clang_cc1 -triple x86_64-unk-unk -o - -emit-llvm -debug-info-kind=limited %s | FileCheck %s
+
+struct First {
+  // CHECK-DAG: ![[FIRST:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "First", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 32, elements: ![[FIRST_ELEMENTS:[0-9]+]])
+  // CHECK-DAG: ![[FIRST_ELEMENTS]] = !{![[FIRST_X:[0-9]+]], ![[FIRST_Y:[0-9]+]]}
+  // CHECK-DAG: ![[FIRST_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[FIRST]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // CHECK-DAG: ![[FIRST_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[FIRST]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 4, flags: DIFlagBitField, extraData: i64 0)
+  int : 0;
+  int x : 4;
+  int y : 4;
+};
+
+struct FirstDuplicate {
+  // CHECK-DAG: ![[FIRSTD:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "FirstDuplicate", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 32, elements: ![[FIRSTD_ELEMENTS:[0-9]+]])
+  // CHECK-DAG: ![[FIRSTD_ELEMENTS]] = !{![[FIRSTD_X:[0-9]+]], ![[FIRSTD_Y:[0-9]+]]}
+  // CHECK-DAG: ![[FIRSTD_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[FIRSTD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // CHECK-DAG: ![[FIRSTD_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[FIRSTD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 4, flags: DIFlagBitField, extraData: i64 0)
+  int : 0;
+  int : 0;
+  int x : 4;
+  int y : 4;
+};
+
+struct Second {
+  // CHECK-DAG: ![[SECOND:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Second", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 64, elements: ![[SECOND_ELEMENTS:[0-9]+]])
+  // CHECK-DAG: ![[SECOND_ELEMENTS]] = !{![[SECOND_X:[0-9]+]], ![[SECOND_ZERO:[0-9]+]], ![[SECOND_Y:[0-9]+]]}
+  // CHECK-DAG: ![[SECOND_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i64 0)
+  // CHECK-DAG: ![[SECOND_ZERO]] = !DIDerivedType(tag: DW_TAG_member, scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  // CHECK-DAG: ![[SECOND_Y]] = !DIDerivedType(tag: DW_TAG_member, name: "y", scope: ![[SECOND]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, offset: 32, flags: DIFlagBitField, extraData: i64 32)
+  int x : 4;
+  int : 0;
+  int y : 4;
+};
+
+struct SecondDuplicate {
+  // CHECK-DAG: ![[SECONDD:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "SecondDuplicate", file: !{{[0-9]+}}, line: {{[0-9]+}}, size: 64, elements: ![[SECONDD_ELEMENTS:[0-9]+]])
+  // CHECK-DAG: ![[SECONDD_ELEMENTS]] = !{![[SECONDD_X:[0-9]+]], ![[SECONDD_ZERO:[0-9]+]], ![[SECONDD_Y:[0-9]+]]}
+  // CHECK-DAG: ![[SECONDD_X]] = !DIDerivedType(tag: DW_TAG_member, name: "x", scope: ![[SECONDD]], file: !{{[0-9]+}}, line: {{[0-9]+}}, baseType: !{{[0-9]+}}, size: 4, flags: DIFlagBitField, extraData: i6

[PATCH] D144638: [lit] Detect Inconsistent File Access Times

2023-02-27 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added a comment.

I see some of these tests previously had `UNSUPPORTED: system-netbsd` but not 
`UNSUPPORTED: system-windows` - do you know why?




Comment at: llvm/utils/lit/lit/llvm/config.py:190
+return False
+if "1995" not in touch_res_out:
+return False

This could end up matching the wrong part of the string, for example if the 
temporary file happened to have 1995 in its name. A regex match for '\b1995\b' 
would be more reliable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144638

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


[PATCH] D143630: [clang] update test case

2023-02-27 Thread Nikita Popov via Phabricator via cfe-commits
nikic requested changes to this revision.
nikic added a comment.
This revision now requires changes to proceed.

(Marking this as changes requested per previous comment.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143630

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


[PATCH] D144873: [OpenMP] Ignore implicit casts on assertion for `use_device_ptr`

2023-02-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, ABataev, ronlieb, 
carlo.bertolli.
Herald added subscribers: guansong, yaxunl.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

There was an assertion triggering when invoking a captured member whose
initializer was in a blase class. This patch fixes it by allowing the
assertion on implicit casts to the base class rather than only the base
class itself.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144873

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp
@@ -0,0 +1,266 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s -Wno-openmp-mapping
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s -Wno-openmp-mapping
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK2
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+class A {
+public:
+  double *ptr = nullptr;
+  virtual void foo() = 0;
+};
+
+class B : public A {
+public:
+  virtual void foo() override;
+};
+
+void B::foo() {
+#pragma omp target data use_device_ptr(A::ptr)
+  {
+  }
+}
+
+void foo() {
+  B b;
+  b.foo();
+}
+
+#endif
+// CHECK-LABEL: define {{[^@]+}}@_ZN1B3fooEv
+// CHECK-SAME: (ptr noundef nonnull align 8 dereferenceable(16) [[THIS:%.*]]) unnamed_addr #[[ATTR0:[0-9]+]] align 2 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[PTR4:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[TMP:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[PTR:%.*]] = getelementptr inbounds [[CLASS_A:%.*]], ptr [[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[PTR2:%.*]] = getelementptr inbounds [[CLASS_A]], ptr [[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[PTR3:%.*]] = getelementptr inbounds [[CLASS_A]], ptr [[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[PTR3]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[THIS1]], ptr [[TMP1]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[THIS1]], ptr [[TMP2]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_MAPPERS]], i64 0, i64 0
+// CHECK-NEXT:store ptr null, ptr [[TMP3]], align 8
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK-NEXT:store ptr [[PTR2]], ptr [[TMP4]], align 8
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 1
+// CHECK-NEXT:store ptr [[TMP0]], ptr [[TMP5]], align 8
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_MAPPERS]], i64 0, i64 1
+// CHECK-NEXT:store ptr null, ptr [[TMP6]], align 8
+// CHECK-NEXT:[[TMP7:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]],

[PATCH] D143803: [clang][alias|ifunc]: Add a diagnostic for mangled names

2023-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D143803#4154736 , @0xdc03 wrote:

> Okay, I have now modified the diagnostic to look something like (as per the 
> discussion at 
> https://discord.com/channels/636084430946959380/636732781086638081/1079356357024694363):
>
>   ../../bug/ifunc-#59164.cpp:17:16: error: ifunc must point to a defined 
> function
>   __attribute__((ifunc("resolver")))
>  ^
>   ../../bug/ifunc-#59164.cpp:17:16: note: the name specified in an ifunc must 
> refer to the mangled name
>   ../../bug/ifunc-#59164.cpp:17:16: note: function by that name is mangled as 
> "_ZL8resolverv"
>   __attribute__((ifunc("resolver")))
>  ^
>  ifunc("_ZL8resolverv")
>   ../../bug/ifunc-#59164.cpp:20:16: error: alias must point to a defined 
> variable or function
>   __attribute__((alias("resolver")))
>  ^
>   ../../bug/ifunc-#59164.cpp:20:16: note: the name specified in an alias must 
> refer to the mangled name
>   ../../bug/ifunc-#59164.cpp:20:16: note: function by that name is mangled as 
> "_ZL8resolverv"
>   __attribute__((alias("resolver")))
>  ^
>  alias("_ZL8resolverv")
>   ../../bug/ifunc-#59164.cpp:23:24: error: ifunc must point to a defined 
> function
>   __attribute__((unused, ifunc("resolver"), deprecated("hahahaha, isn't C 
> great?"))) void func();
>  ^
>   ../../bug/ifunc-#59164.cpp:23:24: note: the name specified in an ifunc must 
> refer to the mangled name
>   ../../bug/ifunc-#59164.cpp:23:24: note: function by that name is mangled as 
> "_ZL8resolverv"
>   __attribute__((unused, ifunc("resolver"), deprecated("hahahaha, isn't C 
> great?"))) void func();
>  ^
>  ifunc("_ZL8resolverv")
>   3 errors generated.
>
> However, `clang/test/SemaCXX/externc-ifunc-resolver.cpp` still fails, and I 
> am not entirely sure what to do with it. Should I update it to check the 
> diagnostic? Also, it seems that the code I wrote prints "must refer to the 
> mangled name" everywhere, even when the resolver or aliasee is not a 
> function. Should I try to fix this? Or is it OK as it is?

I think updating that test with this additional note is the right thing to do.  
As far as that note, saying 'mangled name' is perhaps not correct there, since 
what we really care is that it is the name-as-emitted to the linker. I don't 
have an idea on exactly what to call it.  If we could come up with a better 
phrase, it probably makes the diagnostic on the thing not being a function.

ALSO, it would be worth updating the error here to mention that it must point 
to a defined function,  (where x,y,z are the things that it is allowed 
to target).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143803

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


[PATCH] D144873: [OpenMP] Ignore implicit casts on assertion for `use_device_ptr`

2023-02-27 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 accepted this revision.
tianshilei1992 added a comment.
This revision is now accepted and ready to land.

LG


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144873

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


[PATCH] D143803: [clang][alias|ifunc]: Add a diagnostic for mangled names

2023-02-27 Thread Dhruv Chawla via Phabricator via cfe-commits
0xdc03 added a comment.

In D143803#4155266 , @erichkeane 
wrote:

> I think updating that test with this additional note is the right thing to do.

Will do, will also add checks for the fix-its.

> As far as that note, saying 'mangled name' is perhaps not correct there, 
> since what we really care is that it is the name-as-emitted to the linker. I 
> don't have an idea on exactly what to call it.  If we could come up with a 
> better phrase, it probably makes the diagnostic on the thing not being a 
> function.

First few that come to mind:

- ABI-mangled symbol
- Linked symbol
- Externally-visible name

It may also be worth splitting the diagnostic for `ifunc`s and `alias`es to be 
something like:

- `ifunc`: the function specified in an `ifunc` must refer to its 
- `alias`: the function or variable specified in an `alias` must refer to its 


I feel externally-visible name fits the best, though it doesn't really make 
sense with internal linkage.

> ALSO, it would be worth updating the error here to mention that it must point 
> to a defined function,  (where x,y,z are the things that it is 
> allowed to target).

Hmm, I do not really understand this point, could you please clarify it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143803

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


[PATCH] D136100: [clang-format] Do not parse certain characters in pragma directives

2023-02-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

I would prefer that this doesn't get reverted, see the summary for the awful 
results for OpenMP without this patch. A potential solution would be to parse 
the next token and only add the indent if it's `omp`.




Comment at: clang/unittests/Format/FormatTest.cpp:5175
   verifyFormat("#pragma omp threadprivate( \\\n"
-   "y)), // expected-warning",
+   "y)), // expected-warning",
getLLVMStyleWithColumns(28));

owenpan wrote:
> Why was this test case changed? It seemed to be related to the regression 
> mentioned in D136100#3988574.
It's definitely related, we want some indentation for successive OpenMP clauses 
pushed to a new line, see below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136100

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


[PATCH] D143803: [clang][alias|ifunc]: Add a diagnostic for mangled names

2023-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a subscriber: shafik.
erichkeane added a comment.

In D143803#4155345 , @0xdc03 wrote:

> In D143803#4155266 , @erichkeane 
> wrote:
>
>> I think updating that test with this additional note is the right thing to 
>> do.
>
> Will do, will also add checks for the fix-its.
>
>> As far as that note, saying 'mangled name' is perhaps not correct there, 
>> since what we really care is that it is the name-as-emitted to the linker. I 
>> don't have an idea on exactly what to call it.  If we could come up with a 
>> better phrase, it probably makes the diagnostic on the thing not being a 
>> function.
>
> First few that come to mind:
>
> - ABI-mangled symbol
> - Linked symbol
> - Externally-visible name

I don't think any of those are accurate with internal names.  ABI-mangled is 
incorrect as the ABI says nothing about these.  "Linked Symbol" isnt really 
accurate, as these aren't really 'linked'.  AND, they aren't 
externally-visible.  I wish I was better at this part :D  Perhaps @shafik might 
have a better ability to bikeshed here?

> It may also be worth splitting the diagnostic for `ifunc`s and `alias`es to 
> be something like:
>
> - `ifunc`: the function specified in an `ifunc` must refer to its  name>
> - `alias`: the function or variable specified in an `alias` must refer to its 
> 
>
> I feel externally-visible name fits the best, though it doesn't really make 
> sense with internal linkage.



>> ALSO, it would be worth updating the error here to mention that it must 
>> point to a defined function,  (where x,y,z are the things that it 
>> is allowed to target).
>
> Hmm, I do not really understand this point, could you please clarify it?

Exactly what you were saying above with the 'splitting the diagnostic', I was 
saying in less accurate words, that I'd prefer that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143803

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


[PATCH] D144709: [clang-format] Improve left to right const

2023-02-27 Thread Alexander Hederstaf via Phabricator via cfe-commits
AlexanderHederstaf updated this revision to Diff 500792.
AlexanderHederstaf added a comment.

Update right to left analyzer
Add support for requires clauses
Ignore usages of struct/class keyword

Add new, and uncomment old tests
Fix invalid tests with 'const Foo b* const;'


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

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

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -241,7 +241,7 @@
   verifyFormat("int const *b;", Style);
   verifyFormat("int const &b;", Style);
   verifyFormat("int const &&b;", Style);
-  verifyFormat("int const *b const;", Style);
+  verifyFormat("int const *const b;", Style);
   verifyFormat("int *const c;", Style);
 
   verifyFormat("const Foo a;", Style);
@@ -252,7 +252,7 @@
   verifyFormat("Foo const *b;", Style);
   verifyFormat("Foo const &b;", Style);
   verifyFormat("Foo const &&b;", Style);
-  verifyFormat("Foo const *b const;", Style);
+  verifyFormat("Foo const *const b;", Style);
 
   verifyFormat("LLVM_NODISCARD const int &Foo();", Style);
   verifyFormat("LLVM_NODISCARD int const &Foo();", Style);
@@ -275,7 +275,7 @@
   verifyFormat("int const *b;", Style);
   verifyFormat("int const &b;", Style);
   verifyFormat("int const &&b;", Style);
-  verifyFormat("int const *b const;", Style);
+  verifyFormat("int const *const b;", Style);
   verifyFormat("int *const c;", Style);
 
   verifyFormat("Foo const a;", Style);
@@ -286,7 +286,7 @@
   verifyFormat("Foo const *b;", Style);
   verifyFormat("Foo const &b;", Style);
   verifyFormat("Foo const &&b;", Style);
-  verifyFormat("Foo const *b const;", Style);
+  verifyFormat("Foo const *const b;", Style);
   verifyFormat("Foo *const b;", Style);
   verifyFormat("Foo const *const b;", Style);
   verifyFormat("auto const v = get_value();", Style);
@@ -303,6 +303,11 @@
   verifyFormat("void foo() const final;", Style);
   verifyFormat("void foo() const final LLVM_READONLY;", Style);
   verifyFormat("void foo() const LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile override;", Style);
+  verifyFormat("void foo() const volatile override LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile final;", Style);
+  verifyFormat("void foo() const volatile final LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile LLVM_READONLY;", Style);
 
   verifyFormat(
   "template  explicit Action(Action const &action);",
@@ -343,6 +348,7 @@
   verifyFormat("int const volatile;", "volatile const int;", Style);
   verifyFormat("int const volatile;", "const volatile int;", Style);
   verifyFormat("int const volatile;", "const int volatile;", Style);
+
   verifyFormat("int const volatile *restrict;", "volatile const int *restrict;",
Style);
   verifyFormat("int const volatile *restrict;", "const volatile int *restrict;",
@@ -350,9 +356,24 @@
   verifyFormat("int const volatile *restrict;", "const int volatile *restrict;",
Style);
 
+  verifyFormat("long long int const volatile;", "const long long int volatile;",
+   Style);
+  verifyFormat("long long int const volatile;", "long const long int volatile;",
+   Style);
+  verifyFormat("long long int const volatile;", "long long volatile int const;",
+   Style);
+  verifyFormat("long long int const volatile;", "long volatile long const int;",
+   Style);
+  verifyFormat("long long int const volatile;", "const long long volatile int;",
+   Style);
+
   verifyFormat("static int const bat;", "static const int bat;", Style);
   verifyFormat("static int const bat;", "static int const bat;", Style);
 
+  verifyFormat("Foo::Bar const volatile A::*;",
+   "volatile const Foo::Bar A::*;",
+   Style);
+
   verifyFormat("int const Foo::bat = 0;", "const int Foo::bat = 0;",
Style);
   verifyFormat("int const Foo::bat = 0;", "int const Foo::bat = 0;",
@@ -418,7 +439,41 @@
   verifyFormat("unsigned long long const a;", "const unsigned long long a;",
Style);
 
-  // don't adjust macros
+  // Multiple template parameters.
+  verifyFormat("Bar", "Bar", Style);
+  // Variable declaration based on template type.
+  verifyFormat("Bar bar", "Bar bar", Style);
+
+  // Using typename for a nested dependent type name.
+  verifyFormat("typename Foo::iterator const;", "const typename Foo::iterator;",
+   Style);
+
+  // Doesn't move past C-style struct/class.
+  verifyFormat("void foo(const struct A a);", "void foo(const struct A a);",
+   Style);
+  verifyFormat("void foo(const class A a);", "void foo(const class A a);",
+   Style);
+
+  /

[PATCH] D144878: __builtin_FILE_NAME()

2023-02-27 Thread Ilya Karapsin via Phabricator via cfe-commits
karapsinie created this revision.
karapsinie added reviewers: klimek, aaron.ballman.
Herald added subscribers: luke, frasercrmck, luismarques, apazos, 
sameer.abuasal, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, 
MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, 
simoncook, johnrusso, rbar, asb, hiraditya, arichardson.
Herald added a reviewer: shafik.
Herald added a project: All.
karapsinie requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, pcwang-thead, MaskRay.
Herald added projects: clang, LLVM.

My commit adds "__builtin_FILE_NAME()" to clang, which insert only the filename 
because the full path is not always needed.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144878

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/AST/Expr.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Preprocessor/feature_tests.c
  clang/test/Preprocessor/feature_tests.cpp
  clang/test/Sema/source_location.c
  clang/test/SemaCXX/Inputs/source-location-file.h
  clang/test/SemaCXX/source_location.cpp
  clang/unittests/AST/ASTImporterTest.cpp
  llvm/utils/gn/secondary/llvm/lib/Target/RISCV/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/Target/RISCV/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/Target/RISCV/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/Target/RISCV/BUILD.gn
@@ -82,6 +82,7 @@
 "RISCVMacroFusion.cpp",
 "RISCVMakeCompressible.cpp",
 "RISCVMergeBaseOffset.cpp",
+"RISCVRVVInitUndef.cpp",
 "RISCVRedundantCopyElimination.cpp",
 "RISCVRegisterInfo.cpp",
 "RISCVSExtWRemoval.cpp",
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -259,6 +259,10 @@
  Lang_CXX03, Verifier,
  functionDecl(hasDescendant(
  sourceLocExpr(hasBuiltinStr("__builtin_FILE");
+  testImport("void declToImport() { (void)__builtin_FILE_NAME(); }", Lang_CXX03,
+ "", Lang_CXX03, Verifier,
+ functionDecl(hasDescendant(
+ sourceLocExpr(hasBuiltinStr("__builtin_FILE_NAME");
   testImport("void declToImport() { (void)__builtin_COLUMN(); }", Lang_CXX03,
  "", Lang_CXX03, Verifier,
  functionDecl(hasDescendant(
@@ -1546,7 +1550,7 @@
   R"s(
   struct declToImport {
 int a = d;
-union { 
+union {
   int b;
   int c;
 };
@@ -3804,7 +3808,7 @@
 int a[2] = {1,2};
 auto [x1,y1] = a;
 auto& [x2,y2] = a;
-
+
 struct S {
   mutable int x1 : 2;
   volatile double y1;
Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -84,6 +84,7 @@
 static_assert(is_same);
 static_assert(is_same);
 static_assert(is_same);
+static_assert(is_same);
 static_assert(is_same);
 static_assert(is_same);
 
@@ -91,6 +92,7 @@
 static_assert(noexcept(__builtin_LINE()));
 static_assert(noexcept(__builtin_COLUMN()));
 static_assert(noexcept(__builtin_FILE()));
+static_assert(noexcept(__builtin_FILE_NAME()));
 static_assert(noexcept(__builtin_FUNCTION()));
 static_assert(noexcept(__builtin_source_location()));
 
@@ -346,6 +348,54 @@
 
 } // namespace test_file
 
+//===--===//
+//__builtin_FILE_NAME()
+//===--===//
+
+namespace test_file_name {
+constexpr const char *test_file_name_simple(
+  const char *__f = __builtin_FILE_NAME()) {
+  return __f;
+}
+void test_function() {
+#line 900
+  static_assert(is_equal(test_file_name_simple(), __FILE_NAME__));
+  static_assert(is_equal(SLF::test_function_filename(), __FILE_NAME__), "");
+  static_assert(is_equal(SLF::test_function_filename_template(42),
+ __FILE_NAME__), "");
+
+  static_assert(is_equal(SLF::test_function_filename_indirect(),
+ SLF::global_info_filename), "");
+  static_assert(is_equal(SLF::test_function_filename_template_indirect(42),
+ SLF::global_info_filename), "");
+
+  static_assert(test_file_name_simple() != nullptr);
+  static_assert(is_equal(test_file_name_simple(), "source_location.cpp"));
+}
+
+void test_class() {
+#line 315
+  using SLF::TestClass;
+  constexpr TestClass Default;
+  constexpr TestClass InParam{42};
+  constexpr TestClass Template{42, 42};
+  constexpr auto *F = Default.info_file_name;
+  constexpr auto Char = F[0];
+  static_assert(is_equal(Default.info_file_name, SLF::FILE_NAME), "");
+  static_assert(is_

[PATCH] D144709: [clang-format] Improve left to right const

2023-02-27 Thread Alexander Hederstaf via Phabricator via cfe-commits
AlexanderHederstaf added a comment.

There are a lot of complicated cases when trying to extend this functionality. 
I addressed a few more and thought that it might be acceptable to avoid 
adjusting the qualifiers for variable declared as

  struct Foo const; -> const struct Foo;
  const struct Foo; -> struct Foo const;
  
  const struct {
int a;
  } foo = {5};
   -> 
  struct {
int a;
  } const foo = {5};

as they are difficult to distinguish from

  const struct Foo {
int a;
  }

where this is not valid code

  struct const Foo {
int a;
  }

I have still not tested left->right->left on the llvm codebase, I'll update you 
when it's done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

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


[PATCH] D144709: [clang-format] Improve QualifierAlignment

2023-02-27 Thread Alexander Hederstaf via Phabricator via cfe-commits
AlexanderHederstaf updated this revision to Diff 500799.
AlexanderHederstaf added a comment.

Update commit message


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144709

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

Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -241,7 +241,7 @@
   verifyFormat("int const *b;", Style);
   verifyFormat("int const &b;", Style);
   verifyFormat("int const &&b;", Style);
-  verifyFormat("int const *b const;", Style);
+  verifyFormat("int const *const b;", Style);
   verifyFormat("int *const c;", Style);
 
   verifyFormat("const Foo a;", Style);
@@ -252,7 +252,7 @@
   verifyFormat("Foo const *b;", Style);
   verifyFormat("Foo const &b;", Style);
   verifyFormat("Foo const &&b;", Style);
-  verifyFormat("Foo const *b const;", Style);
+  verifyFormat("Foo const *const b;", Style);
 
   verifyFormat("LLVM_NODISCARD const int &Foo();", Style);
   verifyFormat("LLVM_NODISCARD int const &Foo();", Style);
@@ -275,7 +275,7 @@
   verifyFormat("int const *b;", Style);
   verifyFormat("int const &b;", Style);
   verifyFormat("int const &&b;", Style);
-  verifyFormat("int const *b const;", Style);
+  verifyFormat("int const *const b;", Style);
   verifyFormat("int *const c;", Style);
 
   verifyFormat("Foo const a;", Style);
@@ -286,7 +286,7 @@
   verifyFormat("Foo const *b;", Style);
   verifyFormat("Foo const &b;", Style);
   verifyFormat("Foo const &&b;", Style);
-  verifyFormat("Foo const *b const;", Style);
+  verifyFormat("Foo const *const b;", Style);
   verifyFormat("Foo *const b;", Style);
   verifyFormat("Foo const *const b;", Style);
   verifyFormat("auto const v = get_value();", Style);
@@ -303,6 +303,11 @@
   verifyFormat("void foo() const final;", Style);
   verifyFormat("void foo() const final LLVM_READONLY;", Style);
   verifyFormat("void foo() const LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile override;", Style);
+  verifyFormat("void foo() const volatile override LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile final;", Style);
+  verifyFormat("void foo() const volatile final LLVM_READONLY;", Style);
+  verifyFormat("void foo() const volatile LLVM_READONLY;", Style);
 
   verifyFormat(
   "template  explicit Action(Action const &action);",
@@ -343,6 +348,7 @@
   verifyFormat("int const volatile;", "volatile const int;", Style);
   verifyFormat("int const volatile;", "const volatile int;", Style);
   verifyFormat("int const volatile;", "const int volatile;", Style);
+
   verifyFormat("int const volatile *restrict;", "volatile const int *restrict;",
Style);
   verifyFormat("int const volatile *restrict;", "const volatile int *restrict;",
@@ -350,9 +356,24 @@
   verifyFormat("int const volatile *restrict;", "const int volatile *restrict;",
Style);
 
+  verifyFormat("long long int const volatile;", "const long long int volatile;",
+   Style);
+  verifyFormat("long long int const volatile;", "long const long int volatile;",
+   Style);
+  verifyFormat("long long int const volatile;", "long long volatile int const;",
+   Style);
+  verifyFormat("long long int const volatile;", "long volatile long const int;",
+   Style);
+  verifyFormat("long long int const volatile;", "const long long volatile int;",
+   Style);
+
   verifyFormat("static int const bat;", "static const int bat;", Style);
   verifyFormat("static int const bat;", "static int const bat;", Style);
 
+  verifyFormat("Foo::Bar const volatile A::*;",
+   "volatile const Foo::Bar A::*;",
+   Style);
+
   verifyFormat("int const Foo::bat = 0;", "const int Foo::bat = 0;",
Style);
   verifyFormat("int const Foo::bat = 0;", "int const Foo::bat = 0;",
@@ -418,7 +439,41 @@
   verifyFormat("unsigned long long const a;", "const unsigned long long a;",
Style);
 
-  // don't adjust macros
+  // Multiple template parameters.
+  verifyFormat("Bar", "Bar", Style);
+  // Variable declaration based on template type.
+  verifyFormat("Bar bar", "Bar bar", Style);
+
+  // Using typename for a nested dependent type name.
+  verifyFormat("typename Foo::iterator const;", "const typename Foo::iterator;",
+   Style);
+
+  // Doesn't move past C-style struct/class.
+  verifyFormat("void foo(const struct A a);", "void foo(const struct A a);",
+   Style);
+  verifyFormat("void foo(const class A a);", "void foo(const class A a);",
+   Style);
+
+  // Doesn't move past struct/class combined declaration and variable
+  // definition.
+  verifyFormat("const struct {\n} var;", "const struct {\n} var;", Style

[PATCH] D144853: [Clang][RISCV] Add CMake options to configure default CPU

2023-02-27 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

If this is a useful thing to have, would it make more sense as a 
target-independent option?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144853

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


[PATCH] D140562: [clang][ASTImporter] Improve import of InjectedClassNameType.

2023-02-27 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

@vabridgers Thanks for testing these commits!

As @balazske wrote on D144622 , I'd suggest 
handling the three commits (this one = D140562 
, D144622  
and D144273 ) separately, because they are 
fixing analogous, but independent problems. (They affect separate branches of 
the import process and as far as I see they do not influence each other.)

As this commit seems to be ready, I'd suggest merging this now (while we wait 
for improvements on the other two). @vabridgers What do you think about this 
plan? Do you see any dependency between the three commits that would make 
merging just one of them problematic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140562

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


[PATCH] D144269: [Analyzer] Show "taint originated here" note of alpha.security.taint.TaintPropagation checker at the correct place

2023-02-27 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp planned changes to this revision.
dkrupp added a comment.

@steakhal , @NoQ  thanks for the reviews. I will try to implement an 
alternative solution based on your suggestions.


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

https://reviews.llvm.org/D144269

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


[PATCH] D144352: Do not emit exception diagnostics from coroutines and coroutine lambdas

2023-02-27 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci added a comment.

Author info for the commit: Deniz Evrenci (denizevre...@gmail.com)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144352

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


[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-02-27 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 500807.
TIFitis added a comment.

Added MLIR test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142914

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/include/mlir/Target/LLVMIR/Dialect/OpenMPCommon.h
  mlir/lib/Target/LLVMIR/CMakeLists.txt
  mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- /dev/null
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -0,0 +1,228 @@
+// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
+
+llvm.func @_QPopenmp_target_data() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  omp.target_data   map((tofrom -> %1 : !llvm.ptr)) {
+%2 = llvm.mlir.constant(99 : i32) : i32
+llvm.store %2, %1 : !llvm.ptr
+omp.terminator
+  }
+  llvm.return
+}
+
+// CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
+// CHECK-LABEL: define void @_QPopenmp_target_data() {
+// CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
+// CHECK: br label %[[VAL_4:.*]]
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_8]], align 4
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr %[[VAL_11]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: br label %[[VAL_12:.*]]
+// CHECK:   omp.data.region:  ; preds = %[[VAL_4]]
+// CHECK: store i32 99, ptr %[[VAL_3]], align 4
+// CHECK: br label %[[VAL_13:.*]]
+// CHECK:   omp.region.cont:  ; preds = %[[VAL_12]]
+// CHECK: %[[VAL_14:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_15:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: %[[VAL_16:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_14]], ptr %[[VAL_15]], ptr %[[VAL_16]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: ret void
+
+// -
+
+llvm.func @_QPopenmp_target_data_loop(%1 : !llvm.ptr>) {
+  %2 = llvm.mlir.constant(1 : i64) : i64
+  %3 = llvm.alloca %2 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array, uniq_name = "_QFopenmp_target_data_loopEi"} : (i64) -> !llvm.ptr
+  omp.target_data   map((from -> %1 : !llvm.ptr>)) {
+%4 = llvm.mlir.constant(1 : i32) : i32
+%5 = llvm.sext %4 : i32 to i64
+%6 = llvm.mlir.constant(1024 : i32) : i32
+%7 = llvm.sext %6 : i32 to i64
+%8 = llvm.mlir.constant(1 : index) : i64
+%9 = llvm.trunc %5 : i64 to i32
+%10 = llvm.sub %7, %5  : i64
+%11 = llvm.add %10, %8  : i64
+llvm.br ^bb1(%5, %9, %11 : i64, i32, i64)
+  ^bb1(%12: i64, %13: i32, %14: i64):  // 2 preds: ^bb0, ^bb2
+%15 = llvm.mlir.constant(0 : index) : i64
+%16 = llvm.icmp "sgt" %14, %15 : i64
+llvm.cond_br %16, ^bb2, ^bb3
+  ^bb2:  // pred: ^bb1
+llvm.store %13, %3 : !llvm.ptr
+%17 = llvm.load %3 : !llvm.ptr
+%18 = llvm.load %3 : !llvm.ptr
+%19 = llvm.sext %18 : i32 to i64
+%20 = llvm.mlir.constant(1 : i64) : i64
+%21 = llvm.sub %19, 

[PATCH] D144878: __builtin_FILE_NAME()

2023-02-27 Thread Ilya Karapsin via Phabricator via cfe-commits
karapsinie updated this revision to Diff 500809.
karapsinie added a comment.

Execute "arc diff `git merge-base HEAD origin` --update D144878 
"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144878

Files:
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/AST/Expr.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Preprocessor/feature_tests.c
  clang/test/Preprocessor/feature_tests.cpp
  clang/test/Sema/source_location.c
  clang/test/SemaCXX/Inputs/source-location-file.h
  clang/test/SemaCXX/source_location.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -259,6 +259,10 @@
  Lang_CXX03, Verifier,
  functionDecl(hasDescendant(
  sourceLocExpr(hasBuiltinStr("__builtin_FILE");
+  testImport("void declToImport() { (void)__builtin_FILE_NAME(); }",
+ Lang_CXX03, "", Lang_CXX03, Verifier,
+ functionDecl(hasDescendant(
+ sourceLocExpr(hasBuiltinStr("__builtin_FILE_NAME");
   testImport("void declToImport() { (void)__builtin_COLUMN(); }", Lang_CXX03,
  "", Lang_CXX03, Verifier,
  functionDecl(hasDescendant(
@@ -1546,7 +1550,7 @@
   R"s(
   struct declToImport {
 int a = d;
-union { 
+union {
   int b;
   int c;
 };
@@ -3804,7 +3808,7 @@
 int a[2] = {1,2};
 auto [x1,y1] = a;
 auto& [x2,y2] = a;
-
+
 struct S {
   mutable int x1 : 2;
   volatile double y1;
Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -84,6 +84,7 @@
 static_assert(is_same);
 static_assert(is_same);
 static_assert(is_same);
+static_assert(is_same);
 static_assert(is_same);
 static_assert(is_same);
 
@@ -91,6 +92,7 @@
 static_assert(noexcept(__builtin_LINE()));
 static_assert(noexcept(__builtin_COLUMN()));
 static_assert(noexcept(__builtin_FILE()));
+static_assert(noexcept(__builtin_FILE_NAME()));
 static_assert(noexcept(__builtin_FUNCTION()));
 static_assert(noexcept(__builtin_source_location()));
 
@@ -346,6 +348,54 @@
 
 } // namespace test_file
 
+//===--===//
+//__builtin_FILE_NAME()
+//===--===//
+
+namespace test_file_name {
+constexpr const char *test_file_name_simple(
+  const char *__f = __builtin_FILE_NAME()) {
+  return __f;
+}
+void test_function() {
+#line 900
+  static_assert(is_equal(test_file_name_simple(), __FILE_NAME__));
+  static_assert(is_equal(SLF::test_function_filename(), __FILE_NAME__), "");
+  static_assert(is_equal(SLF::test_function_filename_template(42),
+ __FILE_NAME__), "");
+
+  static_assert(is_equal(SLF::test_function_filename_indirect(),
+ SLF::global_info_filename), "");
+  static_assert(is_equal(SLF::test_function_filename_template_indirect(42),
+ SLF::global_info_filename), "");
+
+  static_assert(test_file_name_simple() != nullptr);
+  static_assert(is_equal(test_file_name_simple(), "source_location.cpp"));
+}
+
+void test_class() {
+#line 315
+  using SLF::TestClass;
+  constexpr TestClass Default;
+  constexpr TestClass InParam{42};
+  constexpr TestClass Template{42, 42};
+  constexpr auto *F = Default.info_file_name;
+  constexpr auto Char = F[0];
+  static_assert(is_equal(Default.info_file_name, SLF::FILE_NAME), "");
+  static_assert(is_equal(InParam.info_file_name, SLF::FILE_NAME), "");
+  static_assert(is_equal(InParam.ctor_info_file_name, __FILE_NAME__), "");
+}
+
+void test_aggr_class() {
+  using Agg = SLF::AggrClass<>;
+  constexpr Agg Default{};
+  constexpr Agg InitOne{42};
+  static_assert(is_equal(Default.init_info_file_name, __FILE_NAME__), "");
+  static_assert(is_equal(InitOne.init_info_file_name, __FILE_NAME__), "");
+}
+
+} // namespace test_file_name
+
 //===--===//
 //__builtin_FUNCTION()
 //===--===//
@@ -487,6 +537,7 @@
 #line 44 "test_file.c"
 static_assert(is_equal("test_file.c", __FILE__));
 static_assert(is_equal("test_file.c", __builtin_FILE()));
+static_assert(is_equal("test_file.c", __builtin_FILE_NAME()));
 static_assert(is_equal("test_file.c", SL::current().file()));
 static_assert(is_equal("test_file.c", SLF::test_function().file

[PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses

2023-02-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: owenpan, MyDeveloperDay, HazardyKnusperkeks, hans.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

The patch in D136100  added custom handling 
for pragmas to assist in
formatting OpenMP clauses correctly. One of these changes added extra
indentation. This is desirable for OpenMP pragmas as they are several
complete tokens that would otherwise we on the exact same line. However,
this is not desired for the other pragmas.

This solution is extremely hacky, I'm not overly familiar with the
`clang-format` codebase. A better solution would probably require
actually parsing these as tokens, but I just wanted to propose a
solution.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144884

Files:
  clang/lib/Format/ContinuationIndenter.cpp


Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1273,8 +1273,13 @@
 return ContinuationIndent;
   }
 
-  if (State.Line->InPragmaDirective)
-return CurrentState.Indent + Style.ContinuationIndentWidth;
+  // OpenMP clauses want to get additional indentation when they are pushed 
onto
+  // the next line.
+  if (State.Line->InPragmaDirective) {
+FormatToken *PragmaType = State.Line->First->Next->Next;
+if (PragmaType && PragmaType->TokenText.equals("omp"))
+  return CurrentState.Indent + Style.ContinuationIndentWidth;
+  }
 
   // This ensure that we correctly format ObjC methods calls without inputs,
   // i.e. where the last element isn't selector like: [callee method];


Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -1273,8 +1273,13 @@
 return ContinuationIndent;
   }
 
-  if (State.Line->InPragmaDirective)
-return CurrentState.Indent + Style.ContinuationIndentWidth;
+  // OpenMP clauses want to get additional indentation when they are pushed onto
+  // the next line.
+  if (State.Line->InPragmaDirective) {
+FormatToken *PragmaType = State.Line->First->Next->Next;
+if (PragmaType && PragmaType->TokenText.equals("omp"))
+  return CurrentState.Indent + Style.ContinuationIndentWidth;
+  }
 
   // This ensure that we correctly format ObjC methods calls without inputs,
   // i.e. where the last element isn't selector like: [callee method];
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 853d405 - [OpenMP] Ignore implicit casts on assertion for `use_device_ptr`

2023-02-27 Thread Joseph Huber via cfe-commits

Author: Joseph Huber
Date: 2023-02-27T10:48:20-06:00
New Revision: 853d4059135bdadf74d67f59215b21026b6f939e

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

LOG: [OpenMP] Ignore implicit casts on assertion for `use_device_ptr`

There was an assertion triggering when invoking a captured member whose
initializer was in a blase class. This patch fixes it by allowing the
assertion on implicit casts to the base class rather than only the base
class itself.

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

Reviewed By: tianshilei1992

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

Added: 
clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp

Modified: 
clang/lib/CodeGen/CGStmtOpenMP.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 6bc30ad0302e5..98efd8a3815f2 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -7146,7 +7146,7 @@ void CodeGenFunction::EmitOMPUseDevicePtrClause(
   // OMPCapturedExprDecl are used to privative fields of the current
   // structure.
   const auto *ME = cast(OED->getInit());
-  assert(isa(ME->getBase()) &&
+  assert(isa(ME->getBase()->IgnoreImpCasts()) &&
  "Base should be the current struct!");
   MatchingVD = ME->getMemberDecl();
 }

diff  --git 
a/clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp 
b/clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp
new file mode 100644
index 0..71eddda1a333a
--- /dev/null
+++ b/clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp
@@ -0,0 +1,266 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex 
"__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" 
"pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-llvm %s -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple 
powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu 
-emit-pch -o %t %s -Wno-openmp-mapping
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify 
%s -emit-llvm -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple 
i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - 
-Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s -Wno-openmp-mapping
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown 
-fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s 
-emit-llvm -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK2
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+class A {
+public:
+  double *ptr = nullptr;
+  virtual void foo() = 0;
+};
+
+class B : public A {
+public:
+  virtual void foo() override;
+};
+
+void B::foo() {
+#pragma omp target data use_device_ptr(A::ptr)
+  {
+  }
+}
+
+void foo() {
+  B b;
+  b.foo();
+}
+
+#endif
+// CHECK-LABEL: define {{[^@]+}}@_ZN1B3fooEv
+// CHECK-SAME: (ptr noundef nonnull align 8 dereferenceable(16) [[THIS:%.*]]) 
unnamed_addr #[[ATTR0:[0-9]+]] align 2 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[PTR4:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[TMP:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[PTR:%.*]] = getelementptr inbounds [[CLASS_A:%.*]], ptr 
[[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[PTR2:%.*]] = getelementptr inbounds [[CLASS_A]], ptr 
[[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[PTR3:%.*]] = getelementptr inbounds [[CLASS_A]], ptr 
[[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[PTR3]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds [2 x ptr], ptr 
[[DOTOFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[THIS1]], ptr [[TMP1]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr 

[PATCH] D144873: [OpenMP] Ignore implicit casts on assertion for `use_device_ptr`

2023-02-27 Thread Joseph Huber 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 rG853d4059135b: [OpenMP] Ignore implicit casts on assertion 
for `use_device_ptr` (authored by jhuber6).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144873

Files:
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp

Index: clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp
===
--- /dev/null
+++ clang/test/OpenMP/target_data_use_device_ptr_inheritance_codegen.cpp
@@ -0,0 +1,266 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --function-signature --include-generated-funcs --replace-value-regex "__omp_offloading_[0-9a-z]+_[0-9a-z]+" "reduction_size[.].+[.]" "pl_cond[.].+[.|,]" --prefix-filecheck-ir-name _
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-llvm %s -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -emit-pch -o %t %s -Wno-openmp-mapping
+// RUN: %clang_cc1 -fopenmp -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=powerpc64le-ibm-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK1
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-llvm %s -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK2
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -emit-pch -o %t %s -Wno-openmp-mapping
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple i386-unknown-unknown -fopenmp-targets=i386-pc-linux-gnu -std=c++11 -include-pch %t -verify %s -emit-llvm -o - -Wno-openmp-mapping | FileCheck %s --check-prefix=CHECK2
+// expected-no-diagnostics
+#ifndef HEADER
+#define HEADER
+
+class A {
+public:
+  double *ptr = nullptr;
+  virtual void foo() = 0;
+};
+
+class B : public A {
+public:
+  virtual void foo() override;
+};
+
+void B::foo() {
+#pragma omp target data use_device_ptr(A::ptr)
+  {
+  }
+}
+
+void foo() {
+  B b;
+  b.foo();
+}
+
+#endif
+// CHECK-LABEL: define {{[^@]+}}@_ZN1B3fooEv
+// CHECK-SAME: (ptr noundef nonnull align 8 dereferenceable(16) [[THIS:%.*]]) unnamed_addr #[[ATTR0:[0-9]+]] align 2 {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[THIS_ADDR:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[DOTOFFLOAD_BASEPTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_PTRS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[DOTOFFLOAD_MAPPERS:%.*]] = alloca [2 x ptr], align 8
+// CHECK-NEXT:[[PTR4:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:[[TMP:%.*]] = alloca ptr, align 8
+// CHECK-NEXT:store ptr [[THIS]], ptr [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[THIS1:%.*]] = load ptr, ptr [[THIS_ADDR]], align 8
+// CHECK-NEXT:[[PTR:%.*]] = getelementptr inbounds [[CLASS_A:%.*]], ptr [[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[PTR2:%.*]] = getelementptr inbounds [[CLASS_A]], ptr [[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[PTR3:%.*]] = getelementptr inbounds [[CLASS_A]], ptr [[THIS1]], i32 0, i32 1
+// CHECK-NEXT:[[TMP0:%.*]] = load ptr, ptr [[PTR3]], align 8
+// CHECK-NEXT:[[TMP1:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[THIS1]], ptr [[TMP1]], align 8
+// CHECK-NEXT:[[TMP2:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 0
+// CHECK-NEXT:store ptr [[THIS1]], ptr [[TMP2]], align 8
+// CHECK-NEXT:[[TMP3:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_MAPPERS]], i64 0, i64 0
+// CHECK-NEXT:store ptr null, ptr [[TMP3]], align 8
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]], i32 0, i32 1
+// CHECK-NEXT:store ptr [[PTR2]], ptr [[TMP4]], align 8
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 1
+// CHECK-NEXT:store ptr [[TMP0]], ptr [[TMP5]], align 8
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_MAPPERS]], i64 0, i64 1
+// CHECK-NEXT:store ptr null, ptr [[TMP6]], align 8
+// CHECK-NEXT:[[TMP7:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_BASEPTRS]], i32 0, i32 0
+// CHECK-NEXT:[[TMP8:%.*]] = getelementptr inbounds [2 x ptr], ptr [[DOTOFFLOAD_PTRS]], i32 0, i32 0
+// CHECK-NEXT:call void @__tgt_target_data_begin_mapper(ptr @[[GLOB1:[0-9]+]], i64 -1, i32 2, ptr [[TMP7]], ptr [[TMP8]], ptr @.offload_sizes, ptr @.offload_

RE: [clang] 398cddf - [clang-format] Fix assertion that doesn't hold under fuzzing.

2023-02-27 Thread Yaghmour, Shafik via cfe-commits
Should that have been an "else if" and not just an "if" otherwise clang-format 
should be applied. 

-Original Message-
From: cfe-commits  On Behalf Of Manuel 
Klimek via cfe-commits
Sent: Monday, February 27, 2023 2:51 AM
To: cfe-commits@lists.llvm.org
Subject: [clang] 398cddf - [clang-format] Fix assertion that doesn't hold under 
fuzzing.


Author: Manuel Klimek
Date: 2023-02-27T10:50:42Z
New Revision: 398cddf6acecfb12b5997c2d639ee3cf31b787ad

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

LOG: [clang-format] Fix assertion that doesn't hold under fuzzing.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index b0314d6cfa75f..c789f2907dac9 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -511,12 +511,11 @@ class LineJoiner {
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (NextLine.First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
-  } else {
+  } if(TheLine->InPPDirective ||
+   !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
+tok::kw_struct)) {
 // Try to merge a block with left brace unwrapped that wasn't yet
 // covered.
-assert(TheLine->InPPDirective ||
-   !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
-tok::kw_struct));
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
   (NextLine.First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyFunction);



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


[PATCH] D144889: [C2x] Support in freestanding

2023-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: clang-language-wg, jyknight, efriedma, joerg.
Herald added a project: All.
aaron.ballman requested review of this revision.
Herald added a project: clang.

This implements most of the support for WG14 N2524 
(https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2524.htm), which adds 
`` to the list of headers required by a freestanding implementation.

We do not currently have builtins for `memccpy`, `memset_explicit`, or 
`strtok`, so those APIs are not yet exposed via our freestanding `string.h`. 
Further, we do not yet implement WG14 N3020 which changes the return type for 
some of the interfaces in string.h. So this patch does not claim full support 
for string.h yet (it adds the `__STDC_VERSION_STRING_H__` macro but leaves its 
value as `202300L` instead of `202311L` as required by the standard).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144889

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/string.h
  clang/lib/Lex/ModuleMap.cpp
  clang/test/C/C2x/n2524.c
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -840,7 +840,15 @@
 
   String functions for freestanding implementations
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2524.htm";>N2524
-  No
+  
+Partial
+  Clang implements all of the freestanding functions from string.h
+  except memset_explicit, strtok, and
+  memccpy. Additionally, Clang is missing support for
+  WG14 N3020 that impacts some of the function return types based on
+  the signature used.
+
+  
 
 
   Digit separators
@@ -1159,6 +1167,11 @@
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2975.pdf";>N2975
   Clang 16
 
+
+  Qualifier-preserving standard library functions, v4
+  https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3020.pdf";>N3020
+  No
+
 
   Enhanced enumerations
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3030.htm";>N3030
Index: clang/test/C/C2x/n2524.c
===
--- /dev/null
+++ clang/test/C/C2x/n2524.c
@@ -0,0 +1,100 @@
+// RUN: %clang_cc1 -std=c2x %s -ffreestanding -verify
+// RUN: %clang_cc1 -std=c2x %s -ffreestanding -DCODEGEN -emit-llvm -o - | FileCheck %s
+
+/* WG14 N2524: partial
+ * String functions for freestanding implementations
+ *
+ * We have partial support, but are still missing builtin implementations for:
+ *   memccpy
+ *   memset_explicit
+ *   strtok
+ * before we can claim full support.
+ */
+
+#include 
+
+/* Ensure that the version macro is defined to the value we expect. */
+#ifndef __STDC_VERSION_STRING_H__
+#error "expected __STDC_VERSION_STRING_H__ to be defined"
+#elif __STDC_VERSION_STRING_H__ != 202300L /* FIXME: This should change to 202311L when ready */
+#error "expected __STDC_VERSION_STRING_H__ to be 202311L"
+#endif
+
+/* Ensure that we emit the expected calls to a builtin function when using the
+ * various freestanding interfaces.
+ */
+void test(char *buffer1, char *buffer2, typeof(sizeof(0)) count, int n) {
+  memcpy(buffer1, buffer2, count);
+  // CHECK: call void @llvm.memcpy.p0.p0.
+  // FIXME memccpy(buffer1, buffer2, count, n);
+  memmove(buffer1, buffer2, count);
+  // CHECK: call void @llvm.memmove.p0.p0.
+  strcpy(buffer1, buffer2);
+  // CHECK: call ptr @strcpy
+  strncpy(buffer1, buffer2, count);
+  // CHECK: call ptr @strncpy
+
+  strcat(buffer1, buffer2);
+  // CHECK: call ptr @strcat
+  strncat(buffer1, buffer2, count);
+  // CHECK: call ptr @strncat
+
+  memcmp(buffer1, buffer2, count);
+  // CHECK: call i32 @memcmp
+  strcmp(buffer1, buffer2);
+  // CHECK: call i32 @strcmp
+  strncmp(buffer1, buffer2, count);
+  // CHECK: call i32 @strncmp
+
+  memchr(buffer1, n, count);
+  // CHECK: call ptr @memchr
+  strchr(buffer1, n);
+  // CHECK: call ptr @strchr
+  strcspn(buffer1, buffer2);
+  // CHECK: call i{{32|64}} @strcspn
+  strpbrk(buffer1, buffer2);
+  // CHECK: call ptr @strpbrk
+  strrchr(buffer1, n);
+  // CHECK: call ptr @strrchr
+  strspn(buffer1, buffer2);
+  // CHECK: call i{{32|64}} @strspn
+  strstr(buffer1, buffer2);
+  // CHECK: call ptr @strstr
+  // FIXME: strtok(buffer1, buffer2);
+
+  memset(buffer1, n, count);
+  // CHECK: call void @llvm.memset.p0
+  // FIXME: memset_explicit(buffer1, n, count);
+  strlen(buffer1);
+  // CHECK: call i{{32|64}} @strlen
+}
+
+/* Some functions take and return a QVoid * or QChar * because the interface
+ * is expected to work with both a pointer to a const-qualified type as well as
+ * a pointer to a non-const-qualified type. Ensure we get the correct type
+ * interfaces we expect.
+ *
+ * This is a feature of WG14 N3020 rather than N2524, but because Clang doesn't
+ * vend libc directly, t

[PATCH] D144889: [C2x] Support in freestanding

2023-02-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma requested changes to this revision.
efriedma added a comment.
This revision now requires changes to proceed.

Providing this header doesn't do anything useful without an actual 
implementation; all of these "__builtin" calls just lower to libc calls in the 
general case.  How do you plan to provide implementations?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144889

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


[clang] 2e73111 - [Sema] Use isSVESizelessBuiltinType instead of isSizelessBuiltinType to prevent crashing on RISC-V.

2023-02-27 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-02-27T09:19:27-08:00
New Revision: 2e7311170201e07e5e067e397aed8fa482d2fb8b

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

LOG: [Sema] Use isSVESizelessBuiltinType instead of isSizelessBuiltinType to 
prevent crashing on RISC-V.

These 2 spots are protecting calls to SVE specific functions. If RISC-V
sizeless types end up in there we trigger assertions.

Use the more specific isSVESizelessBuiltinType() to avoid letting
RISC-V vectors through.

Reviewed By: asb, c-rhodes

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

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/test/Sema/attr-riscv-rvv-vector-bits.c

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 11c07043c9841..4182986aa13a8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -9529,9 +9529,10 @@ static uint64_t getSVETypeSize(ASTContext &Context, 
const BuiltinType *Ty) {
 
 bool ASTContext::areCompatibleSveTypes(QualType FirstType,
QualType SecondType) {
-  assert(((FirstType->isSizelessBuiltinType() && SecondType->isVectorType()) ||
-  (FirstType->isVectorType() && SecondType->isSizelessBuiltinType())) 
&&
- "Expected SVE builtin type and vector type!");
+  assert(
+  ((FirstType->isSVESizelessBuiltinType() && SecondType->isVectorType()) ||
+   (FirstType->isVectorType() && SecondType->isSVESizelessBuiltinType())) 
&&
+  "Expected SVE builtin type and vector type!");
 
   auto IsValidCast = [this](QualType FirstType, QualType SecondType) {
 if (const auto *BT = FirstType->getAs()) {
@@ -9558,9 +9559,10 @@ bool ASTContext::areCompatibleSveTypes(QualType 
FirstType,
 
 bool ASTContext::areLaxCompatibleSveTypes(QualType FirstType,
   QualType SecondType) {
-  assert(((FirstType->isSizelessBuiltinType() && SecondType->isVectorType()) ||
-  (FirstType->isVectorType() && SecondType->isSizelessBuiltinType())) 
&&
- "Expected SVE builtin type and vector type!");
+  assert(
+  ((FirstType->isSVESizelessBuiltinType() && SecondType->isVectorType()) ||
+   (FirstType->isVectorType() && SecondType->isSVESizelessBuiltinType())) 
&&
+  "Expected SVE builtin type and vector type!");
 
   auto IsLaxCompatible = [this](QualType FirstType, QualType SecondType) {
 const auto *BT = FirstType->getAs();

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 817eed986e08a..d870ce4a7942e 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -9871,8 +9871,8 @@ Sema::CheckAssignmentConstraints(QualType LHSType, 
ExprResult &RHS,
 }
 
 // Allow assignments between fixed-length and sizeless SVE vectors.
-if ((LHSType->isSizelessBuiltinType() && RHSType->isVectorType()) ||
-(LHSType->isVectorType() && RHSType->isSizelessBuiltinType()))
+if ((LHSType->isSVESizelessBuiltinType() && RHSType->isVectorType()) ||
+(LHSType->isVectorType() && RHSType->isSVESizelessBuiltinType()))
   if (Context.areCompatibleSveTypes(LHSType, RHSType) ||
   Context.areLaxCompatibleSveTypes(LHSType, RHSType)) {
 Kind = CK_BitCast;

diff  --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index a4485be3b0932..80b414c369777 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -1750,7 +1750,8 @@ static bool IsVectorConversion(Sema &S, QualType 
FromType, QualType ToType,
 }
   }
 
-  if (ToType->isSizelessBuiltinType() || FromType->isSizelessBuiltinType())
+  if (ToType->isSVESizelessBuiltinType() ||
+  FromType->isSVESizelessBuiltinType())
 if (S.Context.areCompatibleSveTypes(FromType, ToType) ||
 S.Context.areLaxCompatibleSveTypes(FromType, ToType)) {
   ICK = ICK_SVE_Vector_Conversion;

diff  --git a/clang/test/Sema/attr-riscv-rvv-vector-bits.c 
b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
index bd69c48578885..2da69191878e4 100644
--- a/clang/test/Sema/attr-riscv-rvv-vector-bits.c
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +zve64x 
-ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f 
-target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify 
%s
 
 // TODO: Support for a arm_sve_vector_bits like attribute will come in the 
future.
 
@@ -60,3 +60,21 @@ void f(int c) {
 
   gs8 = gs8 & ss8; // expected-error {{invalid operands to binary expression 
('gnu_int8_t' (vector of 8 'int8_t' values) and '

[PATCH] D144772: [Sema] Use isSVESizelessBuiltinType instead of isSizelessBuiltinType to prevent crashing on RISC-V.

2023-02-27 Thread Craig Topper 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 rG2e7311170201: [Sema] Use isSVESizelessBuiltinType instead of 
isSizelessBuiltinType to prevent… (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144772

Files:
  clang/lib/AST/ASTContext.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/Sema/attr-riscv-rvv-vector-bits.c


Index: clang/test/Sema/attr-riscv-rvv-vector-bits.c
===
--- clang/test/Sema/attr-riscv-rvv-vector-bits.c
+++ clang/test/Sema/attr-riscv-rvv-vector-bits.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +zve64x 
-ffreestanding -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple riscv64-none-linux-gnu -target-feature +f 
-target-feature +d -target-feature +zve64d -ffreestanding -fsyntax-only -verify 
%s
 
 // TODO: Support for a arm_sve_vector_bits like attribute will come in the 
future.
 
@@ -60,3 +60,21 @@
 
   gs8 = gs8 & ss8; // expected-error {{invalid operands to binary expression 
('gnu_int8_t' (vector of 8 'int8_t' values) and 'vint8m1_t' (aka 
'__rvv_int8m1_t'))}}
 }
+
+// --//
+// Implicit casts
+
+gnu_int8_t to_gnu_int8_t_from_vint8m1_t_(vint8m1_t x) { return x; } // 
expected-error {{returning 'vint8m1_t' (aka '__rvv_int8m1_t') from a function 
with incompatible result type 'gnu_int8_t' (vector of 8 'int8_t' values)}}
+vint8m1_t from_gnu_int8_t_to_vint8m1_t(gnu_int8_t x) { return x; } // 
expected-error {{returning 'gnu_int8_t' (vector of 8 'int8_t' values) from a 
function with incompatible result type 'vint8m1_t' (aka '__rvv_int8m1_t')}}
+
+// --//
+// Test passing GNU vector scalable function
+
+vint32m1_t __attribute__((overloadable)) vfunc(vint32m1_t op1, vint32m1_t op2);
+vfloat64m1_t __attribute__((overloadable)) vfunc(vfloat64m1_t op1, 
vfloat64m1_t op2);
+
+gnu_int32_t call_int32_ff(gnu_int32_t op1, gnu_int32_t op2) {
+  return vfunc(op1, op2); // expected-error {{no matching function for call to 
'vfunc'}}
+  // expected-note@-5 {{candidate function not viable: 
no known conversion from 'gnu_int32_t' (vector of 2 'int32_t' values) to 
'vint32m1_t' (aka '__rvv_int32m1_t') for 1st argument}}
+  // expected-note@-5 {{candidate function not viable: 
no known conversion from 'gnu_int32_t' (vector of 2 'int32_t' values) to 
'vfloat64m1_t' (aka '__rvv_float64m1_t') for 1st argument}}
+}
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -1750,7 +1750,8 @@
 }
   }
 
-  if (ToType->isSizelessBuiltinType() || FromType->isSizelessBuiltinType())
+  if (ToType->isSVESizelessBuiltinType() ||
+  FromType->isSVESizelessBuiltinType())
 if (S.Context.areCompatibleSveTypes(FromType, ToType) ||
 S.Context.areLaxCompatibleSveTypes(FromType, ToType)) {
   ICK = ICK_SVE_Vector_Conversion;
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -9871,8 +9871,8 @@
 }
 
 // Allow assignments between fixed-length and sizeless SVE vectors.
-if ((LHSType->isSizelessBuiltinType() && RHSType->isVectorType()) ||
-(LHSType->isVectorType() && RHSType->isSizelessBuiltinType()))
+if ((LHSType->isSVESizelessBuiltinType() && RHSType->isVectorType()) ||
+(LHSType->isVectorType() && RHSType->isSVESizelessBuiltinType()))
   if (Context.areCompatibleSveTypes(LHSType, RHSType) ||
   Context.areLaxCompatibleSveTypes(LHSType, RHSType)) {
 Kind = CK_BitCast;
Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -9529,9 +9529,10 @@
 
 bool ASTContext::areCompatibleSveTypes(QualType FirstType,
QualType SecondType) {
-  assert(((FirstType->isSizelessBuiltinType() && SecondType->isVectorType()) ||
-  (FirstType->isVectorType() && SecondType->isSizelessBuiltinType())) 
&&
- "Expected SVE builtin type and vector type!");
+  assert(
+  ((FirstType->isSVESizelessBuiltinType() && SecondType->isVectorType()) ||
+   (FirstType->isVectorType() && SecondType->isSVESizelessBuiltinType())) 
&&
+  "Expected SVE builtin type and vector type!");
 
   auto IsValidCast = [this](QualType FirstType, QualType SecondType) {
 if (const auto *BT = FirstType->getAs()) {
@@ -9558,9 +9559,10 @@
 
 bool ASTContext::ar

[PATCH] D144866: [clang] Fix aggregate initialization inside lambda constexpr

2023-02-27 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Thank you for this patch, it looks good.




Comment at: clang/lib/AST/ExprConstant.cpp:8763
 if (isLambdaCallOperator(Info.CurrentCall->Callee)) {
-  // Ensure we actually have captured 'this'. (an error will have
-  // been previously reported if not).
+  // Ensure we actually have captured 'this'. If something was wrong with
+  // 'this' capture, the error would have been previously reported.

It might be worth it to review all the examples here: 
https://eel.is/c++draft/expr.prim.lambda

and make sure the test we have actually covers all the scenarios. It looks like 
we capture most of them but I have not gone over them fully.



Comment at: clang/test/SemaCXX/lambda-expressions.cpp:673
+int i;
+int *p = &i;
+};

It would be helpful to add a comment about the implicit `this` access.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144866

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


[PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses

2023-02-27 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

I'm assuming they have tests?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144884

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


[PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses

2023-02-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D144884#4155730 , @jdoerfert wrote:

> I'm assuming they have tests?

I could add a test for the comment case in the bug report.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144884

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


[PATCH] D144866: [clang] Fix aggregate initialization inside lambda constexpr

2023-02-27 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Also please add a release note before landing the fix, thank you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144866

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


[PATCH] D144802: clang: Add __builtin_elementwise_round

2023-02-27 Thread Joshua Batista via Phabricator via cfe-commits
bob80905 added a comment.

Should the addition of this builtin be mentioned in clang\docs\ReleaseNotes.rst?


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

https://reviews.llvm.org/D144802

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


[PATCH] D144802: clang: Add __builtin_elementwise_round

2023-02-27 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Yep! this does need a release note.


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

https://reviews.llvm.org/D144802

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


[PATCH] D144196: [C2x] Remove the ATOMIC_VAR_INIT macro from stdatomic.h

2023-02-27 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

Thanks for the heads up. As noted in another comment, I don't think this 
impacts libc++ because C++23 (unfortunately) still provides the macro AFAICT. 
We define it ourselves in `libcxx/include/__atomic/atomic_init.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144196

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


[PATCH] D144889: [C2x] Support in freestanding

2023-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D144889#4155686 , @efriedma wrote:

> Providing this header doesn't do anything useful without an actual 
> implementation; all of these "__builtin" calls just lower to libc calls in 
> the general case.  How do you plan to provide implementations?

I *thought* that the difference between:
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Builtins.def#L1038
and
https://github.com/llvm/llvm-project/blob/main/clang/include/clang/Basic/Builtins.def#L559
was that the first one is lowered to a potential library call while the second 
one is is lowered to a backend implementation that performs the work. (This is 
why I thought we would not be able to support `memccpy` or `strtok` -- they 
were missing the `__builtin_` variants.) If the backend is just going to 
generate a library call that requires an external library when calling a 
`__builtin_`, then I agree that there's more here that needs to be done. How do 
we typically handle it for freestanding functions? Do we implement something in 
compiler-rt as a fallback, or do we emit LLVM IR for the function 
implementation, etc?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144889

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


[PATCH] D144894: [clang] Documents clang-scan-deps requirements.

2023-02-27 Thread Mark de Wever via Phabricator via cfe-commits
Mordante created this revision.
Mordante added a reviewer: ChuanqiXu.
Herald added a project: All.
Mordante requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This was discussed in https://llvm.org/PR61006.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144894

Files:
  clang/docs/StandardCPlusPlusModules.rst


Index: clang/docs/StandardCPlusPlusModules.rst
===
--- clang/docs/StandardCPlusPlusModules.rst
+++ clang/docs/StandardCPlusPlusModules.rst
@@ -1033,6 +1033,12 @@
 
   $ clang-scan-deps -format=p1689 -- /clang++ 
-std=c++20 impl_part.cppm -c -o impl_part.o
 
+.. warning::
+
+   The ``/clang++`` should point to the real
+   binary and not to a symlink. If it points to a symlink the include paths
+   will not be correctly resolved.
+
 And we'll get:
 
 .. code-block:: text


Index: clang/docs/StandardCPlusPlusModules.rst
===
--- clang/docs/StandardCPlusPlusModules.rst
+++ clang/docs/StandardCPlusPlusModules.rst
@@ -1033,6 +1033,12 @@
 
   $ clang-scan-deps -format=p1689 -- /clang++ -std=c++20 impl_part.cppm -c -o impl_part.o
 
+.. warning::
+
+   The ``/clang++`` should point to the real
+   binary and not to a symlink. If it points to a symlink the include paths
+   will not be correctly resolved.
+
 And we'll get:
 
 .. code-block:: text
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143524: Make the -Wunused-template default.

2023-02-27 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: clang/test/SemaCXX/warn-func-not-needed.cpp:13
 namespace test1_template {
-template  static void f() {}
+template  static void f() {} // expected-warning {{unused function 
template}}
 template <> void f() {} // expected-warning {{function 'f' is not 
needed and will not be emitted}}

aaron.ballman wrote:
> v.g.vassilev wrote:
> > aaron.ballman wrote:
> > > v.g.vassilev wrote:
> > > > aaron.ballman wrote:
> > > > > Why is this unused? `f()` in `foo()` should cause this to be 
> > > > > used, right?
> > > > > 
> > > > > How should a user silence this diagnostic without disabling it 
> > > > > entirely?
> > > > Nobody uses `foo`.
> > > Ah, good point on `foo` not being used, but the question still stands -- 
> > > how does the user silence this diagnostic? It's not at all uncommon to 
> > > have a primary template with specializations where the TU only uses 
> > > either the primary or a specialization, but not both (and certainly not 
> > > all specializations).
> > @philnik used `[[maybe_unused]]` which seemed reasonable to me for 
> > silencing the diagnostic. Maybe take a look at the changes done here: 
> > https://reviews.llvm.org/D144667
> That's reasonable if the interface is one the user controls, such as one 
> within a .cpp file. But the situation I'm worried about is where the primary 
> template and specializations live in a header file that's shared between 
> multiple TUs. I don't think it's reasonable to expect users to put 
> `[[maybe_unused]]` on the primary template and all specializations in that 
> situation.
Don't y'all find it weird to have to use `[[maybe_unused]]` on something that 
is only a declaration like those CTAD guides? And I agree with @aaron.ballman 
here: we provide headers that are used in various TUs, and we obviously never 
expect that the entirety of our headers is going to be used by every single TU.

In other words, we totally expect that those deduction guides will be unused in 
some cases, since it's entirely fine for a user not to use them but for us to 
still provide them. If I understood this correctly, this seems like a flaw in 
the warning that we should fix in Clang.


Repository:
  rC Clang

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

https://reviews.llvm.org/D143524

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


[PATCH] D144878: __builtin_FILE_NAME()

2023-02-27 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/AST/Expr.cpp:2283
+  case SourceLocExpr::FileName: {
+SmallString<256> Path;
+// builtin_FILE_NAME() is a Clang-specific extension that expands to the

It looks like a copy of the code from `ExpandBuiltinMacro` since we are already 
calling `processPathForFileMacro` from that same file why not factor out this 
code? If we can avoid code duplication we should to prevent possible future 
refactors only updating one copy of the code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144878

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


[PATCH] D144232: [PowerPC] Correctly use ELFv2 ABI on FreeBSD/powerpc64

2023-02-27 Thread Alfredo Dal'Ava Júnior via Phabricator via cfe-commits
adalava added a comment.

In D144232#4137367 , @dim wrote:

> In D144232#4136787 , @brad wrote:
>
>> I noticed this review. I have provided a more complete diff for review at 
>> D144321 .
>
> Yeah I think that is probably the better option, hope @pkubaj and @adalava 
> agree with that?
>
> As Brad's version covers both FreeBSD and OpenBSD, and also updates a bunch 
> of unit tests, which this review appears to break (see the Unit Tests 
> https://reviews.llvm.org/harbormaster/unit/214420/).

I agree with D144321 , sorry for the late 
reply.  @pkubaj and @brad , thanks for pushing it. I think D144232 
 can be abandoned, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144232

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


[PATCH] D143415: LibclangTest: remove libclang-test-* tmp dir reliably

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

LGTM!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143415

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


[PATCH] D144218: [Clang] [AVR] Fix USHRT_MAX for 16-bit int.

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

LGTM with a small change to the test coverage.




Comment at: clang/test/Headers/limits.cpp:8
+// Specifically test 16-bit int platforms.
+// RUN: %clang_cc1 -triple=avr -ffreestanding -fsyntax-only -verify -x c %s
+

Might as well add a C++ RUN as well to make sure we cover both language modes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144218

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


[PATCH] D144285: [Clang] Implement CWG2518 - static_assert(false)

2023-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/SemaDeclCXX.cpp:16824-16841
   if (InnerCond && isa(InnerCond)) {
 // Drill down into concept specialization expressions to see why they
 // weren't satisfied.
 Diag(StaticAssertLoc, diag::err_static_assert_failed)
   << !AssertMessage << Msg.str() << AssertExpr->getSourceRange();
 ConstraintSatisfaction Satisfaction;
 if (!CheckConstraintSatisfaction(InnerCond, Satisfaction))

cor3ntin wrote:
> aaron.ballman wrote:
> > cor3ntin wrote:
> > > rsmith wrote:
> > > > I wonder if it's worth adding a custom diagnostic (eg, "this template 
> > > > cannot be instantiated: %0") for the case where we're in template 
> > > > instantiation and the expression is the bool literal `false`.
> > > I'm not sure i see the motivation. Why would we want to special case 
> > > `false`? The expression could also be an always false, never dependent 
> > > expression
> > Richard may have different ideas in mind, but the motivation to me is code 
> > like: 
> > ```
> > template 
> > struct S {
> >   static_assert(false, "you have to use one of the valid specializations, 
> > not the primary template");
> > };
> > 
> > template <>
> > struct S {
> > };
> > 
> > template <>
> > struct S {
> > };
> > 
> > int main() {
> >   S s1;
> >   S s2;
> >   S s3;
> > }
> > ```
> > Rather than telling the user the static_assert failed because false is not 
> > true, having a custom diagnostic might read better for users. GCC doesn't 
> > produce a custom diagnostic -- the behavior isn't terrible, but the "false 
> > evaluates to false" note is effectively just noise, too: 
> > https://godbolt.org/z/456bzWG7c
> OH. That makes sense now,  thanks. I think I agree.
> Interestingly, in gcc immediate calls are really immediate :) 
> https://godbolt.org/z/b3vrzf4sj 
I think you should add this case as a test in dr25xx.cpp to show we get the 
behavior correct with specializations.



Comment at: clang/test/CXX/drs/dr25xx.cpp:5-14
+#error one
+// expected-error@-1 {{one}}
+#if 0
+#error skip
+#warning skip // expected-error {{skip}}
+#endif
+#error two

What do these tests have to do with this DR?



Comment at: clang/test/CXX/drs/dr25xx.cpp:9
+#error skip
+#warning skip // expected-error {{skip}}
+#endif

Why do we expect an error on this line in a `#if 0` block??



Comment at: clang/test/SemaCXX/static-assert.cpp:235-236
+int f() {
+  S s; //expected-note{{in instantiation of template class 
'DependentAlwaysFalse::S' requested here}}
+  T t; //expected-note{{in instantiation of template class 
'DependentAlwaysFalse::T' requested here}}
+}




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144285

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


[PATCH] D144889: [C2x] Support in freestanding

2023-02-27 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Historically, the required functions for a "freestanding" C implementation were 
very restricted.  Freestanding headers didn't export library functions, just 
constants and types.

As a practical matter, we actually do need a few functions to support code 
generation for C even if they don't include any standard library headers.  We 
expect "freestanding" users to provide the three functions memcpy, memmove, and 
memset.  Other misc. functions like large integer operations and floating point 
are provided by compiler-rt.builtins (which is ABI-compatible with libgcc).

Note that we can't easily expand the API surface of compiler-rt.builtins; see 
https://discourse.llvm.org/t/proposal-split-built-ins-from-the-rest-of-compiler-rt/67978
 .

> was that the first one is lowered to a potential library call while the 
> second one is is lowered to a backend implementation that performs the work

The difference is really that the __builtin_* functions are recognized as 
builtins even if the the user is using -fno-builtin/-ffreestanding.  It doesn't 
mean we actually have dedicated codegen support.

> We do not currently have builtins for memccpy, memset_explicit, or strtok

I'm not sure it makes sense to provide a "freestanding" strtok; it requires 
global state.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144889

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


[PATCH] D144680: [Coroutines] Avoid creating conditional cleanup markers in suspend block

2023-02-27 Thread Wei Wang via Phabricator via cfe-commits
weiwang added a comment.

In D144680#4149149 , @ChuanqiXu wrote:

> BTW, what is the conclusion for the concern about sanitizers? Would change 
> make sanitizers to perform false positive diagnostics?

This change is limited to the `await.suspend` block, which only does codegen 
for `awaiter.await_suspend(coroutine_handle::from_promise(p))`. In this 
case, I think the only asan check removed by the change is the conditional 
marker for cleanup the temporary `coroutine_handler` used as the parameter of 
`await_suspend`, so my understanding is that it shouldn't affect asan 
diagnostic.

To show the difference it makes to the source from issue #59181

Before:

  %ref.tmp25 = alloca %"struct.std::__1::coroutine_handle.6", align 8
  ...
  // asan check inserted here
  bool cond_cleanup_marker = false;
  
  if (cond) {
  // get awaiter
  ...
  
  if (!awaiter.await_ready()) {
  call void @llvm.lifetime.start.p0(i64 8, ptr %ref.tmp25)
  
  // asan check inserted here
cond_cleanup_marker = true;

  // store handler to %ref.tmp25
...

  awaiter.await_suspend();
  
  // asan check inserted here
if (cond_cleanup_marker)
call void @llvm.lifetime.end.p0(i64 8, ptr %ref.tmp25)
  call i8 @llvm.coro.suspend(...)
...
  }
  ...
  } else {
  ... 
  }
  ...
  lpad:
  ...
  // asan check inserted here
  if (cond_cleanup_marker)
  call void @llvm.lifetime.end.p0(i64 8, ptr %ref.tmp25)

The issue is only reproduced in `-O0`, because ``cond_cleanup_marker` is 
optimized away in `-O1` or up opt level.

After:

  %ref.tmp25 = alloca %"struct.std::__1::coroutine_handle.6", align 8
  ...
  
  call void @llvm.lifetime.start.p0(i64 8, ptr %ref.tmp25)
  
  if (cond) {
  ...
  if (!awaiter.await_ready()) {
  // store handler to %ref.tmp25
...
  
awaiter.await_suspend();
call void @llvm.lifetime.end.p0(i64 8, ptr %ref.tmp25)
call i8 @llvm.coro.suspend(...)
...
  }
  ...
  } else {
  ... 
  }
  ...
  lpad:
  call void @llvm.lifetime.end.p0(i64 8, ptr %ref.tmp25)

This also matches with the IR without asan.




Comment at: clang/lib/CodeGen/CGExpr.cpp:544
   // so that it's unconditional. Don't do this with sanitizers which need
   // more precise lifetime marks.
   ConditionalEvaluation *OldConditional = nullptr;

ChuanqiXu wrote:
> We should add comment to explain why we add a forward path for coroutines.
Will do



Comment at: clang/lib/CodeGen/CodeGenFunction.h:336
 std::unique_ptr Data;
+bool InSuspendBlock = false;
 CGCoroInfo();

bruno wrote:
> Should this live inside CGCoroData instead?
`CGCoroData` is forward declared here, so it does not know what's inside.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144680

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


Re: [clang] 6ed67cc - [Coroutines] Remove -fcoroutines-ts

2023-02-27 Thread Bruno Cardoso Lopes via cfe-commits
Hi Chuanqi,

I know the warning mentions it to be removed in clang-17, but a heads
up "landing in a week" or so would have been great :)

I understand that the name "coroutines-ts" isn't meaningful these
days, but it also sounds like this commit does more than remove the
flag, it caps useful functionality. How are users supposed to use
c++17 with coroutines now? It's very common in our codebase and we
have users relying on it.

Thanks,

On Wed, Feb 22, 2023 at 10:44 PM Chuanqi Xu via cfe-commits
 wrote:
>
>
> Author: Chuanqi Xu
> Date: 2023-02-23T14:40:58+08:00
> New Revision: 6ed67ccba7e4699e9e42302f2f9b7653444258ba
>
> URL: 
> https://github.com/llvm/llvm-project/commit/6ed67ccba7e4699e9e42302f2f9b7653444258ba
> DIFF: 
> https://github.com/llvm/llvm-project/commit/6ed67ccba7e4699e9e42302f2f9b7653444258ba.diff
>
> LOG: [Coroutines] Remove -fcoroutines-ts
>
> Since we decided to remove the support for `-fcoroutines-ts` in
> clang/llvm17 and the clang16/llvm16 is branched. So we're going to
> remove the `-fcoroutines-ts` option.
>
> Added:
> clang/test/Parser/cxx20-coroutines.cpp
>
> Modified:
> clang/docs/ReleaseNotes.rst
> clang/include/clang/AST/Stmt.h
> clang/include/clang/Basic/DiagnosticDriverKinds.td
> clang/include/clang/Basic/DiagnosticGroups.td
> clang/include/clang/Basic/StmtNodes.td
> clang/include/clang/Basic/TokenKinds.def
> clang/include/clang/Driver/Options.td
> clang/include/clang/Sema/Sema.h
> clang/lib/AST/StmtPrinter.cpp
> clang/lib/Driver/ToolChains/Clang.cpp
> clang/lib/Sema/TreeTransform.h
> clang/test/AST/Inputs/std-coroutine-exp-namespace.h
> clang/test/AST/Inputs/std-coroutine.h
> clang/test/CodeGen/no-skipped-passes-O0-opt-bisect.c
> clang/test/CodeGenCoroutines/coro-builtins-err.c
> clang/test/CodeGenCoroutines/coro-builtins.c
> clang/test/CodeGenCoroutines/coro-gro2.cpp
> clang/test/CodeGenCoroutines/coro-params.cpp
> clang/test/CoverageMapping/coroutine.cpp
> clang/test/Driver/coroutines.c
> clang/test/Driver/coroutines.cpp
> clang/test/Index/coroutines.cpp
> clang/test/Lexer/coroutines.cpp
> clang/test/Lexer/cxx-features.cpp
> clang/test/Modules/requires-coroutines.mm
> clang/test/PCH/coroutines.cpp
> clang/test/SemaCXX/coroutine-builtins.cpp
> clang/test/SemaCXX/thread-safety-coro.cpp
>
> Removed:
> clang/test/Parser/cxx1z-coroutines.cpp
> clang/test/SemaCXX/Inputs/std-coroutine-exp-namespace.h
>
>
> 
> diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
> index 9c89bbc0d1786..be3ea5ff63cde 100644
> --- a/clang/docs/ReleaseNotes.rst
> +++ b/clang/docs/ReleaseNotes.rst
> @@ -115,6 +115,8 @@ Removed Compiler Flags
>  -
>  - The deprecated flag `-fmodules-ts` is removed. Please use ``-std=c++20``
>or higher to use standard C++ modules instead.
> +- The deprecated flag `-fcoroutines-ts` is removed. Please use ``-std=c++20``
> +  or higher to use standard C++ coroutines instead.
>
>  Attribute Changes in Clang
>  --
>
> diff  --git a/clang/include/clang/AST/Stmt.h b/clang/include/clang/AST/Stmt.h
> index b70cf3aec5d6c..45010f19b69b2 100644
> --- a/clang/include/clang/AST/Stmt.h
> +++ b/clang/include/clang/AST/Stmt.h
> @@ -978,7 +978,7 @@ class alignas(void *) Stmt {
>  SourceLocation RequiresKWLoc;
>};
>
> -  //===--- C++ Coroutines TS bitfields classes ---===//
> +  //===--- C++ Coroutines bitfields classes ---===//
>
>class CoawaitExprBitfields {
>  friend class CoawaitExpr;
> @@ -1082,7 +1082,7 @@ class alignas(void *) Stmt {
>  LambdaExprBitfields LambdaExprBits;
>  RequiresExprBitfields RequiresExprBits;
>
> -// C++ Coroutines TS expressions
> +// C++ Coroutines expressions
>  CoawaitExprBitfields CoawaitBits;
>
>  // Obj-C Expressions
>
> diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
> b/clang/include/clang/Basic/DiagnosticDriverKinds.td
> index 77fb1e00585a0..4c922650e100f 100644
> --- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
> +++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
> @@ -637,11 +637,6 @@ def warn_drv_libstdcxx_not_found : Warning<
>"command line to use the libc++ standard library instead">,
>InGroup>;
>
> -def warn_deperecated_fcoroutines_ts_flag : Warning<
> -  "the '-fcoroutines-ts' flag is deprecated and it will be removed in Clang 
> 17; "
> -  "use '-std=c++20' or higher to use standard C++ coroutines instead">,
> -  InGroup;
> -
>  def err_drv_cannot_mix_options : Error<"cannot specify '%1' along with 
> '%0'">;
>
>  def err_drv_invalid_object_mode : Error<
>
> diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
> b/clang/include/clang/Basic/DiagnosticGroups.td
> index 17fdcffa2d427..d56aba34ac0a3 100644
> --- a/clang/include/clang/Basic/DiagnosticGroups.td
> +++ b/clang/include/clang/Basic/

[PATCH] D144889: [C2x] Support in freestanding

2023-02-27 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

A freestanding implementation doesn't necessarily mean that everything is 
header-only.  It's fine to require linking against a (freestanding) C runtime 
library.  All header-only is fine too though, if you want to make that work.

Architecturally, I don't feel it is required that Clang be the location of all 
the freestanding headers for C.  I think that's fine for the C library in the 
final toolchain to own those headers.  I'm not super familiar with what 
interface contracts you have between the clang-provided C headers and the 
C-library provided C headers though.

> I'm not sure it makes sense to provide a "freestanding" strtok; it requires 
> global state.

I agree with this, but the C committee felt otherwise.  C++26 freestanding is 
most likely including strtok too, to stay consistent with C (the freestanding C 
library paper is through LWG and awaiting a C++26 plenary vote).  It shouldn't 
be hard to implement in an OS-independent way, but it will be a low quality 
implementation with cross-thread races.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144889

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


[PATCH] D144218: [Clang] [AVR] Fix USHRT_MAX for 16-bit int.

2023-02-27 Thread Daniel Thornburgh via Phabricator via cfe-commits
mysterymath updated this revision to Diff 500861.
mysterymath marked an inline comment as done.
mysterymath added a comment.

Add C++ version of test for AVR.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144218

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Headers/limits.h
  clang/test/Headers/limits.cpp

Index: clang/test/Headers/limits.cpp
===
--- clang/test/Headers/limits.cpp
+++ clang/test/Headers/limits.cpp
@@ -3,14 +3,40 @@
 // RUN: %clang_cc1 -std=c++11 -ffreestanding -fsyntax-only -verify %s
 // RUN: %clang_cc1 -std=c17 -ffreestanding -fsyntax-only -verify -x c %s
 // RUN: %clang_cc1 -std=c2x -ffreestanding -fsyntax-only -verify -x c %s
+
+// Specifically test 16-bit int platforms.
+// RUN: %clang_cc1 -triple=avr -ffreestanding -fsyntax-only -verify -x c %s
+// RUN: %clang_cc1 -triple=avr -std=c++11 -ffreestanding -fsyntax-only -verify %s
+
 // expected-no-diagnostics
 
 #include 
 
+#if __cplusplus
+#define EXPR_TYPE_IS(EXPR, TYP) __is_same(__typeof(EXPR), TYP)
+#else
+#define EXPR_TYPE_IS(EXPR, TYP) _Generic(EXPR, TYP: 1, default: 0)
+#endif
+
 _Static_assert(SCHAR_MAX == -(SCHAR_MIN+1), "");
+_Static_assert(EXPR_TYPE_IS(SCHAR_MAX, int), "");
+#if SCHAR_MAX
+#endif
+
 _Static_assert(SHRT_MAX == -(SHRT_MIN+1), "");
+_Static_assert(EXPR_TYPE_IS(SHRT_MAX, int), "");
+#if SHRT_MAX
+#endif
+
 _Static_assert(INT_MAX == -(INT_MIN+1), "");
+_Static_assert(EXPR_TYPE_IS(INT_MAX, int), "");
+#if INT_MAX
+#endif
+
 _Static_assert(LONG_MAX == -(LONG_MIN+1L), "");
+_Static_assert(EXPR_TYPE_IS(LONG_MAX, long), "");
+#if LONG_MAX
+#endif
 
 _Static_assert(SCHAR_MAX == UCHAR_MAX/2, "");
 _Static_assert(SHRT_MAX == USHRT_MAX/2, "");
@@ -18,26 +44,84 @@
 _Static_assert(LONG_MAX == ULONG_MAX/2, "");
 
 _Static_assert(SCHAR_MIN == -SCHAR_MAX-1, "");
+_Static_assert(EXPR_TYPE_IS(SCHAR_MIN, int), "");
+#if SCHAR_MIN
+#endif
+
 _Static_assert(SHRT_MIN == -SHRT_MAX-1, "");
+_Static_assert(EXPR_TYPE_IS(SHRT_MIN, int), "");
+#if SHRT_MIN
+#endif
+
 _Static_assert(INT_MIN == -INT_MAX-1, "");
+_Static_assert(EXPR_TYPE_IS(INT_MIN, int), "");
+#if INT_MIN
+#endif
+
 _Static_assert(LONG_MIN == -LONG_MAX-1L, "");
+_Static_assert(EXPR_TYPE_IS(LONG_MIN, long), "");
+#if LONG_MIN
+#endif
 
 _Static_assert(UCHAR_MAX == (unsigned char)~0ULL, "");
+_Static_assert(UCHAR_MAX <= INT_MAX ?
+ EXPR_TYPE_IS(UCHAR_MAX, int) :
+ EXPR_TYPE_IS(UCHAR_MAX, unsigned int), "");
+#if UCHAR_MAX
+#endif
+
 _Static_assert(USHRT_MAX == (unsigned short)~0ULL, "");
+_Static_assert(USHRT_MAX <= INT_MAX ?
+ EXPR_TYPE_IS(USHRT_MAX, int) :
+ EXPR_TYPE_IS(USHRT_MAX, unsigned int), "");
+#if USHRT_MAX
+#endif
+
 _Static_assert(UINT_MAX == (unsigned int)~0ULL, "");
+_Static_assert(EXPR_TYPE_IS(UINT_MAX, unsigned int), "");
+#if UINT_MAX
+#endif
+
 _Static_assert(ULONG_MAX == (unsigned long)~0ULL, "");
+_Static_assert(EXPR_TYPE_IS(ULONG_MAX, unsigned long), "");
+#if ULONG_MAX
+#endif
 
 _Static_assert(MB_LEN_MAX >= 1, "");
+#if MB_LEN_MAX
+#endif
 
 _Static_assert(CHAR_BIT >= 8, "");
+#if CHAR_BIT
+#endif
 
 _Static_assert(CHAR_MIN == (((char)-1 < (char)0) ? -CHAR_MAX-1 : 0), "");
+_Static_assert(EXPR_TYPE_IS(CHAR_MIN, int), "");
+#if CHAR_MIN
+#endif
+
 _Static_assert(CHAR_MAX == (((char)-1 < (char)0) ? -(CHAR_MIN+1) : (char)~0ULL), "");
+_Static_assert(CHAR_MAX <= INT_MAX ?
+ EXPR_TYPE_IS(CHAR_MAX, int) :
+ EXPR_TYPE_IS(CHAR_MAX, unsigned int), "");
+#if CHAR_MAX
+#endif
 
 #if __STDC_VERSION__ >= 199901 || __cplusplus >= 201103L
 _Static_assert(LLONG_MAX == -(LLONG_MIN+1LL), "");
+_Static_assert(EXPR_TYPE_IS(LLONG_MAX, long long), "");
+#if LLONG_MAX
+#endif
+
 _Static_assert(LLONG_MIN == -LLONG_MAX-1LL, "");
+#if LLONG_MIN
+#endif
+_Static_assert(EXPR_TYPE_IS(LLONG_MIN, long long), "");
+
 _Static_assert(ULLONG_MAX == (unsigned long long)~0ULL, "");
+_Static_assert(EXPR_TYPE_IS(ULLONG_MAX, unsigned long long), "");
+#if ULLONG_MAX
+#endif
 #else
 int LLONG_MIN, LLONG_MAX, ULLONG_MAX; // Not defined.
 #endif
@@ -47,35 +131,61 @@
 #if __STDC_VERSION__ >= 202000L
 /* Validate the standard requirements. */
 _Static_assert(BOOL_WIDTH >= 1);
+#if BOOL_WIDTH
+#endif
 
 _Static_assert(CHAR_WIDTH == CHAR_BIT);
 _Static_assert(CHAR_WIDTH / CHAR_BIT == sizeof(char));
+#if CHAR_WIDTH
+#endif
 _Static_assert(SCHAR_WIDTH == CHAR_BIT);
 _Static_assert(SCHAR_WIDTH / CHAR_BIT == sizeof(signed char));
+#if SCHAR_WIDTH
+#endif
 _Static_assert(UCHAR_WIDTH == CHAR_BIT);
 _Static_assert(UCHAR_WIDTH / CHAR_BIT == sizeof(unsigned char));
+#if UCHAR_WIDTH
+#endif
 
 _Static_assert(USHRT_WIDTH >= 16);
 _Static_assert(USHRT_WIDTH / CHAR_BIT == sizeof(unsigned short));
+#if USHRT_WIDTH
+#endif
 _Static_assert(SHRT_WIDTH == USHRT_WIDTH);
 _Static_assert(SHRT_WIDTH / CHAR_BIT == sizeof(signed short));
+#if SHRT_WIDTH
+#endif
 
 _Static_asse

[PATCH] D144218: [Clang] [AVR] Fix USHRT_MAX for 16-bit int.

2023-02-27 Thread Daniel Thornburgh via Phabricator via cfe-commits
mysterymath added a comment.

Thanks for your help in getting this right!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144218

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


[PATCH] D144903: [X86] Drop single use check for freeze(undef) in LowerAVXCONCAT_VECTORS

2023-02-27 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito created this revision.
ManuelJBrito added a reviewer: RKSimon.
Herald added subscribers: pengfei, hiraditya.
Herald added a project: All.
ManuelJBrito requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

Ignoring freeze(undef) if it has multiple uses in LowerAVXCONCAT_VECTORS causes 
the custom INSERT_SUBVECTOR for vector widening to be ignored.

For example in https://godbolt.org/z/7hacPe1KM extra vinsertf128 instructions 
are introduced.

This is necessary to lower `mm512_cast*128` intel intrinsics as no-op 
intrinsics.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144903

Files:
  clang/test/CodeGen/X86/avx-cast-builtins.c
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/test/CodeGen/X86/avx512-intrinsics.ll
  llvm/test/CodeGen/X86/avx512fp16-intrinsics.ll

Index: llvm/test/CodeGen/X86/avx512fp16-intrinsics.ll
===
--- llvm/test/CodeGen/X86/avx512fp16-intrinsics.ll
+++ llvm/test/CodeGen/X86/avx512fp16-intrinsics.ll
@@ -1231,10 +1231,7 @@
 define <32 x half> @test_mm512_castph128_ph512_freeze(<8 x half> %a0) nounwind {
 ; CHECK-LABEL: test_mm512_castph128_ph512_freeze:
 ; CHECK:   # %bb.0:
-; CHECK-NEXT:# kill: def $xmm0 killed $xmm0 def $ymm0
-; CHECK-NEXT:vinsertf128 $1, %xmm0, %ymm0, %ymm1
-; CHECK-NEXT:vinsertf128 $1, %xmm0, %ymm0, %ymm0
-; CHECK-NEXT:vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
+; CHECK-NEXT:# kill: def $xmm0 killed $xmm0 def $zmm0
 ; CHECK-NEXT:retq
   %a1 = freeze <8 x half> poison
   %res = shufflevector <8 x half> %a0, <8 x half> %a1, <32 x i32> 
Index: llvm/test/CodeGen/X86/avx512-intrinsics.ll
===
--- llvm/test/CodeGen/X86/avx512-intrinsics.ll
+++ llvm/test/CodeGen/X86/avx512-intrinsics.ll
@@ -7495,10 +7495,7 @@
 define <8 x double> @test_mm256_castpd128_pd256_freeze(<2 x double> %a0) nounwind {
 ; CHECK-LABEL: test_mm256_castpd128_pd256_freeze:
 ; CHECK:   # %bb.0:
-; CHECK-NEXT:# kill: def $xmm0 killed $xmm0 def $ymm0
-; CHECK-NEXT:vinsertf128 $1, %xmm0, %ymm0, %ymm1
-; CHECK-NEXT:vinsertf128 $1, %xmm0, %ymm0, %ymm0
-; CHECK-NEXT:vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
+; CHECK-NEXT:# kill: def $xmm0 killed $xmm0 def $zmm0
 ; CHECK-NEXT:ret{{[l|q]}}
   %a1 = freeze <2 x double> poison
   %res = shufflevector <2 x double> %a0, <2 x double> %a1, <8 x i32> 
@@ -7520,10 +7517,7 @@
 define <16 x float> @test_mm256_castps128_ps512_freeze(<4 x float> %a0) nounwind {
 ; CHECK-LABEL: test_mm256_castps128_ps512_freeze:
 ; CHECK:   # %bb.0:
-; CHECK-NEXT:# kill: def $xmm0 killed $xmm0 def $ymm0
-; CHECK-NEXT:vinsertf128 $1, %xmm0, %ymm0, %ymm1
-; CHECK-NEXT:vinsertf128 $1, %xmm0, %ymm0, %ymm0
-; CHECK-NEXT:vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
+; CHECK-NEXT:# kill: def $xmm0 killed $xmm0 def $zmm0
 ; CHECK-NEXT:ret{{[l|q]}}
   %a1 = freeze <4 x float> poison
   %res = shufflevector <4 x float> %a0, <4 x float> %a1, <16x i32> 
@@ -7545,10 +7539,7 @@
 define <8 x i64> @test_mm512_castsi128_si512_freeze(<2 x i64> %a0) nounwind {
 ; CHECK-LABEL: test_mm512_castsi128_si512_freeze:
 ; CHECK:   # %bb.0:
-; CHECK-NEXT:# kill: def $xmm0 killed $xmm0 def $ymm0
-; CHECK-NEXT:vinsertf128 $1, %xmm0, %ymm0, %ymm1
-; CHECK-NEXT:vinsertf128 $1, %xmm0, %ymm0, %ymm0
-; CHECK-NEXT:vinsertf64x4 $1, %ymm1, %zmm0, %zmm0
+; CHECK-NEXT:# kill: def $xmm0 killed $xmm0 def $zmm0
 ; CHECK-NEXT:ret{{[l|q]}}
   %a1 = freeze <2 x i64> poison
   %res = shufflevector <2 x i64> %a0, <2 x i64> %a1, <8 x i32> 
Index: llvm/lib/Target/X86/X86ISelLowering.cpp
===
--- llvm/lib/Target/X86/X86ISelLowering.cpp
+++ llvm/lib/Target/X86/X86ISelLowering.cpp
@@ -11656,7 +11656,7 @@
 SDValue SubVec = Op.getOperand(i);
 if (SubVec.isUndef())
   continue;
-if (ISD::isFreezeUndef(SubVec.getNode()) && SubVec.hasOneUse())
+if (ISD::isFreezeUndef(SubVec.getNode()))
   ++NumFreezeUndef;
 else if (ISD::isBuildVectorAllZeros(SubVec.getNode()))
   ++NumZero;
Index: clang/test/CodeGen/X86/avx-cast-builtins.c
===
--- clang/test/CodeGen/X86/avx-cast-builtins.c
+++ clang/test/CodeGen/X86/avx-cast-builtins.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -O3 -flax-vector-conversions=none -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +avx -target-feature +avx512f  -target-feature +avx512fp16 -S -o - | FileCheck %s
+// RUN: %clang_cc1 %s -O3  -ffreestanding %s -triple=x86_64-unknown-unknown -target-feature +avx -target-feature +avx512f  -target-feature +avx512fp16 -S -o - | FileCheck %s
 
 
 #include 
@@ -38,10 +38,7 @@
 __m512h test_mm512_castph128_ph512(__m128h A) {
   // CHECK-LABEL: test_mm512_castph128_ph512
   // CHECK: # %bb.0:
-  // CHECK-N

[PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses

2023-02-27 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D144884#4155739 , @jhuber6 wrote:

> In D144884#4155730 , @jdoerfert 
> wrote:
>
>> I'm assuming they have tests?
>
> I could add a test for the comment case in the bug report.

Yes please.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144884

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


[PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses

2023-02-27 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:1279
+  if (State.Line->InPragmaDirective) {
+FormatToken *PragmaType = State.Line->First->Next->Next;
+if (PragmaType && PragmaType->TokenText.equals("omp"))

Do we know that the first `Next` is never null?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144884

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


[PATCH] D144884: [clang-format] Only add pragma continuation indentation for 'omp' clauses

2023-02-27 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added inline comments.



Comment at: clang/lib/Format/ContinuationIndenter.cpp:1279
+  if (State.Line->InPragmaDirective) {
+FormatToken *PragmaType = State.Line->First->Next->Next;
+if (PragmaType && PragmaType->TokenText.equals("omp"))

HazardyKnusperkeks wrote:
> Do we know that the first `Next` is never null?
The line should only have `InPragmaDirective` if it found `pragma`, so it 
should look something like this if you go through the tokens. I checked the 
final `Next` because someone could do `#pragma`.
```
#
pragma
comment
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144884

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


[PATCH] D143418: [libclang] Add API to override preamble storage path

2023-02-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang-c/Index.h:319
+   */
+  size_t Size;
+  /**

vedgy wrote:
> The type is `size_t` instead of the agreed upon `unsigned`, because the 
> addition of `unsigned GlobalOptions` below means that `unsigned Size` no 
> longer reduces the overall struct's size.
SGTM, thanks for the explanation



Comment at: clang/include/clang-c/Index.h:353
+ */
+CINDEX_LINKAGE unsigned clang_getDefaultGlobalOptions();
+

Don't want this to be a K&R C interface in pre-C2x modes.



Comment at: clang/tools/c-index-test/c-index-test.c:79
+Opts.PreambleStoragePath = NULL;
+Opts.InvocationEmissionPath = 
getenv("CINDEXTEST_INVOCATION_EMISSION_PATH");
+

vedgy wrote:
> When a libclang user needs to override a single option in `CXIndexOptions`, 
> [s]he has to set every member of the struct explicitly. When new options are 
> added, each libclang user needs to update the code that sets the options 
> under `CINDEX_VERSION_MINOR` `#if`s. Accidentally omitting even one member 
> assignment risks undefined or wrong behavior. How about adding an `inline` 
> helper function `CXIndexOptions clang_getDefaultIndexOptions()`, which 
> assigns default values to all struct members? Libclang users can then call 
> this function to obtain the default configuration, then tweak only the 
> members they want to override.
> 
> If this suggestion is to be implemented, how to deal with 
> [[https://stackoverflow.com/questions/68004269/differences-of-the-inline-keyword-in-c-and-c|the
>  differences of the inline keyword in C and C++]]?
By default, `0` should give you the most reasonable default behavior for most 
of the existing options (and new options should follow the same pattern). 
Ideally, users should be able to do:
```
CXIndexOptions Opts;
memset(&Opts, 0, sizeof(Opts));
Opts.Size = sizeof(Opts);
Opts.Whatever = 12;
CXIndex Idx = clang_createIndexWithOptions(&Opts);
```
Global options defaulting to 0 is fine (uses regular thread priorities), we 
don't think want to default to excluding declarations from PCH, and we want to 
use the default preamble and invocation emission paths (if any). The only 
option that nonzero as a default *might* make sense for is displaying 
diagnostics, but even that seems reasonable to expect the developer to manually 
enable.

So I don't know that we need a function to get us default indexing options as 
`0` should be a reasonable default for all of the options. As we add new 
options, we need to be careful to add them in backwards compatible ways where 
`0` means "do the most likely thing".

WDYT?



Comment at: clang/tools/c-index-test/c-index-test.c:2079
+  if (!Idx)
+return -1;
 

vedgy wrote:
> Not sure `-1` is the right value to return here. This return value becomes 
> the exit code of the `c-index-test` executable.
I think `-1` is fine -- the important thing is a nonzero return code so it's 
logged as an error rather than a valid result.



Comment at: clang/tools/libclang/CIndex.cpp:3691
 
+unsigned clang_getDefaultGlobalOptions() {
+  unsigned GlobalOptions = CXGlobalOpt_None;





Comment at: clang/tools/libclang/CIndex.cpp:3701-3702
+CXIndex clang_createIndexWithOptions(const CXIndexOptions *options) {
+  if (options->Size != sizeof(CXIndexOptions))
+return NULL;
+  CIndexer *CIdxr = clang_createIndex_Impl(options->ExcludeDeclarationsFromPCH,

I think we want this to be `>` and not `!=`, maybe.

If the sizes are equal, we're on the happy path.

If the options from the caller are smaller than the options we know about, that 
should be okay because we won't attempt read the options not provided and 
instead rely on the default behavior being reasonable.

If the options from the caller are larger than the options we know about, we 
have to assume the user set an option we can't handle, and thus failing the 
request is reasonable.

So the way I'm envisioning us reading the options is:
```
if (options->Size >= offsetof(CXIndexOptions, FieldWeCareAbout))
  do_something(options->FieldWeCareAbout);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143418

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


[PATCH] D144285: [Clang] Implement CWG2518 - static_assert(false)

2023-02-27 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 500866.
cor3ntin marked an inline comment as done.
cor3ntin added a comment.

Address Aaron's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144285

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/drs/dr25xx.cpp
  clang/test/SemaCXX/access-base-class.cpp
  clang/test/SemaCXX/coroutines-exp-namespace.cpp
  clang/test/SemaCXX/coroutines.cpp
  clang/test/SemaCXX/static-assert.cpp
  clang/test/SemaTemplate/instantiate-var-template.cpp
  clang/test/SemaTemplate/instantiation-dependence.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -14915,7 +14915,7 @@
 https://wg21.link/cwg2518";>2518
 review
 Conformance requirements and #error/#warning
-Not resolved
+Clang 17
   
   
 https://wg21.link/cwg2519";>2519
Index: clang/test/SemaTemplate/instantiation-dependence.cpp
===
--- clang/test/SemaTemplate/instantiation-dependence.cpp
+++ clang/test/SemaTemplate/instantiation-dependence.cpp
@@ -37,8 +37,8 @@
   template using indirect_void_t = typename indirect_void_t_imp::type;
 
   template void foo() {
-static_assert(!__is_void(indirect_void_t)); // "ok", dependent
-static_assert(!__is_void(void_t)); // expected-error {{failed}}
+int check1[__is_void(indirect_void_t) == 0 ? 1 : -1]; // "ok", dependent
+int check2[__is_void(void_t) == 0 ? 1 : -1]; // expected-error {{array with a negative size}}
   }
 }
 
Index: clang/test/SemaTemplate/instantiate-var-template.cpp
===
--- clang/test/SemaTemplate/instantiate-var-template.cpp
+++ clang/test/SemaTemplate/instantiate-var-template.cpp
@@ -31,9 +31,9 @@
   static_assert(b == 1, ""); // expected-note {{in instantiation of}}
 
   template void f() {
-static_assert(a == 0, ""); // expected-error {{static assertion failed due to requirement 'a == 0'}} \
-   // expected-note {{evaluates to '1 == 0'}}
+int check[a == 0 ? 1 : -1]; // expected-error {{array with a negative size}}
   }
+
 }
 
 namespace PR24483 {
Index: clang/test/SemaCXX/static-assert.cpp
===
--- clang/test/SemaCXX/static-assert.cpp
+++ clang/test/SemaCXX/static-assert.cpp
@@ -52,9 +52,11 @@
 
 template struct AlwaysFails {
   // Only give one error here.
-  static_assert(false, ""); // expected-error {{static assertion failed}}
+  static_assert(false, ""); // expected-error 2{{static assertion failed}}
 };
-AlwaysFails alwaysFails;
+AlwaysFails alwaysFails; // expected-note {{instantiation}}
+AlwaysFails alwaysFails2; // expected-note {{instantiation}}
+
 
 template struct StaticAssertProtected {
   static_assert(__is_literal(T), ""); // expected-error {{static assertion failed}}
@@ -217,6 +219,23 @@
 
 static_assert(1 , "") // expected-error {{expected ';' after 'static_assert'}}
 
+namespace DependentAlwaysFalse {
+template 
+struct S {
+  static_assert(false); // expected-error{{static assertion failed}} \
+// expected-warning {{C++17 extension}}
+};
+
+template 
+struct T {
+  static_assert(false, "test"); // expected-error{{static assertion failed: test}}
+};
+
+int f() {
+  S s; //expected-note {{in instantiation of template class 'DependentAlwaysFalse::S' requested here}}
+  T t; //expected-note {{in instantiation of template class 'DependentAlwaysFalse::T' requested here}}
+}
+}
 
 namespace Diagnostics {
   /// No notes for literals.
Index: clang/test/SemaCXX/coroutines.cpp
===
--- clang/test/SemaCXX/coroutines.cpp
+++ clang/test/SemaCXX/coroutines.cpp
@@ -1309,7 +1309,7 @@
   }
 };
 
-template struct DepTestType; // expected-note {{requested here}}
+template struct DepTestType; // expected-note 2{{requested here}}
 template CoroMemberTag DepTestType::test_member_template(long, const char *) const &&;
 
 template CoroMemberTag DepTestType::test_static_template(const char *volatile &, unsigned);
Index: clang/test/SemaCXX/coroutines-exp-namespace.cpp
===
--- clang/test/SemaCXX/coroutines-exp-namespace.cpp
+++ clang/test/SemaCXX/coroutines-exp-namespace.cpp
@@ -1288,7 +1288,7 @@
   }
 };
 
-template struct DepTestType; // expected-note {{requested here}}
+template struct DepTestType; // expected-note 2{{requested here}}
 template CoroMemberTag DepTestType::test_member_template(long, const char *) const &&;
 
 template CoroMemberTag DepTestType::test_static_template(const char *volatile &, unsigned);
Index: clang/test/SemaCXX/access-base-class.cpp

  1   2   >