[PATCH] D149437: [clangd] Emit ChangeAnnotation label and description for include-cleaner diagnostics.

2023-05-02 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:445
 
-Fix removeAllUnusedIncludes(llvm::ArrayRef UnusedIncludes) {
+Fix removeAllUnusedIncludes(llvm::ArrayRef UnusedIncludes,
+llvm::StringRef Code) {

what about just taking in `llvm::ArrayRef UnusedIncludes` 
and having a `TextEdit dropInclude(const Inclusion&);` that we can use in here 
& inside `generateUnusedIncludeDiagnostics`? That way we can just use the 
spelling inside the inclusion to generate the `label`, without all the extra 
logic.



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:485
   // newText (#include "my_missing_header.h") -> TextEdit.
-  llvm::StringMap Edits;
+  llvm::StringMap> Edits;
   for (const auto &Diag : MissingIncludeDiags) {

i think rather than a single diag info, we should actually store a set of them 
now, right? as we want to surface not only the "first" use of a header, but 
all. (possibly with some trimming).



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:514
+ /*description=*/
+ llvm::formatv("Line {0}: '{1}'", StartLine, Lines[StartLine])}});
   }

i don't think line information is as useful (as there's no structured link to 
it). what about something like:

```
label: `Include "foo.h"`
description: `Provides 'X', 'Y', 'Z', ...`
```



Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:550
   std::optional FixAll;
   if (RemoveAllUnused && AddAllMissing)
 FixAll = fixAll(*RemoveAllUnused, *AddAllMissing);

sorry for missing it during last review, but this should actually be `if 
(!UnusedIncludes.empty() && !MissingIncludeDiags.empty())` as even if we have 
only 1 fix for each category, we should still show the fix all. probably it 
deserves a fix in a separate patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149437

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


[PATCH] D148944: [clang][Driver] Fix crash with unsupported architectures in MinGW and CrossWindows.

2023-05-02 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/test/Driver/unsupported-target-arch.c:33
+// RUN: FileCheck --input-file=%t.err --check-prefix=CHECK-NOARCH-CROSSWINDOWS 
%s
+// CHECK-NOARCH-CROSSWINDOWS: error: unknown target triple 
'noarch-unknown-windows-itanium', please use -triple or -arch

MaskRay wrote:
> mstorsjo wrote:
> > Separate side note; the suggested option `-triple` isn't really a clang 
> > driver level option, and `-arch` is only relevant for darwin targets 
> > (AFAIK) - so maybe the error message text should be revised?
> The part ", please use -triple or -arch" is almost always wrong.
> 
> For cc1, the error is due to a specified but unknown -triple, we should not 
> suggest specifying -triple.
> For driver, -triple and -arch are not driver options.
> 
> I just removed the hint from the diagnostic.
`-arch` is a driver option, for darwin targets though. But I agree that it's 
probably best to leave it out since it's more misleading than helping here (and 
`-triple` is indeed not a relevant option here).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148944

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


[PATCH] D142967: [clangd] Introduce source.organizeImports code action.

2023-05-02 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1035
   }
+  if (KindAllowed(CodeAction::SOURCE_ORGANIZE_IMPORT)) {
+std::lock_guard Lock(FixItsMutex);

kadircet wrote:
> instead of doing this in here, what about introducing a new "tweak" that'll 
> perform include-cleaner fixes?
> Pros are:
> - We can use it in places that don't use LSPServer.
> - We can later on extend "organize imports" behaviour to do other things if 
> needed.
> - Results will be always up-to-date, as we can use the AST and compute the 
> fixes. rather than making use of the "latest" cached version.
> - Implementation would be a little bit neater (and contained), as we can just 
> re-use the existing components in IncludeCleaner, rather than doing some 
> ad-hoc matching & retrieval.
> 
> WDYT?
I think it is a matter of how we view it (whether it is a fix for all 
diagnostics or a tweak).

but +1, yeah, this looks like a good idea to me.



Comment at: clang-tools-extra/clangd/ClangdLSPServer.cpp:1072-1074
+  AddFix(RemoveAllUnused);
+  AddFix(AddAllMissing);
+  AddFix(FixAll);

kadircet wrote:
> what does the UI look like when there are multiple code actions with 
> "organize imports" kind?
> e.g. 1&2 can actually be applied together, but 3rd one can't be combined with 
> others, and in theory these can also be triggered on save (if the user opts 
> in). so I am not sure if having multiple code actions, especially when they 
> can't be merged together, really makes much sense on the editor side.
> what does the UI look like when there are multiple code actions with 
> "organize imports" kind?

Similar to the normal code action, if you trigger it via the right context menu 
(`SourceAction`), a window with 3 alternatives will pop up, so that you can 
select one of them (verified on VSCode).

> e.g. 1&2 can actually be applied together, but 3rd one can't be combined with 
> others, and in theory these can also be triggered on save (if the user opts 
> in). so I am not sure if having multiple code actions, especially when they 
> can't be merged together, really makes much sense on the editor side.

Good point.  The VSocde `codeActionsOnSave` behavior is like what you said -- 
it applies each fix one by one (because we trigger preview window per fix, so 3 
preview windows will be triggered in sequence).

I don't see the best way to fix it (from the `codeAction` requests are 
identical from the one sent via the context menu), one option is to send only a 
`fixAll` codeAction rather than 3.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142967

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


[PATCH] D148822: [clang][BFloat] Avoid redefining bfloat16_t in arm_neon.h

2023-05-02 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

I agree it makes sense to remove the typedef if they are also defined in 
`arm_bf16.h`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148822

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


[PATCH] D149637: [Clang] Correctly expand pack in binary subscript expression.

2023-05-02 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

When constructing an array expression where the index expression
was a pack expansion, we would construct an ArraySubscriptExpr
instead of an CreateOverloadedArraySubscriptExpr, and pack
expansion would not occur - leading a crash during code gen
or a failure during constant evaluation


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149637

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/cxx2b-overloaded-operator.cpp


Index: clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
===
--- clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
+++ clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
@@ -73,3 +73,47 @@
 static_assert(T2{}[] == 1);
 static_assert(T2{}[1] == 2);
 static_assert(T2{}[1, 1] == 3);
+
+namespace test_packs {
+
+struct foo_t {
+template
+constexpr int operator[](Ts... idx) {
+return (0 + ... + idx);
+}
+};
+
+template
+constexpr int cxx_subscript() {
+  foo_t foo;
+  return foo[Is...];
+}
+
+template
+int cxx_subscript_unexpanded() {
+  foo_t foo;
+  return foo[Is]; // expected-error {{expression contains unexpanded parameter 
pack 'Is'}}
+}
+
+template
+constexpr int c_array() {
+  int arr[] = {1, 2, 3};
+  return arr[Is...]; // expected-error 2{{type 'int[3]' does not provide a 
subscript operator}}
+}
+
+template
+int c_array_unexpanded() {
+  int arr[] = {1, 2, 3};
+  return arr[Is]; // expected-error {{expression contains unexpanded parameter 
pack 'Is'}}
+}
+
+void test() {
+  static_assert(cxx_subscript<1, 2, 3>() == 6);
+  static_assert(c_array<1>() == 2);
+
+  c_array<>(); // expected-note {{in instantiation}}
+  c_array<1>();
+  c_array<1, 2>(); // expected-note {{in instantiation}}
+}
+
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4924,7 +4924,8 @@
   // Build an unanalyzed expression if either operand is type-dependent.
   if (getLangOpts().CPlusPlus && ArgExprs.size() == 1 &&
   (base->isTypeDependent() ||
-   Expr::hasAnyTypeDependentArguments(ArgExprs))) {
+   Expr::hasAnyTypeDependentArguments(ArgExprs)) &&
+  !isa(ArgExprs[0])) {
 return new (Context) ArraySubscriptExpr(
 base, ArgExprs.front(),
 getDependentArraySubscriptType(base, ArgExprs.front(), 
getASTContext()),
@@ -4958,7 +4959,8 @@
   // to overload resolution and so should not take this path.
   if (getLangOpts().CPlusPlus && !base->getType()->isObjCObjectPointerType() &&
   ((base->getType()->isRecordType() ||
-(ArgExprs.size() != 1 || ArgExprs[0]->getType()->isRecordType() {
+(ArgExprs.size() != 1 || isa(ArgExprs[0]) ||
+ ArgExprs[0]->getType()->isRecordType() {
 return CreateOverloadedArraySubscriptExpr(lbLoc, rbLoc, base, ArgExprs);
   }
 


Index: clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
===
--- clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
+++ clang/test/SemaCXX/cxx2b-overloaded-operator.cpp
@@ -73,3 +73,47 @@
 static_assert(T2{}[] == 1);
 static_assert(T2{}[1] == 2);
 static_assert(T2{}[1, 1] == 3);
+
+namespace test_packs {
+
+struct foo_t {
+template
+constexpr int operator[](Ts... idx) {
+return (0 + ... + idx);
+}
+};
+
+template
+constexpr int cxx_subscript() {
+  foo_t foo;
+  return foo[Is...];
+}
+
+template
+int cxx_subscript_unexpanded() {
+  foo_t foo;
+  return foo[Is]; // expected-error {{expression contains unexpanded parameter pack 'Is'}}
+}
+
+template
+constexpr int c_array() {
+  int arr[] = {1, 2, 3};
+  return arr[Is...]; // expected-error 2{{type 'int[3]' does not provide a subscript operator}}
+}
+
+template
+int c_array_unexpanded() {
+  int arr[] = {1, 2, 3};
+  return arr[Is]; // expected-error {{expression contains unexpanded parameter pack 'Is'}}
+}
+
+void test() {
+  static_assert(cxx_subscript<1, 2, 3>() == 6);
+  static_assert(c_array<1>() == 2);
+
+  c_array<>(); // expected-note {{in instantiation}}
+  c_array<1>();
+  c_array<1, 2>(); // expected-note {{in instantiation}}
+}
+
+}
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -4924,7 +4924,8 @@
   // Build an unanalyzed expression if either operand is type-dependent.
   if (getLangOpts().CPlusPlus && ArgExprs.size() == 1 &&
   (base->isTypeDependent() ||
-   Expr::hasAnyTypeDependentArguments(ArgExprs))) {
+   Expr::hasAnyTypeDependentArguments(ArgExprs)) &&
+  !isa(ArgExprs[0])) {
 return new (Context) ArraySubscriptExpr(
 base, ArgExprs.front(),
 getDependentArraySubscriptType(base, ArgExprs.front(), getASTContext()),
@@ -4958,

[PATCH] D148680: [RISCV] Split out part of riscv_vector.td to riscv_vector_common.td

2023-05-02 Thread Kito Cheng via Phabricator via cfe-commits
kito-cheng accepted this revision.
kito-cheng 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/D148680/new/

https://reviews.llvm.org/D148680

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


[PATCH] D133863: [RISCV] Add MC support of RISCV zcmt Extension

2023-05-02 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 518653.
VincentWu marked an inline comment as done.
VincentWu added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133863

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVSchedRocket.td
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
  llvm/lib/Target/RISCV/RISCVSystemOperands.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmt-invalid.s
  llvm/test/MC/RISCV/rv32zcmt-valid.s
  llvm/test/MC/RISCV/rvzcmt-user-csr-name.s

Index: llvm/test/MC/RISCV/rvzcmt-user-csr-name.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rvzcmt-user-csr-name.s
@@ -0,0 +1,29 @@
+# RUN: llvm-mc %s -triple=riscv32 -riscv-no-aliases -mattr=+experimental-zcmt -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zcmt < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zcmt - \
+# RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
+#
+# RUN: llvm-mc %s -triple=riscv64 -riscv-no-aliases -mattr=+experimental-zcmt -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-INST,CHECK-ENC %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zcmt < %s \
+# RUN: | llvm-objdump -d --mattr=+experimental-zcmt - \
+# RUN: | FileCheck -check-prefix=CHECK-INST-ALIAS %s
+
+##
+# Jump Vector Table CSR
+##
+
+# jvt
+# name
+# CHECK-INST: csrrs t1, jvt, zero
+# CHECK-ENC:  encoding: [0x73,0x23,0x70,0x01]
+# CHECK-INST-ALIAS: csrr t1, jvt
+# uimm12
+# CHECK-INST: csrrs t2, jvt, zero
+# CHECK-ENC:  encoding: [0xf3,0x23,0x70,0x01]
+# CHECK-INST-ALIAS: csrr t2, jvt
+# name
+csrrs t1, jvt, zero
+# uimm12
+csrrs t2, 0x017, zero
Index: llvm/test/MC/RISCV/rv32zcmt-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zcmt-valid.s
@@ -0,0 +1,39 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zcmt\
+# RUN:  -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zcmt\
+# RUN:  -mattr=m < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcmt\
+# RUN:  -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zcmt\
+# RUN:  -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zcmt\
+# RUN:  -mattr=m < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcmt\
+# RUN:  -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+#
+# RUN: not llvm-mc -triple riscv32 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+# RUN: not llvm-mc -triple riscv64 \
+# RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+# CHECK-ASM-AND-OBJ: cm.jt 1
+# CHECK-ASM: encoding: [0x06,0xa0]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcmt' (table jump instuctions for code-size reduction){{$}}
+cm.jt 1
+
+# CHECK-ASM: cm.jalt 1
+# CHECK-OBJ: cm.jt 1
+# CHECK-ASM: encoding: [0x06,0xa0]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcmt' (table jump instuctions for code-size reduction){{$}}
+cm.jalt 1
+
+# CHECK-ASM-AND-OBJ: cm.jalt 32
+# CHECK-ASM: encoding: [0x82,0xa0]
+# CHECK-NO-EXT: error: instruction requires the following: 'Zcmt' (table jump instuctions for code-size reduction){{$}}
+cm.jalt 32
Index: llvm/test/MC/RISCV/rv32zcmt-invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zcmt-invalid.s
@@ -0,0 +1,10 @@
+# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zcmt -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-ERROR %s
+# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zcmt -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: error: immediate must be an integer in the range [0, 31]
+cm.jt 64
+
+# CHECK-ERROR: error: immediate must be an integer in the range [0, 255]
+cm.jalt 256
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-ar

[clang-tools-extra] 1aa36da - [clang-tidy] Add check bugprone-multiple-new-in-one-expression.

2023-05-02 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2023-05-02T10:59:07+02:00
New Revision: 1aa36da15369678d94add0f64809b11f95795efd

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

LOG: [clang-tidy] Add check bugprone-multiple-new-in-one-expression.

Reviewed By: donat.nagy

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

Added: 
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone/multiple-new-in-one-expression.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone/multiple-new-in-one-expression.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 60666287cf307..5e9c7d0add4f8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -36,6 +36,7 @@
 #include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
+#include "MultipleNewInOneExpressionCheck.h"
 #include "MultipleStatementMacroCheck.h"
 #include "NoEscapeCheck.h"
 #include "NonZeroEnumToBoolConversionCheck.h"
@@ -133,6 +134,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-misplaced-widening-cast");
 CheckFactories.registerCheck(
 "bugprone-move-forwarding-reference");
+CheckFactories.registerCheck(
+"bugprone-multiple-new-in-one-expression");
 CheckFactories.registerCheck(
 "bugprone-multiple-statement-macro");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 5af5a59e5340f..e70d1b426a1c6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -31,6 +31,7 @@ add_clang_library(clangTidyBugproneModule
   MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
+  MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
   NoEscapeCheck.cpp
   NonZeroEnumToBoolConversionCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
new file mode 100644
index 0..47b9667859903
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
@@ -0,0 +1,162 @@
+//===--- MultipleNewInOneExpressionCheck.cpp - 
clang-tidy--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MultipleNewInOneExpressionCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+using namespace clang;
+
+namespace {
+
+// Determine if the result of an expression is "stored" in some way.
+// It is true if the value is stored into a variable or used as initialization
+// or passed to a function or constructor.
+// For this use case compound assignments are not counted as a "store" (the 'E'
+// expression should have pointer type).
+bool isExprValueStored(const Expr *E, ASTContext &C) {
+  E = E->IgnoreParenCasts();
+  // Get first non-paren, non-cast parent.
+  ParentMapContext &PMap = C.getParentMapContext();
+  DynTypedNodeList P = PMap.getParents(*E);
+  if (P.size() != 1)
+return false;
+  const Expr *ParentE;
+  while ((ParentE = P[0].get()) && ParentE->IgnoreParenCasts() == E) {
+P = PMap.getParents(P[0]);
+if (P.size() != 1)
+  return false;
+  }
+
+  if (const auto *ParentVarD = P[0].get())
+return ParentVarD->getInit()->IgnoreParenCasts() == E;
+
+  if (!ParentE)
+return false;
+
+  if (const auto *BinOp = dyn_cast(ParentE))
+return BinOp->getOpcode() == BO_Assign &&
+   BinOp->getRHS()->IgnoreParenCasts() == E;
+
+  return isa(ParentE);
+}
+
+} // namespace
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  for (unsigned 

[PATCH] D138777: [clang-tidy] Add check bugprone-multiple-new-in-one-expression.

2023-05-02 Thread Balázs Kéri via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
balazske marked an inline comment as done.
Closed by commit rG1aa36da15369: [clang-tidy] Add check 
bugprone-multiple-new-in-one-expression. (authored by balazske).

Changed prior to commit:
  https://reviews.llvm.org/D138777?vs=512808&id=518654#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138777

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/bugprone/multiple-new-in-one-expression.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/multiple-new-in-one-expression.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/multiple-new-in-one-expression.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/multiple-new-in-one-expression.cpp
@@ -0,0 +1,197 @@
+// RUN: %check_clang_tidy -std=c++11 -check-suffixes=ALL,CPP11 %s bugprone-multiple-new-in-one-expression %t
+// RUN: %check_clang_tidy -std=c++17 -check-suffixes=ALL,CPP17 %s bugprone-multiple-new-in-one-expression %t
+
+namespace std {
+typedef __typeof__(sizeof(0)) size_t;
+enum class align_val_t : std::size_t {};
+class exception {};
+class bad_alloc : public exception {};
+struct nothrow_t {};
+extern const nothrow_t nothrow;
+} // namespace std
+
+void *operator new(std::size_t, const std::nothrow_t &) noexcept;
+void *operator new(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept;
+void *operator new(std::size_t, void *) noexcept;
+void *operator new(std::size_t, char);
+
+struct B;
+
+struct A { int VarI; int *PtrI; B *PtrB; };
+
+struct B { int VarI; };
+
+struct G {
+  G(A*, B*) {}
+  int operator+=(A *) { return 3; };
+};
+
+struct H {
+  int *a;
+  int *b;
+};
+
+int f(int);
+int f(A*);
+int f(A*, B*);
+int f(int, B*);
+int f(G, G);
+int f(B*);
+int f(const H &);
+void f1(void *, void *);
+A *g(A *);
+
+G operator+(const G&, const G&);
+
+void test_function_parameter(A *XA, B *XB) {
+  (void)f(new A, new B);
+  try {
+(void)f(new A, new B);
+  }
+  catch (A) {};
+  try {
+(void)f(new A, new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:13: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception; order of these allocations is undefined [
+(void)f(f(new A, new B));
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:15: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+int X = f(new A, new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:15: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+X = f(new A, new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:11: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+X = 1 + f(new A, new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:15: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+
+(void)f(g(new A), new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:15: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+
+(void)f(1 + f(new A), new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:19: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+(void)f(XA = new A, new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:18: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+(void)f(1 + f(new A), XB = new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:19: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+  }
+  catch (std::exception) {}
+}
+
+void test_operator(G *G1) {
+  (void)(f(new A) + f(new B));
+  try {
+(void)(f(new A) + f(new B));
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:14: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+(void)f(f(new A) + f(new B));
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:15: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+int X = f(new A) + f(new B);
+ // CHECK-MESSAGES-ALL: :[[@LINE-1]]:15: warning: memory allocation may leak if an other allocation is sequenced after it and throws an exception;
+X = f(new A) + f(new B);
+ // CHECK-MESSAGES-ALL:

[clang-tools-extra] 7b7a6b6 - Revert "[clang-tidy] Add check bugprone-multiple-new-in-one-expression."

2023-05-02 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2023-05-02T11:23:31+02:00
New Revision: 7b7a6b641afdb9cae4ca1bb033ad65ee8177c9cb

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

LOG: Revert "[clang-tidy] Add check bugprone-multiple-new-in-one-expression."

This reverts commit 1aa36da15369678d94add0f64809b11f95795efd.

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone/multiple-new-in-one-expression.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone/multiple-new-in-one-expression.cpp



diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 5e9c7d0add4f8..60666287cf307 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -36,7 +36,6 @@
 #include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
-#include "MultipleNewInOneExpressionCheck.h"
 #include "MultipleStatementMacroCheck.h"
 #include "NoEscapeCheck.h"
 #include "NonZeroEnumToBoolConversionCheck.h"
@@ -134,8 +133,6 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-misplaced-widening-cast");
 CheckFactories.registerCheck(
 "bugprone-move-forwarding-reference");
-CheckFactories.registerCheck(
-"bugprone-multiple-new-in-one-expression");
 CheckFactories.registerCheck(
 "bugprone-multiple-statement-macro");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index e70d1b426a1c6..5af5a59e5340f 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -31,7 +31,6 @@ add_clang_library(clangTidyBugproneModule
   MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
-  MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
   NoEscapeCheck.cpp
   NonZeroEnumToBoolConversionCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
deleted file mode 100644
index 47b9667859903..0
--- a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
+++ /dev/null
@@ -1,162 +0,0 @@
-//===--- MultipleNewInOneExpressionCheck.cpp - 
clang-tidy--===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "MultipleNewInOneExpressionCheck.h"
-#include "clang/AST/ASTContext.h"
-#include "clang/ASTMatchers/ASTMatchFinder.h"
-#include "clang/Lex/Lexer.h"
-
-using namespace clang::ast_matchers;
-using namespace clang;
-
-namespace {
-
-// Determine if the result of an expression is "stored" in some way.
-// It is true if the value is stored into a variable or used as initialization
-// or passed to a function or constructor.
-// For this use case compound assignments are not counted as a "store" (the 'E'
-// expression should have pointer type).
-bool isExprValueStored(const Expr *E, ASTContext &C) {
-  E = E->IgnoreParenCasts();
-  // Get first non-paren, non-cast parent.
-  ParentMapContext &PMap = C.getParentMapContext();
-  DynTypedNodeList P = PMap.getParents(*E);
-  if (P.size() != 1)
-return false;
-  const Expr *ParentE;
-  while ((ParentE = P[0].get()) && ParentE->IgnoreParenCasts() == E) {
-P = PMap.getParents(P[0]);
-if (P.size() != 1)
-  return false;
-  }
-
-  if (const auto *ParentVarD = P[0].get())
-return ParentVarD->getInit()->IgnoreParenCasts() == E;
-
-  if (!ParentE)
-return false;
-
-  if (const auto *BinOp = dyn_cast(ParentE))
-return BinOp->getOpcode() == BO_Assign &&
-   BinOp->getRHS()->IgnoreParenCasts() == E;
-
-  return isa(ParentE);
-}
-
-} // namespace
-
-namespace clang {
-namespace tidy {
-namespace bugprone {
-
-AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
-  ast_matchers::internal::Matcher, InnerMatcher) {
-  for (unsigned NH = N

[clang] 87ae746 - [clang-repl] Add a test coverage for nested out-of-line dtor disambiguation.

2023-05-02 Thread Vassil Vassilev via cfe-commits

Author: Vassil Vassilev
Date: 2023-05-02T09:39:48Z
New Revision: 87ae74692456f5ef72dadff508af99371ddc1135

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

LOG: [clang-repl] Add a test coverage for nested out-of-line dtor 
disambiguation.

This came up as a review comment in https://reviews.llvm.org/D148425

Added: 


Modified: 
clang/test/Interpreter/disambiguate-decl-stmt.cpp

Removed: 




diff  --git a/clang/test/Interpreter/disambiguate-decl-stmt.cpp 
b/clang/test/Interpreter/disambiguate-decl-stmt.cpp
index 8f8a2a91b0b35..6f97310475980 100644
--- a/clang/test/Interpreter/disambiguate-decl-stmt.cpp
+++ b/clang/test/Interpreter/disambiguate-decl-stmt.cpp
@@ -30,6 +30,9 @@ struct Dtor1 {~Dtor1();};
 Dtor1::~Dtor1() { printf("Dtor1\n"); }
 Dtor1 d1;
 
+struct ANestedDtor { struct A1 { struct A2 { ~A2(); }; }; };
+ANestedDtor::A1::A2::~A2() { printf("Dtor A::A1::A2::~A2\n"); }
+
 // Ctors
 
 // Deduction guide



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


[PATCH] D148425: [clang-repl] Correctly disambiguate dtor declarations from statements

2023-05-02 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev marked an inline comment as done.
v.g.vassilev added inline comments.



Comment at: clang/lib/Parse/ParseTentative.cpp:91
 return true;
-  case tok::annot_cxxscope: // Check if this is a dtor.
-if (NextToken().is(tok::tilde))

aaron.ballman wrote:
> Are you sure you can remove this? Wouldn't this be used for a case like:
> ```
> struct Foo {
>   struct Bar {
> struct Baz {
>   ~Baz();
> };
>   };
> };
> 
> Foo::Bar::Baz::~Baz() {}
> ```
> (I could be reading the code wrong, but I thought we had a reason to check 
> for `annot_cxxscope` -- seems we missed test coverage for it!)
It looks like we do not need the `annot_cxxscope` as it seems it was processed 
above (likely one of the recent additions such as 
`ParseOptionalCXXScopeSpecifier`). I added a test case for the case you 
proposed in rG87ae74692456


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148425

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


[PATCH] D132819: [RISCV] Add MC support of RISCV zcmp Extension

2023-05-02 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 518662.
VincentWu marked 12 inline comments as done.
VincentWu added a comment.

address comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132819

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVBaseInfo.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.cpp
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVInstPrinter.h
  llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVRegisterInfo.td
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmp-invalid.s
  llvm/test/MC/RISCV/rv32zcmp-valid.s
  llvm/test/MC/RISCV/rv64zcmp-invalid.s
  llvm/test/MC/RISCV/rv64zcmp-valid.s

Index: llvm/test/MC/RISCV/rv64zcmp-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmp-valid.s
@@ -0,0 +1,149 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=experimental-zcmp -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=experimental-zcmp < %s \
+# RUN: | llvm-objdump --mattr=-c,experimental-zcmp -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.mvsa01 s1, s0
+# CHECK-ASM: encoding: [0xa2,0xac]
+cm.mvsa01 s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.mva01s s1, s0
+# CHECK-ASM: encoding: [0xe2,0xac]
+cm.mva01s s1, s0
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbe]
+cm.popret {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbe]
+cm.popret {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbe]
+cm.popret {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbe]
+cm.popret {ra,s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbe]
+cm.popret {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbe]
+cm.popret {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbe]
+cm.popret {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbe]
+cm.popret {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popret   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbe]
+cm.popret {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xbc]
+cm.popretz {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xbc]
+cm.popretz {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0}, 64
+# CHECK-ASM: encoding: [0x5e,0xbc]
+cm.popretz {ra, s0}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xbc]
+cm.popretz {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xbc]
+cm.popretz {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s3}, 64
+# CHECK-ASM: encoding: [0x86,0xbc]
+cm.popretz {ra, s0-s3}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xbc]
+cm.popretz {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xbc]
+cm.popretz {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.popretz   {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xbc]
+cm.popretz {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 16
+# CHECK-ASM: encoding: [0x42,0xba]
+cm.pop {ra}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra}, 32
+# CHECK-ASM: encoding: [0x46,0xba]
+cm.pop {ra}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0}, 16
+# CHECK-ASM: encoding: [0x52,0xba]
+cm.pop {ra, s0}, 16
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s1}, 32
+# CHECK-ASM: encoding: [0x62,0xba]
+cm.pop {ra, s0-s1}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s2}, 32
+# CHECK-ASM: encoding: [0x72,0xba]
+cm.pop {ra, s0-s2}, 32
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s5}, 64
+# CHECK-ASM: encoding: [0xa2,0xba]
+cm.pop {ra, s0-s5}, 64
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s7}, 80
+# CHECK-ASM: encoding: [0xc2,0xba]
+cm.pop {ra, s0-s7}, 80
+
+# CHECK-ASM-AND-OBJ: cm.pop  {ra, s0-s11}, 112
+# CHECK-ASM: encoding: [0xf2,0xba]
+cm.pop {ra, s0-s11}, 112
+
+# CHECK-ASM-AND-OBJ: cm.push {ra}, -16
+# CHECK-ASM: encoding: [0x42,0xb8]
+cm.push {ra}, -16
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0}, -32
+# CHECK-ASM: encoding: [0x56,0xb8]
+cm.push {ra, s0}, -32
+
+# CHECK-ASM-AND-OBJ: cm.push {ra, s0-s1}, -32
+# CHECK-A

[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Kinuko Yasuda via Phabricator via cfe-commits
kinu created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
kinu requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It looks like keeping this false could end up with extra iterations
on a lot of loops that aren't real ones (e.g. they could be a
do-while-false for macros).

This patch changes the default for
CFG::BuildOptions.PruneTriviallyFalseEdges to true to avoid it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149640

Files:
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp


Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -70,7 +70,7 @@
 llvm::Expected
 ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) {
   CFG::BuildOptions Options;
-  Options.PruneTriviallyFalseEdges = false;
+  Options.PruneTriviallyFalseEdges = true;
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
   Options.AddInitializers = true;


Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -70,7 +70,7 @@
 llvm::Expected
 ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) {
   CFG::BuildOptions Options;
-  Options.PruneTriviallyFalseEdges = false;
+  Options.PruneTriviallyFalseEdges = true;
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
   Options.AddInitializers = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

Is it testable? For example, can we show that we don't compute the program 
state for the program point "p" here:

  void f() {
while (true) {
}
/*p*/
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149640

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


[PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs

2023-05-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, shafik.
Herald added a reviewer: bollu.
Herald added subscribers: bviyer, Moerafaat, zero9178, bzcheeseman, ayermolo, 
sdasgup3, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, thopre.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added projects: Flang, All.
tbaeder requested review of this revision.
Herald added subscribers: cfe-commits, llvm-commits, openmp-commits, 
lldb-commits, yota9, stephenneuendorffer, nicolasvasilache, jdoerfert.
Herald added projects: clang, LLDB, OpenMP, MLIR, LLVM, clang-tools-extra.

I think they are pretty useless and make the docs harder to read.

Set the `COLLABORATION_GRAPH`, `INCLUDE_GRAPH` and `INCLUDED_BY_GRAPH` 
variables all to `NO`.

The changes are similar to the ones done in 
https://github.com/googleapis/google-cloud-cpp/pull/397, but I did not remove 
the class graph, I think that one is actually helpful.

Not sure who to add as reviewers (none of the codeowners files seem to mention 
a owner for docs...), so adding some frontend people.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149641

Files:
  bolt/docs/doxygen.cfg.in
  clang-tools-extra/docs/doxygen.cfg.in
  clang/docs/doxygen.cfg.in
  flang/docs/doxygen.cfg.in
  lldb/docs/doxygen.cfg.in
  llvm/docs/doxygen.cfg.in
  mlir/docs/doxygen.cfg.in
  openmp/docs/doxygen.cfg.in
  openmp/runtime/doc/doxygen/config
  polly/docs/doxygen.cfg.in

Index: polly/docs/doxygen.cfg.in
===
--- polly/docs/doxygen.cfg.in
+++ polly/docs/doxygen.cfg.in
@@ -2103,7 +2103,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-COLLABORATION_GRAPH= YES
+COLLABORATION_GRAPH= NO
 
 # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
 # groups, showing the direct groups dependencies.
@@ -2148,7 +2148,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-INCLUDE_GRAPH  = YES
+INCLUDE_GRAPH  = NO
 
 # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
 # set to YES then doxygen will generate a graph for each documented file showing
@@ -2157,7 +2157,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-INCLUDED_BY_GRAPH  = YES
+INCLUDED_BY_GRAPH  = NO
 
 # If the CALL_GRAPH tag is set to YES then doxygen will generate a call
 # dependency graph for every global function or class method.
Index: openmp/runtime/doc/doxygen/config
===
--- openmp/runtime/doc/doxygen/config
+++ openmp/runtime/doc/doxygen/config
@@ -1671,7 +1671,7 @@
 # indirect implementation dependencies (inheritance, containment, and
 # class references variables) of the class with other documented classes.
 
-COLLABORATION_GRAPH= YES
+COLLABORATION_GRAPH= NO
 
 # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen
 # will generate a graph for groups, showing the direct groups dependencies
@@ -1703,14 +1703,14 @@
 # file showing the direct and indirect include dependencies of the file with
 # other documented files.
 
-INCLUDE_GRAPH  = YES
+INCLUDE_GRAPH  = NO
 
 # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and
 # HAVE_DOT tags are set to YES then doxygen will generate a graph for each
 # documented header file showing the documented files that directly or
 # indirectly include this file.
 
-INCLUDED_BY_GRAPH  = YES
+INCLUDED_BY_GRAPH  = NO
 
 # If the CALL_GRAPH and HAVE_DOT options are set to YES then
 # doxygen will generate a call dependency graph for every global function
Index: openmp/docs/doxygen.cfg.in
===
--- openmp/docs/doxygen.cfg.in
+++ openmp/docs/doxygen.cfg.in
@@ -2091,7 +2091,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-COLLABORATION_GRAPH= YES
+COLLABORATION_GRAPH= NO
 
 # If the GROUP_GRAPHS tag is set to YES then doxygen will generate a graph for
 # groups, showing the direct groups dependencies.
@@ -2136,7 +2136,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-INCLUDE_GRAPH  = YES
+INCLUDE_GRAPH  = NO
 
 # If the INCLUDED_BY_GRAPH, ENABLE_PREPROCESSING and SEARCH_INCLUDES tags are
 # set to YES then doxygen will generate a graph for each documented file showing
@@ -2145,7 +2145,7 @@
 # The default value is: YES.
 # This tag requires that the tag HAVE_DOT is set to YES.
 
-INCLUDED_BY_GRAPH  = YES
+INCLUDED_BY_GRAPH  = NO
 
 # If the CALL_GRAPH tag is set to YES then doxygen wil

[PATCH] D149643: Correctly limit formatted ranges when specifying qualifier alignment

2023-05-02 Thread Colin Ogilvie via Phabricator via cfe-commits
cogilvie created this revision.
cogilvie added reviewers: MyDeveloperDay, rymiel, HazardyKnusperkeks, owenpan.
cogilvie added a project: clang-format.
Herald added projects: All, clang.
cogilvie requested review of this revision.

The qualifier alignment fixer appeared to ignore any ranges specified for 
limiting formatting.
This change ensures that it only formats affected lines to avoid unexpected 
changes as reported by:
https://github.com/llvm/llvm-project/issues/54888


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149643

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
@@ -1343,6 +1343,31 @@
"TemplateType t;", Style);
 }
 
+TEST_F(QualifierFixerTest, Ranges) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"const", "volatile", "type"};
+
+  // Only the first line should be formatted the second should remain as is
+  EXPECT_EQ("template  const Foo f();\n"
+"template  Foo const f();",
+format("template  Foo const f();\n"
+   "template  Foo const f();",
+   Style, SC_ExpectComplete,
+   std::vector(1, tooling::Range(0, 36;
+
+  // Only the middle line should be formatted the first and last should remain
+  // as is
+  EXPECT_EQ("template  Foo const f();\n"
+"template  const Foo f();\n"
+"template  Foo const f();",
+format("template  Foo const f();\n"
+   "template  Foo const f();\n"
+   "template  Foo const f();",
+   Style, SC_ExpectComplete,
+   std::vector(1, tooling::Range(37, 36;
+}
+
 } // namespace
 } // namespace test
 } // namespace format
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -587,7 +587,7 @@
   assert(QualifierToken != tok::identifier && "Unrecognised Qualifier");
 
   for (AnnotatedLine *Line : AnnotatedLines) {
-if (Line->InPPDirective)
+if (!Line->Affected || Line->InPPDirective)
   continue;
 FormatToken *First = Line->First;
 assert(First);


Index: clang/unittests/Format/QualifierFixerTest.cpp
===
--- clang/unittests/Format/QualifierFixerTest.cpp
+++ clang/unittests/Format/QualifierFixerTest.cpp
@@ -1343,6 +1343,31 @@
"TemplateType t;", Style);
 }
 
+TEST_F(QualifierFixerTest, Ranges) {
+  FormatStyle Style = getLLVMStyle();
+  Style.QualifierAlignment = FormatStyle::QAS_Custom;
+  Style.QualifierOrder = {"const", "volatile", "type"};
+
+  // Only the first line should be formatted the second should remain as is
+  EXPECT_EQ("template  const Foo f();\n"
+"template  Foo const f();",
+format("template  Foo const f();\n"
+   "template  Foo const f();",
+   Style, SC_ExpectComplete,
+   std::vector(1, tooling::Range(0, 36;
+
+  // Only the middle line should be formatted the first and last should remain
+  // as is
+  EXPECT_EQ("template  Foo const f();\n"
+"template  const Foo f();\n"
+"template  Foo const f();",
+format("template  Foo const f();\n"
+   "template  Foo const f();\n"
+   "template  Foo const f();",
+   Style, SC_ExpectComplete,
+   std::vector(1, tooling::Range(37, 36;
+}
+
 } // namespace
 } // namespace test
 } // namespace format
Index: clang/lib/Format/QualifierAlignmentFixer.cpp
===
--- clang/lib/Format/QualifierAlignmentFixer.cpp
+++ clang/lib/Format/QualifierAlignmentFixer.cpp
@@ -587,7 +587,7 @@
   assert(QualifierToken != tok::identifier && "Unrecognised Qualifier");
 
   for (AnnotatedLine *Line : AnnotatedLines) {
-if (Line->InPPDirective)
+if (!Line->Affected || Line->InPPDirective)
   continue;
 FormatToken *First = Line->First;
 assert(First);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 852bf52 - [clang-tidy] Add check bugprone-multiple-new-in-one-expression.

2023-05-02 Thread Balázs Kéri via cfe-commits

Author: Balázs Kéri
Date: 2023-05-02T12:29:17+02:00
New Revision: 852bf52cc957dc9a14c425e9f22969338d84b178

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

LOG: [clang-tidy] Add check bugprone-multiple-new-in-one-expression.

Reviewed By: donat.nagy
Fixed test failures with previous commit.

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

Added: 
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone/multiple-new-in-one-expression.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone/multiple-new-in-one-expression.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 60666287cf307..5e9c7d0add4f8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -36,6 +36,7 @@
 #include "MisplacedPointerArithmeticInAllocCheck.h"
 #include "MisplacedWideningCastCheck.h"
 #include "MoveForwardingReferenceCheck.h"
+#include "MultipleNewInOneExpressionCheck.h"
 #include "MultipleStatementMacroCheck.h"
 #include "NoEscapeCheck.h"
 #include "NonZeroEnumToBoolConversionCheck.h"
@@ -133,6 +134,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-misplaced-widening-cast");
 CheckFactories.registerCheck(
 "bugprone-move-forwarding-reference");
+CheckFactories.registerCheck(
+"bugprone-multiple-new-in-one-expression");
 CheckFactories.registerCheck(
 "bugprone-multiple-statement-macro");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 5af5a59e5340f..e70d1b426a1c6 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -31,6 +31,7 @@ add_clang_library(clangTidyBugproneModule
   MisplacedPointerArithmeticInAllocCheck.cpp
   MisplacedWideningCastCheck.cpp
   MoveForwardingReferenceCheck.cpp
+  MultipleNewInOneExpressionCheck.cpp
   MultipleStatementMacroCheck.cpp
   NoEscapeCheck.cpp
   NonZeroEnumToBoolConversionCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
new file mode 100644
index 0..47b9667859903
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/MultipleNewInOneExpressionCheck.cpp
@@ -0,0 +1,162 @@
+//===--- MultipleNewInOneExpressionCheck.cpp - 
clang-tidy--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "MultipleNewInOneExpressionCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+using namespace clang;
+
+namespace {
+
+// Determine if the result of an expression is "stored" in some way.
+// It is true if the value is stored into a variable or used as initialization
+// or passed to a function or constructor.
+// For this use case compound assignments are not counted as a "store" (the 'E'
+// expression should have pointer type).
+bool isExprValueStored(const Expr *E, ASTContext &C) {
+  E = E->IgnoreParenCasts();
+  // Get first non-paren, non-cast parent.
+  ParentMapContext &PMap = C.getParentMapContext();
+  DynTypedNodeList P = PMap.getParents(*E);
+  if (P.size() != 1)
+return false;
+  const Expr *ParentE;
+  while ((ParentE = P[0].get()) && ParentE->IgnoreParenCasts() == E) {
+P = PMap.getParents(P[0]);
+if (P.size() != 1)
+  return false;
+  }
+
+  if (const auto *ParentVarD = P[0].get())
+return ParentVarD->getInit()->IgnoreParenCasts() == E;
+
+  if (!ParentE)
+return false;
+
+  if (const auto *BinOp = dyn_cast(ParentE))
+return BinOp->getOpcode() == BO_Assign &&
+   BinOp->getRHS()->IgnoreParenCasts() == E;
+
+  return isa(ParentE);
+}
+
+} // namespace
+
+namespace clang {
+namespace tidy {
+namespace bugprone {
+
+AST_MATCHER_P(CXXTryStmt, hasHandlerFor,
+  ast_matchers::internal::

[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Kinuko Yasuda via Phabricator via cfe-commits
kinu updated this revision to Diff 518676.
kinu added a comment.

Add a while-true test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149640

Files:
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5271,4 +5271,22 @@
   });
 }
 
+TEST(TransferTest, UnreachedAfterWhileTrue) {
+  // PruneTriviallyFalseEdges should have pruned the unreached node.
+  std::string Code = R"(
+void target() {
+  while (true) {}
+  (void)0;
+  /*[[p]]*/
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_TRUE(Results.empty());
+  });
+}
+
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -70,7 +70,7 @@
 llvm::Expected
 ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) {
   CFG::BuildOptions Options;
-  Options.PruneTriviallyFalseEdges = false;
+  Options.PruneTriviallyFalseEdges = true;
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
   Options.AddInitializers = true;


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5271,4 +5271,22 @@
   });
 }
 
+TEST(TransferTest, UnreachedAfterWhileTrue) {
+  // PruneTriviallyFalseEdges should have pruned the unreached node.
+  std::string Code = R"(
+void target() {
+  while (true) {}
+  (void)0;
+  /*[[p]]*/
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+ASSERT_TRUE(Results.empty());
+  });
+}
+
+
 } // namespace
Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -70,7 +70,7 @@
 llvm::Expected
 ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) {
   CFG::BuildOptions Options;
-  Options.PruneTriviallyFalseEdges = false;
+  Options.PruneTriviallyFalseEdges = true;
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
   Options.AddInitializers = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Kinuko Yasuda via Phabricator via cfe-commits
kinu added a comment.

In D149640#4311889 , @gribozavr2 
wrote:

> Is it testable? For example, can we show that we don't compute the program 
> state for the program point "p" here:

I added a simple test, how does it look?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149640

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


[PATCH] D147217: [OpenMP][OMPIRBuilder] OpenMPIRBuilder support for requires directive

2023-05-02 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak updated this revision to Diff 518677.
skatrak edited the summary of this revision.
skatrak added a comment.
Herald added subscribers: bviyer, Moerafaat, zero9178, awarzynski, sdasgup3, 
wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, jurahul, 
Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, csigg, 
nicolasvasilache, antiagainst, shauheen, mehdi_amini, thopre.
Herald added a reviewer: ftynse.
Herald added a project: MLIR.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147217

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/lib/Target/LLVMIR/ModuleTranslation.cpp

Index: mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
===
--- mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
+++ mlir/lib/Target/LLVMIR/ModuleTranslation.cpp
@@ -1269,8 +1269,11 @@
 // TODO: set the flags when available
 llvm::OpenMPIRBuilderConfig Config(
 isDevice, /* IsTargetCodegen */ false,
+/* OpenMPOffloadMandatory */ false,
+/* HasRequiresReverseOffload */ false,
+/* HasRequiresUnifiedAddress */ false,
 /* HasRequiresUnifiedSharedMemory */ false,
-/* OpenMPOffloadMandatory */ false);
+/* HasRequiresDynamicAllocators */ false);
 ompBuilder->setConfig(Config);
   }
   return ompBuilder.get();
Index: llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
===
--- llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -9,12 +9,14 @@
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/IR/BasicBlock.h"
+#include "llvm/IR/Constants.h"
 #include "llvm/IR/DIBuilder.h"
 #include "llvm/IR/Function.h"
 #include "llvm/IR/InstIterator.h"
 #include "llvm/IR/Instructions.h"
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/Type.h"
 #include "llvm/IR/Verifier.h"
 #include "llvm/Passes/PassBuilder.h"
 #include "llvm/Support/Casting.h"
@@ -5123,7 +5125,7 @@
   using InsertPointTy = OpenMPIRBuilder::InsertPointTy;
   OpenMPIRBuilder OMPBuilder(*M);
   OMPBuilder.initialize();
-  OpenMPIRBuilderConfig Config(false, false, false, false);
+  OpenMPIRBuilderConfig Config(false, false, false, false, false, false, false);
   OMPBuilder.setConfig(Config);
   F->setName("func");
   IRBuilder<> Builder(BB);
@@ -5751,7 +5753,8 @@
 
 TEST_F(OpenMPIRBuilderTest, OffloadEntriesInfoManager) {
   OpenMPIRBuilder OMPBuilder(*M);
-  OMPBuilder.setConfig(OpenMPIRBuilderConfig(true, false, false, false));
+  OMPBuilder.setConfig(
+  OpenMPIRBuilderConfig(true, false, false, false, false, false, false));
   OffloadEntriesInfoManager &InfoManager = OMPBuilder.OffloadInfoManager;
   TargetRegionEntryInfo EntryInfo("parent", 1, 2, 4, 0);
   InfoManager.initializeTargetRegionEntryInfo(EntryInfo, 0);
@@ -5766,4 +5769,44 @@
   GlobalValue::WeakAnyLinkage);
   EXPECT_TRUE(InfoManager.hasDeviceGlobalVarEntryInfo("gvar"));
 }
+
+TEST_F(OpenMPIRBuilderTest, CreateRegisterRequires) {
+  OpenMPIRBuilder OMPBuilder(*M);
+  OMPBuilder.initialize();
+
+  OMPBuilder.setConfig(
+  OpenMPIRBuilderConfig(/*IsEmbedded=*/false,
+/*IsTargetCodegen=*/false,
+/*OpenMPOffloadMandatory=*/false,
+/*HasRequiresReverseOffload=*/true,
+/*HasRequiresUnifiedAddress=*/false,
+/*HasRequiresUnifiedSharedMemory=*/true,
+/*HasRequiresDynamicAllocators=*/false));
+
+  auto FName =
+  OMPBuilder.createPlatformSpecificName({"omp_offloading", "requires_reg"});
+  EXPECT_EQ(FName, ".omp_offloading.requires_reg");
+
+  Function *Fn = OMPBuilder.createRegisterRequires(FName);
+  EXPECT_NE(Fn, nullptr);
+  EXPECT_EQ(FName, Fn->getName());
+
+  EXPECT_EQ(Fn->getSection(), ".text.startup");
+  EXPECT_TRUE(Fn->hasInternalLinkage());
+  EXPECT_TRUE(Fn->hasFnAttribute(Attribute::NoInline));
+  EXPECT_TRUE(Fn->hasFnAttribute(Attribute::NoUnwind));
+  EXPECT_EQ(Fn->size(), 1u);
+
+  BasicBlock *Entry = &Fn->getEntryBlock();
+  EXPECT_FALSE(Entry->empty());
+  EXPECT_EQ(Fn->getReturnType()->getTypeID(), Type::VoidTyID);
+
+  CallInst *Call = &cast(*Entry->begin());
+  EXPECT_EQ(Call->getCalledFunction()->getName(), "__tgt_register_requires");
+  EXPECT_EQ(Call->getNumOperands(), 2u);
+
+  Value *Flags = Call->getArgOperand(0);
+  EXPECT_EQ(cast(Flags)->getSExtValue(),
+OMPBuilder.Config.getRequiresFlags());
+}
 } // namespace
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
=

[PATCH] D148822: [clang][BFloat] Avoid redefining bfloat16_t in arm_neon.h

2023-05-02 Thread Simon Butcher via Phabricator via cfe-commits
simonbutcher accepted this revision.
simonbutcher added a comment.

> we definitely use -Wsystem-headers.

Fair enough, that hadn't occurred to me. The change LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148822

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


[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added a comment.

In D149640#4311963 , @kinu wrote:

> In D149640#4311889 , @gribozavr2 
> wrote:
>
>> Is it testable? For example, can we show that we don't compute the program 
>> state for the program point "p" here:
>
> I added a simple test, how does it look?

Do we even need to add a new test for this?

This change breaks the existing test `TransferTest.VarDeclInDoWhile`, which 
tests essentially the same scenario, so it's probably sufficient to just update 
that test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149640

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


[clang] 2cdb6b8 - [clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.

2023-05-02 Thread Yitzhak Mandelbaum via cfe-commits

Author: Samira Bazuzi
Date: 2023-05-02T11:32:19Z
New Revision: 2cdb6b84c157b5fe9c1e3540e7362beef2a7d8e6

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

LOG: [clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.

This will eliminate the need for more pass-through APIs. Also replace 
pass-through usages with this exposure.

Reviewed By: ymandel, gribozavr2, xazax.hun

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

Added: 


Modified: 
clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h 
b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
index 8690616411db9..9c027ef4552ee 100644
--- a/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
+++ b/clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
@@ -27,6 +27,7 @@
 #include "clang/Analysis/FlowSensitive/Value.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
+#include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include 
 #include 
@@ -178,12 +179,16 @@ class Environment {
   /// with a symbolic representation of the `this` pointee.
   Environment(DataflowAnalysisContext &DACtx, const DeclContext &DeclCtx);
 
+  LLVM_DEPRECATED("Use getDataflowAnalysisContext().getOptions() instead.", "")
   const DataflowAnalysisContext::Options &getAnalysisOptions() const {
 return DACtx->getOptions();
   }
 
+  LLVM_DEPRECATED("Use getDataflowAnalysisContext().arena() instead.", "")
   Arena &arena() const { return DACtx->arena(); }
 
+  LLVM_DEPRECATED("Use getDataflowAnalysisContext().getOptions().Log instead.",
+  "")
   Logger &logger() const { return *DACtx->getOptions().Log; }
 
   /// Creates and returns an environment to use for an inline analysis  of the
@@ -331,23 +336,23 @@ class Environment {
   template 
   std::enable_if_t::value, T &>
   create(Args &&...args) {
-return arena().create(std::forward(args)...);
+return DACtx->arena().create(std::forward(args)...);
   }
 
   /// Returns a symbolic boolean value that models a boolean literal equal to
   /// `Value`
   AtomicBoolValue &getBoolLiteralValue(bool Value) const {
-return arena().makeLiteral(Value);
+return DACtx->arena().makeLiteral(Value);
   }
 
   /// Returns an atomic boolean value.
   BoolValue &makeAtomicBoolValue() const {
-return arena().create();
+return DACtx->arena().create();
   }
 
   /// Returns a unique instance of boolean Top.
   BoolValue &makeTopBoolValue() const {
-return arena().create();
+return DACtx->arena().create();
   }
 
   /// Returns a boolean value that represents the conjunction of `LHS` and
@@ -355,7 +360,7 @@ class Environment {
   /// order, will return the same result. If the given boolean values represent
   /// the same value, the result will be the value itself.
   BoolValue &makeAnd(BoolValue &LHS, BoolValue &RHS) const {
-return arena().makeAnd(LHS, RHS);
+return DACtx->arena().makeAnd(LHS, RHS);
   }
 
   /// Returns a boolean value that represents the disjunction of `LHS` and
@@ -363,13 +368,13 @@ class Environment {
   /// order, will return the same result. If the given boolean values represent
   /// the same value, the result will be the value itself.
   BoolValue &makeOr(BoolValue &LHS, BoolValue &RHS) const {
-return arena().makeOr(LHS, RHS);
+return DACtx->arena().makeOr(LHS, RHS);
   }
 
   /// Returns a boolean value that represents the negation of `Val`. Subsequent
   /// calls with the same argument will return the same result.
   BoolValue &makeNot(BoolValue &Val) const {
-return arena().makeNot(Val);
+return DACtx->arena().makeNot(Val);
   }
 
   /// Returns a boolean value represents `LHS` => `RHS`. Subsequent calls with
@@ -377,7 +382,7 @@ class Environment {
   /// values represent the same value, the result will be a value that
   /// represents the true boolean literal.
   BoolValue &makeImplication(BoolValue &LHS, BoolValue &RHS) const {
-return arena().makeImplies(LHS, RHS);
+return DACtx->arena().makeImplies(LHS, RHS);
   }
 
   /// Returns a boolean value represents `LHS` <=> `RHS`. Subsequent calls with
@@ -385,7 +390,7 @@ class Environment {
   /// result. If the given boolean values represent the same value, the result
   /// will be a value that represents the true boolean literal.
   BoolValue &makeIff(BoolValue &LHS,

[PATCH] D149464: [clang][dataflow] Expose DataflowAnalysisContext from DataflowEnvironment.

2023-05-02 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2cdb6b84c157: [clang][dataflow] Expose 
DataflowAnalysisContext from DataflowEnvironment. (authored by bazuzi, 
committed by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149464

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -53,9 +53,10 @@
   [UseBuiltinModel = Options.BuiltinOpts.has_value()](ASTContext &C,
   Environment &Env) {
 return NoopAnalysis(
-C, DataflowAnalysisOptions{UseBuiltinModel
-   ? Env.getAnalysisOptions()
-   : std::optional()});
+C,
+DataflowAnalysisOptions{
+UseBuiltinModel ? Env.getDataflowAnalysisContext().getOptions()
+: std::optional()});
   });
   AI.ASTBuildArgs = ASTBuildArgs;
   if (Options.BuiltinOpts)
Index: clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/LoggerTest.cpp
@@ -37,14 +37,16 @@
 
   static TestLattice initialElement() { return TestLattice{}; }
   void transfer(const CFGElement &, TestLattice &L, Environment &E) {
-E.logger().log([](llvm::raw_ostream &OS) { OS << "transfer()"; });
+E.getDataflowAnalysisContext().getOptions().Log->log(
+[](llvm::raw_ostream &OS) { OS << "transfer()"; });
 ++L.Elements;
   }
   void transferBranch(bool Branch, const Stmt *S, TestLattice &L,
   Environment &E) {
-E.logger().log([&](llvm::raw_ostream &OS) {
-  OS << "transferBranch(" << Branch << ")";
-});
+E.getDataflowAnalysisContext().getOptions().Log->log(
+[&](llvm::raw_ostream &OS) {
+  OS << "transferBranch(" << Branch << ")";
+});
 ++L.Branches;
   }
 };
Index: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
===
--- clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
+++ clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
@@ -168,7 +168,8 @@
   llvm::ArrayRef>
   BlockStates)
   : CFCtx(CFCtx), Analysis(Analysis), InitEnv(InitEnv),
-Log(InitEnv.logger()), BlockStates(BlockStates) {
+Log(*InitEnv.getDataflowAnalysisContext().getOptions().Log),
+BlockStates(BlockStates) {
 Log.beginAnalysis(CFCtx, Analysis);
   }
   ~AnalysisContext() { Log.endAnalysis(); }
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -496,7 +496,7 @@
   }
 
   void VisitReturnStmt(const ReturnStmt *S) {
-if (!Env.getAnalysisOptions().ContextSensitiveOpts)
+if (!Env.getDataflowAnalysisContext().getOptions().ContextSensitiveOpts)
   return;
 
 auto *Ret = S->getRetValue();
@@ -863,12 +863,13 @@
   // `F` of `S`. The type `E` must be either `CallExpr` or `CXXConstructExpr`.
   template 
   void transferInlineCall(const E *S, const FunctionDecl *F) {
-const auto &Options = Env.getAnalysisOptions();
+const auto &Options = Env.getDataflowAnalysisContext().getOptions();
 if (!(Options.ContextSensitiveOpts &&
   Env.canDescend(Options.ContextSensitiveOpts->Depth, F)))
   return;
 
-const ControlFlowContext *CFCtx = Env.getControlFlowContext(F);
+const ControlFlowContext *CFCtx =
+Env.getDataflowAnalysisContext().getControlFlowContext(F);
 if (!CFCtx)
   return;
 
Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -381,7 +381,7 @@
 
 QualType ParamType = Param->getType();
 if (ParamType->isReferenceType()) {
-  auto &Val = arena().create(*ArgLoc);
+  auto &Val = DACtx->arena().create(*ArgLoc);
   setValue(Loc, Val);
 } else if (auto *ArgVal = getValue(*Ar

[PATCH] D149645: [clang][Interp] Optionally cast comparison result to non-bool

2023-05-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  Our comparison opcodes always produce a Boolean value and push it on the
  stack. However, the result of such a comparison in C is int, so the
  later code expects an integer value on the stack.
  
  Work around this problem by casting the boolean value to int in those
  cases. This is not ideal for C however. The comparison is usually
  wrapped in a IntegerToBool cast anyway.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149645

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/c.c


Index: clang/test/AST/Interp/c.c
===
--- /dev/null
+++ clang/test/AST/Interp/c.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -verify=ref %s
+
+/// expected-no-diagnostics
+/// ref-no-diagnostics
+
+_Static_assert(1, "");
+_Static_assert(0 != 1, "");
+_Static_assert(1.0 == 1.0, "");
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -319,19 +319,29 @@
   if (!visit(LHS) || !visit(RHS))
 return false;
 
+  // For languages such as C, cast the result of one
+  // of our comparision opcodes to T (which is usually int).
+  auto MaybeCastToBool = [this, T, BO](bool Result) {
+if (!Result)
+  return false;
+if (T != PT_Bool)
+  return this->emitCast(PT_Bool, *T, BO);
+return true;
+  };
+
   switch (Op) {
   case BO_EQ:
-return this->emitEQ(*LT, BO);
+return MaybeCastToBool(this->emitEQ(*LT, BO));
   case BO_NE:
-return this->emitNE(*LT, BO);
+return MaybeCastToBool(this->emitNE(*LT, BO));
   case BO_LT:
-return this->emitLT(*LT, BO);
+return MaybeCastToBool(this->emitLT(*LT, BO));
   case BO_LE:
-return this->emitLE(*LT, BO);
+return MaybeCastToBool(this->emitLE(*LT, BO));
   case BO_GT:
-return this->emitGT(*LT, BO);
+return MaybeCastToBool(this->emitGT(*LT, BO));
   case BO_GE:
-return this->emitGE(*LT, BO);
+return MaybeCastToBool(this->emitGE(*LT, BO));
   case BO_Sub:
 if (T == PT_Float)
   return this->emitSubf(getRoundingMode(BO), BO);


Index: clang/test/AST/Interp/c.c
===
--- /dev/null
+++ clang/test/AST/Interp/c.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -verify=ref %s
+
+/// expected-no-diagnostics
+/// ref-no-diagnostics
+
+_Static_assert(1, "");
+_Static_assert(0 != 1, "");
+_Static_assert(1.0 == 1.0, "");
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -319,19 +319,29 @@
   if (!visit(LHS) || !visit(RHS))
 return false;
 
+  // For languages such as C, cast the result of one
+  // of our comparision opcodes to T (which is usually int).
+  auto MaybeCastToBool = [this, T, BO](bool Result) {
+if (!Result)
+  return false;
+if (T != PT_Bool)
+  return this->emitCast(PT_Bool, *T, BO);
+return true;
+  };
+
   switch (Op) {
   case BO_EQ:
-return this->emitEQ(*LT, BO);
+return MaybeCastToBool(this->emitEQ(*LT, BO));
   case BO_NE:
-return this->emitNE(*LT, BO);
+return MaybeCastToBool(this->emitNE(*LT, BO));
   case BO_LT:
-return this->emitLT(*LT, BO);
+return MaybeCastToBool(this->emitLT(*LT, BO));
   case BO_LE:
-return this->emitLE(*LT, BO);
+return MaybeCastToBool(this->emitLE(*LT, BO));
   case BO_GT:
-return this->emitGT(*LT, BO);
+return MaybeCastToBool(this->emitGT(*LT, BO));
   case BO_GE:
-return this->emitGE(*LT, BO);
+return MaybeCastToBool(this->emitGE(*LT, BO));
   case BO_Sub:
 if (T == PT_Float)
   return this->emitSubf(getRoundingMode(BO), BO);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149640

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


[PATCH] D148425: [clang-repl] Correctly disambiguate dtor declarations from statements

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



Comment at: clang/lib/Parse/ParseTentative.cpp:91
 return true;
-  case tok::annot_cxxscope: // Check if this is a dtor.
-if (NextToken().is(tok::tilde))

v.g.vassilev wrote:
> aaron.ballman wrote:
> > Are you sure you can remove this? Wouldn't this be used for a case like:
> > ```
> > struct Foo {
> >   struct Bar {
> > struct Baz {
> >   ~Baz();
> > };
> >   };
> > };
> > 
> > Foo::Bar::Baz::~Baz() {}
> > ```
> > (I could be reading the code wrong, but I thought we had a reason to check 
> > for `annot_cxxscope` -- seems we missed test coverage for it!)
> It looks like we do not need the `annot_cxxscope` as it seems it was 
> processed above (likely one of the recent additions such as 
> `ParseOptionalCXXScopeSpecifier`). I added a test case for the case you 
> proposed in rG87ae74692456
Ah, good to know, and thank you for the additional test case!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148425

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


[PATCH] D147717: [C++20][NFC] Claim full support for consteval again

2023-05-02 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

In D147717#4275410 , @cjdb wrote:

> I'm gonna get started on this today!

@cjdb , how is this going? I've seen 
https://github.com/llvm/llvm-project/issues/62224, but no more issues with 
consteval label.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[clang] 7133283 - [clang] Do not attempt to zero-extend _BitInt(1) when not required

2023-05-02 Thread Mariya Podchishchaeva via cfe-commits

Author: Mariya Podchishchaeva
Date: 2023-05-02T08:23:22-04:00
New Revision: 7133283835fbc260465e899ff86c07202486558a

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

LOG: [clang] Do not attempt to zero-extend _BitInt(1) when not required

`ConvertTypeForMem` doesn't return wider type for _BitInt unless it is
used in a bitfield, so no need to extend when trying to initialize a
global variable.

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

Reviewed By: erichkeane, shafik

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/CodeGen/CGExprConstant.cpp
clang/test/CodeGen/ext-int.c

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 34636faa36bf6..ce3f6351e234d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -337,6 +337,9 @@ Bug Fixes in This Version
   (`#62296 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
   (`#60082` `_)
+- Fix the assertion hit when generating code for global variable initializer of
+  _BitInt(1) type.
+  (`#62207 `_)
 
 Bug Fixes to Compiler Builtins
 ^^

diff  --git a/clang/lib/CodeGen/CGExprConstant.cpp 
b/clang/lib/CodeGen/CGExprConstant.cpp
index 329e1a27d98fc..5d77e513da5eb 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -1730,7 +1730,7 @@ llvm::Constant 
*ConstantEmitter::emitForMemory(CodeGenModule &CGM,
   }
 
   // Zero-extend bool.
-  if (C->getType()->isIntegerTy(1)) {
+  if (C->getType()->isIntegerTy(1) && !destType->isBitIntType()) {
 llvm::Type *boolTy = CGM.getTypes().ConvertTypeForMem(destType);
 return llvm::ConstantExpr::getZExt(C, boolTy);
   }

diff  --git a/clang/test/CodeGen/ext-int.c b/clang/test/CodeGen/ext-int.c
index 8112d9b044a51..4cb399d108f29 100644
--- a/clang/test/CodeGen/ext-int.c
+++ b/clang/test/CodeGen/ext-int.c
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm 
-o - %s | FileCheck %s --check-prefixes=CHECK,LIN32
 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm 
-o - %s | FileCheck %s --check-prefixes=CHECK,WIN32
 
+//GH62207
+unsigned _BitInt(1) GlobSize1 = 0;
+// CHECK: @GlobSize1 = {{.*}}global i1 false
+
 void GenericTest(_BitInt(3) a, unsigned _BitInt(3) b, _BitInt(4) c) {
   // CHECK: define {{.*}}void @GenericTest
   int which = _Generic(a, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 
3);



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


[PATCH] D149436: [clang] Do not attempt to zero-extend _BitInt(1) when not required

2023-05-02 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7133283835fb: [clang] Do not attempt to zero-extend 
_BitInt(1) when not required (authored by Fznamznon).

Changed prior to commit:
  https://reviews.llvm.org/D149436?vs=517863&id=518688#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149436

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/test/CodeGen/ext-int.c


Index: clang/test/CodeGen/ext-int.c
===
--- clang/test/CodeGen/ext-int.c
+++ clang/test/CodeGen/ext-int.c
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm 
-o - %s | FileCheck %s --check-prefixes=CHECK,LIN32
 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm 
-o - %s | FileCheck %s --check-prefixes=CHECK,WIN32
 
+//GH62207
+unsigned _BitInt(1) GlobSize1 = 0;
+// CHECK: @GlobSize1 = {{.*}}global i1 false
+
 void GenericTest(_BitInt(3) a, unsigned _BitInt(3) b, _BitInt(4) c) {
   // CHECK: define {{.*}}void @GenericTest
   int which = _Generic(a, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 
3);
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1730,7 +1730,7 @@
   }
 
   // Zero-extend bool.
-  if (C->getType()->isIntegerTy(1)) {
+  if (C->getType()->isIntegerTy(1) && !destType->isBitIntType()) {
 llvm::Type *boolTy = CGM.getTypes().ConvertTypeForMem(destType);
 return llvm::ConstantExpr::getZExt(C, boolTy);
   }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -337,6 +337,9 @@
   (`#62296 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
   (`#60082` `_)
+- Fix the assertion hit when generating code for global variable initializer of
+  _BitInt(1) type.
+  (`#62207 `_)
 
 Bug Fixes to Compiler Builtins
 ^^


Index: clang/test/CodeGen/ext-int.c
===
--- clang/test/CodeGen/ext-int.c
+++ clang/test/CodeGen/ext-int.c
@@ -3,6 +3,10 @@
 // RUN: %clang_cc1 -triple i386-gnu-linux -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,LIN32
 // RUN: %clang_cc1 -triple i386-windows-pc -O3 -disable-llvm-passes -emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,WIN32
 
+//GH62207
+unsigned _BitInt(1) GlobSize1 = 0;
+// CHECK: @GlobSize1 = {{.*}}global i1 false
+
 void GenericTest(_BitInt(3) a, unsigned _BitInt(3) b, _BitInt(4) c) {
   // CHECK: define {{.*}}void @GenericTest
   int which = _Generic(a, _BitInt(3): 1, unsigned _BitInt(3) : 2, _BitInt(4) : 3);
Index: clang/lib/CodeGen/CGExprConstant.cpp
===
--- clang/lib/CodeGen/CGExprConstant.cpp
+++ clang/lib/CodeGen/CGExprConstant.cpp
@@ -1730,7 +1730,7 @@
   }
 
   // Zero-extend bool.
-  if (C->getType()->isIntegerTy(1)) {
+  if (C->getType()->isIntegerTy(1) && !destType->isBitIntType()) {
 llvm::Type *boolTy = CGM.getTypes().ConvertTypeForMem(destType);
 return llvm::ConstantExpr::getZExt(C, boolTy);
   }
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -337,6 +337,9 @@
   (`#62296 `_)
 - Fix a stack overflow issue when evaluating ``consteval`` default arguments.
   (`#60082` `_)
+- Fix the assertion hit when generating code for global variable initializer of
+  _BitInt(1) type.
+  (`#62207 `_)
 
 Bug Fixes to Compiler Builtins
 ^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148223: [SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8ed9cf06e900: [SiFive][RISCV][clang] Support C intrinsics 
for xsfvcp extension. (authored by Nelson1225, committed by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

Files:
  clang/include/clang/Basic/riscv_sifive_vector.td
  clang/include/clang/Basic/riscv_vector.td
  clang/lib/Sema/SemaChecking.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp-index-out-of-range.c

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


[clang] 4bf846b - [RISCV] Split out part of riscv_vector.td to riscv_vector_common.td

2023-05-02 Thread via cfe-commits

Author: 4vtomat
Date: 2023-05-02T05:40:13-07:00
New Revision: 4bf846ba40f1867889e13596cdcd06ed6f036c7f

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

LOG: [RISCV] Split out part of riscv_vector.td to riscv_vector_common.td

This makes other new targets able to reuse predefined classes
in their own *.td files.

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

Added: 
clang/include/clang/Basic/riscv_vector_common.td

Modified: 
clang/include/clang/Basic/riscv_vector.td

Removed: 




diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index aec204afdccb..f9e9c7d80cca 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -12,233 +12,7 @@
 //
 
//===--===//
 
-//===--===//
-// Instruction definitions
-//===--===//
-// Each record of the class RVVBuiltin defines a collection of builtins (i.e.
-// "def vadd : RVVBuiltin" will be used to define things like "vadd_vv_i32m1",
-// "vadd_vv_i32m2", etc).
-//
-// The elements of this collection are defined by an instantiation process the
-// range of which is specified by the cross product of the LMUL attribute and
-// every element in the attribute TypeRange. By default builtins have LMUL = 
[1,
-// 2, 4, 8, 1/2, 1/4, 1/8] so the process is repeated 7 times. In tablegen we
-// use the Log2LMUL [0, 1, 2, 3, -1, -2, -3] to represent the LMUL.
-//
-// LMUL represents the fact that the types of values used by that builtin are
-// values generated by instructions that are executed under that LMUL. However,
-// this does not mean the builtin is necessarily lowered into an instruction
-// that executes under the specified LMUL. An example where this happens are
-// loads and stores of masks. A mask like `vbool8_t` can be generated, for
-// instance, by comparing two `__rvv_int8m1_t` (this is LMUL=1) or comparing 
two
-// `__rvv_int16m2_t` (this is LMUL=2). The actual load or store, however, will
-// be performed under LMUL=1 because mask registers are not grouped.
-//
-// TypeRange is a non-empty sequence of basic types:
-//
-//   c: int8_t (i8)
-//   s: int16_t (i16)
-//   i: int32_t (i32)
-//   l: int64_t (i64)
-//   x: float16_t (half)
-//   f: float32_t (float)
-//   d: float64_t (double)
-//
-// This way, given an LMUL, a record with a TypeRange "sil" will cause the
-// definition of 3 builtins. Each type "t" in the TypeRange (in this example
-// they are int16_t, int32_t, int64_t) is used as a parameter that drives the
-// definition of that particular builtin (for the given LMUL).
-//
-// During the instantiation, types can be transformed or modified using type
-// transformers. Given a type "t" the following primitive type transformers can
-// be applied to it to yield another type.
-//
-//   e: type of "t" as is (identity)
-//   v: computes a vector type whose element type is "t" for the current LMUL
-//   w: computes a vector type identical to what 'v' computes except for the
-//  element type which is twice as wide as the element type of 'v'
-//   q: computes a vector type identical to what 'v' computes except for the
-//  element type which is four times as wide as the element type of 'v'
-//   o: computes a vector type identical to what 'v' computes except for the
-//  element type which is eight times as wide as the element type of 'v'
-//   m: computes a vector type identical to what 'v' computes except for the
-//  element type which is bool
-//   0: void type, ignores "t"
-//   z: size_t, ignores "t"
-//   t: ptr
diff _t, ignores "t"
-//   u: unsigned long, ignores "t"
-//   l: long, ignores "t"
-//
-// So for instance if t is "i", i.e. int, then "e" will yield int again. "v"
-// will yield an RVV vector type (assume LMUL=1), so __rvv_int32m1_t.
-// Accordingly "w" would yield __rvv_int64m2_t.
-//
-// A type transformer can be prefixed by other non-primitive type transformers.
-//
-//   P: constructs a pointer to the current type
-//   C: adds const to the type
-//   K: requires the integer type to be a constant expression
-//   U: given an integer type or vector type, computes its unsigned variant
-//   I: given a vector type, compute the vector type with integer type
-//  elements of the same width
-//   F: given a vector type, compute the vector type with floating-point type
-//  elements of the same width
-//   S: given a vector type, computes its equivalent one for LMUL=1. This is a
-//  no-op if the vector was already LMUL=1
-//   (Log2EEW:Value): Log2EEW value could be 3/4/5/6 (8/16/32

[PATCH] D148680: [RISCV] Split out part of riscv_vector.td to riscv_vector_common.td

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4bf846ba40f1: [RISCV] Split out part of riscv_vector.td to 
riscv_vector_common.td (authored by 4vtomat).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148680

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Basic/riscv_vector_common.td

Index: clang/include/clang/Basic/riscv_vector_common.td
===
--- /dev/null
+++ clang/include/clang/Basic/riscv_vector_common.td
@@ -0,0 +1,239 @@
+//==-- riscv_vector_common.td - RISC-V V-ext builtin class ===//
+//
+//  Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+//  See https://llvm.org/LICENSE.txt for license information.
+//  SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file defines RVV builtin base class for RISC-V V-extension.
+//
+//===--===//
+
+//===--===//
+// Instruction definitions
+//===--===//
+// Each record of the class RVVBuiltin defines a collection of builtins (i.e.
+// "def vadd : RVVBuiltin" will be used to define things like "vadd_vv_i32m1",
+// "vadd_vv_i32m2", etc).
+//
+// The elements of this collection are defined by an instantiation process the
+// range of which is specified by the cross product of the LMUL attribute and
+// every element in the attribute TypeRange. By default builtins have LMUL = [1,
+// 2, 4, 8, 1/2, 1/4, 1/8] so the process is repeated 7 times. In tablegen we
+// use the Log2LMUL [0, 1, 2, 3, -1, -2, -3] to represent the LMUL.
+//
+// LMUL represents the fact that the types of values used by that builtin are
+// values generated by instructions that are executed under that LMUL. However,
+// this does not mean the builtin is necessarily lowered into an instruction
+// that executes under the specified LMUL. An example where this happens are
+// loads and stores of masks. A mask like `vbool8_t` can be generated, for
+// instance, by comparing two `__rvv_int8m1_t` (this is LMUL=1) or comparing two
+// `__rvv_int16m2_t` (this is LMUL=2). The actual load or store, however, will
+// be performed under LMUL=1 because mask registers are not grouped.
+//
+// TypeRange is a non-empty sequence of basic types:
+//
+//   c: int8_t (i8)
+//   s: int16_t (i16)
+//   i: int32_t (i32)
+//   l: int64_t (i64)
+//   x: float16_t (half)
+//   f: float32_t (float)
+//   d: float64_t (double)
+//
+// This way, given an LMUL, a record with a TypeRange "sil" will cause the
+// definition of 3 builtins. Each type "t" in the TypeRange (in this example
+// they are int16_t, int32_t, int64_t) is used as a parameter that drives the
+// definition of that particular builtin (for the given LMUL).
+//
+// During the instantiation, types can be transformed or modified using type
+// transformers. Given a type "t" the following primitive type transformers can
+// be applied to it to yield another type.
+//
+//   e: type of "t" as is (identity)
+//   v: computes a vector type whose element type is "t" for the current LMUL
+//   w: computes a vector type identical to what 'v' computes except for the
+//  element type which is twice as wide as the element type of 'v'
+//   q: computes a vector type identical to what 'v' computes except for the
+//  element type which is four times as wide as the element type of 'v'
+//   o: computes a vector type identical to what 'v' computes except for the
+//  element type which is eight times as wide as the element type of 'v'
+//   m: computes a vector type identical to what 'v' computes except for the
+//  element type which is bool
+//   0: void type, ignores "t"
+//   z: size_t, ignores "t"
+//   t: ptrdiff_t, ignores "t"
+//   u: unsigned long, ignores "t"
+//   l: long, ignores "t"
+//
+// So for instance if t is "i", i.e. int, then "e" will yield int again. "v"
+// will yield an RVV vector type (assume LMUL=1), so __rvv_int32m1_t.
+// Accordingly "w" would yield __rvv_int64m2_t.
+//
+// A type transformer can be prefixed by other non-primitive type transformers.
+//
+//   P: constructs a pointer to the current type
+//   C: adds const to the type
+//   K: requires the integer type to be a constant expression
+//   U: given an integer type or vector type, computes its unsigned variant
+//   I: given a vector type, compute the vector type with integer type
+//  elements of the same width
+//   F: given a vector type, compute the vector type with floating-point type
+//  elements of the same width
+//   S: given a vector

[PATCH] D149647: [NFC][Clang]Fix static analyzer tool remarks about large copies by value

2023-05-02 Thread Soumi Manna via Phabricator via cfe-commits
Manna created this revision.
Manna added a reviewer: tahonermann.
Herald added subscribers: manas, ASDenysPetrov, dkrupp, donat.nagy, Szelethus, 
a.sidorin, baloghadamsoftware.
Herald added projects: All, clang, clang-format.
Herald added reviewers: rymiel, HazardyKnusperkeks, owenpan, MyDeveloperDay.
Manna requested review of this revision.

Reported by Static Analyzer Tool:

Inside "Format.cpp" file, in 
clang::format::internal::reformat(clang::format::FormatStyle const &, 
llvm::StringRef, llvm::ArrayRef, unsigned int, unsigned 
int, unsigned int, llvm::StringRef, clang::format::FormattingAttemptStatus 
*)::[lambda(clang::format::Environment const &) (instance 4)]::operator 
()(clang::format::Environment const &): A very large function call parameter 
exceeding the high threshold is passed by value.

pass_by_value: Capturing variable S of type clang::format::FormatStyle (size 
800 bytes) by value, which exceeds the high threshold of 512 bytes

This patch removes redundant capturing variable S and passes type 
clang::format::FormatStyle Expanded instead in BracesInserter(), 
BracesRemover(), and SemiRemover().


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149647

Files:
  clang/lib/Format/Format.cpp


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3483,26 +3483,23 @@
 }
 
 if (Style.InsertBraces) {
-  FormatStyle S = Expanded;
-  S.InsertBraces = true;
-  Passes.emplace_back([&, S](const Environment &Env) {
-return BracesInserter(Env, S).process(/*SkipAnnotation=*/true);
+  Expanded.InsertBraces = true;
+  Passes.emplace_back([&](const Environment &Env) {
+return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
 if (Style.RemoveBracesLLVM) {
-  FormatStyle S = Expanded;
-  S.RemoveBracesLLVM = true;
-  Passes.emplace_back([&, S](const Environment &Env) {
-return BracesRemover(Env, S).process(/*SkipAnnotation=*/true);
+  Expanded.RemoveBracesLLVM = true;
+  Passes.emplace_back([&](const Environment &Env) {
+return BracesRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
 if (Style.RemoveSemicolon) {
-  FormatStyle S = Expanded;
-  S.RemoveSemicolon = true;
-  Passes.emplace_back([&, S](const Environment &Env) {
-return SemiRemover(Env, S).process(/*SkipAnnotation=*/true);
+  Expanded.RemoveSemicolon = true;
+  Passes.emplace_back([&](const Environment &Env) {
+return SemiRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 


Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3483,26 +3483,23 @@
 }
 
 if (Style.InsertBraces) {
-  FormatStyle S = Expanded;
-  S.InsertBraces = true;
-  Passes.emplace_back([&, S](const Environment &Env) {
-return BracesInserter(Env, S).process(/*SkipAnnotation=*/true);
+  Expanded.InsertBraces = true;
+  Passes.emplace_back([&](const Environment &Env) {
+return BracesInserter(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
 if (Style.RemoveBracesLLVM) {
-  FormatStyle S = Expanded;
-  S.RemoveBracesLLVM = true;
-  Passes.emplace_back([&, S](const Environment &Env) {
-return BracesRemover(Env, S).process(/*SkipAnnotation=*/true);
+  Expanded.RemoveBracesLLVM = true;
+  Passes.emplace_back([&](const Environment &Env) {
+return BracesRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
 if (Style.RemoveSemicolon) {
-  FormatStyle S = Expanded;
-  S.RemoveSemicolon = true;
-  Passes.emplace_back([&, S](const Environment &Env) {
-return SemiRemover(Env, S).process(/*SkipAnnotation=*/true);
+  Expanded.RemoveSemicolon = true;
+  Passes.emplace_back([&](const Environment &Env) {
+return SemiRemover(Env, Expanded).process(/*SkipAnnotation=*/true);
   });
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fa43608 - [RISCV][RISCV][clang] Split out SiFive Vector C intrinsics from riscv_vector.td

2023-05-02 Thread via cfe-commits

Author: 4vtomat
Date: 2023-05-02T05:51:51-07:00
New Revision: fa43608d1649553814a179cd76d67ea7bdc068d3

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

LOG: [RISCV][RISCV][clang] Split out SiFive Vector C intrinsics from 
riscv_vector.td

Since we don't always need the vendor extension to be in riscv_vector.td,
so it's better to make it be in separated header.

Depends on D148223 and D148680

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

Added: 
clang/lib/Headers/sifive_vector.h

Modified: 
clang/include/clang/Basic/BuiltinsRISCVVector.def
clang/include/clang/Basic/CMakeLists.txt
clang/include/clang/Basic/riscv_sifive_vector.td
clang/include/clang/Basic/riscv_vector.td
clang/include/clang/Sema/RISCVIntrinsicManager.h
clang/include/clang/Sema/Sema.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Headers/CMakeLists.txt
clang/lib/Parse/ParsePragma.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaRISCVVectorLookup.cpp

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x-rv64.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv-rv64.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv-rv64.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c

clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c

clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp-index-out-of-range.c
clang/test/Sema/riscv-bad-intrinsic-pragma.c
clang/utils/TableGen/TableGen.cpp
llvm/docs/CommandGuide/tblgen.rst

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsRISCVVector.def 
b/clang/include/clang/Basic/BuiltinsRISCVVector.def
index 008cb939a30bc..6dfa87a1a1d31 100644
--- a/clang/include/clang/Basic/BuiltinsRISCVVector.def
+++ b/clang/include/clang/Basic/BuiltinsRISCVVector.def
@@ -16,6 +16,7 @@
 #endif
 
 #include "clang/Basic/riscv_vector_builtins.inc"
+#include "clang/Basic/riscv_sifive_vector_builtins.inc"
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

diff  --git a/clang/include/clang/Basic/CMakeLists.txt 
b/clang/include/clang/Basic/CMakeLists.txt
index b930842ae8cfd..53a713b13ea39 100644
--- a/clang/include/clang/Basic/CMakeLists.txt
+++ b/clang/include/clang/Basic/CMakeLists.txt
@@ -93,3 +93,12 @@ clang_tablegen(riscv_vector_builtin_cg.inc 
-gen-riscv-vector-builtin-codegen
 clang_tablegen(riscv_vector_builtin_sema.inc -gen-riscv-vector-builtin-sema
   SOURCE riscv_vector.td
   TARGET ClangRISCVVectorBuiltinSema)
+clang_tablegen(riscv_sifive_vector_builtins.inc 
-gen-riscv-sifive-vector-builtins
+  SOURCE riscv_sifive_vector.td
+  TARGET ClangRISCVSiFiveVectorBuiltins)
+clang_tablegen(riscv_sifive_vector_builtin_cg.inc 
-gen-riscv-sifive-vector-builtin-codegen
+  SOURCE riscv_sifive_vector.td
+  TARGET ClangRISCVSiFiveVectorBuiltinCG)
+clang_tablegen(riscv_sifive_vector_builtin_sema.inc 
-gen-riscv-sifive-vector-builtin-sema
+  SOURCE riscv_sifive_vector.td
+  TARGET ClangRISCVSiFiveVectorBuiltinSema)

diff  --git a/clang/include/clang/Basic/riscv_sifive_vector.td 
b/clang/include/clang/Basic/riscv_sifive_vector.td
index a000a226b795a..0d390be711c83 100644
--- a/clang/include/clang/Basic/riscv_sifive_vector.td
+++ b/clang/include/clang/Basic/riscv_sifive_vector.td
@@ -12,6 +12,8 @@
 //
 
//===--===//
 
+include "riscv_vector_common.td"
+
 
//===--===//
 // Instruction definitions
 
//===--===//

diff  --git a/clang/include/clang/Basic/riscv_vector.td 
b/clang/include/clang/Basic/riscv_vector.td
index f9e9c7d80cca7..8eb873dfafc79 100644
--- a/clang/include/clang/Basic/riscv_vector.td
+++ b/clang/include/clang/Basic/riscv_vector.td
@@ -2148,5 +2148,3 @@ let HasMasked = false, HasVL = false, IRName = "" in {
 }
   }
 }
-
-include "riscv_sifive_vector.td"

diff  --git a/clang/include/clang/Sema/RISCVIntrinsicManager.h 
b/clang/include/clang/Sema/RISCVIntrinsicManager.h
index 128858bb43019..66e7dbd281c1d 100644
--- a/clang/include/clang/Sema/RISCVIntrinsicManager.h
+++ b/clang/include/clang/Sema/RISCVIntrinsicManager.h
@@ -22,6 +22,8 @@ class Preprocessor;
 namespace sema {
 class RISCVIntrinsicManager {
 public:
+  enum class IntrinsicKind : uint8_t { RVV, SIFIVE_VECTOR };
+
   virtual ~RISCVIntrinsicManager() = default;

[PATCH] D148308: [RISCV][RISCV][clang] Split out SiFive VCIX C intrinsics from riscv_vector.td

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfa43608d1649: [RISCV][RISCV][clang] Split out SiFive Vector 
C intrinsics from riscv_vector.td (authored by 4vtomat).

Changed prior to commit:
  https://reviews.llvm.org/D148308?vs=514817&id=518694#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148308

Files:
  clang/include/clang/Basic/BuiltinsRISCVVector.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/riscv_sifive_vector.td
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Sema/RISCVIntrinsicManager.h
  clang/include/clang/Sema/Sema.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Headers/sifive_vector.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp-index-out-of-range.c
  clang/test/Sema/riscv-bad-intrinsic-pragma.c
  clang/utils/TableGen/TableGen.cpp
  llvm/docs/CommandGuide/tblgen.rst

Index: llvm/docs/CommandGuide/tblgen.rst
===
--- llvm/docs/CommandGuide/tblgen.rst
+++ llvm/docs/CommandGuide/tblgen.rst
@@ -348,6 +348,14 @@
 
   Generate ``riscv_vector_builtin_cg.inc`` for Clang.
 
+.. option:: -gen-riscv-sifive-vector-builtins
+
+  Generate ``riscv_sifive_vector_builtins.inc`` for Clang.
+
+.. option:: -gen-riscv-sifive-vector-builtin-codegen
+
+  Generate ``riscv_sifive_vector_builtin_cg.inc`` for Clang.
+
 .. option:: -gen-attr-docs
 
   Generate attribute documentation.
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -91,6 +91,9 @@
   GenRISCVVectorBuiltins,
   GenRISCVVectorBuiltinCG,
   GenRISCVVectorBuiltinSema,
+  GenRISCVSiFiveVectorBuiltins,
+  GenRISCVSiFiveVectorBuiltinCG,
+  GenRISCVSiFiveVectorBuiltinSema,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -251,6 +254,12 @@
"Generate riscv_vector_builtin_cg.inc for clang"),
 clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema",
"Generate riscv_vector_builtin_sema.inc for clang"),
+clEnumValN(GenRISCVSiFiveVectorBuiltins, "gen-riscv-sifive-vector-builtins",
+   "Generate riscv_sifive_vector_builtins.inc for clang"),
+clEnumValN(GenRISCVSiFiveVectorBuiltinCG, "gen-riscv-sifive-vector-builtin-codegen",
+   "Generate riscv_sifive_vector_builtin_cg.inc for clang"),
+clEnumValN(GenRISCVSiFiveVectorBuiltinSema, "gen-riscv-sifive-vector-builtin-sema",
+   "Generate riscv_sifive_vector_builtin_sema.inc for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -472,6 +481,15 @@
   case GenRISCVVectorBuiltinSema:
 EmitRVVBuiltinSema(Records, OS);
 break;
+  case GenRISCVSiFiveVectorBuiltins:
+EmitRVVBuiltins(Records, OS);
+break;
+  case GenRISCVSiFiveVectorBuiltinCG:
+EmitRVVBuiltinCG(Records, OS);
+break;
+  case GenRISCVSiFiveVectorBuiltinSema:
+EmitRVVBuiltinSema(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/test/Sema/riscv-bad-intrinsic-pragma.c
===
--- clang/test/Sema/riscv-bad-intrinsic-pragma.c
+++ clang/test/Sema/riscv-bad-intrinsic-pragma.c
@@ -2,7 +2,7 @@
 // RUN:2>&1 | FileCheck %s
 
 #pragma clang riscv intrinsic 
-// CHECK:  warning: unexpected argument '' to '#pragma riscv'; expected 'vector' [-Wignored-pragmas]
+// CHECK:  warning: unexpected argument '' to '#pragma riscv'; expected 'vector' or 'sifive_vector' [-Wignored-pragmas]
 
 #pragma clang riscv what + 3241
 // CHECK:  warning: unexpected argument 'what' to '#pragma riscv'; expected 'intrinsic' [-Wignored-pragmas]
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/xsfvcp-index-out-of

[PATCH] D147626: [clang] Reject flexible array member in a union in C++

2023-05-02 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon updated this revision to Diff 518695.
Fznamznon added a comment.

Rebase, add a comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147626

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/test/Layout/aix-power-alignment-typedef.cpp
  clang/test/Sema/MicrosoftExtensions.c
  clang/test/Sema/init.c
  clang/test/SemaCXX/flexible-array-test.cpp
  clang/test/SemaCXX/gnu-flags.cpp
  clang/test/SemaObjCXX/flexible-array.mm

Index: clang/test/SemaObjCXX/flexible-array.mm
===
--- clang/test/SemaObjCXX/flexible-array.mm
+++ clang/test/SemaObjCXX/flexible-array.mm
@@ -4,7 +4,7 @@
 
 union VariableSizeUnion {
   int s;
-  char c[];
+  char c[]; //expected-error {{flexible array member 'c' in a union is not allowed}}
 };
 
 @interface LastUnionIvar {
Index: clang/test/SemaCXX/gnu-flags.cpp
===
--- clang/test/SemaCXX/gnu-flags.cpp
+++ clang/test/SemaCXX/gnu-flags.cpp
@@ -8,34 +8,27 @@
 
 // RUN: %clang_cc1 -fsyntax-only -verify %s -DALL -Wno-gnu \
 // RUN:   -Wgnu-anonymous-struct -Wredeclared-class-member \
-// RUN:   -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
-// RUN:   -Wgnu-empty-struct
+// RUN:   -Wgnu-folding-constant -Wgnu-empty-struct
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DALL -Wno-gnu \
 // RUN:   -Wgnu-anonymous-struct -Wredeclared-class-member \
-// RUN:   -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
-// RUN:   -Wgnu-empty-struct
+// RUN:   -Wgnu-folding-constant -Wgnu-empty-struct
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DALL -Wno-gnu \
 // RUN:   -Wgnu-anonymous-struct -Wredeclared-class-member \
-// RUN:   -Wgnu-flexible-array-union-member -Wgnu-folding-constant \
-// RUN:   -Wgnu-empty-struct
+// RUN:   -Wgnu-folding-constant -Wgnu-empty-struct
 
 // RUN: %clang_cc1 -fsyntax-only -verify %s -DNONE -Wgnu \
 // RUN:   -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
-// RUN:   -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
-// RUN:   -Wno-gnu-empty-struct
+// RUN:   -Wno-gnu-folding-constant -Wno-gnu-empty-struct
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s -DNONE -Wgnu \
 // RUN:   -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
-// RUN:   -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
-// RUN:   -Wno-gnu-empty-struct
+// RUN:   -Wno-gnu-folding-constant -Wno-gnu-empty-struct
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s -DNONE -Wgnu \
 // RUN:   -Wno-gnu-anonymous-struct -Wno-redeclared-class-member \
-// RUN:   -Wno-gnu-flexible-array-union-member -Wno-gnu-folding-constant \
-// RUN:   -Wno-gnu-empty-struct
+// RUN:   -Wno-gnu-folding-constant -Wno-gnu-empty-struct
 
 // Additional disabled tests:
 // %clang_cc1 -fsyntax-only -verify %s -DANONYMOUSSTRUCT -Wno-gnu -Wgnu-anonymous-struct
 // %clang_cc1 -fsyntax-only -verify %s -DREDECLAREDCLASSMEMBER -Wno-gnu -Wredeclared-class-member
-// %clang_cc1 -fsyntax-only -verify %s -DFLEXIBLEARRAYUNIONMEMBER -Wno-gnu -Wgnu-flexible-array-union-member
 // %clang_cc1 -fsyntax-only -verify %s -DFOLDINGCONSTANT -Wno-gnu -Wgnu-folding-constant
 // %clang_cc1 -fsyntax-only -verify %s -DEMPTYSTRUCT -Wno-gnu -Wgnu-empty-struct
 
@@ -70,19 +63,6 @@
   };
 }
 
-
-#if ALL || FLEXIBLEARRAYUNIONMEMBER
-// expected-warning@+6 {{flexible array member 'c1' in a union is a GNU extension}}
-#endif
-
-struct faum {
-   int l;
-   union {
-   int c1[];
-   };
-};
-
-
 #if (ALL || FOLDINGCONSTANT) && (__cplusplus <= 199711L) // C++03 or earlier modes
 // expected-warning@+4 {{in-class initializer for static data member is not a constant expression; folding it to a constant is a GNU extension}}
 #endif
Index: clang/test/SemaCXX/flexible-array-test.cpp
===
--- clang/test/SemaCXX/flexible-array-test.cpp
+++ clang/test/SemaCXX/flexible-array-test.cpp
@@ -16,7 +16,7 @@
 
 struct Rec {
   union { // expected-warning-re {{variable sized type '{{.*}}' not at the end of a struct or class is a GNU extension}}
-int u0[];
+int u0[]; // expected-error {{flexible array member 'u0' in a union is not allowed}}
   };
   int x;
 } rec;
@@ -63,7 +63,7 @@
 
 union B {
   int s;
-  char c[];
+  char c[]; // expected-error {{flexible array member 'c' in a union is not allowed}}
 };
 
 class C {
Index: clang/test/Sema/init.c
===
--- clang/test/Sema/init.c
+++ clang/test/Sema/init.c
@@ -164,3 +164,6 @@
 
 typedef struct { uintptr_t x : 2; } StructWithBitfield;
 StructWithBitfield bitfieldvar = { (uintptr_t)&bitfieldvar }; // expected-error {{initializer eleme

[PATCH] D147626: [clang] Reject flexible array member in a union in C++

2023-05-02 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6241-6244
 def ext_flexible_array_empty_aggregate_ms : Extension<
   "flexible array member %0 in otherwise empty "
   "%select{struct|interface|union|class|enum}1 is a Microsoft extension">,
   InGroup;

aaron.ballman wrote:
> Fznamznon wrote:
> > aaron.ballman wrote:
> > > Should this be updated to remove the union case?
> > Sounds reasonable, but what is unfortunate is that this diagnostic exactly 
> > matches TagTypeKind enum, so now it can be emitted with `Diag(...) << ... 
> > << SomeTagDecl->getTagKind().` Once I remove `union` from there, this neat 
> > thing fails.
> Oh, that might be worth leaving alone then, but put a comment next to the 
> diagnostic definition to explain the relationship to `TagTypeKind`.
Sure, added a comment above the first diagnostic that uses the same structure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147626

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


[PATCH] D144634: [Clang][OpenMP] Support for Code Generation of loop bind clause

2023-05-02 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added a comment.

In D144634#4308872 , @koops wrote:

> 1. Taken care of some of the comments by Alexey.
> 2. Added extra tests of loop_bind_messages.cpp
>
> However, generic_loop_messages.cpp & generic_loop_ast_print.cpp are present 
> and provide a good coverage.

I rather doubt that these tests provide good coverage, since you're changing 
the directive kind here on the fly. This is a very new functionality, which was 
not tested before.
Add the tests for nesting of the regions, i.e. loop bind directive, enclosed in 
different regions, and diagnostics.




Comment at: clang/lib/Sema/SemaOpenMP.cpp:339
 
+  OpenMPDirectiveKind Map1D = OMPD_unknown;
+

What Ma1D stands for, what is the meaning of this abbrev? Add a comment.



Comment at: clang/test/OpenMP/loop_bind_codegen.cpp:2
+// expected-no-diagnostics
+// RUN: %clang_cc1 -DCK1 -verify -fopenmp -x c++ %s -emit-llvm -o - | 
FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -x c++ -triple x86_64-unknown-unknown 
-emit-llvm %s -o - | FileCheck %s

Add tests with save/load precompiled code.



Comment at: clang/test/OpenMP/loop_bind_messages.cpp:3
+#define HEADER
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=50 -verify %s
+

Add tests with save/load precompiled code.


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

https://reviews.llvm.org/D144634

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


[PATCH] D147218: [OpenMP][Flang][MLIR] Lowering of OpenMP requires directive from parse tree to MLIR

2023-05-02 Thread Sergio Afonso via Phabricator via cfe-commits
skatrak updated this revision to Diff 518698.
skatrak added a comment.

Rebase. Disable some known failing 'declare target' tests temporarily until 
they are fixed by parent patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147218

Files:
  flang/include/flang/Lower/OpenMP.h
  flang/lib/Lower/Bridge.cpp
  flang/lib/Lower/OpenMP.cpp
  flang/test/Lower/OpenMP/omp-declare-target-data.f90
  flang/test/Lower/OpenMP/requires-notarget.f90
  flang/test/Lower/OpenMP/requires.f90

Index: flang/test/Lower/OpenMP/requires.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/requires.f90
@@ -0,0 +1,14 @@
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+
+! This test checks the lowering of requires into MLIR
+
+!CHECK:  module attributes {
+!CHECK-SAME: omp.atomic_default_mem_order = #omp
+!CHECK-SAME: omp.requires = #omp
+program requires
+  !$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
+end program requires
+
+subroutine f
+  !$omp declare target
+end subroutine f
Index: flang/test/Lower/OpenMP/requires-notarget.f90
===
--- /dev/null
+++ flang/test/Lower/OpenMP/requires-notarget.f90
@@ -0,0 +1,12 @@
+! RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s
+
+! This test checks that requires lowering into MLIR skips creating the
+! omp.requires attribute with target-related clauses if there are no device
+! functions in the compilation unit
+
+!CHECK:  module attributes {
+!CHECK-SAME: omp.atomic_default_mem_order = #omp
+!CHECK-NOT:  omp.requires
+program requires
+  !$omp requires unified_shared_memory reverse_offload atomic_default_mem_order(seq_cst)
+end program requires
Index: flang/test/Lower/OpenMP/omp-declare-target-data.f90
===
--- flang/test/Lower/OpenMP/omp-declare-target-data.f90
+++ flang/test/Lower/OpenMP/omp-declare-target-data.f90
@@ -1,7 +1,8 @@
 !RUN: %flang_fc1 -emit-fir -fopenmp %s -o - | FileCheck %s 
 !RUN: %flang_fc1 -emit-fir -fopenmp -fopenmp-is-device %s -o - | FileCheck %s
-!RUN: %flang_fc1 -emit-llvm-bc -fopenmp -o %t.bc %s | llvm-dis %t.bc -o - | FileCheck %s --check-prefix=HOST
-!RUN: %flang_fc1 -emit-llvm -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -o - %s 2>&1 | FileCheck %s --check-prefix=DEVICE
+!COM: TODO Uncomment following commands, once all required declare target lowering work lands
+!COM: %flang_fc1 -emit-llvm-bc -fopenmp -o %t.bc %s | llvm-dis %t.bc -o - | FileCheck %s --check-prefix=HOST
+!COM: %flang_fc1 -emit-llvm -fopenmp -fopenmp-is-device -fopenmp-host-ir-file-path %t.bc -o - %s 2>&1 | FileCheck %s --check-prefix=DEVICE
 
 !HOST-DAG: %struct.__tgt_offload_entry = type { ptr, ptr, i64, i32, i32 }
 !HOST-DAG: !omp_offload.info = !{!{{.*}}}
Index: flang/lib/Lower/OpenMP.cpp
===
--- flang/lib/Lower/OpenMP.cpp
+++ flang/lib/Lower/OpenMP.cpp
@@ -24,7 +24,9 @@
 #include "flang/Semantics/tools.h"
 #include "mlir/Dialect/OpenMP/OpenMPDialect.h"
 #include "mlir/Dialect/SCF/IR/SCF.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Frontend/OpenMP/OMPConstants.h"
+#include 
 
 using namespace mlir;
 
@@ -2262,14 +2264,14 @@
   converter.bindSymbol(sym, symThreadprivateExv);
 }
 
-void handleDeclareTarget(Fortran::lower::AbstractConverter &converter,
- Fortran::lower::pft::Evaluation &eval,
- const Fortran::parser::OpenMPDeclareTargetConstruct
- &declareTargetConstruct) {
-  llvm::SmallVector,
-0>
-  symbolAndClause;
+/// Extract the list of function and variable symbols affected by the given
+/// 'declare target' directive and return the intended device type for them.
+static mlir::omp::DeclareTargetDeviceType getDeclareTargetInfo(
+Fortran::lower::pft::Evaluation &eval,
+const Fortran::parser::OpenMPDeclareTargetConstruct &declareTargetConstruct,
+SmallVectorImpl> &symbolAndClause) {
+  // Gather the symbols and clauses
   auto findFuncAndVarSyms = [&](const Fortran::parser::OmpObjectList &objList,
 mlir::omp::DeclareTargetCaptureClause clause) {
 for (const auto &ompObject : objList.v) {
@@ -2289,12 +2291,11 @@
 }
   };
 
+  // The default capture type
+  auto deviceType = Fortran::parser::OmpDeviceTypeClause::Type::Any;
   const auto &spec{std::get(
   declareTargetConstruct.t)};
-  auto mod = converter.getFirOpBuilder().getModule();
 
-  // The default capture type
-  auto deviceType = Fortran::parser::OmpDeviceTypeClause::Type::Any;
   if (const auto *objectList{
   Fortran::parser::Unwrap(spec.u)}) {
 // Case: declare target(func, var1, var2)
@@ -2330,22 +2331,31 @@
 }
   }
 
+  switch (d

[PATCH] D149645: [clang][Interp] Optionally cast comparison result to non-bool

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

For C, should we instead be teaching our boolean operations to understand it 
might be int?  I fear this will end up causing conversion problems later, such 
as with:

`int F = 1 > 2;`.  We won't end up having a conversion operation there, since 
the RHS is already `int`, for the LHS.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149645

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


[PATCH] D149634: [clang][Interp] Implement inc/dec operators for floats

2023-05-02 Thread Erich Keane via Phabricator via cfe-commits
erichkeane accepted this revision.
erichkeane added a comment.
This revision is now accepted and ready to land.

This looks right to me.




Comment at: clang/lib/AST/Interp/Floating.h:132
+*R = Floating(A.F);
+
+return R->F.add(One, RM);

Extra new line vs the decrement?  Obviously the nittiest of nits.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149634

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


[PATCH] D147626: [clang] Reject flexible array member in a union in C++

2023-05-02 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/D147626/new/

https://reviews.llvm.org/D147626

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


[PATCH] D149649: Update comment.

2023-05-02 Thread Jens Massberg via Phabricator via cfe-commits
massberg created this revision.
massberg added a reviewer: ilya-biryukov.
Herald added a project: All.
massberg requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

[class.rel] has been renamed to [class.compare.secondary].


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149649

Files:
  clang/lib/Sema/SemaDeclCXX.cpp


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -8706,7 +8706,7 @@
 }
   }
 
-  // C++2a [class.eq]p1, [class.rel]p1:
+  // C++2a [class.eq]p1, [class.compare.secondary]p1:
   //   A [defaulted comparison other than <=>] shall have a declared return
   //   type bool.
   if (DCK != DefaultedComparisonKind::ThreeWay &&


Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -8706,7 +8706,7 @@
 }
   }
 
-  // C++2a [class.eq]p1, [class.rel]p1:
+  // C++2a [class.eq]p1, [class.compare.secondary]p1:
   //   A [defaulted comparison other than <=>] shall have a declared return
   //   type bool.
   if (DCK != DefaultedComparisonKind::ThreeWay &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Kinuko Yasuda via Phabricator via cfe-commits
kinu updated this revision to Diff 518702.
kinu added a comment.

Changing the existing test to reflect the flag change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149640

Files:
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2652,25 +2652,8 @@
   Code,
   [](const llvm::StringMap> &Results,
  ASTContext &ASTCtx) {
-ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
-const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
-
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
-
-const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
-ASSERT_THAT(BarDecl, NotNull());
-
-const auto *FooVal =
-cast(Env.getValue(*FooDecl, SkipPast::None));
-const auto *FooPointeeVal =
-cast(Env.getValue(FooVal->getPointeeLoc()));
-
-const auto *BarVal = dyn_cast_or_null(
-Env.getValue(*BarDecl, SkipPast::None));
-ASSERT_THAT(BarVal, NotNull());
-
-EXPECT_EQ(BarVal, FooPointeeVal);
+// PruneTriviallyFalseEdges prunes the unreachable node.
+ASSERT_TRUE(Results.empty());
   });
 }
 
Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -70,7 +70,7 @@
 llvm::Expected
 ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) {
   CFG::BuildOptions Options;
-  Options.PruneTriviallyFalseEdges = false;
+  Options.PruneTriviallyFalseEdges = true;
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
   Options.AddInitializers = true;


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -2652,25 +2652,8 @@
   Code,
   [](const llvm::StringMap> &Results,
  ASTContext &ASTCtx) {
-ASSERT_THAT(Results.keys(), UnorderedElementsAre("p"));
-const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
-
-const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
-ASSERT_THAT(FooDecl, NotNull());
-
-const ValueDecl *BarDecl = findValueDecl(ASTCtx, "Bar");
-ASSERT_THAT(BarDecl, NotNull());
-
-const auto *FooVal =
-cast(Env.getValue(*FooDecl, SkipPast::None));
-const auto *FooPointeeVal =
-cast(Env.getValue(FooVal->getPointeeLoc()));
-
-const auto *BarVal = dyn_cast_or_null(
-Env.getValue(*BarDecl, SkipPast::None));
-ASSERT_THAT(BarVal, NotNull());
-
-EXPECT_EQ(BarVal, FooPointeeVal);
+// PruneTriviallyFalseEdges prunes the unreachable node.
+ASSERT_TRUE(Results.empty());
   });
 }
 
Index: clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
+++ clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
@@ -70,7 +70,7 @@
 llvm::Expected
 ControlFlowContext::build(const Decl *D, Stmt &S, ASTContext &C) {
   CFG::BuildOptions Options;
-  Options.PruneTriviallyFalseEdges = false;
+  Options.PruneTriviallyFalseEdges = true;
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
   Options.AddInitializers = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149645: [clang][Interp] Optionally cast comparison result to non-bool

2023-05-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

In D149645#4312162 , @erichkeane 
wrote:

> For C, should we instead be teaching our boolean operations to understand it 
> might be int?  I fear this will end up causing conversion problems later, 
> such as with:
>
> `int F = 1 > 2;`.  We won't end up having a conversion operation there, since 
> the RHS is already `int`, for the LHS.

The result of `1 > 2` is int, yes. That's what this patch does - it converts 
the `Boolean` we create to the `int` the AST (and thus all the intepreter code 
inspecting it) expects.

The AST has no `IntegralToBool` cast in the example, but that doesn't matter 
for this patch; it just fixes the types on the stack to correspond to what the 
later code expects. I'm not opposed to adding a target type to the comparison 
ops, but I'm not sure if the additional complexity is worth it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149645

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


[PATCH] D149645: [clang][Interp] Optionally cast comparison result to non-bool

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

In D149645#4312190 , @tbaeder wrote:

> In D149645#4312162 , @erichkeane 
> wrote:
>
>> For C, should we instead be teaching our boolean operations to understand it 
>> might be int?  I fear this will end up causing conversion problems later, 
>> such as with:
>>
>> `int F = 1 > 2;`.  We won't end up having a conversion operation there, 
>> since the RHS is already `int`, for the LHS.
>
> The result of `1 > 2` is int, yes. That's what this patch does - it converts 
> the `Boolean` we create to the `int` the AST (and thus all the intepreter 
> code inspecting it) expects.
>
> The AST has no `IntegralToBool` cast in the example, but that doesn't matter 
> for this patch; it just fixes the types on the stack to correspond to what 
> the later code expects. I'm not opposed to adding a target type to the 
> comparison ops, but I'm not sure if the additional complexity is worth it.

That is pretty simplified, but I guess I'm concerned about situations where the 
next action is an assignment or other integer action in the constant expression 
evaluator. ARE you able to handle things like:

`_Static_assert( (5 > 4) + (3 > 2) == 2, "");` in C mode (where this change is 
needed?)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149645

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


[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:2641
 
 TEST(TransferTest, VarDeclInDoWhile) {
   std::string Code = R"(

Could you update the test name to reflect what the test is checking now? (the 
comment that you added below)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149640

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


[PATCH] D149640: [clang][dataflow] Change PruneTriviallyFalseEdges for building CFG

2023-05-02 Thread Martin Böhme via Phabricator via cfe-commits
mboehme added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:2673
-
-EXPECT_EQ(BarVal, FooPointeeVal);
   });

It's unfortuante that all of these checks have gone away. I think the test was 
actually trying to test something.

I'd suggest checking the environment at two different places:

```
void target(int *Foo) {
  do {
int Bar = *Foo;
// [[in_loop]]
  } while (true);
  (void)0;
  // [[after_loop]]
}
```

You can keep the existing checks for the `in_loop` environment and verify that 
`Results` doesn't actually contain an environment for `after_loop`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149640

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


[PATCH] D149182: Remove -Wpacked false positive for non-pod types where the layout isn't directly changed

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

Precommit CI found a valid issue (at least on Debian, the Windows failure 
appears to be unrelated but it's really hard to tell from that output). Also, 
this should have a release note, right?




Comment at: clang/lib/AST/RecordLayoutBuilder.cpp:2203-2205
 // Warn if we packed it unnecessarily, when the unpacked alignment is not
 // greater than the one after packing, the size in bits doesn't change and
 // the offset of each field is identical.

You probably should update the comment to explain the new changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149182

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


[PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs

2023-05-02 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.
Herald added a reviewer: jdoerfert.
Herald added subscribers: jplehr, sstefan1, JDevlieghere.

I think this is a reasonable change -- I don't see a whole lot of value out 
from the include or collaboration graphs, so unless someone has strong opinions 
otherwise, I think this LG for the Clang side of things.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149641

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


[PATCH] D149645: [clang][Interp] Optionally cast comparison result to non-bool

2023-05-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 518707.

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

https://reviews.llvm.org/D149645

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/c.c


Index: clang/test/AST/Interp/c.c
===
--- /dev/null
+++ clang/test/AST/Interp/c.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -verify=ref %s
+
+/// expected-no-diagnostics
+/// ref-no-diagnostics
+
+_Static_assert(1, "");
+_Static_assert(0 != 1, "");
+_Static_assert(1.0 == 1.0, "");
+_Static_assert( (5 > 4) + (3 > 2) == 2, "");
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -319,19 +319,29 @@
   if (!visit(LHS) || !visit(RHS))
 return false;
 
+  // For languages such as C, cast the result of one
+  // of our comparision opcodes to T (which is usually int).
+  auto MaybeCastToBool = [this, T, BO](bool Result) {
+if (!Result)
+  return false;
+if (T != PT_Bool)
+  return this->emitCast(PT_Bool, *T, BO);
+return true;
+  };
+
   switch (Op) {
   case BO_EQ:
-return this->emitEQ(*LT, BO);
+return MaybeCastToBool(this->emitEQ(*LT, BO));
   case BO_NE:
-return this->emitNE(*LT, BO);
+return MaybeCastToBool(this->emitNE(*LT, BO));
   case BO_LT:
-return this->emitLT(*LT, BO);
+return MaybeCastToBool(this->emitLT(*LT, BO));
   case BO_LE:
-return this->emitLE(*LT, BO);
+return MaybeCastToBool(this->emitLE(*LT, BO));
   case BO_GT:
-return this->emitGT(*LT, BO);
+return MaybeCastToBool(this->emitGT(*LT, BO));
   case BO_GE:
-return this->emitGE(*LT, BO);
+return MaybeCastToBool(this->emitGE(*LT, BO));
   case BO_Sub:
 if (T == PT_Float)
   return this->emitSubf(getRoundingMode(BO), BO);


Index: clang/test/AST/Interp/c.c
===
--- /dev/null
+++ clang/test/AST/Interp/c.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fexperimental-new-constant-interpreter -verify %s
+// RUN: %clang_cc1 -verify=ref %s
+
+/// expected-no-diagnostics
+/// ref-no-diagnostics
+
+_Static_assert(1, "");
+_Static_assert(0 != 1, "");
+_Static_assert(1.0 == 1.0, "");
+_Static_assert( (5 > 4) + (3 > 2) == 2, "");
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -319,19 +319,29 @@
   if (!visit(LHS) || !visit(RHS))
 return false;
 
+  // For languages such as C, cast the result of one
+  // of our comparision opcodes to T (which is usually int).
+  auto MaybeCastToBool = [this, T, BO](bool Result) {
+if (!Result)
+  return false;
+if (T != PT_Bool)
+  return this->emitCast(PT_Bool, *T, BO);
+return true;
+  };
+
   switch (Op) {
   case BO_EQ:
-return this->emitEQ(*LT, BO);
+return MaybeCastToBool(this->emitEQ(*LT, BO));
   case BO_NE:
-return this->emitNE(*LT, BO);
+return MaybeCastToBool(this->emitNE(*LT, BO));
   case BO_LT:
-return this->emitLT(*LT, BO);
+return MaybeCastToBool(this->emitLT(*LT, BO));
   case BO_LE:
-return this->emitLE(*LT, BO);
+return MaybeCastToBool(this->emitLE(*LT, BO));
   case BO_GT:
-return this->emitGT(*LT, BO);
+return MaybeCastToBool(this->emitGT(*LT, BO));
   case BO_GE:
-return this->emitGE(*LT, BO);
+return MaybeCastToBool(this->emitGE(*LT, BO));
   case BO_Sub:
 if (T == PT_Float)
   return this->emitSubf(getRoundingMode(BO), BO);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149444: [ARM] Allow codegen for Armv6m eXecute-Only (XO) sections

2023-05-02 Thread Simon Wallis via Phabricator via cfe-commits
simonwallis2 added inline comments.



Comment at: llvm/lib/Target/ARM/ARMSubtarget.cpp:434
   // range otherwise.
-  return !NoMovt && hasV8MBaselineOps() &&
+  return !NoMovt && hasV6MOps() &&
  (isTargetWindows() || !OptMinSize || genExecuteOnly());

V6M does not have Movt.
At face value, this line looks wrong and leads to about 30 unit test fails.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149444

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


[PATCH] D149645: [clang][Interp] Optionally cast comparison result to non-bool

2023-05-02 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

In D149645#4312193 , @erichkeane 
wrote:

> In D149645#4312190 , @tbaeder wrote:
>
>> In D149645#4312162 , @erichkeane 
>> wrote:
>>
>>> For C, should we instead be teaching our boolean operations to understand 
>>> it might be int?  I fear this will end up causing conversion problems 
>>> later, such as with:
>>>
>>> `int F = 1 > 2;`.  We won't end up having a conversion operation there, 
>>> since the RHS is already `int`, for the LHS.
>>
>> The result of `1 > 2` is int, yes. That's what this patch does - it converts 
>> the `Boolean` we create to the `int` the AST (and thus all the intepreter 
>> code inspecting it) expects.
>>
>> The AST has no `IntegralToBool` cast in the example, but that doesn't matter 
>> for this patch; it just fixes the types on the stack to correspond to what 
>> the later code expects. I'm not opposed to adding a target type to the 
>> comparison ops, but I'm not sure if the additional complexity is worth it.
>
> That is pretty simplified, but I guess I'm concerned about situations where 
> the next action is an assignment or other integer action in the constant 
> expression evaluator. ARE you able to handle things like:
>
> `_Static_assert( (5 > 4) + (3 > 2) == 2, "");` in C mode (where this change 
> is needed?)?

Yes, that works :)


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

https://reviews.llvm.org/D149645

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


[PATCH] D149573: [Clang][C++23] Implement core language changes from P1467R9 extended floating-point types and standard names and introduce Bfloat16 arithmetic type.

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

I




Comment at: clang/include/clang/AST/ASTContext.h:28
 #include "clang/AST/TemplateName.h"
+#include "clang/AST/Type.h"
 #include "clang/Basic/IdentifierTable.h"

What is this needed for?  



Comment at: clang/include/clang/AST/ASTContext.h:2808
+  /// are unordered, return FRCR_Unordered. If \p LHS and \p RHS are equal but
+  /// subrank of \p LHS is greater than \p RHS, return
+  /// FRCR_Equal_Greater_Subrank. If \p LHS and \p RHS are equal but subrank of





Comment at: clang/include/clang/AST/ASTContext.h:2809
+  /// subrank of \p LHS is greater than \p RHS, return
+  /// FRCR_Equal_Greater_Subrank. If \p LHS and \p RHS are equal but subrank of
+  /// \p LHS is less than \p RHS, return FRCR_Equal_Lesser_Subrank. Subrank and





Comment at: clang/include/clang/AST/ASTContext.h:2811
+  /// \p LHS is less than \p RHS, return FRCR_Equal_Lesser_Subrank. Subrank and
+  /// Unordered comparision was introduced in C++23.
+  FloatingRankCompareResult getFloatingTypeOrder(QualType LHS,





Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:8745
 def err_cast_from_bfloat16 : Error<"cannot type-cast from __bf16">;
+def err_cxx2b_invalid_implicit_floating_point_cast : Error<"floating point 
cast results in loss of precision.">;
 def err_typecheck_expect_scalar_operand : Error<





Comment at: clang/include/clang/Basic/LangOptions.def:468
 
+LANGOPT(ExperimentalNewItaniumMangling, 1, 0, "experimental new Itanium 
mangling")
+

I'm not sure I like the implications or maintainability of this.  This is 
something that is likely to get out of hand too quickly.  We probably need to 
just figure out what the itanium mangling is GOING to be (perhaps @rjmccall has 
some  insight?), and just implement that.

Also, this isn't really a 'Language Option', so much as a codegen option.



Comment at: clang/lib/AST/ASTContext.cpp:116
+// C++23 6.8.6p2 [conv.rank]
+using RankMap =
+std::unordered_map;

I don't quite see what this is used for yet, but nested unordered-maps for what 
is all compile-time constants seems like a waste of compile-time.  I wonder if 
there is a good way to use a table for this comparison (perhaps with some level 
of adjustment on the type-kinds to make them non-sparse).



Comment at: clang/lib/AST/ASTContext.cpp:7152
+  RHSKind = RHS->castAs()->getKind();
+auto comp = CXX23FloatingPointConversionRankMap[LHSKind][RHSKind];
+return comp;

by coding standard, you can't use 'auto' here.  Also, variables are capital. I 
probably just would return it without the intermediary variable.

That said, this is exactly what I feared the unordered-map table above was for. 
 We need to come up with a better storage medium for that.

My thought is to introduce something like:

```
constexpr unsigned FloatRankToIndex(clang::BuiltinType::Kind) {
  switch(Kind) {
case clang::BuiltinType::Float16: return 0;  
case clang::BuiltinType::BF16: return 1;
case clang::BuiltinType::Float: return 2;
case clang::BuiltinType::Double: return 3;
case clang::BuiltinType::LongDouble: return 4;
default: llvm_unreachable("Not a floating builtin type");
 }
```
And just run that on `LHSKind` and `RHSKind` here.  Then, the 
`CXX23FloatingPointConversionRankMap` can be just a 2d pair of arrays:



```
std::array, 5> 
CXX23FloatingPointConversionRankMap = 
```

We get the same results with very small runtime cost (for the 2 switches per 
operation), but save two `unordered_map` lookups, AND save the runtime 
construction of the `unordered_map`s.



Comment at: clang/test/CodeGenCXX/cxx2b-fp-ext-std-names-p1467r9.cpp:5
+// CHECK-LABEL: @_Z1fDF16b(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[V_ADDR:%.*]] = alloca bfloat, align 2

`entry` isn't a stable name here, so you shouldn't use this label.



Comment at: clang/test/CodeGenCXX/cxx2b-fp-ext-std-names-p1467r9.cpp:101
+
+// CHECK-LABEL: @_Z4testv(
+// CHECK-NEXT:  entry:

I'd vastly prefer these check-next commands be interlaced in teh code, so it is 
easy to see which line is supposed to associate with which.



Comment at: clang/test/Sema/cxx2b-fp-ext-std-names-p1467r9.cpp:9
+//CHECK:  |-VarDecl {{.*}} f16_val_6 '_Float16' cinit
+//CHECK-NEXT: | `-FloatingLiteral {{.*}} '_Float16' 1.00e+00
+_Float16 f16_val_7 = static_cast<_Float16>(1.0bf16); // expected-error 
{{static_cast from 'BF16' to '_Float16' is not allowed}}

How we emit the result of the floats is inconsistent, at least in IR, so I'm 
not sure how stable it'll be here.

Also, don't use the `|-` and `| \`-`` in the check-lines, those get messy when 
som

[PATCH] D149514: Check if First argument in _builtin_assume_aligned_ is of pointer type

2023-05-02 Thread Yurong via Phabricator via cfe-commits
yronglin added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:7979-7986
   {
 ExprResult FirstArgResult =
 DefaultFunctionArrayLvalueConversion(FirstArg);
-if (FirstArgResult.isInvalid())
+if (checkBuiltinArgument(*this, TheCall, 0))
   return true;
+/// In-place updation of FirstArg by checkBuiltinArgument is ignored.
 TheCall->setArg(0, FirstArgResult.get());

rsmith wrote:
> This still seems to be more complex than necessary. If we can't just do this, 
> we should have a comment explaining why. (Eg, does CodeGen really want the 
> final conversion from `T*` to `const void*` to not be in the AST?)
As far as I know, alignment sanitizer need a user written type descriptor (but 
not `const void *`) to emit diagnostic message, Eg:
```
/app/example.cpp:7:35: runtime error: assumption of 8 byte alignment for 
pointer of type 'B *' failed

```
So, not only convert `T *` to `const void *`, but also we need keep the user 
written type info. Previously, the solution to this problem was to use below 
code in codegen:
```
if (auto *CE = dyn_cast(E))
E = CE->getSubExprAsWritten();
```
since D133202 and D133583, we only do de default array/function conversion in 
sema, and convert the 1st arg to `const void *` in codegen. And I think the 
current solution is not very good, do you have any other better solutions? 
Should we keep the original type info in somewhere? Then we can simplify our 
work in sema. WDYT?


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

https://reviews.llvm.org/D149514

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


[PATCH] D141451: [clang] report inlining decisions with -Wattribute-{warning|error}

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

In D141451#4311199 , @dblaikie wrote:

>> probably too much, but then I wonder "how do we make Fortify work?".
>
> (I'm still sort of on the side of "if the compile-time costs to get more 
> verbose diagnostics is high, we could have a low-quality default-on 
> diagnostic and it could mention/recommend a different/high 
> quality/compile-time costly diagnostic" so for code bases like the Linux 
> kernel that rely on this sort of thing a lot, with lots of always_inlining, 
> etc, they can tradeoff toward the better diagnostic experience and codebases 
> that don't use these features much they can still get the checking for when 
> it does come up, but at some cost of quality/awkwardness in needing to 
> rebuild with other flags)

This isn't about verbosity of the diagnostics, though, so much as it's about 
user experience. I'd agree that enabling more verbose diagnostic checking is 
reasonable to ask users to opt into, but what I'm struggling with is expecting 
users to opt into a mode so that the diagnostics appear in the correct places 
instead of detached from the source they're noting. Also, with the `error` and 
`warning` attributes both being used by glibc (and not just for fortify source, 
but as a general part of the interface), I think this is broader than just 
inlining decision notes.

> But if folks decided some more invasive tracking was worth implementing 
> (alongside the debug info codepath that already exists but is perhaps too 
> slow to be always on) I wouldn't get up on a soapbox to strenuously object - 
> I just think it's a bit unfortunate to build a duplicate thing, but maybe 
> necessary.

Agreed on the unfortunateness of duplicating functionality; if we can avoid 
that, it'd be best. But I'm not sure we have more ideas on how to accomplish 
it, either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141451

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


[PATCH] D149144: [clang][dataflow] Eliminate intermediate `ReferenceValue`s from `Environment::DeclToLoc`.

2023-05-02 Thread Martin Böhme via Phabricator via cfe-commits
mboehme updated this revision to Diff 518709.
mboehme marked an inline comment as done.
mboehme added a comment.

Changes in response to review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149144

Files:
  clang/include/clang/Analysis/FlowSensitive/DataflowEnvironment.h
  clang/lib/Analysis/FlowSensitive/ControlFlowContext.cpp
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -403,14 +403,9 @@
 
 const StorageLocation *FooLoc =
 Env.getStorageLocation(*FooDecl, SkipPast::None);
-ASSERT_TRUE(isa_and_nonnull(FooLoc));
-
-const ReferenceValue *FooVal =
-cast(Env.getValue(*FooLoc));
-const StorageLocation &FooReferentLoc = FooVal->getReferentLoc();
-EXPECT_TRUE(isa(&FooReferentLoc));
+ASSERT_TRUE(isa_and_nonnull(FooLoc));
 
-const Value *FooReferentVal = Env.getValue(FooReferentLoc);
+const Value *FooReferentVal = Env.getValue(*FooLoc);
 EXPECT_TRUE(isa_and_nonnull(FooReferentVal));
   });
 }
@@ -494,11 +489,9 @@
 ASSERT_THAT(BazRefDecl, NotNull());
 ASSERT_THAT(BazPtrDecl, NotNull());
 
-const auto *FooLoc = cast(
+const auto *FooLoc = cast(
 Env.getStorageLocation(*FooDecl, SkipPast::None));
-const auto *FooVal = cast(Env.getValue(*FooLoc));
-const auto *FooReferentVal =
-cast(Env.getValue(FooVal->getReferentLoc()));
+const auto *FooReferentVal = cast(Env.getValue(*FooLoc));
 
 const auto *BarVal =
 cast(FooReferentVal->getChild(*BarDecl));
@@ -507,13 +500,17 @@
 
 const auto *FooRefVal =
 cast(BarReferentVal->getChild(*FooRefDecl));
-const StorageLocation &FooReferentLoc = FooRefVal->getReferentLoc();
-EXPECT_THAT(Env.getValue(FooReferentLoc), IsNull());
+const auto &FooReferentLoc =
+cast(FooRefVal->getReferentLoc());
+EXPECT_THAT(Env.getValue(FooReferentLoc), NotNull());
+EXPECT_THAT(Env.getValue(FooReferentLoc.getChild(*BarDecl)), IsNull());
 
 const auto *FooPtrVal =
 cast(BarReferentVal->getChild(*FooPtrDecl));
-const StorageLocation &FooPtrPointeeLoc = FooPtrVal->getPointeeLoc();
-EXPECT_THAT(Env.getValue(FooPtrPointeeLoc), IsNull());
+const auto &FooPtrPointeeLoc =
+cast(FooPtrVal->getPointeeLoc());
+EXPECT_THAT(Env.getValue(FooPtrPointeeLoc), NotNull());
+EXPECT_THAT(Env.getValue(FooPtrPointeeLoc.getChild(*BarDecl)), IsNull());
 
 const auto *BazRefVal =
 cast(BarReferentVal->getChild(*BazRefDecl));
@@ -1058,16 +1055,9 @@
 
 const StorageLocation *FooLoc =
 Env.getStorageLocation(*FooDecl, SkipPast::None);
-ASSERT_TRUE(isa_and_nonnull(FooLoc));
-
-const ReferenceValue *FooVal =
-dyn_cast(Env.getValue(*FooLoc));
-ASSERT_THAT(FooVal, NotNull());
+ASSERT_TRUE(isa_and_nonnull(FooLoc));
 
-const StorageLocation &FooReferentLoc = FooVal->getReferentLoc();
-EXPECT_TRUE(isa(&FooReferentLoc));
-
-const Value *FooReferentVal = Env.getValue(FooReferentLoc);
+const Value *FooReferentVal = Env.getValue(*FooLoc);
 EXPECT_TRUE(isa_and_nonnull(FooReferentVal));
   });
 }
@@ -1905,15 +1895,13 @@
 const ValueDecl *FooDecl = findValueDecl(ASTCtx, "Foo");
 ASSERT_THAT(FooDecl, NotNull());
 
-const auto *FooVal =
-cast(Env.getValue(*FooDecl, SkipPast::None));
+const auto *FooLoc = Env.getStorageLocation(*FooDecl);
 
 const ValueDecl *QuxDecl = findValueDecl(ASTCtx, "Qux");
 ASSERT_THAT(QuxDecl, NotNull());
 
-const auto *QuxVal =
-cast(Env.getValue(*QuxDecl, SkipPast::None));
-EXPECT_EQ(&QuxVal->getReferentLoc(), &FooVal->getReferentLoc());
+const auto *QuxLoc = Env.getStorageLocation(*QuxDecl);
+EXPECT_EQ(QuxLoc, FooLoc);
   });
 }
 
@@ -2593,9 +2581,8 @@
 
 const auto *FooVal =
 cast(Env.getValue(*FooDecl, SkipPast::None));
-const auto *BarVal =
-cast(Env.getValue(*BarDecl, SkipPast::None));
-EXPECT_EQ(&BarVal->getReferentLoc(), &FooVal->getPointeeLoc());
+const auto *BarLoc = Env.getStorageLocation(*BarDecl);
+EXPECT_EQ(BarLoc, &FooVal->getPointeeLoc());
   });
 }
 
@@ -2643,17 +2630,20 @@
 void target(int *Foo) {
   do {
 int Bar = *Foo;
+// [[in_loop]]
   } while (true);
   (void)0;
-  /*[[p]]*/
+  // [[after_loop]]
 }
   )";

[PATCH] D144999: [RFC][MC][MachO]Only emits compact-unwind format for "canonical" personality symbols. For the rest, use DWARFs.

2023-05-02 Thread Vy Nguyen via Phabricator via cfe-commits
oontvoo updated this revision to Diff 518710.
oontvoo added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

updated clang test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144999

Files:
  clang/test/Driver/femit-dwarf-unwind.c
  lld/MachO/UnwindInfoSection.cpp
  lld/test/MachO/Inputs/eh-frame-x86_64-r.o
  lld/test/MachO/compact-unwind-both-local-and-dylib-personality.s
  lld/test/MachO/compact-unwind-generated.test
  lld/test/MachO/compact-unwind-lsda-folding.s
  lld/test/MachO/compact-unwind-stack-ind.s
  lld/test/MachO/compact-unwind.s
  lld/test/MachO/eh-frame-personality-dedup.s
  lld/test/MachO/eh-frame.s
  lld/test/MachO/icf-only-lsda-folded.s
  lld/test/MachO/icf.s
  lld/test/MachO/invalid/compact-unwind-bad-reloc.s
  lld/test/MachO/invalid/compact-unwind-personalities.s
  llvm/include/llvm/MC/MCAsmBackend.h
  llvm/include/llvm/MC/MCContext.h
  llvm/include/llvm/MC/MCTargetOptions.h
  llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/MCContext.cpp
  llvm/lib/MC/MCStreamer.cpp
  llvm/lib/MC/MCTargetOptionsCommandFlags.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
  llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp

Index: llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
===
--- llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
+++ llvm/lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp
@@ -1350,9 +1350,13 @@
 
   /// Implementation of algorithm to generate the compact unwind encoding
   /// for the CFI instructions.
-  uint32_t
-  generateCompactUnwindEncoding(ArrayRef Instrs) const override {
+  uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
+ const MCContext *Ctxt) const override {
+ArrayRef Instrs = FI->Instructions;
 if (Instrs.empty()) return 0;
+if (!isDarwinCanonicalPersonality(FI->Personality) &&
+!Ctxt->emitCompactUnwindNonCanonical())
+  return CU::UNWIND_MODE_DWARF;
 
 // Reset the saved registers.
 unsigned SavedRegIdx = 0;
Index: llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
===
--- llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
+++ llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackendDarwin.h
@@ -11,6 +11,7 @@
 
 #include "ARMAsmBackend.h"
 #include "llvm/BinaryFormat/MachO.h"
+#include "llvm/MC/MCContext.h"
 #include "llvm/MC/MCObjectWriter.h"
 
 namespace llvm {
@@ -32,8 +33,8 @@
 /*Is64Bit=*/false, cantFail(MachO::getCPUType(TT)), Subtype);
   }
 
-  uint32_t generateCompactUnwindEncoding(
-  ArrayRef Instrs) const override;
+  uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
+ const MCContext *Ctxt) const override;
 };
 } // end namespace llvm
 
Index: llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
===
--- llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
+++ llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
@@ -1108,14 +1108,19 @@
 /// encoded in compact unwind, the method returns UNWIND_ARM_MODE_DWARF which
 /// tells the runtime to fallback and unwind using dwarf.
 uint32_t ARMAsmBackendDarwin::generateCompactUnwindEncoding(
-ArrayRef Instrs) const {
+const MCDwarfFrameInfo *FI, const MCContext *Ctxt) const {
   DEBUG_WITH_TYPE("compact-unwind", llvm::dbgs() << "generateCU()\n");
   // Only armv7k uses CFI based unwinding.
   if (Subtype != MachO::CPU_SUBTYPE_ARM_V7K)
 return 0;
   // No .cfi directives means no frame.
+  ArrayRef Instrs = FI->Instructions;
   if (Instrs.empty())
 return 0;
+  if (!isDarwinCanonicalPersonality(FI->Personality) &&
+  !Ctxt->emitCompactUnwindNonCanonical())
+return CU::UNWIND_ARM_MODE_DWARF;
+
   // Start off assuming CFA is at SP+0.
   unsigned CFARegister = ARM::SP;
   int CFARegisterOffset = 0;
Index: llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
===
--- llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
+++ llvm/lib/Target/AArch64/MCTargetDesc/AArch64AsmBackend.cpp
@@ -564,10 +564,14 @@
   }
 
   /// Generate the compact unwind encoding from the CFI directives.
-  uint32_t generateCompactUnwindEncoding(
- ArrayRef Instrs) const override {
+  uint32_t generateCompactUnwindEncoding(const MCDwarfFrameInfo *FI,
+ const MCContext *Ctxt) const override {
+ArrayRef Instrs = FI->Instructions;
 if (Instrs.empty())
   return CU::UNWIND_ARM64_MODE_FRAMELESS;
+if (!isDarwinCanonicalPersonality(FI->Personality) 

[PATCH] D149444: [ARM] Allow codegen for Armv6m eXecute-Only (XO) sections

2023-05-02 Thread Simon Wallis via Phabricator via cfe-commits
simonwallis2 added inline comments.



Comment at: llvm/lib/Target/ARM/ARMSubtarget.cpp:434
   // range otherwise.
-  return !NoMovt && hasV8MBaselineOps() &&
+  return !NoMovt && hasV6MOps() &&
  (isTargetWindows() || !OptMinSize || genExecuteOnly());

simonwallis2 wrote:
> V6M does not have Movt.
> At face value, this line looks wrong and leads to about 30 unit test fails.
> 
I clarify: there are no test fails with this patch on its own.
The unit test fails I saw where when building this patch in conjunction with 
related patch https://reviews.llvm.org/D149443


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149444

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


[PATCH] D148767: Restore CodeGen/LowLevelType from `Support`

2023-05-02 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni updated this revision to Diff 518713.
chapuni retitled this revision from "Restore CodeGen/LowLevelType" to "Restore 
CodeGen/LowLevelType from `Support`".
chapuni edited the summary of this revision.
chapuni added a comment.

- Rebase and update the desc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148767

Files:
  clang/lib/CodeGen/CMakeLists.txt
  llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
  llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
  llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h
  llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
  llvm/include/llvm/CodeGen/GlobalISel/Utils.h
  llvm/include/llvm/CodeGen/LowLevelType.h
  llvm/include/llvm/CodeGen/LowLevelTypeUtils.h
  llvm/include/llvm/CodeGen/MachineMemOperand.h
  llvm/include/llvm/CodeGen/RegisterBankInfo.h
  llvm/include/llvm/Support/LowLevelTypeImpl.h
  llvm/include/llvm/module.modulemap
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
  llvm/lib/CodeGen/LowLevelType.cpp
  llvm/lib/CodeGen/MIRParser/MIParser.cpp
  llvm/lib/CodeGen/MIRPrinter.cpp
  llvm/lib/CodeGen/MachineInstr.cpp
  llvm/lib/CodeGen/MachineVerifier.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/LowLevelType.cpp
  llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
  llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp
  llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
  llvm/lib/Target/ARC/Disassembler/CMakeLists.txt
  llvm/lib/Target/ARM/ARMCallLowering.cpp
  llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
  llvm/lib/Target/ARM/Disassembler/CMakeLists.txt
  llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AVR/AsmParser/CMakeLists.txt
  llvm/lib/Target/AVR/Disassembler/CMakeLists.txt
  llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/Lanai/AsmParser/CMakeLists.txt
  llvm/lib/Target/Lanai/Disassembler/CMakeLists.txt
  llvm/lib/Target/M68k/AsmParser/CMakeLists.txt
  llvm/lib/Target/M68k/Disassembler/CMakeLists.txt
  llvm/lib/Target/MSP430/AsmParser/CMakeLists.txt
  llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp
  llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/MCA/CMakeLists.txt
  llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/SystemZ/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/VE/AsmParser/CMakeLists.txt
  llvm/lib/Target/VE/Disassembler/CMakeLists.txt
  llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
  llvm/lib/Target/WebAssembly/Disassembler/CMakeLists.txt
  llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/X86/MCA/CMakeLists.txt
  llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/X86/X86CallLowering.cpp
  llvm/lib/Target/X86/X86InstructionSelector.cpp
  llvm/lib/Target/XCore/Disassembler/CMakeLists.txt
  llvm/tools/llvm-dwarfutil/CMakeLists.txt
  llvm/tools/llvm-exegesis/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/GlobalISel/CMakeLists.txt
  llvm/utils/TableGen/GlobalISelEmitter.cpp
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -616,6 +616,7 @@
 features = ["-header_modules"],
 strip_include_prefix = "utils/TableGen",
 deps = [
+":CodeGen",
 ":Support",
 ":TableGen",
 ":config",
@@ -642,11 +643,11 @@
 copts = llvm_copts,
 stamp = 0,
 deps = [
+":CodeGen",
 ":Support",
 ":TableGen",
 ":TableGenGlobalISel",
 ":config",
-":intrinsic_enums_gen",
 ":llvm-tblgen-headers",
 ],
 )
@@ -2336,6 +2337,7 @@
 copts = llvm_copts,
 features = ["-layering_check"],
 deps = [
+":CodeGen",
 ":MC",
 ":MCA",
 ":MCParser",
@@ -3404,6 +3406,7 @@
 deps = [
 ":AllTargetsAsmParsers",
 ":AllTargetsCodeGens",
+":CodeGen",
 ":DWARFLinker",
 ":DebugInfoDWARF",
 ":DwarfutilOptionsTableGen",
@@ -3444,6 +3447,7 @@
   

[PATCH] D147626: [clang] Reject flexible array member in a union in C++

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



Comment at: clang/test/SemaObjCXX/flexible-array.mm:7
   int s;
-  char c[];
+  char c[]; //expected-error {{flexible array member 'c' in a union is not 
allowed}}
 };

CC @rjmccall -- this is changing Objective-C++ behavior, which I assume you're 
fine with because it's following the same changes in C++ behavior, but wanted 
to call out explicitly in case you had concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147626

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


[PATCH] D148223: [SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

2023-05-02 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

Hello and Good Afternoon from the UK,

I believe this revision has started the following build bot to start failing on 
these 5 tests:

https://lab.llvm.org/buildbot/#/builders/216/builds/20627

xsfvcp-x-rv64.c
xsfvcp-x.c
xsfvcp-xv.c
xsfvcp-xvv.c
xsfvcp-xvw.c

Is anyone able to take a look?

Thanks in advance,
Tom W


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

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


[PATCH] D149144: [clang][dataflow] Eliminate intermediate `ReferenceValue`s from `Environment::DeclToLoc`.

2023-05-02 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked 5 inline comments as done.
mboehme added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:307-311
+  auto &ParamLoc =
+  createStorageLocation(ParamDecl->getType().getNonReferenceType());
   setStorageLocation(*ParamDecl, ParamLoc);
-  if (Value *ParamVal = createValue(ParamDecl->getType()))
-setValue(ParamLoc, *ParamVal);
+  if (Value *ParamVal =
+  createValue(ParamDecl->getType().getNonReferenceType()))

ymandel wrote:
> Maybe comment as to why we're not use the `VarDecl` overloads of 
> `createStorageLocation` and why we're specifically using 
> `getNonReferenceType` for `createValue`.
Added comment on the `getNonReferenceType()`.

As to why we're not using the `VarDecl` overload -- it's really just because we 
don't need the "stable" location behavior here. Wasn't sure if this rises to 
the level of needing to be addressed in a comment, so I've left it out for now. 
WDYT?



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:616
+  bool erased = DeclToLoc.erase(&D);
+  if (!erased)
+D.dump();

xazax.hun wrote:
> Would we dump this in release builds? Do we want to limit this to 
> debug/assert builds?
True, we'd want to do this only in debug builds. For simplicity, I've taken out 
the `dump` entirely -- it's easy enough to add back if we do actually encounter 
assertion failures here.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp:631
+
+  assert(dyn_cast_or_null(getValue(*Loc)) == nullptr);
+

ymandel wrote:
> would `isa_and_nonnull` work?
Good point, done!



Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:329
+  // against this above.
+  ProcessVarDecl(*VD);
+  auto *VDLoc = Env.getStorageLocation(*VD);

ymandel wrote:
> why the recursive call rather than relying on what we know about their 
> structure?
Not sure exactly what you're asking?

If we don't want to make a recursive call here, we'd need to duplicate behavior 
that `ProcessVarDecl()` already contains and inline that code here. It seems 
preferable to just call `ProcessVarDecl()` instead? (Or to put it differently, 
what is a reason against making this call?)



Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:329
+static void
+builtinTransferScopeEnd(const CFGScopeEnd &Elt,
+TypeErasedDataflowAnalysisState &InputState) {

xazax.hun wrote:
> I think one question is whether we are interested in ScopeEnd or LifetimeEnd, 
> see the discussions in https://reviews.llvm.org/D15031 and 
> https://reviews.llvm.org/D16403, specifically Devin's comment: 
> 
> >>! In D16403#799926, @dcoughlin wrote:
> >> @dcoughlin As a reviewer of both patches - could you tell us what's the 
> >> difference between them? And how are we going to resolve this issue?
> > 
> > These two patches are emitting markers in the CFG for different things.
> > 
> > Here is how I would characterize the difference between the two patches.
> > 
> > - Despite its name, https://reviews.llvm.org/D15031, is really emitting 
> > markers for when the lifetime of a C++ object in an automatic variable 
> > ends.  For C++ objects with non-trivial destructors, this point is when the 
> > destructor is called. At this point the storage for the variable still 
> > exists, but what you can do with that storage is very restricted by the 
> > language because its contents have been destroyed. Note that even with the 
> > contents of the object have been destroyed, it is still meaningful to, say, 
> > take the address of the variable and construct a new object into it with a 
> > placement new. In other words, the same variable can have different 
> > objects, with different lifetimes, in it at different program points.
> > 
> > - In contrast, the purpose of this patch (https://reviews.llvm.org/D16403) 
> > is to add markers for when the storage duration for the variable begins and 
> > ends (this is, when the storage exists). Once the storage duration has 
> > ended, you can't placement new into the variables address, because another 
> > variable may already be at that address.
> > 
> > I don't think there is an "issue" to resolve here.  We should make sure the 
> > two patches play nicely with each other, though. In particular, we should 
> > make sure that the markers for when lifetime ends and when storage duration 
> > ends are ordered correctly.
> 
> 
> What I wanted to add, I wonder if we might not get ScopeEnd event for 
> temporaries and there might be other differences. The Clang implementation of 
> P1179 used LifetimeEnd instead of ScopeEnd, and I believe probably most 
> clients are more interested in LifetimeEnd events rather than ScopeEnd.
> 
> I think I understand why you went with ScopeEnd for th

[PATCH] D149380: [clang] Add -Wunused-result-always warning

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

In D149380#4311237 , @dblaikie wrote:

> Seems more stylistic/unlikely to meet the diagnostic bar (certtainly couldn't 
> be on-by-default for instance) for clang to me (but could go into something 
> like clang-tidy), at least.

+1 -- we expect new diagnostics to be ones we can enable by default (experience 
has shown us that off-by-default warnings don't typically get enabled often 
enough to be worth adding except for special circumstances), and there's 
basically no way to enable this by default. However, it does seem appropriate 
as a clang-tidy check: https://clang.llvm.org/extra/clang-tidy/Contributing.html


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149380

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


[PATCH] D149650: Give NullabilityKind a printing operator<

2023-05-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added a reviewer: mboehme.
Herald added a project: All.
sammccall requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This is more useful for debug/test than getNullabilitySpelling:

- default form has uglifying underscores
- non-default form crashes on NullableResult
- both return unhelpfully verbose strings for Unspecified
- operator<< works with gtest, formatv, etc


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149650

Files:
  clang/include/clang/Basic/Specifiers.h
  clang/lib/Basic/IdentifierTable.cpp


Index: clang/lib/Basic/IdentifierTable.cpp
===
--- clang/lib/Basic/IdentifierTable.cpp
+++ clang/lib/Basic/IdentifierTable.cpp
@@ -849,6 +849,20 @@
   llvm_unreachable("Unknown nullability kind.");
 }
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, NullabilityKind NK) {
+  switch (NK) {
+  case NullabilityKind::NonNull:
+return OS << "NonNull";
+  case NullabilityKind::Nullable:
+return OS << "Nullable";
+  case NullabilityKind::NullableResult:
+return OS << "NullableResult";
+  case NullabilityKind::Unspecified:
+return OS << "Unspecified";
+  }
+  llvm_unreachable("Unknown nullability kind.");
+}
+
 diag::kind
 IdentifierTable::getFutureCompatDiagKind(const IdentifierInfo &II,
  const LangOptions &LangOpts) {
Index: clang/include/clang/Basic/Specifiers.h
===
--- clang/include/clang/Basic/Specifiers.h
+++ clang/include/clang/Basic/Specifiers.h
@@ -19,6 +19,9 @@
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/ErrorHandling.h"
 
+namespace llvm {
+class raw_ostream;
+} // namespace llvm
 namespace clang {
 
   /// Define the meaning of possible values of the kind in ExplicitSpecifier.
@@ -333,6 +336,8 @@
 // parameters are assumed to only get null on error.
 NullableResult,
   };
+  /// Prints human-readable debug representation.
+  llvm::raw_ostream &operator<<(llvm::raw_ostream&, NullabilityKind);
 
   /// Return true if \p L has a weaker nullability annotation than \p R. The
   /// ordering is: Unspecified < Nullable < NonNull.


Index: clang/lib/Basic/IdentifierTable.cpp
===
--- clang/lib/Basic/IdentifierTable.cpp
+++ clang/lib/Basic/IdentifierTable.cpp
@@ -849,6 +849,20 @@
   llvm_unreachable("Unknown nullability kind.");
 }
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, NullabilityKind NK) {
+  switch (NK) {
+  case NullabilityKind::NonNull:
+return OS << "NonNull";
+  case NullabilityKind::Nullable:
+return OS << "Nullable";
+  case NullabilityKind::NullableResult:
+return OS << "NullableResult";
+  case NullabilityKind::Unspecified:
+return OS << "Unspecified";
+  }
+  llvm_unreachable("Unknown nullability kind.");
+}
+
 diag::kind
 IdentifierTable::getFutureCompatDiagKind(const IdentifierInfo &II,
  const LangOptions &LangOpts) {
Index: clang/include/clang/Basic/Specifiers.h
===
--- clang/include/clang/Basic/Specifiers.h
+++ clang/include/clang/Basic/Specifiers.h
@@ -19,6 +19,9 @@
 #include "llvm/Support/DataTypes.h"
 #include "llvm/Support/ErrorHandling.h"
 
+namespace llvm {
+class raw_ostream;
+} // namespace llvm
 namespace clang {
 
   /// Define the meaning of possible values of the kind in ExplicitSpecifier.
@@ -333,6 +336,8 @@
 // parameters are assumed to only get null on error.
 NullableResult,
   };
+  /// Prints human-readable debug representation.
+  llvm::raw_ostream &operator<<(llvm::raw_ostream&, NullabilityKind);
 
   /// Return true if \p L has a weaker nullability annotation than \p R. The
   /// ordering is: Unspecified < Nullable < NonNull.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D149650: Give NullabilityKind a printing operator<

2023-05-02 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/lib/Basic/IdentifierTable.cpp:852
 
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, NullabilityKind NK) {
+  switch (NK) {

IdentifierTable.cpp is a weird place to implement this function (I put it next 
to getNullabilitySpelling).
Happy to move to a different file, or add a new file, if you think either is 
significantly better.

Similarly, happy to add a test for this if it's worth having a unittest with 
only this (obviously nothing else in Specifiers is tested)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149650

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


[PATCH] D146764: [clang] Make predefined expressions string literals under -fms-extensions

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

In D146764#4310655 , @aeubanks wrote:

> In D146764#4310398 , @aaron.ballman 
> wrote:
>
>> I think you're missing changes in ASTReaderStmt.cpp and ASTWriterStmt.cpp, 
>> so serialization through modules or PCH won't work without that.
>
> done. how would this sort of change be tested?

Thanks! Typically with a test using modules or PCH, so something along these 
lines: 
https://github.com/llvm/llvm-project/blob/main/clang/test/Modules/cxx20-10-5-ex1.cpp
 and/or 
https://github.com/llvm/llvm-project/blob/main/clang/test/PCH/cxx-namespaces.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146764

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


[PATCH] D149215: [MemProf] Control availability of hot/cold operator new from LTO link

2023-05-02 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson updated this revision to Diff 518721.
tejohnson added a comment.

Address comment (add TODO about automatically detecting support)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149215

Files:
  clang/test/CodeGen/thinlto-distributed-supports-hot-cold-new.ll
  llvm/include/llvm/IR/ModuleSummaryIndex.h
  llvm/include/llvm/LTO/LTO.h
  llvm/lib/Bitcode/Reader/BitcodeReader.cpp
  llvm/lib/IR/ModuleSummaryIndex.cpp
  llvm/lib/LTO/LTO.cpp
  llvm/lib/LTO/LTOBackend.cpp
  llvm/lib/Transforms/IPO/MemProfContextDisambiguation.cpp
  llvm/test/LTO/X86/memprof-supports-hot-cold-new.ll
  llvm/test/ThinLTO/X86/memprof-basic.ll
  llvm/test/ThinLTO/X86/memprof-duplicate-context-ids.ll
  llvm/test/ThinLTO/X86/memprof-duplicate-context-ids2.ll
  llvm/test/ThinLTO/X86/memprof-funcassigncloning.ll
  llvm/test/ThinLTO/X86/memprof-indirectcall.ll
  llvm/test/ThinLTO/X86/memprof-inlined.ll
  llvm/test/ThinLTO/X86/memprof-inlined2.ll
  llvm/test/ThinLTO/X86/memprof-supports-hot-cold-new.ll
  llvm/test/Transforms/MemProfContextDisambiguation/basic.ll
  llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids.ll
  llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
  llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
  llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
  llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
  llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll

Index: llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/inlined2.ll
@@ -42,7 +42,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:	%s -S 2>&1 | FileCheck %s --check-prefix=DUMP
 
Index: llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/inlined.ll
@@ -41,7 +41,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:	-memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:	-memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
Index: llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/indirectcall.ll
@@ -51,7 +51,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -memprof-export-to-dot -memprof-dot-file-path-prefix=%t. \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
Index: llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/funcassigncloning.ll
@@ -45,7 +45,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -stats -pass-remarks=memprof-context-disambiguation \
 ; RUN:  %s -S 2>&1 | FileCheck %s --check-prefix=DUMP --check-prefix=IR \
Index: llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
===
--- llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
+++ llvm/test/Transforms/MemProfContextDisambiguation/duplicate-context-ids2.ll
@@ -93,7 +93,7 @@
 ;;
 ;; The IR was then reduced using llvm-reduce with the expected FileCheck input.
 
-; RUN: opt -passes=memprof-context-disambiguation \
+; RUN: opt -passes=memprof-context-disambiguation -supports-hot-cold-new \
 ; RUN:  -memprof-verify-ccg -memprof-verify-nodes -memprof-dump-ccg \
 ; RUN:  -memprof-export-to-dot -mem

[PATCH] D148223: [SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

In D148223#4312296 , @TWeaver wrote:

> Hello and Good Afternoon from the UK,
>
> I believe this revision has started the following build bot to start failing 
> on these 5 tests:
>
> https://lab.llvm.org/buildbot/#/builders/216/builds/20627
>
> xsfvcp-x-rv64.c
> xsfvcp-x.c
> xsfvcp-xv.c
> xsfvcp-xvv.c
> xsfvcp-xvw.c
>
> Is anyone able to take a look?
>
> Thanks in advance,
> Tom W

I'll take a look, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

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


[PATCH] D148769: Split out `CodeGenTypes` from `CodeGen` for LLT/MVT

2023-05-02 Thread NAKAMURA Takumi via Phabricator via cfe-commits
chapuni updated this revision to Diff 518722.
chapuni edited the summary of this revision.
chapuni added a comment.

- Updat the desc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148769

Files:
  clang/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
  llvm/lib/CodeGen/MIRParser/CMakeLists.txt
  llvm/lib/CodeGen/SelectionDAG/CMakeLists.txt
  llvm/lib/DWARFLinker/CMakeLists.txt
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
  llvm/lib/Target/AArch64/CMakeLists.txt
  llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
  llvm/lib/Target/AMDGPU/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
  llvm/lib/Target/ARC/CMakeLists.txt
  llvm/lib/Target/ARC/Disassembler/CMakeLists.txt
  llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
  llvm/lib/Target/ARM/CMakeLists.txt
  llvm/lib/Target/ARM/Disassembler/CMakeLists.txt
  llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AVR/AsmParser/CMakeLists.txt
  llvm/lib/Target/AVR/CMakeLists.txt
  llvm/lib/Target/AVR/Disassembler/CMakeLists.txt
  llvm/lib/Target/BPF/CMakeLists.txt
  llvm/lib/Target/CSKY/CMakeLists.txt
  llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/DirectX/CMakeLists.txt
  llvm/lib/Target/Hexagon/CMakeLists.txt
  llvm/lib/Target/Lanai/AsmParser/CMakeLists.txt
  llvm/lib/Target/Lanai/CMakeLists.txt
  llvm/lib/Target/Lanai/Disassembler/CMakeLists.txt
  llvm/lib/Target/LoongArch/CMakeLists.txt
  llvm/lib/Target/M68k/AsmParser/CMakeLists.txt
  llvm/lib/Target/M68k/CMakeLists.txt
  llvm/lib/Target/M68k/Disassembler/CMakeLists.txt
  llvm/lib/Target/MSP430/AsmParser/CMakeLists.txt
  llvm/lib/Target/MSP430/CMakeLists.txt
  llvm/lib/Target/Mips/CMakeLists.txt
  llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/NVPTX/CMakeLists.txt
  llvm/lib/Target/PowerPC/CMakeLists.txt
  llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/CMakeLists.txt
  llvm/lib/Target/RISCV/MCA/CMakeLists.txt
  llvm/lib/Target/SPIRV/CMakeLists.txt
  llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/Sparc/CMakeLists.txt
  llvm/lib/Target/SystemZ/CMakeLists.txt
  llvm/lib/Target/SystemZ/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/VE/AsmParser/CMakeLists.txt
  llvm/lib/Target/VE/CMakeLists.txt
  llvm/lib/Target/VE/Disassembler/CMakeLists.txt
  llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
  llvm/lib/Target/WebAssembly/CMakeLists.txt
  llvm/lib/Target/WebAssembly/Disassembler/CMakeLists.txt
  llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/WebAssembly/Utils/CMakeLists.txt
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/MCA/CMakeLists.txt
  llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/XCore/CMakeLists.txt
  llvm/lib/Target/XCore/Disassembler/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/llvm-dwarfutil/CMakeLists.txt
  llvm/tools/llvm-exegesis/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt
  llvm/tools/llvm-reduce/CMakeLists.txt
  llvm/unittests/CodeGen/CMakeLists.txt
  llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
  llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
  llvm/unittests/MI/CMakeLists.txt
  llvm/unittests/MIR/CMakeLists.txt
  llvm/unittests/Target/AArch64/CMakeLists.txt
  llvm/unittests/Target/AMDGPU/CMakeLists.txt
  llvm/unittests/Target/ARM/CMakeLists.txt
  llvm/unittests/Target/LoongArch/CMakeLists.txt
  llvm/unittests/Target/WebAssembly/CMakeLists.txt
  llvm/unittests/Target/X86/CMakeLists.txt
  llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/GlobalISel/CMakeLists.txt
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
@@ -141,6 +141,7 @@
 "//llvm:AsmParser",
 "//llvm:BinaryFormat",
 "//llvm:CodeGen",
+"//llvm:CodeGenTypes",
 "//llvm:Core",
 "//llvm:MC",
 "//llvm:Passes",
@@ -169,6 +170,7 @@
 

[PATCH] D149650: Give NullabilityKind a printing operator<

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

I guess I'm not seeing much motivation for this change. We already have 
`clang::getNullabilitySpelling()` and `const StreamingDiagnostic 
&clang::operator<<(const StreamingDiagnostic &DB, DiagNullabilityKind 
nullability)` and now we're adding a third way to get this information. If this 
is just for debug/testing purposes, can we use existing debug formatters to 
convert the enumeration value into the enumerator name instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149650

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


[PATCH] D149641: [docs] Hide collaboration and include graphs in doxygen docs

2023-05-02 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

Looks good on the OpenMP side as we don’t generally have a good API doc anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149641

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


[PATCH] D149492: [clang] makes built-in traits match their stdlib counterparts' names

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

In D149492#4311026 , @cjdb wrote:

> Looks like I need to special-case `__is_null_pointer` as a function for 
> libstdc++.

Yeah, precommit CI found an issue with that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149492

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


[PATCH] D148223: [SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

2023-05-02 Thread Tom Weaver via Phabricator via cfe-commits
TWeaver added a comment.

In D148223#4312352 , @4vtomat wrote:

> I'll take a look, thanks!

Much obliged and thanks for the speedy reply! 👍


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

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


[PATCH] D148223: [SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

Hi @craig.topper and @kito-cheng , the build error message was: 
'z:\test\build\lib\clang\17\include\sifive_vector.h:12:10: fatal error: 
'riscv_vector.h' file not found'.
Have you ever met this before? I'm not sure if I forgot to add something or 
not..


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-05-02 Thread David Goldblatt via Phabricator via cfe-commits
davidtgoldblatt added a comment.

This breaks ~the world in the versions of libstdc++ I can easily check -- see 
e.g. https://gcc.godbolt.org/z/ETeGzc3ve (crashes at this commit, changes to an 
error at ce861ec782ae3f41807b61e855512aaccf3c2149 
).

I'm not deep enough into this nook of the language to tell if the bug is here 
or libstdc++, though.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D148654: Modify BoundsSan to improve debuggability

2023-05-02 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

Thinking about this a bit more, should the trap not have an associated stack 
trace that can be symbolicated to tell you which line of code was crashing? If 
the issue is that multiple traps can get folded together, the `nomerge` 
attribute (D78659 ) could be useful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148654

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

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

In D146178#4312473 , @davidtgoldblatt 
wrote:

> This breaks ~the world in the versions of libstdc++ I can easily check -- see 
> e.g. https://gcc.godbolt.org/z/ETeGzc3ve (crashes at this commit, changes to 
> an error at ce861ec782ae3f41807b61e855512aaccf3c2149 
> ).
>
> I'm not deep enough into this nook of the language to tell if the bug is here 
> or libstdc++, though.

Anything that is fixed by e861ec782 is almost definitely a clang bug. I 
objected to that quite strongly in this patch, and am quite disappointed that 
it made it back in.  We're likely going to have a significant number of clang 
bugs that were previously an assert now be an odd, incorrect diagnostic.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D149637: [Clang] Correctly expand pack in binary subscript expression.

2023-05-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.

LGTM, other than my comment on the diagnostic wording




Comment at: clang/test/SemaCXX/cxx2b-overloaded-operator.cpp:101
+  int arr[] = {1, 2, 3};
+  return arr[Is...]; // expected-error 2{{type 'int[3]' does not provide a 
subscript operator}}
+}

The diagnostic is not great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149637

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


[PATCH] D148997: [clang] Add a new annotation token: annot_repl_input_end

2023-05-02 Thread Jun Zhang via Phabricator via cfe-commits
junaire updated this revision to Diff 518738.
junaire marked 3 inline comments as done.
junaire added a comment.

Address comments, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148997

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Interpreter/IncrementalParser.cpp
  clang/lib/Lex/PPLexerChange.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseStmt.cpp
  clang/lib/Parse/Parser.cpp

Index: clang/lib/Parse/Parser.cpp
===
--- clang/lib/Parse/Parser.cpp
+++ clang/lib/Parse/Parser.cpp
@@ -320,6 +320,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_repl_input_end:
   // Stop before we change submodules. They generally indicate a "good"
   // place to pick up parsing again (except in the special case where
   // we're trying to skip to EOF).
@@ -614,11 +615,6 @@
Sema::ModuleImportState &ImportState) {
   DestroyTemplateIdAnnotationsRAIIObj CleanupRAII(*this);
 
-  // Skip over the EOF token, flagging end of previous input for incremental
-  // processing
-  if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
-ConsumeToken();
-
   Result = nullptr;
   switch (Tok.getKind()) {
   case tok::annot_pragma_unused:
@@ -697,6 +693,7 @@
 return false;
 
   case tok::eof:
+  case tok::annot_repl_input_end:
 // Check whether -fmax-tokens= was reached.
 if (PP.getMaxTokens() != 0 && PP.getTokenCount() > PP.getMaxTokens()) {
   PP.Diag(Tok.getLocation(), diag::warn_max_tokens_total)
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -543,9 +543,22 @@
 return ParseCaseStatement(StmtCtx, /*MissingCase=*/true, Expr);
   }
 
-  // Otherwise, eat the semicolon.
-  ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
-  return handleExprStmt(Expr, StmtCtx);
+  Token *CurTok = nullptr;
+  // If the semicolon is missing at the end of REPL input, consider if
+  // we want to do value printing. Note this is only enabled in C++ mode
+  // since part of the implementation requires C++ language features.
+  // Note we shouldn't eat the token since the callback needs it.
+  if (Tok.is(tok::annot_repl_input_end) && Actions.getLangOpts().CPlusPlus)
+CurTok = &Tok;
+  else
+// Otherwise, eat the semicolon.
+ExpectAndConsumeSemi(diag::err_expected_semi_after_expr);
+
+  StmtResult R = handleExprStmt(Expr, StmtCtx);
+  if (CurTok && !R.isInvalid())
+CurTok->setAnnotationValue(R.get());
+
+  return R;
 }
 
 /// ParseSEHTryBlockCommon
Index: clang/lib/Parse/ParseDecl.cpp
===
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -2069,6 +2069,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_repl_input_end:
   return;
 
 default:
@@ -5453,6 +5454,13 @@
 
   SmallVector DeclsInGroup;
   DeclsInGroup.push_back(Actions.ActOnTopLevelStmtDecl(R.get()));
+
+  if (Tok.is(tok::annot_repl_input_end) &&
+  Tok.getAnnotationValue() != nullptr) {
+ConsumeAnnotationToken();
+cast(DeclsInGroup.back())->setValuePrinting();
+  }
+
   // Currently happens for things like  -fms-extensions and use `__if_exists`.
   for (Stmt *S : Stmts)
 DeclsInGroup.push_back(Actions.ActOnTopLevelStmtDecl(S));
Index: clang/lib/Parse/ParseCXXInlineMethods.cpp
===
--- clang/lib/Parse/ParseCXXInlineMethods.cpp
+++ clang/lib/Parse/ParseCXXInlineMethods.cpp
@@ -836,6 +836,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_repl_input_end:
   // Ran out of tokens.
   return false;
 
@@ -1242,6 +1243,7 @@
 case tok::annot_module_begin:
 case tok::annot_module_end:
 case tok::annot_module_include:
+case tok::annot_repl_input_end:
   // Ran out of tokens.
   return false;
 
Index: clang/lib/Lex/PPLexerChange.cpp
===
--- clang/lib/Lex/PPLexerChange.cpp
+++ clang/lib/Lex/PPLexerChange.cpp
@@ -535,13 +535,19 @@
   return LeavingSubmodule;
 }
   }
-
   // If this is the end of the main file, form an EOF token.
   assert(CurLexer && "Got EOF but no current lexer set!");
   const char *EndPos = getCurLexerEndPos();
   Result.startToken();
   CurLexer->BufferPtr = EndPos;
-  CurLexer->FormTokenW

[PATCH] D148997: [clang] Add a new annotation token: annot_repl_input_end

2023-05-02 Thread Jun Zhang via Phabricator via cfe-commits
junaire added inline comments.



Comment at: clang/lib/Interpreter/IncrementalParser.cpp:162
+  if (P->getCurToken().is(tok::annot_repl_input_end)) {
+P->ConsumeAnyToken();
 // FIXME: Clang does not call ExitScope on finalizing the regular TU, we

rsmith wrote:
> 
Sorry but that's a private member function so I can't do that. Should I make it 
public?



Comment at: clang/lib/Parse/Parser.cpp:620-621
   // processing
-  if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::eof))
-ConsumeToken();
+  if (PP.isIncrementalProcessingEnabled() && Tok.is(tok::annot_repl_input_end))
+ConsumeAnnotationToken();
 

rsmith wrote:
> Do we need to do this here? `IncrementalParser` already seems to take care of 
> this, and the logic here would be easier to reason about if `Parser` never 
> steps past an `annot_repl_input_end` token, and such tokens instead are only 
> ever consumed by the REPL.
> 
> Are there other users of incremental processing mode, other than the REPL / 
> `IncrementalParser`?
Make sense to me, I'll remove it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148997

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


[PATCH] D149144: [clang][dataflow] Eliminate intermediate `ReferenceValue`s from `Environment::DeclToLoc`.

2023-05-02 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel accepted this revision.
ymandel added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/Transfer.cpp:329
+  // against this above.
+  ProcessVarDecl(*VD);
+  auto *VDLoc = Env.getStorageLocation(*VD);

mboehme wrote:
> ymandel wrote:
> > why the recursive call rather than relying on what we know about their 
> > structure?
> Not sure exactly what you're asking?
> 
> If we don't want to make a recursive call here, we'd need to duplicate 
> behavior that `ProcessVarDecl()` already contains and inline that code here. 
> It seems preferable to just call `ProcessVarDecl()` instead? (Or to put it 
> differently, what is a reason against making this call?)
At least previously, given what we know of their structure, the inlining was 
trivial. But, I think your second point is key -- why not recursively call -- 
it's a clean solution. I'm fine with that, thx.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149144

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


[clang] 3e850a6 - Revert "[Clang][Sema] Fix comparison of constraint expressions"

2023-05-02 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2023-05-02T08:09:35-07:00
New Revision: 3e850a6eea5277082a0b7b701754c86530d25c40

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

LOG: Revert "[Clang][Sema] Fix comparison of constraint expressions"

This reverts commit e3b1083e00e62f5d157d15cb8c63a1c3dfdf12e2.

This was reverted because it breaks a number of libstdc++ examples, AND
required a workaround that causes hiding of legitimate bugs.

Added: 


Modified: 
clang/include/clang/AST/DeclTemplate.h
clang/include/clang/Sema/Template.h
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
clang/test/SemaTemplate/concepts-friends.cpp
clang/test/SemaTemplate/concepts-out-of-line-def.cpp
clang/test/SemaTemplate/concepts.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclTemplate.h 
b/clang/include/clang/AST/DeclTemplate.h
index 7cd505218f2b9..3677335fa176f 100644
--- a/clang/include/clang/AST/DeclTemplate.h
+++ b/clang/include/clang/AST/DeclTemplate.h
@@ -2309,15 +2309,9 @@ class ClassTemplateDecl : public 
RedeclarableTemplateDecl {
 return static_cast(RedeclarableTemplateDecl::getCommonPtr());
   }
 
-  void setCommonPtr(Common *C) {
-RedeclarableTemplateDecl::Common = C;
-  }
-
 public:
-
   friend class ASTDeclReader;
   friend class ASTDeclWriter;
-  friend class TemplateDeclInstantiator;
 
   /// Load any lazily-loaded specializations from the external source.
   void LoadLazySpecializations() const;

diff  --git a/clang/include/clang/Sema/Template.h 
b/clang/include/clang/Sema/Template.h
index 1de2cc6917b42..48e8b78311e12 100644
--- a/clang/include/clang/Sema/Template.h
+++ b/clang/include/clang/Sema/Template.h
@@ -232,21 +232,9 @@ enum class TemplateSubstitutionKind : char {
 /// Replaces the current 'innermost' level with the provided argument list.
 /// This is useful for type deduction cases where we need to get the entire
 /// list from the AST, but then add the deduced innermost list.
-void replaceInnermostTemplateArguments(Decl *AssociatedDecl, ArgList Args) 
{
-  assert((!TemplateArgumentLists.empty() || NumRetainedOuterLevels) &&
- "Replacing in an empty list?");
-
-  if (!TemplateArgumentLists.empty()) {
-assert((TemplateArgumentLists[0].AssociatedDeclAndFinal.getPointer() ||
-TemplateArgumentLists[0].AssociatedDeclAndFinal.getPointer() ==
-AssociatedDecl) &&
-   "Trying to change incorrect declaration?");
-TemplateArgumentLists[0].Args = Args;
-  } else {
---NumRetainedOuterLevels;
-TemplateArgumentLists.push_back(
-{{AssociatedDecl, /*Final=*/false}, Args});
-  }
+void replaceInnermostTemplateArguments(ArgList Args) {
+  assert(TemplateArgumentLists.size() > 0 && "Replacing in an empty 
list?");
+  TemplateArgumentLists[0].Args = Args;
 }
 
 /// Add an outermost level that we are not substituting. We have no

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index f208cdbd1d87d..328d66bf33afa 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -721,7 +721,7 @@ CalculateTemplateDepthForConstraints(Sema &S, const 
NamedDecl *ND,
   ND, /*Final=*/false, /*Innermost=*/nullptr, /*RelativeToPrimary=*/true,
   /*Pattern=*/nullptr,
   /*ForConstraintInstantiation=*/true, SkipForSpecialization);
-  return MLTAL.getNumLevels();
+  return MLTAL.getNumSubstitutedLevels();
 }
 
 namespace {
@@ -752,44 +752,27 @@ namespace {
   };
 } // namespace
 
-static const Expr *SubstituteConstraintExpression(Sema &S, const NamedDecl *ND,
-  const Expr *ConstrExpr) {
-  MultiLevelTemplateArgumentList MLTAL = S.getTemplateInstantiationArgs(
-  ND, /*Final=*/false, /*Innermost=*/nullptr,
-  /*RelativeToPrimary=*/true,
-  /*Pattern=*/nullptr, /*ForConstraintInstantiation=*/true,
-  /*SkipForSpecialization*/ false);
-  if (MLTAL.getNumSubstitutedLevels() == 0)
-return ConstrExpr;
-
-  Sema::SFINAETrap SFINAE(S, /*AccessCheckingSFINAE=*/false);
-  std::optional ThisScope;
-  if (auto *RD = dyn_cast(ND->getDeclContext()))
-ThisScope.emplace(S, const_cast(RD), Qualifiers());
-  ExprResult SubstConstr =
-  S.SubstConstraintExpr(const_cast(ConstrExpr), MLTAL);
-  if (SFINAE.hasErrorOccurred() || !SubstConstr.isUsable())
-return nullptr;
-  return SubstConstr.get();
-}
-
 bool Sema::AreConstraintExpressionsEqual(const NamedDecl *Old,
  const Expr *OldConstr,

[clang] ad71114 - Revert "[Clang][Sema] Add a temporary workaround in SemaConcept.cpp"

2023-05-02 Thread Erich Keane via cfe-commits

Author: Erich Keane
Date: 2023-05-02T08:09:01-07:00
New Revision: ad7111495f43fe8f837007b9e21afb9e515df4d1

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

LOG: Revert "[Clang][Sema] Add a temporary workaround in SemaConcept.cpp"

This reverts commit ce861ec782ae3f41807b61e855512aaccf3c2149.

Added: 


Modified: 
clang/lib/Sema/SemaConcept.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index a9335d6689ec1..f208cdbd1d87d 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -260,11 +260,6 @@ calculateConstraintSatisfaction(Sema &S, const Expr 
*ConstraintExpr,
 return SubstitutedAtomicExpr;
   }
 
-  // FIXME: Remove this workaround.
-  // It's necessary to investigate how we get here.
-  if (SubstitutedAtomicExpr.get()->isValueDependent())
-return SubstitutedAtomicExpr;
-
   EnterExpressionEvaluationContext ConstantEvaluated(
   S, Sema::ExpressionEvaluationContext::ConstantEvaluated);
   SmallVector EvaluationDiags;



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


[PATCH] D149637: [Clang] Correctly expand pack in binary subscript expression.

2023-05-02 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/test/SemaCXX/cxx2b-overloaded-operator.cpp:101
+  int arr[] = {1, 2, 3};
+  return arr[Is...]; // expected-error 2{{type 'int[3]' does not provide a 
subscript operator}}
+}

shafik wrote:
> The diagnostic is not great.
Indeed. The issue is that we only add the built-in to the set of candidates if 
there are two args (ie one index, after expansion).
So we cannot produce a nice error with mismatching arity.
I looked into changing that but it requires some refactor to how we add 
built-in to the overload set and diagnose built-ins. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149637

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


[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

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

I reverted due to the workaround (which I'd objected to before, I don't think 
it is acceptable) and the breakage David mentioned.  I'll make sure to review 
the commit message when you put it back up for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D148223: [SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

2023-05-02 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D148223#4312460 , @4vtomat wrote:

> Hi @craig.topper and @kito-cheng , the build error message was: 
> 'Z:\test\llvm-project\clang\test\CodeGen\RISCV\rvv-intrinsics-autogenerated\non-policy\non-overloaded\xsfvcp-x-rv64.c:4:10:
>  fatal error: 'riscv_vector.h' file not found'.
> Have you ever met this before? I'm not sure if I forgot to add something or 
> not..

This bot only builds the x86_64 backend. Isn’t that file only generated when 
the riscv backend is built?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

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


[PATCH] D149119: [CMake] Use llvm-nm to extract symbols for staged LTO builds on Windows

2023-05-02 Thread Simon Tatham via Phabricator via cfe-commits
simon_tatham added a comment.

Do LLVM's current portability goals include the constraint that you can only 
build LLVM for a platform it can also target? If not, then there surely still 
needs to be //some// kind of escape hatch so that you can avoid needing 
`llvm-nm` to already support the object file format of the host platform.

I suppose you could say that in that unusual situation it's up to you to adapt 
`extract_symbols.py` so that it has some other way to get the answers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149119

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


[PATCH] D148223: [SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

In D148223#4312460 , @4vtomat wrote:

> Hi @craig.topper and @kito-cheng , the build error message was: 
> 'Z:\test\llvm-project\clang\test\CodeGen\RISCV\rvv-intrinsics-autogenerated\non-policy\non-overloaded\xsfvcp-x-rv64.c:4:10:
>  fatal error: 'riscv_vector.h' file not found'.
> Have you ever met this before? I'm not sure if I forgot to add something or 
> not..

I found it, seems I have to add this in the beginning of the file: '// 
REQUIRES: riscv-registered-target' to prevent the test case run in other 
targets.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

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


[PATCH] D148767: Restore CodeGen/LowLevelType from `Support`

2023-05-02 Thread NAKAMURA Takumi 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 rG9cfeba5b12b6: Restore CodeGen/LowLevelType from `Support` 
(authored by chapuni).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148767

Files:
  clang/lib/CodeGen/CMakeLists.txt
  llvm/include/llvm/CodeGen/GlobalISel/CallLowering.h
  llvm/include/llvm/CodeGen/GlobalISel/CombinerHelper.h
  llvm/include/llvm/CodeGen/GlobalISel/InstructionSelector.h
  llvm/include/llvm/CodeGen/GlobalISel/LegacyLegalizerInfo.h
  llvm/include/llvm/CodeGen/GlobalISel/LegalizerInfo.h
  llvm/include/llvm/CodeGen/GlobalISel/Utils.h
  llvm/include/llvm/CodeGen/LowLevelType.h
  llvm/include/llvm/CodeGen/LowLevelTypeUtils.h
  llvm/include/llvm/CodeGen/MachineMemOperand.h
  llvm/include/llvm/CodeGen/RegisterBankInfo.h
  llvm/include/llvm/Support/LowLevelTypeImpl.h
  llvm/include/llvm/module.modulemap
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
  llvm/lib/CodeGen/GlobalISel/LegalizerInfo.cpp
  llvm/lib/CodeGen/LowLevelType.cpp
  llvm/lib/CodeGen/MIRParser/MIParser.cpp
  llvm/lib/CodeGen/MIRPrinter.cpp
  llvm/lib/CodeGen/MachineInstr.cpp
  llvm/lib/CodeGen/MachineVerifier.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/LowLevelType.cpp
  llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
  llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/AMDGPUGlobalISelUtils.cpp
  llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
  llvm/lib/Target/ARC/Disassembler/CMakeLists.txt
  llvm/lib/Target/ARM/ARMCallLowering.cpp
  llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
  llvm/lib/Target/ARM/Disassembler/CMakeLists.txt
  llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AVR/AsmParser/CMakeLists.txt
  llvm/lib/Target/AVR/Disassembler/CMakeLists.txt
  llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/Lanai/AsmParser/CMakeLists.txt
  llvm/lib/Target/Lanai/Disassembler/CMakeLists.txt
  llvm/lib/Target/M68k/AsmParser/CMakeLists.txt
  llvm/lib/Target/M68k/Disassembler/CMakeLists.txt
  llvm/lib/Target/MSP430/AsmParser/CMakeLists.txt
  llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/Mips/MCTargetDesc/MipsABIInfo.cpp
  llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/MCA/CMakeLists.txt
  llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/SystemZ/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/VE/AsmParser/CMakeLists.txt
  llvm/lib/Target/VE/Disassembler/CMakeLists.txt
  llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
  llvm/lib/Target/WebAssembly/Disassembler/CMakeLists.txt
  llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/X86/MCA/CMakeLists.txt
  llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/X86/X86CallLowering.cpp
  llvm/lib/Target/X86/X86InstructionSelector.cpp
  llvm/lib/Target/XCore/Disassembler/CMakeLists.txt
  llvm/tools/llvm-dwarfutil/CMakeLists.txt
  llvm/tools/llvm-exegesis/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
  llvm/unittests/CodeGen/MachineOperandTest.cpp
  llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/GlobalISel/CMakeLists.txt
  llvm/utils/TableGen/GlobalISelEmitter.cpp
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
@@ -616,6 +616,7 @@
 features = ["-header_modules"],
 strip_include_prefix = "utils/TableGen",
 deps = [
+":CodeGen",
 ":Support",
 ":TableGen",
 ":config",
@@ -642,11 +643,11 @@
 copts = llvm_copts,
 stamp = 0,
 deps = [
+":CodeGen",
 ":Support",
 ":TableGen",
 ":TableGenGlobalISel",
 ":config",
-":intrinsic_enums_gen",
 ":llvm-tblgen-headers",
 ],
 )
@@ -2336,6 +2337,7 @@
 copts = llvm_copts,
 features = ["-layering_check"],
 deps = [
+":CodeGen",
 ":MC",
 ":MCA",
 ":MCParser",
@@ -3404,6 +3406,7 @@
 deps = [
 ":AllTargetsAsmParsers",
 ":AllTargetsCodeGens",
+":CodeGen",
 ":DWARFLinker",
 ":DebugInfoDWARF",
 ":DwarfutilOptionsTableGen",
@@ -3444,6 +3447,7 @@
 ":AllTargetsAsmParsers",
   

[PATCH] D148769: Split out `CodeGenTypes` from `CodeGen` for LLT/MVT

2023-05-02 Thread NAKAMURA Takumi 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 rG5d71ec6e448f: Split out `CodeGenTypes` from `CodeGen` for 
LLT/MVT (authored by chapuni).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148769

Files:
  clang/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/AsmPrinter/CMakeLists.txt
  llvm/lib/CodeGen/CMakeLists.txt
  llvm/lib/CodeGen/GlobalISel/CMakeLists.txt
  llvm/lib/CodeGen/MIRParser/CMakeLists.txt
  llvm/lib/CodeGen/SelectionDAG/CMakeLists.txt
  llvm/lib/DWARFLinker/CMakeLists.txt
  llvm/lib/LTO/CMakeLists.txt
  llvm/lib/Target/AArch64/AsmParser/CMakeLists.txt
  llvm/lib/Target/AArch64/CMakeLists.txt
  llvm/lib/Target/AArch64/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/AsmParser/CMakeLists.txt
  llvm/lib/Target/AMDGPU/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Disassembler/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCA/CMakeLists.txt
  llvm/lib/Target/AMDGPU/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AMDGPU/Utils/CMakeLists.txt
  llvm/lib/Target/ARC/CMakeLists.txt
  llvm/lib/Target/ARC/Disassembler/CMakeLists.txt
  llvm/lib/Target/ARM/AsmParser/CMakeLists.txt
  llvm/lib/Target/ARM/CMakeLists.txt
  llvm/lib/Target/ARM/Disassembler/CMakeLists.txt
  llvm/lib/Target/ARM/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/AVR/AsmParser/CMakeLists.txt
  llvm/lib/Target/AVR/CMakeLists.txt
  llvm/lib/Target/AVR/Disassembler/CMakeLists.txt
  llvm/lib/Target/BPF/CMakeLists.txt
  llvm/lib/Target/CSKY/CMakeLists.txt
  llvm/lib/Target/CSKY/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/DirectX/CMakeLists.txt
  llvm/lib/Target/Hexagon/CMakeLists.txt
  llvm/lib/Target/Lanai/AsmParser/CMakeLists.txt
  llvm/lib/Target/Lanai/CMakeLists.txt
  llvm/lib/Target/Lanai/Disassembler/CMakeLists.txt
  llvm/lib/Target/LoongArch/CMakeLists.txt
  llvm/lib/Target/M68k/AsmParser/CMakeLists.txt
  llvm/lib/Target/M68k/CMakeLists.txt
  llvm/lib/Target/M68k/Disassembler/CMakeLists.txt
  llvm/lib/Target/MSP430/AsmParser/CMakeLists.txt
  llvm/lib/Target/MSP430/CMakeLists.txt
  llvm/lib/Target/Mips/CMakeLists.txt
  llvm/lib/Target/Mips/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/NVPTX/CMakeLists.txt
  llvm/lib/Target/PowerPC/CMakeLists.txt
  llvm/lib/Target/PowerPC/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/RISCV/CMakeLists.txt
  llvm/lib/Target/RISCV/MCA/CMakeLists.txt
  llvm/lib/Target/SPIRV/CMakeLists.txt
  llvm/lib/Target/SPIRV/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/Sparc/CMakeLists.txt
  llvm/lib/Target/SystemZ/CMakeLists.txt
  llvm/lib/Target/SystemZ/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/VE/AsmParser/CMakeLists.txt
  llvm/lib/Target/VE/CMakeLists.txt
  llvm/lib/Target/VE/Disassembler/CMakeLists.txt
  llvm/lib/Target/VE/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/WebAssembly/AsmParser/CMakeLists.txt
  llvm/lib/Target/WebAssembly/CMakeLists.txt
  llvm/lib/Target/WebAssembly/Disassembler/CMakeLists.txt
  llvm/lib/Target/WebAssembly/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/WebAssembly/Utils/CMakeLists.txt
  llvm/lib/Target/X86/CMakeLists.txt
  llvm/lib/Target/X86/MCA/CMakeLists.txt
  llvm/lib/Target/X86/MCTargetDesc/CMakeLists.txt
  llvm/lib/Target/XCore/CMakeLists.txt
  llvm/lib/Target/XCore/Disassembler/CMakeLists.txt
  llvm/tools/dsymutil/CMakeLists.txt
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/llvm-dwarfutil/CMakeLists.txt
  llvm/tools/llvm-exegesis/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/AArch64/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/Mips/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/PowerPC/CMakeLists.txt
  llvm/tools/llvm-exegesis/lib/X86/CMakeLists.txt
  llvm/tools/llvm-reduce/CMakeLists.txt
  llvm/unittests/CodeGen/CMakeLists.txt
  llvm/unittests/CodeGen/GlobalISel/CMakeLists.txt
  llvm/unittests/DebugInfo/DWARF/CMakeLists.txt
  llvm/unittests/MI/CMakeLists.txt
  llvm/unittests/MIR/CMakeLists.txt
  llvm/unittests/Target/AArch64/CMakeLists.txt
  llvm/unittests/Target/AMDGPU/CMakeLists.txt
  llvm/unittests/Target/ARM/CMakeLists.txt
  llvm/unittests/Target/LoongArch/CMakeLists.txt
  llvm/unittests/Target/WebAssembly/CMakeLists.txt
  llvm/unittests/Target/X86/CMakeLists.txt
  llvm/unittests/tools/llvm-exegesis/CMakeLists.txt
  llvm/utils/TableGen/CMakeLists.txt
  llvm/utils/TableGen/GlobalISel/CMakeLists.txt
  utils/bazel/llvm-project-overlay/clang/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/BUILD.bazel
  utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel

Index: utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
===
--- utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
+++ utils/bazel/llvm-project-overlay/llvm/unittests/BUILD.bazel
@@ -141,6 +141,7 @@
 "//llvm:AsmParser",
 "//llvm:BinaryFormat",
 "//llvm:CodeGen",
+"//llvm:CodeGenTypes

[PATCH] D147840: [clang][Interp] Handle DiscardResult for DeclRef- and ParenExprs

2023-05-02 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik accepted this revision.
shafik added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D147840

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


[PATCH] D146090: [Clang] Updating handling of defaulted comparison operators to reflect changes from P2448R2

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

ping


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

https://reviews.llvm.org/D146090

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


[PATCH] D148474: [Clang] Fix ResolveConstructorOverload to not select a conversion function if we are going use copy elision

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

ping


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

https://reviews.llvm.org/D148474

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


[PATCH] D148223: [SiFive][RISCV][clang] Support C intrinsics for xsfvcp extension.

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat added a comment.

In D148223#4312515 , @dyung wrote:

> In D148223#4312460 , @4vtomat wrote:
>
>> Hi @craig.topper and @kito-cheng , the build error message was: 
>> 'Z:\test\llvm-project\clang\test\CodeGen\RISCV\rvv-intrinsics-autogenerated\non-policy\non-overloaded\xsfvcp-x-rv64.c:4:10:
>>  fatal error: 'riscv_vector.h' file not found'.
>> Have you ever met this before? I'm not sure if I forgot to add something or 
>> not..
>
> This bot only builds the x86_64 backend. Isn’t that file only generated when 
> the riscv backend is built?

Got it, I should add 'REQUIRES: riscv-registered-target' in the beginning of 
the file, thanks!!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148223

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


[PATCH] D149655: [tests] Add missing REQUIRES: riscv-registered-target to clang test

2023-05-02 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat created this revision.
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, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
4vtomat requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D149655

Files:
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x-rv64.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c


Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvw.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +v -target-feature +zfh 
-target-feature +xsfvcp -disable-O0-optnone -emit-llvm %s -o - | opt -S 
-passes=mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh 
-target-feature +xsfvcp -disable-O0-optnone -emit-llvm %s -o - | opt -S 
-passes=mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
 
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xvv.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +v -target-feature +zfh 
-target-feature +xsfvcp -disable-O0-optnone -emit-llvm %s -o - | opt -S 
-passes=mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh 
-target-feature +xsfvcp -disable-O0-optnone -emit-llvm %s -o - | opt -S 
-passes=mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
 
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-xv.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +v -target-feature +zfh 
-target-feature +xsfvcp -disable-O0-optnone -emit-llvm %s -o - | opt -S 
-passes=mem2reg | FileCheck --check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh 
-target-feature +xsfvcp -disable-O0-optnone -emit-llvm %s -o - | opt -S 
-passes=mem2reg | FileCheck --check-prefix=CHECK-RV64 %s
 
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c
+++ 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x.c
@@ -1,4 +1,5 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
 // RUN: %clang_cc1 -triple riscv32 -target-feature +v -target-feature +xsfvcp 
-disable-O0-optnone -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck 
--check-prefix=CHECK-RV32 %s
 // RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +xsfvcp 
-disable-O0-optnone -emit-llvm %s -o - | opt -S -passes=mem2reg | FileCheck 
--check-prefix=CHECK-RV64 %s
 
Index: 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x-rv64.c
===
--- 
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/xsfvcp-x-rv64.c
+++ 
clang/test/CodeGen/RISCV/rvv-in

[PATCH] D149633: [clang][codegen] Add F128 vsnprintf_chk builtin

2023-05-02 Thread Tulio Magno Quites Machado Filho via Phabricator via cfe-commits
tuliom requested changes to this revision.
tuliom added a comment.
This revision now requires changes to proceed.

@tbaeder Keep in mind that I don't think this will completely fix issue 61913 
because there are other 2 functions affected.
Otherwise, I believe this patch is in the right direction.




Comment at: clang/lib/CodeGen/CGBuiltin.cpp:104
   {Builtin::BI__builtin_printf, "__printfieee128"},
+  {Builtin::BI__builtin___vsnprintf_chk, "__vsnprintfieee128"},
   {Builtin::BI__builtin_vsnprintf, "__vsnprintfieee128"},

I believe this should be redirected to `__vsnprintf_chkieee128`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149633

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


[PATCH] D149562: [clang-format] Stop comment disrupting indentation of Verilog ports

2023-05-02 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

In D149562#4310396 , 
@HazardyKnusperkeks wrote:

> I don't see the problem, could you elaborate a bit more? (Keep in mind, I 
> have no idea about Verilog.)

The current way the port list gets formatted is like this:

  module x
  (input x1,
   input x2,
   input x3,
   input x4);
  endmodule

One may want to add a comment for one of the ports like this:

  module x
  (input x1,
   // second port
   input x2,
   // third port
   input x3,
   // forth port
   input x4);
  endmodule

The port list thing and the comment thing work fine for now, except
when there is a comment for the first port.  The comment on the first
line would cause the port list to be indented, like this:

  module x
  ( // first port
  input x1,
  // second port
  input x2,
  // third port
  input x3,
  // forth port
  input x4);
  endmodule

After this patch, a comment on the first line would not cause the
problem.  Now the code gets formatted like this.  The ports are
indented the same whether or not there is a comment on the first line.

  module x
  (// first port
   input x1,
   // second port
   input x2,
   // third port
   input x3,
   // forth port
   input x4);
  endmodule




Comment at: clang/include/clang/Format/Format.h:4027
+  /// is probably for the port on the following line instead of the parenthesis
+  /// it follows.
   /// \code

MyDeveloperDay wrote:
> This seems an odd corner case
See the last block of code in the example I added.  This is the only way I came 
up with to ensure that the comment for the first port is aligned with the 
comments for the rest of the ports and that whether the first comment exists 
does not affect how other lines are indented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149562

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


  1   2   3   >