[PATCH] D141035: [clang-format] Add an option to insert a newline at EOF if missing

2023-01-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes #https://github.com/llvm/llvm-project/issues/38042.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141035

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25121,6 +25121,17 @@
 #endif
 }
 
+TEST_F(FormatTest, InsertNewlineAtEOF) {
+  verifyFormat("int i;\n");
+  verifyFormat("int i;");
+
+  FormatStyle Style = getLLVMStyle();
+  Style.InsertNewlineAtEOF = true;
+
+  verifyFormat("int i;\n", Style);
+  verifyFormat("int i;\n", "int i;", Style);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -167,6 +167,7 @@
   CHECK_PARSE_BOOL(IndentRequiresClause);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(InsertBraces);
+  CHECK_PARSE_BOOL(InsertNewlineAtEOF);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
   CHECK_PARSE_BOOL(ObjCSpaceBeforeProtocolList);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1283,6 +1283,10 @@
 Tok->setType(TT_TrailingReturnArrow);
   }
   break;
+case tok::eof:
+  if (Style.InsertNewlineAtEOF && Tok->NewlinesBefore == 0)
+Tok->NewlinesBefore = 1;
+  break;
 default:
   break;
 }
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -889,6 +889,7 @@
 IO.mapOptional("IndentWrappedFunctionNames",
Style.IndentWrappedFunctionNames);
 IO.mapOptional("InsertBraces", Style.InsertBraces);
+IO.mapOptional("InsertNewlineAtEOF", Style.InsertNewlineAtEOF);
 IO.mapOptional("InsertTrailingCommas", Style.InsertTrailingCommas);
 IO.mapOptional("IntegerLiteralSeparator", Style.IntegerLiteralSeparator);
 IO.mapOptional("JavaImportGroups", Style.JavaImportGroups);
@@ -1344,6 +1345,7 @@
   LLVMStyle.IndentWidth = 2;
   LLVMStyle.IndentWrappedFunctionNames = false;
   LLVMStyle.InsertBraces = false;
+  LLVMStyle.InsertNewlineAtEOF = false;
   LLVMStyle.InsertTrailingCommas = FormatStyle::TCS_None;
   LLVMStyle.IntegerLiteralSeparator = {/*Binary=*/0, /*Decimal=*/0, /*Hex=*/0};
   LLVMStyle.JavaScriptQuotes = FormatStyle::JSQS_Leave;
Index: clang/include/clang/Format/Format.h
===
--- clang/include/clang/Format/Format.h
+++ clang/include/clang/Format/Format.h
@@ -2420,6 +2420,10 @@
   /// \version 15
   bool InsertBraces;
 
+  /// Insert a newline at end of file if missing.
+  /// \version 16
+  bool InsertNewlineAtEOF;
+
   /// The style of inserting trailing commas into container literals.
   enum TrailingCommaStyle : int8_t {
 /// Do not insert trailing commas.
@@ -4120,6 +4124,7 @@
IndentWidth == R.IndentWidth &&
IndentWrappedFunctionNames == R.IndentWrappedFunctionNames &&
InsertBraces == R.InsertBraces &&
+   InsertNewlineAtEOF == R.InsertNewlineAtEOF &&
IntegerLiteralSeparator.Binary == R.IntegerLiteralSeparator.Binary &&
IntegerLiteralSeparator.Decimal ==
R.IntegerLiteralSeparator.Decimal &&
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -867,6 +867,7 @@
   To match the default behavior of clang-format 15, use the ``Keyword`` value.
 - Add ``IntegerLiteralSeparator`` option for fixing integer literal separators
   in C++, C#, Java, and JavaScript.
+- Add ``InsertNewlineAtEOF`` option for inserting a newline at EOF if missing.
 
 clang-extdef-mapping
 
Index: clang/docs/ClangFormatStyleOptions.rst
===
--- clang/docs/ClangFormatStyleOptions.rst
+++ clang/docs/ClangFormatStyleOptions.rst
@@ -3127,6 +3127,9 @@
   --i;  --i;
 while (i); 

[PATCH] D141032: [Clang][RISCV] Expose vlenb to user

2023-01-05 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD added a comment.

Upon a second thought, with future extensions of the intrinsics, we will add 
rounding mode and exception intrinsics. The exposure of vxsat, vxrm, and vcsr 
in vread_csr and vwrite_csr will confuse user and we should remove them. 
Furthermore, vstart is pretty much always kept to zero, and intrinsic users 
probably should not have access to them.

With the considerations above, I think vread_csr and vwrite_csr can be removed 
in the future when the rounding mode and exception intrinsics are added. This 
is why this patch is opening up a separate function to provide access to vlenb 
and not choose to extend another member in the enum.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141032

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


[PATCH] D140745: WIP: generate Config {Fragment structure, json schema, docs, YAML parser} from schema spec

2023-01-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added a comment.

In D140745#4021783 , @sammccall wrote:

> worthwhile overall?
> ---
>
> This isn't trivial: does it solve a big enough problem to be worth the 
> complexity? (Benefit would be improved maintenance of existing config 
> duplication, and being able to accept JSON-schema which IMO we shouldn't 
> without automation).

I find the solution here valuable, especially considering all the times that 
we've failed to wire/test things properly when we introduced new config options 
and the lack of documentation in clangd-www. Also this will make introducing 
new options straightforward (no need to write fragments or parse logic).
Last time we discussed the concerns I had (at least the ones I can remember) 
were losing the readability we have in a C++ header file (when performing the 
fragment->config step) and difficulty about changing "parse" behavior every now 
and then, but considering all the bugs/outages we had ever since I think these 
concerns are OK to give up at this point (I also like the solution around only 
writing custom parse logic when needed).

> better off parsing schema.json rather than defining a new format?
> -
>
> I don't think so (json-schema is too powerful a language, and it's IMO pretty 
> verbose and painful to edit).
> But the bias towards creating new things needs to be double-checked!

I also feel like editing the YAML format is easier than the JSON one, this 
might be an LLVM bias but considering the project is part of LLVM, I don't 
think that'll be a bad thing.

> does the YAML structure seem OK?
> 
>
> I'm reasonably happy with the compromises I landed on e.g.
>
> - distinction between lowercase for meta-properties and UpperCase for schema 
> children
> - ways to handle special casing around `If.UnknownKey` and `Index.External = 
> None`
>
> but maybe they only make sense in my own head

I am still a little unhappy with losing the readability through the new YAML 
format. but I also don't have any better alternatives and we still get to keep 
the Config.h so at least when writing features we still have a single C++ 
header to read.

> build-time generation vs checking in generated files
> 
>
> Generating at cmake-time is the obvious choice for *.inc, but the consumers 
> of schema.json and doc.md aren't part of our build.
>
> 1. we could generate *.inc at build time, and say that it's up to some other 
> repo(s) to run the llvm build system and produce+publish schema.json and 
> doc.md
> 2. we could generate *.inc at build time, and check in schema.json and doc.md 
> (need to update by rerunning the tool, we could have a test)
> 3. we could generate all files by hand and check them in
>
> My feeling is that 1 is too burdensome to get these extra files.
> 2 is a bit more complicated than 3 (two ways to do things, and building the 
> tool in host config adds some cmake complexity).
> And I'm not sure it has any advantages: regenerating all the files isn't more 
> work than regenerating half.
>
> So I lean towards 3 but I don't have much confidence in what will be least 
> annoying overall.

I am actually more inclined towards option 1). Having *.inc generation as part 
of the build step and not caring about them ever sounds like the better 
trade-off. I don't know how troublesome it's in the CMake sense (but we already 
do that with proto-generated files in clangd for example).
If you think that's too much work I am also fine with option 3 as you mentioned 
(this also has the nice side effect of checking the delta to real code after a 
change to the schema).
As for doc.md, it's unfortunate that we'll need to publish it in a different 
repository anyways, but I don't think that's a huge burden and we can probably 
get away with doing that only at branch cuts. Having doc.md and schema.json 
always available in the repo as source of truth (to aid debugging when things 
go wrong) sounds like a good plus to me. So I am in favor of having them in.

> meta-schema.json
> 
>
> Once I got the tooling set up, having a schema+diagnostics for `schema.yaml` 
> is pretty nice.
> It provides a place to document the structure of the file, and gives a crisp 
> answer to "is this change broken" (albeit one we won't actually have a test 
> for).
> OTOH it's not strictly necessary, and yet more stuff in the tree.

I am in favor of having it. this is unlikely to change so not a huge burden for 
maintenance. I'd still like to have some sort of schema description in the YAML 
file though (as a comment, both for a place to read without context switches 
and to serve as a template when introducing a new option).

> Enums in ConfigFragment.h
> -
>
> Previously these were strings in `ConfigFragment.h`, and the enums were 
> defined in `Config.h`

[PATCH] D141032: [Clang][RISCV] Expose vlenb to user

2023-01-05 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 486486.
eopXD edited the summary of this revision.
eopXD added a comment.

Update code. Add function `vlenb` instead of extending inside the `vread_csr` 
function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141032

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/test/CodeGen/RISCV/rvv-intrinsics/vlenb.c


Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vlenb.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vlenb.c
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone 
-emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @test_vlenb(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, 
vlenb", "=r,~{memory}"() #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long test_vlenb(void) {
+  return vlenb();
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1557,6 +1557,17 @@
 }
 }] in
 def vread_vwrite_csr: RVVHeader;
+let HeaderCode =
+[{
+static __inline__ __attribute__((__always_inline__, __nodebug__))
+unsigned long vlenb() {
+  unsigned long __rv = 0;
+  __asm__ __volatile__ ("csrr\t%0, vlenb" : "=r"(__rv) : : "memory");
+  return __rv;
+}
+}] in
+def vlenb: RVVHeader;
+
 
 // 6. Configuration-Setting Instructions
 // 6.1. vsetvli/vsetvl instructions


Index: clang/test/CodeGen/RISCV/rvv-intrinsics/vlenb.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics/vlenb.c
@@ -0,0 +1,15 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -disable-O0-optnone -emit-llvm %s -o - \
+// RUN: | opt -S -O2 | FileCheck  %s
+
+#include 
+
+// CHECK-LABEL: @test_vlenb(
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[TMP0:%.*]] = tail call i64 asm sideeffect "csrr\09$0, vlenb", "=r,~{memory}"() #[[ATTR1:[0-9]+]], !srcloc !4
+// CHECK-NEXT:ret i64 [[TMP0]]
+//
+unsigned long test_vlenb(void) {
+  return vlenb();
+}
Index: clang/include/clang/Basic/riscv_vector.td
===
--- clang/include/clang/Basic/riscv_vector.td
+++ clang/include/clang/Basic/riscv_vector.td
@@ -1557,6 +1557,17 @@
 }
 }] in
 def vread_vwrite_csr: RVVHeader;
+let HeaderCode =
+[{
+static __inline__ __attribute__((__always_inline__, __nodebug__))
+unsigned long vlenb() {
+  unsigned long __rv = 0;
+  __asm__ __volatile__ ("csrr\t%0, vlenb" : "=r"(__rv) : : "memory");
+  return __rv;
+}
+}] in
+def vlenb: RVVHeader;
+
 
 // 6. Configuration-Setting Instructions
 // 6.1. vsetvli/vsetvl instructions
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141032: [Clang][RISCV] Expose vlenb to user

2023-01-05 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD marked an inline comment as done.
eopXD added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:1559
   __asm__ __volatile__ ("csrw\tvcsr, %z0" : : "rJ"(__value) : "memory");
   break;
   }

pcwang-thead wrote:
> Should we report errors if `vwrite_csr(RVV_VLENB, some_value)`?
Thanks pointing this out. I think my second approach here won't create such 
problem.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141032

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


[PATCH] D141032: [Clang][RISCV] Expose vlenb to user

2023-01-05 Thread Wang Pengcheng via Phabricator via cfe-commits
pcwang-thead added inline comments.



Comment at: clang/include/clang/Basic/riscv_vector.td:1565
+  unsigned long __rv = 0;
+  __asm__ __volatile__ ("csrr\t%0, vlenb" : "=r"(__rv) : : "memory");
+  return __rv;

Inline assembly may not be elegant since it can't be optimized in many ways. We 
can eliminate some redundant reads of vlenb currently(done in D125564). So I 
think we may add a builtin function and lower it to `llvm.read_register`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141032

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


[PATCH] D80392: [mips][mc][clang] Use pc-relative relocations in .eh_frame

2023-01-05 Thread YunQiang Su via Phabricator via cfe-commits
wzssyqa added a comment.

When link with ld.bfd, we get:

  ld/ld-new: .eh_frame_hdr entry overflow
  ld/ld-new: final link failed: bad value

It seems due to the `initial_loc` in the object from LLVM is quite big than the 
gcc/gas one.

  initial_loc: 0x10cd0, vma: 0xe78




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80392

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


[PATCH] D140860: [Diagnostics][NFC] Fix -Wlogical-op-parentheses warning inconsistency for const and constexpr values

2023-01-05 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet added a comment.

As you point out, enhancement may be more accurate than bug fix.
There are rare cases where enabling a warning for missing parentheses in 
`constexpr` logical expressions can be helpful, I think. For example, consider 
the following code:

  constexpr A = ...;
  constexpr B = ...;
  constexpr C = ...;
  
  static_assert(!(A && B || C));

In this case, the static assertion will only be successful if `(A && B || C)` 
evaluates to `false`, which is equivalent to the following combinations of 
values for `A`, `B`, and `C`:

  (A, B, C) = (T, F, F) (F, T, F) (F, F, F)

Note that `T` means `true` and `F` means `false`. Here, `C` is always `false`, 
so `A && B || C` matches the case of `a && b || 0`. Thus, the warning is not 
issued before this patch.
If the programmer is not careful and assumes that `(A && B || C)` is equivalent 
to `(A && (B || C))`, then they expect the values of `A`, `B`, and `C` to also 
include the following combinations:

  (A, B, C) = (F, T, T) (F, F, T)

This would require the programmer to consider additional, unnecessary 
combinations after the successful static assertion.

Enabling a warning for missing parentheses in this scenario could help prevent 
the programmer from making this mistake.


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

https://reviews.llvm.org/D140860

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


[PATCH] D140757: [Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2023-01-05 Thread Brad Smith via Phabricator via cfe-commits
brad added inline comments.



Comment at: clang/test/Preprocessor/predefined-arch-macros.c:4337
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target hexagon-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_HEXAGON_ATOMICS

MaskRay wrote:
> Use `--target=` for new tests. `-target ` is legacy.
> Use `--target=` for new tests. `-target ` is legacy.

Ok, I will do so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140757

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


[PATCH] D141008: [Clang][SPIR-V] Emit target extension types for OpenCL types on SPIR-V.

2023-01-05 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh added a comment.

> it may be more appropriate to make these triggered off of a hidden option 
> defaulted to off for now, or maybe based on whether or not opaque pointers 
> are enabled

There isn't really a meaningful alternative representation for these opaque 
types when opaque pointers are enabled. So it sounds reasonable to gate it on 
whether opaque pointers are enabled.




Comment at: clang/include/clang-c/Index.h:30
  * The version constants for the libclang API.
  * CINDEX_VERSION_MINOR should increase when there are API additions.
  * CINDEX_VERSION_MAJOR is intended for "major" source/ABI breaking changes.

I suppose you need to bump `CINDEX_VERSION_MINOR` for the enum additions?



Comment at: llvm/docs/SPIRVUsage.rst:103
+
+All integer arguments take the same value as they do in the SPIR-V type name.
+For example, the OpenCL type ``image2d_depth_ro_t`` would be represented in




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141008

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


[clang] d227c3b - [Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2023-01-05 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-01-05T04:45:07-05:00
New Revision: d227c3b68cf5c236902c9ff4fdf8b719c9a3dd26

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

LOG: [Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

Reviewed By: kparzysz, aheejin, MaskRay

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

Added: 


Modified: 
clang/lib/Basic/Targets/Hexagon.cpp
clang/lib/Basic/Targets/VE.cpp
clang/lib/Basic/Targets/WebAssembly.cpp
clang/test/Preprocessor/init.c
clang/test/Preprocessor/predefined-arch-macros.c

Removed: 




diff  --git a/clang/lib/Basic/Targets/Hexagon.cpp 
b/clang/lib/Basic/Targets/Hexagon.cpp
index 07649bc793370..8bc3c2b3d0cef 100644
--- a/clang/lib/Basic/Targets/Hexagon.cpp
+++ b/clang/lib/Basic/Targets/Hexagon.cpp
@@ -102,6 +102,11 @@ void HexagonTargetInfo::getTargetDefines(const LangOptions 
&Opts,
 
   std::string NumPhySlots = isTinyCore() ? "3" : "4";
   Builder.defineMacro("__HEXAGON_PHYSICAL_SLOTS__", NumPhySlots);
+
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 }
 
 bool HexagonTargetInfo::initFeatureMap(

diff  --git a/clang/lib/Basic/Targets/VE.cpp b/clang/lib/Basic/Targets/VE.cpp
index bfd0292d130b8..667808d95d82f 100644
--- a/clang/lib/Basic/Targets/VE.cpp
+++ b/clang/lib/Basic/Targets/VE.cpp
@@ -38,6 +38,11 @@ void VETargetInfo::getTargetDefines(const LangOptions &Opts,
   // FIXME: define __FAST_MATH__ 1 if -ffast-math is enabled
   // FIXME: define __OPTIMIZE__ n if -On is enabled
   // FIXME: define __VECTOR__ n 1 if automatic vectorization is enabled
+
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 }
 
 ArrayRef VETargetInfo::getTargetBuiltins() const {

diff  --git a/clang/lib/Basic/Targets/WebAssembly.cpp 
b/clang/lib/Basic/Targets/WebAssembly.cpp
index 86d6975105044..36d8d5449fb35 100644
--- a/clang/lib/Basic/Targets/WebAssembly.cpp
+++ b/clang/lib/Basic/Targets/WebAssembly.cpp
@@ -96,6 +96,11 @@ void WebAssemblyTargetInfo::getTargetDefines(const 
LangOptions &Opts,
 Builder.defineMacro("__wasm_reference_types__");
   if (HasExtendedConst)
 Builder.defineMacro("__wasm_extended_const__");
+
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 }
 
 void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap &Features,

diff  --git a/clang/test/Preprocessor/init.c b/clang/test/Preprocessor/init.c
index 312723acf598a..46f79414fb7c3 100644
--- a/clang/test/Preprocessor/init.c
+++ b/clang/test/Preprocessor/init.c
@@ -1597,6 +1597,10 @@
 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+// WEBASSEMBLY-NEXT:#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// WEBASSEMBLY-NEXT:#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// WEBASSEMBLY-NEXT:#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// WEBASSEMBLY-NEXT:#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
 // WEBASSEMBLY-NEXT:#define __GNUC_MINOR__ {{.*}}
 // WEBASSEMBLY-NEXT:#define __GNUC_PATCHLEVEL__ {{.*}}
 // WEBASSEMBLY-NEXT:#define __GNUC_STDC_INLINE__ 1

diff  --git a/clang/test/Preprocessor/predefined-arch-macros.c 
b/clang/test/Preprocessor/predefined-arch-macros.c
index 5abcdab7da037..13e1e9c7e5b50 100644
--- a/clang/test/Preprocessor/predefined-arch-macros.c
+++ b/clang/test/Preprocessor/predefined-arch-macros.c
@@ -4330,3 +4330,39 @@
 // CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+
+// Begin Hexagon tests 
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=hexagon-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_HEXAGON_ATOMICS
+
+// CHECK_HEXAGON_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_HEXAGON_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_HEXAGON_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_HEXAGON_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// Begin VE tests --

[PATCH] D140757: [Hexagon][VE][WebAssembly] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2023-01-05 Thread Brad Smith via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd227c3b68cf5: [Hexagon][VE][WebAssembly] Define 
__GCC_HAVE_SYNC_COMPARE_AND_SWAP macros (authored by brad).

Changed prior to commit:
  https://reviews.llvm.org/D140757?vs=485743&id=486501#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140757

Files:
  clang/lib/Basic/Targets/Hexagon.cpp
  clang/lib/Basic/Targets/VE.cpp
  clang/lib/Basic/Targets/WebAssembly.cpp
  clang/test/Preprocessor/init.c
  clang/test/Preprocessor/predefined-arch-macros.c

Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4330,3 +4330,39 @@
 // CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
 // CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // CHECK_M68K_68020_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+
+// Begin Hexagon tests 
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=hexagon-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_HEXAGON_ATOMICS
+
+// CHECK_HEXAGON_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_HEXAGON_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_HEXAGON_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_HEXAGON_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// Begin VE tests 
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=ve-unknown-linux \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_VE_ATOMICS
+
+// CHECK_VE_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_VE_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_VE_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_VE_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// Begin WebAssembly tests 
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=wasm32-unknown-unknown \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_WASM_ATOMICS
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=wasm64-unknown-unknown \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_WASM_ATOMICS
+
+// CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -1597,6 +1597,10 @@
 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_SHORT_LOCK_FREE 2
 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
 // WEBASSEMBLY-NEXT:#define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+// WEBASSEMBLY-NEXT:#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// WEBASSEMBLY-NEXT:#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// WEBASSEMBLY-NEXT:#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// WEBASSEMBLY-NEXT:#define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
 // WEBASSEMBLY-NEXT:#define __GNUC_MINOR__ {{.*}}
 // WEBASSEMBLY-NEXT:#define __GNUC_PATCHLEVEL__ {{.*}}
 // WEBASSEMBLY-NEXT:#define __GNUC_STDC_INLINE__ 1
Index: clang/lib/Basic/Targets/WebAssembly.cpp
===
--- clang/lib/Basic/Targets/WebAssembly.cpp
+++ clang/lib/Basic/Targets/WebAssembly.cpp
@@ -96,6 +96,11 @@
 Builder.defineMacro("__wasm_reference_types__");
   if (HasExtendedConst)
 Builder.defineMacro("__wasm_extended_const__");
+
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 }
 
 void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap &Features,
Index: clang/lib/Basic/Targets/VE.cpp
===
--- clang/lib/Basic/Targets/VE.cpp
+++ clang/lib/Basic/Targets/VE.cpp
@@ -38,6 +38,11 @@
   // FIXME: define __FAST_MATH__ 1 if -ffast-math is enabled
   // FIXME: define __OPTIMIZE__ n if -On is enabled
   // FIXME: define __VECTOR__ n 1 if automatic vectorization is enabled
+
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 }
 
 ArrayRef VETargetInfo::getTargetBuiltins() const {
Index: clang/lib/Basic/Targets/Hexagon.cpp
==

[PATCH] D140999: [NFC][TargetParser] Deprecate llvm/Support/AArch64TargetParser.h

2023-01-05 Thread Lucas Prates via Phabricator via cfe-commits
pratlucas accepted this revision.
pratlucas 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/D140999/new/

https://reviews.llvm.org/D140999

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


[clang] ebd9753 - [CodeGenOpenCLCXX] Convert tests to opaque pointers (NFC)

2023-01-05 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2023-01-05T11:03:15+01:00
New Revision: ebd97534e71aafaa637e466d700f66bbfa63d56b

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

LOG: [CodeGenOpenCLCXX] Convert tests to opaque pointers (NFC)

Added: 


Modified: 
clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-conversion.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-derived-base.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-new-delete.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-of-this.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-operators.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-references.clcpp
clang/test/CodeGenOpenCLCXX/addrspace-with-class.clcpp
clang/test/CodeGenOpenCLCXX/addrspace_cast.clcpp
clang/test/CodeGenOpenCLCXX/atexit.clcpp
clang/test/CodeGenOpenCLCXX/constexpr.clcpp
clang/test/CodeGenOpenCLCXX/method-overload-address-space.clcpp
clang/test/CodeGenOpenCLCXX/reinterpret_cast.clcpp
clang/test/CodeGenOpenCLCXX/template-address-spaces.clcpp

Removed: 




diff  --git a/clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp 
b/clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
index 40bac730fd00b..5d7360f406dc3 100644
--- a/clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
+++ b/clang/test/CodeGenOpenCLCXX/address-space-deduction.clcpp
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -no-opaque-pointers %s -triple spir-unknown-unknown -O0 
-emit-llvm -o - | FileCheck %s -check-prefixes=COMMON,PTR
-// RUN: %clang_cc1 -no-opaque-pointers %s -triple spir-unknown-unknown -O0 
-emit-llvm -o - -DREF | FileCheck %s -check-prefixes=COMMON,REF
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -emit-llvm -o - | 
FileCheck %s -check-prefixes=COMMON,PTR
+// RUN: %clang_cc1 %s -triple spir-unknown-unknown -O0 -emit-llvm -o - -DREF | 
FileCheck %s -check-prefixes=COMMON,REF
 
 #ifdef REF
 #define PTR &
@@ -11,26 +11,26 @@
 
 //COMMON: @glob ={{.*}} addrspace(1) global i32
 int glob;
-//PTR: @glob_p ={{.*}} addrspace(1) global i32 addrspace(4)* addrspacecast 
(i32 addrspace(1)* @glob to i32 addrspace(4)*)
-//REF: @glob_p ={{.*}} addrspace(1) constant i32 addrspace(4)* addrspacecast 
(i32 addrspace(1)* @glob to i32 addrspace(4)*)
+//PTR: @glob_p ={{.*}} addrspace(1) global ptr addrspace(4) addrspacecast (ptr 
addrspace(1) @glob to ptr addrspace(4))
+//REF: @glob_p ={{.*}} addrspace(1) constant ptr addrspace(4) addrspacecast 
(ptr addrspace(1) @glob to ptr addrspace(4))
 int PTR glob_p = ADR(glob);
 
 //COMMON: @_ZZ3fooi{{P|R}}U3AS4iE6loc_st = internal addrspace(1) global i32
-//PTR: @_ZZ3fooiPU3AS4iE8loc_st_p = internal addrspace(1) global i32 
addrspace(4)* addrspacecast (i32 addrspace(1)* @_ZZ3fooiPU3AS4iE6loc_st to i32 
addrspace(4)*)
-//REF: @_ZZ3fooiRU3AS4iE8loc_st_p = internal addrspace(1) constant i32 
addrspace(4)* addrspacecast (i32 addrspace(1)* @_ZZ3fooiRU3AS4iE6loc_st to i32 
addrspace(4)*)
-//COMMON: @loc_ext_p = external addrspace(1) {{global|constant}} i32 
addrspace(4)*
+//PTR: @_ZZ3fooiPU3AS4iE8loc_st_p = internal addrspace(1) global ptr 
addrspace(4) addrspacecast (ptr addrspace(1) @_ZZ3fooiPU3AS4iE6loc_st to ptr 
addrspace(4))
+//REF: @_ZZ3fooiRU3AS4iE8loc_st_p = internal addrspace(1) constant ptr 
addrspace(4) addrspacecast (ptr addrspace(1) @_ZZ3fooiRU3AS4iE6loc_st to ptr 
addrspace(4))
+//COMMON: @loc_ext_p = external addrspace(1) {{global|constant}} ptr 
addrspace(4)
 //COMMON: @loc_ext = external addrspace(1) global i32
 
-//COMMON: define{{.*}} spir_func noundef i32 @_Z3fooi{{P|R}}U3AS4i(i32 noundef 
%par, i32 addrspace(4)*{{.*}} %par_p)
+//COMMON: define{{.*}} spir_func noundef i32 @_Z3fooi{{P|R}}U3AS4i(i32 noundef 
%par, ptr addrspace(4){{.*}} %par_p)
 int foo(int par, int PTR par_p){
   //COMMON: %loc = alloca i32
   int loc;
-  //COMMON: %loc_p = alloca i32 addrspace(4)*
-  //COMMON: %loc_p_const = alloca i32*
-  //COMMON: [[GAS:%[._a-z0-9]*]] ={{.*}} addrspacecast i32* %loc to i32 
addrspace(4)*
-  //COMMON: store i32 addrspace(4)* [[GAS]], i32 addrspace(4)** %loc_p
+  //COMMON: %loc_p = alloca ptr addrspace(4)
+  //COMMON: %loc_p_const = alloca ptr
+  //COMMON: [[GAS:%[._a-z0-9]*]] ={{.*}} addrspacecast ptr %loc to ptr 
addrspace(4)
+  //COMMON: store ptr addrspace(4) [[GAS]], ptr %loc_p
   int PTR loc_p = ADR(loc);
-  //COMMON: store i32* %loc, i32** %loc_p_const
+  //COMMON: store ptr %loc, ptr %loc_p_const
   const __private int PTR loc_p_const = ADR(loc);
 
   // CHECK directives for the following code are located above.

diff  --git a/clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp 
b/clang/test/CodeGenOpenCLCXX/addrspace-constructors.clcpp
index 3a87d47acc839..62258cae90647 100644
--- a/clang

[PATCH] D141035: [clang-format] Add an option to insert a newline at EOF if missing

2023-01-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

I think I've died an gone to heaven!! LGTM...  Happy New Year!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141035

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


[PATCH] D140843: [clang-format] fix template closer followed by >

2023-01-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a subscriber: rymiel.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for adding an annotator test, I'd like one of @owenpan, 
@HazardyKnusperkeks  or @rymiel to comment before commit, just to get another 
view.


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

https://reviews.llvm.org/D140843

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


[PATCH] D140956: [clang-format] Add an option for breaking after C++11 attributes

2023-01-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.

I'm good with that. I like small pieces of contained work and not open ended 
reviews that try to cover everything. If someone wants to extend this to 
include the old form, then that can be a completely different review. But this 
is a great start (especially as I heavily use [[nodiscard]])

Go for it..


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

https://reviews.llvm.org/D140956

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


[PATCH] D140950: [X86] Support -march=emeraldrapids

2023-01-05 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe added a comment.

ping...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140950

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


[PATCH] D140968: [clang-tidy] Add check for passing the result of `std::string::c_str` to `strlen`

2023-01-05 Thread Alex Coster via Phabricator via cfe-commits
acoster updated this revision to Diff 486504.
acoster added a comment.

Generlised the check to cover string_view and "string-like" classes

Removed the option of ignoring `data()`, and generalised the check to suggest
fixes if the result of `data()` or `c_str()` method of any class with a public
`length()` or `size()` method is passed to `strlen`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140968

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/StrlenStringCStrCheck.cpp
  clang-tools-extra/clang-tidy/readability/StrlenStringCStrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/strlen-string-cstr.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/strlen-string-cstr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/strlen-string-cstr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/strlen-string-cstr.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s readability-strlen-string-cstr %t
+int strlen(const char *);
+int strnlen(const char *, int);
+int strnlen_s(const char *, int);
+
+int wcslen(const wchar_t *);
+int wcsnlen_s(const wchar_t *, int);
+
+namespace std {
+template  class allocator {};
+template  class char_traits {};
+
+template >
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const basic_string_view &other);
+  const C *data() const;
+  int size() const;
+  int length() const;
+};
+
+using string_view = basic_string_view;
+using wstring_view = basic_string_view;
+
+template ,
+  typename A = std::allocator>
+class basic_string {
+public:
+  basic_string();
+  basic_string(const C *, unsigned int size);
+  basic_string(const C *, const A &allocator = A());
+  const C *c_str() const;
+  const C *data() const;
+  int size() const;
+  int length() const;
+  operator basic_string_view() const;
+};
+
+using wstring = basic_string;
+using string = basic_string;
+
+int strlen(const char *);
+int wcslen(const wchar_t *);
+} // namespace std
+
+void handlesBasicString() {
+  std::string str1("a", 1);
+  int length = strlen(str1.c_str());
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant call to 'strlen' {{.*}}
+  // CHECK-FIXES: {{^  }}int length = str1.size();{{$}}
+
+  length = strnlen(str1.data(), 30);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call to 'strnlen' {{.*}}
+  // CHECK-FIXES: {{^  }}length = str1.size();{{$}}
+
+  const std::string *p1 = &str1;
+  length = std::strlen(p1->c_str()) + 30;
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}length = p1->size() + 30;{{$}}
+
+  std::wstring wstr1;
+  length = wcslen(wstr1.c_str());
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call to 'wcslen' {{.*}}
+  // CHECK-FIXES: {{^  }}length = wstr1.size();{{$}}
+
+  const std::wstring &wstr2 = wstr1;
+  length = std::wcslen(wstr2.data());
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call to {{.*}}
+  // CHECK-FIXES: {{^  }}length = wstr2.size();{{$}}
+}
+
+void handlesStringView() {
+  std::string str1("foo");
+  std::string_view view = str1;
+  int length = strnlen_s(view.data(), 300);
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant call to 'strnlen_s'
+  // {{.*}} CHECK-FIXES: {{^  }}int length = view.size();{{$}}
+
+  std::wstring wstr1;
+  std::wstring_view wview = wstr1;
+  length = wcsnlen_s(wview.data(), 300);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call to 'wcsnlen_s'
+  // {{.*}} CHECK-FIXES: {{^  }}length = wview.size();{{$}}
+}
+
+class CustomStringClass {
+public:
+  CustomStringClass(int, char);
+  const char *data() const;
+  int length() const;
+
+private:
+  int size() const;
+};
+
+void handlesStringLikeTypes() {
+  CustomStringClass str(123, 'f');
+  int size = strlen(str.data());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: redundant call to
+  // CHECK-FIXES: {{^  }}int size = str.length();{{$}}
+}
+
+class StringWithoutPublicSizeMethod {
+public:
+  StringWithoutPublicSizeMethod(const char *);
+  const char *c_str();
+
+private:
+  int size() const;
+  int length() const;
+};
+
+void ignoresStringTypesWithoutPublicSizeMethod() {
+  StringWithoutPublicSizeMethod str("foo");
+  int length = strlen(str.c_str());
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability/strlen-string-cstr.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/readability/strlen-string-cstr.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - readability-strlen-string-cstr
+
+readability-strlen-string-cstr
+=

[PATCH] D140817: [Driver] move NetBSD header search path management to the driver

2023-01-05 Thread Brad Smith via Phabricator via cfe-commits
brad updated this revision to Diff 486505.
brad added a comment.

Tweak test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140817

Files:
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/NetBSD.h
  clang/lib/Lex/InitHeaderSearch.cpp
  clang/test/Driver/netbsd.c
  clang/test/Driver/netbsd.cpp

Index: clang/test/Driver/netbsd.cpp
===
--- clang/test/Driver/netbsd.cpp
+++ clang/test/Driver/netbsd.cpp
@@ -339,3 +339,10 @@
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crti.o"
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
 // S-POWERPC64: "-lm" "-lc" "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
+
+// Check that the driver passes include paths to cc1 on NetBSD.
+// RUN: %clang -### %s --target=x86_64-unknown-netbsd -r 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=DRIVER-PASS-INCLUDES
+// DRIVER-PASS-INCLUDES:  "-cc1" {{.*}}"-resource-dir" "[[RESOURCE:[^"]+]]"
+// DRIVER-PASS-INCLUDES:  "-internal-isystem" "[[RESOURCE]]{{/|}}include"
+// DRIVER-PASS-INCLUDES:  "-internal-externc-isystem" "/usr/include"
Index: clang/test/Driver/netbsd.c
===
--- clang/test/Driver/netbsd.c
+++ clang/test/Driver/netbsd.c
@@ -477,3 +477,10 @@
 // RELOCATABLE-NOT: "-dynamic-linker"
 // RELOCATABLE-NOT: "-l
 // RELOCATABLE-NOT: crt{{[^./\\]+}}.o
+
+// Check that the driver passes include paths to cc1 on NetBSD.
+// RUN: %clang -### %s --target=x86_64-unknown-netbsd -r 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=DRIVER-PASS-INCLUDES
+// DRIVER-PASS-INCLUDES:  "-cc1" {{.*}}"-resource-dir" "[[RESOURCE:[^"]+]]"
+// DRIVER-PASS-INCLUDES-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]{{/|}}include"
+// DRIVER-PASS-INCLUDES-SAME: {{^}} "-internal-externc-isystem" "/usr/include"
Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -231,7 +231,6 @@
   if (HSOpts.UseStandardSystemIncludes) {
 switch (os) {
 case llvm::Triple::CloudABI:
-case llvm::Triple::NetBSD:
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
 case llvm::Triple::PS5:
@@ -412,9 +411,10 @@
   case llvm::Triple::AIX:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
+  case llvm::Triple::NetBSD:
+  case llvm::Triple::OpenBSD:
   case llvm::Triple::Hurd:
   case llvm::Triple::Linux:
-  case llvm::Triple::OpenBSD:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
 return false;
Index: clang/lib/Driver/ToolChains/NetBSD.h
===
--- clang/lib/Driver/ToolChains/NetBSD.h
+++ clang/lib/Driver/ToolChains/NetBSD.h
@@ -58,6 +58,9 @@
 
   CXXStdlibType GetDefaultCXXStdlibType() const override;
 
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
   void addLibCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
Index: clang/lib/Driver/ToolChains/NetBSD.cpp
===
--- clang/lib/Driver/ToolChains/NetBSD.cpp
+++ clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -11,6 +11,7 @@
 #include "Arch/Mips.h"
 #include "Arch/Sparc.h"
 #include "CommonArgs.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
@@ -435,6 +436,40 @@
   return ToolChain::CST_Libstdcxx;
 }
 
+void NetBSD::AddClangSystemIncludeArgs(
+const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const {
+  const Driver &D = getDriver();
+
+  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
+return;
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> Dir(D.ResourceDir);
+llvm::sys::path::append(Dir, "include");
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+  }
+
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Check for configure-time C include directories.
+  StringRef CIncludeDirs(C_INCLUDE_DIRS);
+  if (CIncludeDirs != "") {
+SmallVector dirs;
+CIncludeDirs.split(dirs, ":");
+for (StringRef dir : dirs) {
+  StringRef Prefix =
+  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+}
+return;
+  }
+
+  addExternCSystemInclude(DriverArgs, CC1Args,
+  concat(D.SysRoot, "/usr/include"));
+}
+
 void NetBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) c

[PATCH] D140968: [clang-tidy] Add check for passing the result of `std::string::c_str` to `strlen`

2023-01-05 Thread Alex Coster via Phabricator via cfe-commits
acoster marked 12 inline comments as done.
acoster added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/strlen-string-cstr.rst:24
+
+.. option:: EnableForDataMethod
+

carlosgalvezp wrote:
> Is there a use case for wanting this option? (As opposed to unconditionally 
> warning about data()) The problem is the same and the same fix applies?
@carlosgalvezp Removed the option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140968

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


[PATCH] D136554: Implement CWG2631

2023-01-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 486508.
cor3ntin added a comment.

I've convinced myself that the assertition case should be removed.

Before this patch, CXXDefaultInitExpr where never visited
by UsedDeclVisitor.

After this patch, when doing that visitation,
a variable can appear in an unevaluated context without having been mark
non odr used (and doing so would require to unconditionally transform
default member initializers, which we want to avoid).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/UsedDeclVisitor.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-records.cpp
  clang/test/CXX/class/class.local/p1-0x.cpp
  clang/test/CXX/drs/dr26xx.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/CodeGenCXX/default-arguments-with-immediate.cpp
  clang/test/CodeGenCXX/meminit-initializers-odr.cpp
  clang/test/PCH/default-argument-with-immediate-calls.cpp
  clang/test/SemaCXX/cxx11-default-member-initializers.cpp
  clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
  clang/test/SemaCXX/source_location.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15593,7 +15593,7 @@
 https://wg21.link/cwg2631";>2631
 DR
 Immediate function evaluations in default arguments
-Unknown
+Clang 16
   
   
 https://wg21.link/cwg2632";>2632
Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -verify %s
 // expected-no-diagnostics
 
 #define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
@@ -8,15 +9,22 @@
 template 
 struct Printer;
 
+#ifdef USE_CONSTEVAL
+#define SOURCE_LOC_EVAL_KIND consteval
+#else
+#define SOURCE_LOC_EVAL_KIND constexpr
+#endif
+
 namespace std {
 class source_location {
   struct __impl;
 
 public:
-  static constexpr source_location current(const __impl *__p = __builtin_source_location()) noexcept {
-source_location __loc;
-__loc.__m_impl = __p;
-return __loc;
+  static SOURCE_LOC_EVAL_KIND source_location
+current(const __impl *__p = __builtin_source_location()) noexcept {
+  source_location __loc;
+  __loc.__m_impl = __p;
+  return __loc;
   }
   constexpr source_location() = default;
   constexpr source_location(source_location const &) = default;
@@ -593,3 +601,73 @@
   }
   static_assert(test());
 }
+
+namespace Lambda {
+#line 8000 "TestLambda.cpp"
+constexpr int nested_lambda(int l = []{
+  return SL::current().line();
+}()) {
+  return l;
+}
+static_assert(nested_lambda() == __LINE__ - 4);
+
+constexpr int lambda_param(int l = [](int l = SL::current().line()) {
+  return l;
+}()) {
+  return l;
+}
+static_assert(lambda_param() == __LINE__);
+
+
+}
+
+constexpr int compound_literal_fun(int a =
+  (int){ SL::current().line() }
+) { return a ;}
+static_assert(compound_literal_fun() == __LINE__);
+
+struct CompoundLiteral {
+  int a = (int){ SL::current().line() };
+};
+static_assert(CompoundLiteral{}.a == __LINE__);
+
+
+// FIXME
+// Init captures are subexpressions of the lambda expression
+// so according to the standard immediate invocations in init captures
+// should be evaluated at the call site.
+// However Clang does not yet implement this as it would introduce
+// a fair bit of complexity.
+// We intend to implement that functionality once we find real world
+// use cases that require it.
+constexpr int test_init_capture(int a =
+[b = SL::current().line()] { return b; }()) {
+  return a;
+}
+#ifdef USE_CONSTEVAL
+static_assert(test_init_capture() == __LINE__ - 4);
+#else
+static_assert(test_init_capture() == __LINE__ );
+#endif
+
+namespace check_immediate_invocations_in_templates {
+
+template 
+struct G {
+T line = __builtin_LINE();
+};
+template 
+struct S {
+int i = G{}.line;
+};
+static_assert(S{}.i != // intentional new line
+  S{}.i);
+
+template 
+constexpr int f(int i = G{}.line) {
+return i;
+}
+
+static_assert(f() != // 

[PATCH] D136554: Implement CWG2631

2023-01-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 486510.
cor3ntin added a comment.

formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/Stmt.h
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/Parse/ParseCXXInlineMethods.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Sema/UsedDeclVisitor.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/test/AST/ast-dump-records.cpp
  clang/test/CXX/class/class.local/p1-0x.cpp
  clang/test/CXX/drs/dr26xx.cpp
  clang/test/CodeGenCXX/builtin-source-location.cpp
  clang/test/CodeGenCXX/default-arguments-with-immediate.cpp
  clang/test/CodeGenCXX/meminit-initializers-odr.cpp
  clang/test/PCH/default-argument-with-immediate-calls.cpp
  clang/test/SemaCXX/cxx11-default-member-initializers.cpp
  clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
  clang/test/SemaCXX/source_location.cpp
  clang/www/cxx_dr_status.html

Index: clang/www/cxx_dr_status.html
===
--- clang/www/cxx_dr_status.html
+++ clang/www/cxx_dr_status.html
@@ -15593,7 +15593,7 @@
 https://wg21.link/cwg2631";>2631
 DR
 Immediate function evaluations in default arguments
-Unknown
+Clang 16
   
   
 https://wg21.link/cwg2632";>2632
Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// RUN: %clang_cc1 -std=c++2a -fcxx-exceptions -DUSE_CONSTEVAL -fexceptions -verify %s
 // expected-no-diagnostics
 
 #define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
@@ -8,15 +9,22 @@
 template 
 struct Printer;
 
+#ifdef USE_CONSTEVAL
+#define SOURCE_LOC_EVAL_KIND consteval
+#else
+#define SOURCE_LOC_EVAL_KIND constexpr
+#endif
+
 namespace std {
 class source_location {
   struct __impl;
 
 public:
-  static constexpr source_location current(const __impl *__p = __builtin_source_location()) noexcept {
-source_location __loc;
-__loc.__m_impl = __p;
-return __loc;
+  static SOURCE_LOC_EVAL_KIND source_location
+current(const __impl *__p = __builtin_source_location()) noexcept {
+  source_location __loc;
+  __loc.__m_impl = __p;
+  return __loc;
   }
   constexpr source_location() = default;
   constexpr source_location(source_location const &) = default;
@@ -593,3 +601,73 @@
   }
   static_assert(test());
 }
+
+namespace Lambda {
+#line 8000 "TestLambda.cpp"
+constexpr int nested_lambda(int l = []{
+  return SL::current().line();
+}()) {
+  return l;
+}
+static_assert(nested_lambda() == __LINE__ - 4);
+
+constexpr int lambda_param(int l = [](int l = SL::current().line()) {
+  return l;
+}()) {
+  return l;
+}
+static_assert(lambda_param() == __LINE__);
+
+
+}
+
+constexpr int compound_literal_fun(int a =
+  (int){ SL::current().line() }
+) { return a ;}
+static_assert(compound_literal_fun() == __LINE__);
+
+struct CompoundLiteral {
+  int a = (int){ SL::current().line() };
+};
+static_assert(CompoundLiteral{}.a == __LINE__);
+
+
+// FIXME
+// Init captures are subexpressions of the lambda expression
+// so according to the standard immediate invocations in init captures
+// should be evaluated at the call site.
+// However Clang does not yet implement this as it would introduce
+// a fair bit of complexity.
+// We intend to implement that functionality once we find real world
+// use cases that require it.
+constexpr int test_init_capture(int a =
+[b = SL::current().line()] { return b; }()) {
+  return a;
+}
+#ifdef USE_CONSTEVAL
+static_assert(test_init_capture() == __LINE__ - 4);
+#else
+static_assert(test_init_capture() == __LINE__ );
+#endif
+
+namespace check_immediate_invocations_in_templates {
+
+template 
+struct G {
+T line = __builtin_LINE();
+};
+template 
+struct S {
+int i = G{}.line;
+};
+static_assert(S{}.i != // intentional new line
+  S{}.i);
+
+template 
+constexpr int f(int i = G{}.line) {
+return i;
+}
+
+static_assert(f() != // intentional new line
+  f());
+}
Index: clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/cxx2a-consteval-default-params.cpp
@@ -0,0 +1,81 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++2b %s
+
+c

[PATCH] D140950: [X86] Support -march=emeraldrapids

2023-01-05 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei 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/D140950/new/

https://reviews.llvm.org/D140950

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


[PATCH] D140950: [X86] Support -march=emeraldrapids

2023-01-05 Thread Kan Shengchen via Phabricator via cfe-commits
skan accepted this revision.
skan added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140950

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


[PATCH] D136554: Implement CWG2631

2023-01-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Unless something else pops up, I'll try to land that this week end.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136554

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


[clang] e449e1d - [Driver] move NetBSD header search path management to the driver

2023-01-05 Thread Brad Smith via cfe-commits

Author: Brad Smith
Date: 2023-01-05T06:13:40-05:00
New Revision: e449e1dff9f83e45c1a290214e9f49b2c562b343

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

LOG: [Driver] move NetBSD header search path management to the driver

This matches OpenBSD and FreeBSD. https://reviews.llvm.org/D138183

Reviewed By: MaskRay

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/NetBSD.cpp
clang/lib/Driver/ToolChains/NetBSD.h
clang/lib/Lex/InitHeaderSearch.cpp
clang/test/Driver/netbsd.c
clang/test/Driver/netbsd.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/NetBSD.cpp 
b/clang/lib/Driver/ToolChains/NetBSD.cpp
index ac90ed49b8a54..7a7c905e3e7a6 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.cpp
+++ b/clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -11,6 +11,7 @@
 #include "Arch/Mips.h"
 #include "Arch/Sparc.h"
 #include "CommonArgs.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
@@ -435,6 +436,40 @@ ToolChain::CXXStdlibType NetBSD::GetDefaultCXXStdlibType() 
const {
   return ToolChain::CST_Libstdcxx;
 }
 
+void NetBSD::AddClangSystemIncludeArgs(
+const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const {
+  const Driver &D = getDriver();
+
+  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
+return;
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> Dir(D.ResourceDir);
+llvm::sys::path::append(Dir, "include");
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+  }
+
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Check for configure-time C include directories.
+  StringRef CIncludeDirs(C_INCLUDE_DIRS);
+  if (CIncludeDirs != "") {
+SmallVector dirs;
+CIncludeDirs.split(dirs, ":");
+for (StringRef dir : dirs) {
+  StringRef Prefix =
+  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+}
+return;
+  }
+
+  addExternCSystemInclude(DriverArgs, CC1Args,
+  concat(D.SysRoot, "/usr/include"));
+}
+
 void NetBSD::addLibCxxIncludePaths(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args) const {
   const std::string Candidates[] = {

diff  --git a/clang/lib/Driver/ToolChains/NetBSD.h 
b/clang/lib/Driver/ToolChains/NetBSD.h
index 6bcbe16316cef..0f9b6dceb6fcf 100644
--- a/clang/lib/Driver/ToolChains/NetBSD.h
+++ b/clang/lib/Driver/ToolChains/NetBSD.h
@@ -58,6 +58,9 @@ class LLVM_LIBRARY_VISIBILITY NetBSD : public Generic_ELF {
 
   CXXStdlibType GetDefaultCXXStdlibType() const override;
 
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
   void addLibCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;

diff  --git a/clang/lib/Lex/InitHeaderSearch.cpp 
b/clang/lib/Lex/InitHeaderSearch.cpp
index f91988c4085d0..8dc5d95f9c6b0 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -231,7 +231,6 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const 
llvm::Triple &triple,
   if (HSOpts.UseStandardSystemIncludes) {
 switch (os) {
 case llvm::Triple::CloudABI:
-case llvm::Triple::NetBSD:
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
 case llvm::Triple::PS5:
@@ -412,9 +411,10 @@ bool InitHeaderSearch::ShouldAddDefaultIncludePaths(
   case llvm::Triple::AIX:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
+  case llvm::Triple::NetBSD:
+  case llvm::Triple::OpenBSD:
   case llvm::Triple::Hurd:
   case llvm::Triple::Linux:
-  case llvm::Triple::OpenBSD:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
 return false;

diff  --git a/clang/test/Driver/netbsd.c b/clang/test/Driver/netbsd.c
index 52f3a33198059..b59acf144fbc6 100644
--- a/clang/test/Driver/netbsd.c
+++ b/clang/test/Driver/netbsd.c
@@ -477,3 +477,10 @@
 // RELOCATABLE-NOT: "-dynamic-linker"
 // RELOCATABLE-NOT: "-l
 // RELOCATABLE-NOT: crt{{[^./\\]+}}.o
+
+// Check that the driver passes include paths to cc1 on NetBSD.
+// RUN: %clang -### %s --target=x86_64-unknown-netbsd -r 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=DRIVER-PASS-INCLUDES
+// DRIVER-PASS-INCLUDES:  "-cc1" {{.*}}"-resource-dir" "[[RESOURCE:[^"]+]]"
+// DRIVER-PASS-INCLUDES-SAME: {{^}} "-internal-isystem" 
"[[RESOURCE]]{{/|}}include"
+// DRIVER-PASS-INCLUDES-SAME: {{^}} "-internal-externc-isystem" "/usr/include"

diff  --git a/clang/test/D

[PATCH] D140817: [Driver] move NetBSD header search path management to the driver

2023-01-05 Thread Brad Smith 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 rGe449e1dff9f8: [Driver] move NetBSD header search path 
management to the driver (authored by brad).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140817

Files:
  clang/lib/Driver/ToolChains/NetBSD.cpp
  clang/lib/Driver/ToolChains/NetBSD.h
  clang/lib/Lex/InitHeaderSearch.cpp
  clang/test/Driver/netbsd.c
  clang/test/Driver/netbsd.cpp

Index: clang/test/Driver/netbsd.cpp
===
--- clang/test/Driver/netbsd.cpp
+++ clang/test/Driver/netbsd.cpp
@@ -339,3 +339,10 @@
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crti.o"
 // S-POWERPC64: "{{.*}}/usr/lib{{/|}}crtbegin.o" "{{.*}}.o" "-lc++"
 // S-POWERPC64: "-lm" "-lc" "{{.*}}/usr/lib{{/|}}crtend.o" "{{.*}}/usr/lib{{/|}}crtn.o"
+
+// Check that the driver passes include paths to cc1 on NetBSD.
+// RUN: %clang -### %s --target=x86_64-unknown-netbsd -r 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=DRIVER-PASS-INCLUDES
+// DRIVER-PASS-INCLUDES:  "-cc1" {{.*}}"-resource-dir" "[[RESOURCE:[^"]+]]"
+// DRIVER-PASS-INCLUDES:  "-internal-isystem" "[[RESOURCE]]{{/|}}include"
+// DRIVER-PASS-INCLUDES:  "-internal-externc-isystem" "/usr/include"
Index: clang/test/Driver/netbsd.c
===
--- clang/test/Driver/netbsd.c
+++ clang/test/Driver/netbsd.c
@@ -477,3 +477,10 @@
 // RELOCATABLE-NOT: "-dynamic-linker"
 // RELOCATABLE-NOT: "-l
 // RELOCATABLE-NOT: crt{{[^./\\]+}}.o
+
+// Check that the driver passes include paths to cc1 on NetBSD.
+// RUN: %clang -### %s --target=x86_64-unknown-netbsd -r 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=DRIVER-PASS-INCLUDES
+// DRIVER-PASS-INCLUDES:  "-cc1" {{.*}}"-resource-dir" "[[RESOURCE:[^"]+]]"
+// DRIVER-PASS-INCLUDES-SAME: {{^}} "-internal-isystem" "[[RESOURCE]]{{/|}}include"
+// DRIVER-PASS-INCLUDES-SAME: {{^}} "-internal-externc-isystem" "/usr/include"
Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -231,7 +231,6 @@
   if (HSOpts.UseStandardSystemIncludes) {
 switch (os) {
 case llvm::Triple::CloudABI:
-case llvm::Triple::NetBSD:
 case llvm::Triple::NaCl:
 case llvm::Triple::PS4:
 case llvm::Triple::PS5:
@@ -412,9 +411,10 @@
   case llvm::Triple::AIX:
   case llvm::Triple::Emscripten:
   case llvm::Triple::FreeBSD:
+  case llvm::Triple::NetBSD:
+  case llvm::Triple::OpenBSD:
   case llvm::Triple::Hurd:
   case llvm::Triple::Linux:
-  case llvm::Triple::OpenBSD:
   case llvm::Triple::Solaris:
   case llvm::Triple::WASI:
 return false;
Index: clang/lib/Driver/ToolChains/NetBSD.h
===
--- clang/lib/Driver/ToolChains/NetBSD.h
+++ clang/lib/Driver/ToolChains/NetBSD.h
@@ -58,6 +58,9 @@
 
   CXXStdlibType GetDefaultCXXStdlibType() const override;
 
+  void
+  AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const override;
   void addLibCxxIncludePaths(
   const llvm::opt::ArgList &DriverArgs,
   llvm::opt::ArgStringList &CC1Args) const override;
Index: clang/lib/Driver/ToolChains/NetBSD.cpp
===
--- clang/lib/Driver/ToolChains/NetBSD.cpp
+++ clang/lib/Driver/ToolChains/NetBSD.cpp
@@ -11,6 +11,7 @@
 #include "Arch/Mips.h"
 #include "Arch/Sparc.h"
 #include "CommonArgs.h"
+#include "clang/Config/config.h"
 #include "clang/Driver/Compilation.h"
 #include "clang/Driver/Driver.h"
 #include "clang/Driver/Options.h"
@@ -435,6 +436,40 @@
   return ToolChain::CST_Libstdcxx;
 }
 
+void NetBSD::AddClangSystemIncludeArgs(
+const llvm::opt::ArgList &DriverArgs,
+llvm::opt::ArgStringList &CC1Args) const {
+  const Driver &D = getDriver();
+
+  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc))
+return;
+
+  if (!DriverArgs.hasArg(options::OPT_nobuiltininc)) {
+SmallString<128> Dir(D.ResourceDir);
+llvm::sys::path::append(Dir, "include");
+addSystemInclude(DriverArgs, CC1Args, Dir.str());
+  }
+
+  if (DriverArgs.hasArg(options::OPT_nostdlibinc))
+return;
+
+  // Check for configure-time C include directories.
+  StringRef CIncludeDirs(C_INCLUDE_DIRS);
+  if (CIncludeDirs != "") {
+SmallVector dirs;
+CIncludeDirs.split(dirs, ":");
+for (StringRef dir : dirs) {
+  StringRef Prefix =
+  llvm::sys::path::is_absolute(dir) ? StringRef(D.SysRoot) : "";
+  addExternCSystemInclude(DriverArgs, CC1Args, Prefix + dir);
+}
+return;
+  }
+
+  addExternCSystemInclude(DriverArgs, CC1Args,
+  concat(D.SysRoot,

[PATCH] D140835: [clang-format] Improve UnwrappedLineParser::mightFitOnOneLine()

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

In D140835#4023132 , @owenpan wrote:

> In D140835#4023080 , 
> @HazardyKnusperkeks wrote:
>
>> On second thought, shouldn't we test for removing the braces?
>
> Hmm. This patch including the added test case //is// for removing braces.

Then replace `test` with `check`.
I mean if we don't want to remove braces and the line than becomes to long, 
because we keep the brace. As far as I can see that could now happen right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140835

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


[PATCH] D140835: [clang-format] Improve UnwrappedLineParser::mightFitOnOneLine()

2023-01-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D140835#4028257 , 
@HazardyKnusperkeks wrote:

> In D140835#4023132 , @owenpan wrote:
>
>> In D140835#4023080 , 
>> @HazardyKnusperkeks wrote:
>>
>>> On second thought, shouldn't we test for removing the braces?
>>
>> Hmm. This patch including the added test case //is// for removing braces.
>
> Then replace `test` with `check`.

There is no `test` in my patch. What's `check`?

> I mean if we don't want to remove braces and the line than becomes to long, 
> because we keep the brace. As far as I can see that could now happen right?

If `RemoveBracesLLVM` is false, the line is too long and will wrap. If 
`RemoveBracesLLVM` is true, the line will fit on a single line after the braces 
are removed, However, without this patch, the braces would be kept and the line 
would wrap. (See the linked issue in the summary.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140835

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


[PATCH] D140956: [clang-format] Add an option for breaking after C++11 attributes

2023-01-05 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D140956#4028147 , @MyDeveloperDay 
wrote:

> If someone wants to extend this to include the old form, then that can be a 
> completely different review.

Better yet, use another tool like clang-tidy to replace the old with the new.


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

https://reviews.llvm.org/D140956

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


[clang] a28f074 - [clang-format] Add an option for breaking after C++11 attributes

2023-01-05 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-01-05T04:08:58-08:00
New Revision: a28f0747c2f3728bd8a6f64f7c8ba80b4e0cda9f

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

LOG: [clang-format] Add an option for breaking after C++11 attributes

Fixes #45968.
Fixes #54265.
Fixes #58102.

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

Added: 


Modified: 
clang/docs/ClangFormatStyleOptions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/Format/Format.h
clang/lib/Format/ContinuationIndenter.cpp
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/lib/Format/TokenAnnotator.h
clang/unittests/Format/ConfigParseTest.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index b69a1158acfd0..2fa0eef92c9d9 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -1762,6 +1762,41 @@ the configuration (without a prefix: ``Auto``).
}
 
 
+**BreakAfterAttributes** (``AttributeBreakingStyle``) 
:versionbadge:`clang-format 16`
+  Break after a group of C++11 attributes before a function
+  declaration/definition name.
+
+  Possible values:
+
+  * ``ABS_Always`` (in configuration: ``Always``)
+Always break after attributes.
+
+.. code-block:: c++
+
+  [[nodiscard]]
+  inline int f();
+  [[gnu::const]] [[nodiscard]]
+  int g();
+
+  * ``ABS_Leave`` (in configuration: ``Leave``)
+Leave the line breaking after attributes as is.
+
+.. code-block:: c++
+
+  [[nodiscard]] inline int f();
+  [[gnu::const]] [[nodiscard]]
+  int g();
+
+  * ``ABS_Never`` (in configuration: ``Never``)
+Never break after attributes.
+
+.. code-block:: c++
+
+  [[nodiscard]] inline int f();
+  [[gnu::const]] [[nodiscard]] int g();
+
+
+
 **BreakAfterJavaFieldAnnotations** (``Boolean``) :versionbadge:`clang-format 
3.8`
   Break after each annotation on a field in Java files.
 

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a3abdf45fead1..cf7c730f38ebb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -867,6 +867,8 @@ clang-format
   To match the default behavior of clang-format 15, use the ``Keyword`` value.
 - Add ``IntegerLiteralSeparator`` option for fixing integer literal separators
   in C++, C#, Java, and JavaScript.
+- Add ``BreakAfterAttributes`` option for breaking after a group of C++11
+  attributes before a function declaration/definition name.
 
 clang-extdef-mapping
 

diff  --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index b6fd6611fb5b1..1762ff977aa49 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -1221,6 +1221,36 @@ struct FormatStyle {
   /// \version 3.8
   BraceWrappingFlags BraceWrapping;
 
+  /// Different ways to break after attributes.
+  enum AttributeBreakingStyle : int8_t {
+/// Always break after attributes.
+/// \code
+///   [[nodiscard]]
+///   inline int f();
+///   [[gnu::const]] [[nodiscard]]
+///   int g();
+/// \endcode
+ABS_Always,
+/// Leave the line breaking after attributes as is.
+/// \code
+///   [[nodiscard]] inline int f();
+///   [[gnu::const]] [[nodiscard]]
+///   int g();
+/// \endcode
+ABS_Leave,
+/// Never break after attributes.
+/// \code
+///   [[nodiscard]] inline int f();
+///   [[gnu::const]] [[nodiscard]] int g();
+/// \endcode
+ABS_Never,
+  };
+
+  /// Break after a group of C++11 attributes before a function
+  /// declaration/definition name.
+  /// \version 16
+  AttributeBreakingStyle BreakAfterAttributes;
+
   /// If ``true``, clang-format will always break after a Json array `[`
   /// otherwise it will scan until the closing `]` to determine if it should 
add
   /// newlines between elements (prettier compatible).
@@ -4079,6 +4109,7 @@ struct FormatStyle {
BinPackArguments == R.BinPackArguments &&
BinPackParameters == R.BinPackParameters &&
BitFieldColonSpacing == R.BitFieldColonSpacing &&
+   BreakAfterAttributes == R.BreakAfterAttributes &&
BreakAfterJavaFieldAnnotations == R.BreakAfterJavaFieldAnnotations 
&&
BreakArrays == R.BreakArrays &&
BreakBeforeBinaryOperators == R.BreakBeforeBinaryOperators &&

diff  --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 04244c1468278..afc1860652463 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.

[PATCH] D140956: [clang-format] Add an option for breaking after C++11 attributes

2023-01-05 Thread Owen Pan 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 rGa28f0747c2f3: [clang-format] Add an option for breaking 
after C++11 attributes (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140956

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/TokenAnnotator.h
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -25121,6 +25121,56 @@
 #endif
 }
 
+TEST_F(FormatTest, BreakAfterAttributes) {
+  FormatStyle Style = getLLVMStyle();
+  EXPECT_EQ(Style.BreakAfterAttributes, FormatStyle::ABS_Never);
+
+  const StringRef Code("[[nodiscard]] inline int f(int &i);\n"
+   "[[foo([[]])]] [[nodiscard]]\n"
+   "int g(int &i);\n"
+   "[[nodiscard]]\n"
+   "inline int f(int &i) {\n"
+   "  i = 1;\n"
+   "  return 0;\n"
+   "}\n"
+   "[[foo([[]])]] [[nodiscard]] int g(int &i) {\n"
+   "  i = 0;\n"
+   "  return 1;\n"
+   "}");
+
+  verifyFormat("[[nodiscard]] inline int f(int &i);\n"
+   "[[foo([[]])]] [[nodiscard]] int g(int &i);\n"
+   "[[nodiscard]] inline int f(int &i) {\n"
+   "  i = 1;\n"
+   "  return 0;\n"
+   "}\n"
+   "[[foo([[]])]] [[nodiscard]] int g(int &i) {\n"
+   "  i = 0;\n"
+   "  return 1;\n"
+   "}",
+   Code, Style);
+
+  Style.BreakAfterAttributes = FormatStyle::ABS_Always;
+  verifyFormat("[[nodiscard]]\n"
+   "inline int f(int &i);\n"
+   "[[foo([[]])]] [[nodiscard]]\n"
+   "int g(int &i);\n"
+   "[[nodiscard]]\n"
+   "inline int f(int &i) {\n"
+   "  i = 1;\n"
+   "  return 0;\n"
+   "}\n"
+   "[[foo([[]])]] [[nodiscard]]\n"
+   "int g(int &i) {\n"
+   "  i = 0;\n"
+   "  return 1;\n"
+   "}",
+   Code, Style);
+
+  Style.BreakAfterAttributes = FormatStyle::ABS_Leave;
+  EXPECT_EQ(Code, format(Code, Style));
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/unittests/Format/ConfigParseTest.cpp
===
--- clang/unittests/Format/ConfigParseTest.cpp
+++ clang/unittests/Format/ConfigParseTest.cpp
@@ -878,6 +878,13 @@
   BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Always);
   CHECK_PARSE("BreakBeforeConceptDeclarations: false",
   BreakBeforeConceptDeclarations, FormatStyle::BBCDS_Allowed);
+
+  CHECK_PARSE("BreakAfterAttributes: Always", BreakAfterAttributes,
+  FormatStyle::ABS_Always);
+  CHECK_PARSE("BreakAfterAttributes: Leave", BreakAfterAttributes,
+  FormatStyle::ABS_Leave);
+  CHECK_PARSE("BreakAfterAttributes: Never", BreakAfterAttributes,
+  FormatStyle::ABS_Never);
 }
 
 TEST(ConfigParseTest, ParsesConfigurationWithLanguages) {
Index: clang/lib/Format/TokenAnnotator.h
===
--- clang/lib/Format/TokenAnnotator.h
+++ clang/lib/Format/TokenAnnotator.h
@@ -47,7 +47,7 @@
 MustBeDeclaration(Line.MustBeDeclaration), MightBeFunctionDecl(false),
 IsMultiVariableDeclStmt(false), Affected(false),
 LeadingEmptyLinesAffected(false), ChildrenAffected(false),
-IsContinuation(Line.IsContinuation),
+ReturnTypeWrapped(false), IsContinuation(Line.IsContinuation),
 FirstStartColumn(Line.FirstStartColumn) {
 assert(!Line.Tokens.empty());
 
@@ -151,6 +151,9 @@
   /// \c True if one of this line's children intersects with an input range.
   bool ChildrenAffected;
 
+  /// \c True if breaking after last attribute group in function return type.
+  bool ReturnTypeWrapped;
+
   /// \c True if this line should be indented by ContinuationIndent in addition
   /// to the normal indention level.
   bool IsContinuation;
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -595,8 +595,9 @@
 (Contexts.back().CanBeExpression || Contexts.back().IsExpression ||
   

[clang] 27b8f54 - [X86] Support -march=emeraldrapids

2023-01-05 Thread Freddy Ye via cfe-commits

Author: Freddy Ye
Date: 2023-01-05T20:27:32+08:00
New Revision: 27b8f54f5174aa4d8ea254a7efefd7110b247c17

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

LOG: [X86] Support -march=emeraldrapids

Reviewed By: pengfei, skan

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Basic/Targets/X86.cpp
clang/test/CodeGen/attr-target-mv.c
clang/test/CodeGen/target-builtin-noerror.c
clang/test/Driver/x86-march.c
clang/test/Misc/target-invalid-cpu-note.c
clang/test/Preprocessor/predefined-arch-macros.c
compiler-rt/lib/builtins/cpu_model.c
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/TargetParser/X86TargetParser.def
llvm/include/llvm/TargetParser/X86TargetParser.h
llvm/lib/Target/X86/X86.td
llvm/lib/TargetParser/Host.cpp
llvm/lib/TargetParser/X86TargetParser.cpp
llvm/test/CodeGen/X86/cpus-intel.ll

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cf7c730f38ebb..b308dd6c87860 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -798,7 +798,7 @@ X86 Support in Clang
   * Support intrinsic of ``_mm(256)_cvtneobf16_ps``.
   * Support intrinsic of ``_mm(256)_cvtneoph_ps``.
   * Support intrinsic of ``_mm(256)_cvtneps_avx_pbh``.
-- ``-march=raptorlake`` and ``-march=meteorlake`` are now supported.
+- ``-march=raptorlake``, ``-march=meteorlake`` and ``-march=emeraldrapids`` 
are now supported.
 - ``-march=sierraforest``, ``-march=graniterapids`` and ``-march=grandridge`` 
are now supported.
 - Lift _BitInt() supported max width from 128 to 8388608.
 - Support intrinsics of ``_mm(256)_reduce_(add|mul|or|and)_epi8/16``.

diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 3e3a843e1f9e3..4a3ce3698911b 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -529,6 +529,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_Sierraforest:
   case CK_Grandridge:
   case CK_Graniterapids:
+  case CK_Emeraldrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1422,6 +1423,7 @@ Optional X86TargetInfo::getCPUCacheLineSize() 
const {
 case CK_Sierraforest:
 case CK_Grandridge:
 case CK_Graniterapids:
+case CK_Emeraldrapids:
 case CK_KNL:
 case CK_KNM:
 // K7

diff  --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 81dd81586de5e..d10f75d58dbdc 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -20,6 +20,7 @@ int __attribute__((target("arch=meteorlake"))) foo(void) 
{return 15;}
 int __attribute__((target("arch=sierraforest"))) foo(void) {return 16;}
 int __attribute__((target("arch=grandridge"))) foo(void) {return 17;}
 int __attribute__((target("arch=graniterapids"))) foo(void) {return 18;}
+int __attribute__((target("arch=emeraldrapids"))) foo(void) {return 19;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
@@ -164,6 +165,8 @@ void calls_pr50025c(void) { pr50025c(); }
 // LINUX: ret i32 17
 // LINUX: define{{.*}} i32 @foo.arch_graniterapids()
 // LINUX: ret i32 18
+// LINUX: define{{.*}} i32 @foo.arch_emeraldrapids()
+// LINUX: ret i32 19
 // LINUX: define{{.*}} i32 @foo()
 // LINUX: ret i32 2
 // LINUX: define{{.*}} i32 @bar()
@@ -205,6 +208,8 @@ void calls_pr50025c(void) { pr50025c(); }
 // WINDOWS: ret i32 17
 // WINDOWS: define{{.*}} i32 @foo.arch_graniterapids()
 // WINDOWS: ret i32 18
+// WINDOWS: define dso_local i32 @foo.arch_emeraldrapids()
+// WINDOWS: ret i32 19
 // WINDOWS: define dso_local i32 @foo()
 // WINDOWS: ret i32 2
 // WINDOWS: define dso_local i32 @bar()

diff  --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 8597f7d47be5a..ac50da36844a4 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -109,6 +109,7 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("goldmont-plus");
   (void)__builtin_cpu_is("grandridge");
   (void)__builtin_cpu_is("graniterapids");
+  (void)__builtin_cpu_is("emeraldrapids");
   (void)__builtin_cpu_is("haswell");
   (void)__builtin_cpu_is("icelake-client");
   (void)__builtin_cpu_is("icelake-server");

diff  --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index ee7ccace61669..8e86be6c76cd7 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -131,6 +131,10 @@
 // RUN:   | FileCheck %s -check-prefix=grani

[PATCH] D140950: [X86] Support -march=emeraldrapids

2023-01-05 Thread Freddy, Ye 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 rG27b8f54f5174: [X86] Support -march=emeraldrapids (authored 
by FreddyYe).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140950

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Targets/X86.cpp
  clang/test/CodeGen/attr-target-mv.c
  clang/test/CodeGen/target-builtin-noerror.c
  clang/test/Driver/x86-march.c
  clang/test/Misc/target-invalid-cpu-note.c
  clang/test/Preprocessor/predefined-arch-macros.c
  compiler-rt/lib/builtins/cpu_model.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/Host.cpp
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -22,6 +22,7 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=sierraforest 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=grandridge 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=graniterapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=emeraldrapids 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
Index: llvm/lib/TargetParser/X86TargetParser.cpp
===
--- llvm/lib/TargetParser/X86TargetParser.cpp
+++ llvm/lib/TargetParser/X86TargetParser.cpp
@@ -391,8 +391,10 @@
   { {"sierraforest"}, CK_Sierraforest, FEATURE_AVX2, FeaturesSierraforest },
   // Grandridge microarchitecture based processors.
   { {"grandridge"}, CK_Grandridge, FEATURE_AVX2, FeaturesGrandridge },
-  // Graniterapids microarchitecture based processors.
+  // Granite Rapids microarchitecture based processors.
   { {"graniterapids"}, CK_Graniterapids, FEATURE_AVX512BF16, FeaturesGraniteRapids },
+  // Emerald Rapids microarchitecture based processors.
+  { {"emeraldrapids"}, CK_Emeraldrapids, FEATURE_AVX512BF16, FeaturesSapphireRapids },
   // Knights Landing processor.
   { {"knl"}, CK_KNL, FEATURE_AVX512F, FeaturesKNL },
   // Knights Mill processor.
Index: llvm/lib/TargetParser/Host.cpp
===
--- llvm/lib/TargetParser/Host.cpp
+++ llvm/lib/TargetParser/Host.cpp
@@ -847,6 +847,8 @@
   *Subtype = X86::INTEL_COREI7_ICELAKE_SERVER;
   break;
 
+// Emerald Rapids:
+case 0xcf:
 // Sapphire Rapids:
 case 0x8f:
   CPU = "sapphirerapids";
Index: llvm/lib/Target/X86/X86.td
===
--- llvm/lib/Target/X86/X86.td
+++ llvm/lib/Target/X86/X86.td
@@ -1548,6 +1548,8 @@
 ProcessorFeatures.ADLFeatures, ProcessorFeatures.ADLTuning>;
 def : ProcModel<"graniterapids", SkylakeServerModel,
 ProcessorFeatures.GNRFeatures, ProcessorFeatures.SPRTuning>;
+def : ProcModel<"emeraldrapids", SkylakeServerModel,
+ProcessorFeatures.SPRFeatures, ProcessorFeatures.SPRTuning>;
 
 // AMD CPUs.
 
Index: llvm/include/llvm/TargetParser/X86TargetParser.h
===
--- llvm/include/llvm/TargetParser/X86TargetParser.h
+++ llvm/include/llvm/TargetParser/X86TargetParser.h
@@ -109,6 +109,7 @@
   CK_Sierraforest,
   CK_Grandridge,
   CK_Graniterapids,
+  CK_Emeraldrapids,
   CK_KNL,
   CK_KNM,
   CK_Lakemont,
Index: llvm/include/llvm/TargetParser/X86TargetParser.def
===
--- llvm/include/llvm/TargetParser/X86TargetParser.def
+++ llvm/include/llvm/TargetParser/X86TargetParser.def
@@ -103,6 +103,7 @@
 // Alternate names supported by __builtin_cpu_is and target multiversioning.
 X86_CPU_SUBTYPE_ALIAS(INTEL_COREI7_ALDERLAKE, "raptorlake")
 X86_CPU_SUBTYPE_ALIAS(INTEL_COREI7_ALDERLAKE, "meteorlake")
+X86_CPU_SUBTYPE_ALIAS(INTEL_COREI7_SAPPHIRERAPIDS, "emeraldrapids")
 
 #undef X86_CPU_SUBTYPE_ALIAS
 #undef X86_CPU_SUBTYPE
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -186,7 +186,7 @@
 * Support ISA of ``AVX-IF

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-01-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Sorry for not getting back to you earlier.
It mostly looks reasonable to me.
what do you think @erichkeane ?




Comment at: clang/lib/Sema/SemaInit.cpp:10338
+Context.getRValueReferenceType(ElementTypes[i]);
+  else if (isa(ListInit->getInit(i)))
+// This deviates from the wording which is incorrect.

I think we need to support `A{("Hello")};` so we probably need to get rid of 
parentheses (maybe other implicit nodes?)



Comment at: clang/lib/Sema/SemaInit.cpp:10364
+FunctionTemplateDecl *TD = GD->getDescribedFunctionTemplate();
+assert(TD);
+addDeductionCandidate(TD, GD, DeclAccessPair::make(TD, AS_public),

Maybe add a message here



Comment at: clang/lib/Sema/SemaTemplate.cpp:2590-2591
+  // constructors into deduction guides.
+  // FIXME: Add a kind for this to give more meaningful diagnostics. But can
+  // this substitution process actually fail?
+  InstantiatingTemplate BuildingDeductionGuides(*this, Loc, Template);

Maybe we should have an asserton !isInvalid then?



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:368
   NewPack.push_back(Merged);
+++YA;
+  } else {

I think you can do that in the for loop as it was before



Comment at: clang/lib/Sema/SemaTemplateDeduction.cpp:998
   bool IsPartiallyExpanded = false;
+  bool DeducePackIfNotAlreadyDeduced;
   /// The number of expansions, if we have a fully-expanded pack in this scope.

That could always be initialized, to avoid future surprises


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

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



Comment at: clang/include/clang/AST/DeclCXX.h:1953-1959
   bool isCopyDeductionCandidate() const {
-return FunctionDeclBits.IsCopyDeductionCandidate;
+return getDeductionCandidateKind() == DeductionCandidateKind::Copy;
+  }
+
+  bool isAggregateDeductionCandidate() const {
+return getDeductionCandidateKind() == DeductionCandidateKind::Aggregate;
   }

ychen wrote:
> cor3ntin wrote:
> > I'm not sure how useful these things are, isAggregateDeductionCandidate is 
> > only used once
> I meant to make it consistent with `isCopyDeductionCandidate` which is also 
> used once. Maybe remove both `isCopyDeductionCandidate` and 
> `isAggregateDeductionCandidate`?
Yes, i think we might as well


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D140387: [clang][analyzer] Add stream related functions to StdLibraryFunctionsChecker.

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

LGTM! I think I prefer this solution anyways. Please commit (the entire 
patchstack).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140387

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


[PATCH] D137070: [clang][Interp] Support destructors

2023-01-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 486525.
tbaeder marked an inline comment as done.
tbaeder set the repository for this revision to rG LLVM Github Monorepo.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137070

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

Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -217,3 +217,177 @@
// ref-error {{must be initialized by a constant expression}}
 
 };
+
+namespace Destructors {
+
+  class Inc final {
+  public:
+int &I;
+constexpr Inc(int &I) : I(I) {}
+constexpr ~Inc() {
+  I++;
+}
+  };
+
+  class Dec final {
+  public:
+int &I;
+constexpr Dec(int &I) : I(I) {}
+constexpr ~Dec() {
+  I--;
+}
+  };
+
+
+
+  constexpr int m() {
+int i = 0;
+{
+  Inc f1(i);
+  Inc f2(i);
+  Inc f3(i);
+}
+return i;
+  }
+  static_assert(m() == 3, "");
+
+
+  constexpr int C() {
+int i = 0;
+
+while (i < 10) {
+  Inc inc(i);
+  continue;
+  Dec dec(i);
+}
+return i;
+  }
+  static_assert(C() == 10, "");
+
+
+  constexpr int D() {
+int i = 0;
+
+{
+  Inc i1(i);
+  {
+Inc i2(i);
+return i;
+  }
+}
+
+return i;
+  }
+  static_assert(D() == 0, "");
+
+  constexpr int E() {
+int i = 0;
+
+for(;;) {
+  Inc i1(i);
+  break;
+}
+return i;
+  }
+  static_assert(E() == 1, "");
+
+
+  /// FIXME: This should be rejected, since we call the destructor
+  ///   twice. However, GCC doesn't care either.
+  constexpr int ManualDtor() {
+int i = 0;
+{
+  Inc I(i); // ref-note {{destroying object 'I' whose lifetime has already ended}}
+  I.~Inc();
+}
+return i;
+  }
+  static_assert(ManualDtor() == 1, ""); // expected-error {{static assertion failed}} \
+// expected-note {{evaluates to '2 == 1'}} \
+// ref-error {{not an integral constant expression}} \
+// ref-note {{in call to 'ManualDtor()'}}
+
+  constexpr void doInc(int &i) {
+Inc I(i);
+return;
+  }
+  constexpr int testInc() {
+int i = 0;
+doInc(i);
+return i;
+  }
+  static_assert(testInc() == 1, "");
+  constexpr void doInc2(int &i) {
+Inc I(i);
+// No return statement.
+  }
+   constexpr int testInc2() {
+int i = 0;
+doInc2(i);
+return i;
+  }
+  static_assert(testInc2() == 1, "");
+
+
+  namespace DtorOrder {
+class A {
+  public:
+  int &I;
+  constexpr A(int &I) : I(I) {}
+  constexpr ~A() {
+I = 1337;
+  }
+};
+
+class B : public A {
+  public:
+  constexpr B(int &I) : A(I) {}
+  constexpr ~B() {
+I = 42;
+  }
+};
+
+constexpr int foo() {
+  int i = 0;
+  {
+B b(i);
+  }
+  return i;
+}
+
+static_assert(foo() == 1337);
+  }
+
+  class FieldDtor1 {
+  public:
+Inc I1;
+Inc I2;
+constexpr FieldDtor1(int &I) : I1(I), I2(I){}
+  };
+
+  constexpr int foo2() {
+int i = 0;
+{
+  FieldDtor1 FD1(i);
+}
+return i;
+  }
+
+  static_assert(foo2() == 2);
+
+  class FieldDtor2 {
+  public:
+Inc Incs[3];
+constexpr FieldDtor2(int &I)  : Incs{Inc(I), Inc(I), Inc(I)} {}
+  };
+
+  constexpr int foo3() {
+int i = 0;
+{
+  FieldDtor2 FD2(i);
+}
+return i;
+  }
+
+  static_assert(foo3() == 3);
+}
Index: clang/lib/AST/Interp/ByteCodeStmtGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -429,6 +429,7 @@
   if (!BreakLabel)
 return false;
 
+  this->emitCleanup();
   return this->jump(*BreakLabel);
 }
 
@@ -437,6 +438,7 @@
   if (!ContinueLabel)
 return false;
 
+  this->emitCleanup();
   return this->jump(*ContinueLabel);
 }
 
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -274,6 +274,8 @@
 return FPO.getRoundingMode();
   }
 
+  bool emitRecordDestruction(const Descriptor *Desc);
+
 protected:
   /// Variable to storage mapping.
   llvm::DenseMap Locals;
@@ -340,7 +342,7 @@
 public:
   LocalScope(ByteCodeExprGen *Ctx) : VariableScope(Ctx) {}
 
-  ~LocalScope() override { this->emitDestruction(); }
+  virtual ~LocalScope() override { this->emitDestruction(); }
 
   void addLocal(const Scope::Local &Local) override {
 if (!Idx) {
@@ -351,9 +353,20 @@
 this->Ctx->Descriptors[*Idx].emplace_back(Local);
   }
 
+  //

[PATCH] D140807: [clang][Interp] Skip calling simple destructors

2023-01-05 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder abandoned this revision.
tbaeder added a comment.

I added the `isTrivial()` checks to the new version in 
https://reviews.llvm.org/D137070.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140807

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


[PATCH] D140915: [clangd] Fix getQueryScopes for using-directive with inline namespace

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



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:674
+else if (const auto *ND = dyn_cast(Context)) {
+  if (ND->isInlineNamespace())
+Scopes.AccessibleScopes.push_back(printQualifiedName(*ND) + "::");

tom-anders wrote:
> kadircet wrote:
> > since we know that the `Context` is a `NamespaceDecl` it should be safe to 
> > use `printQualifiedName` always. any reason for the extra branching here 
> > (apart from minimizing the change to behaviour)? if not I think we can get 
> > rid of the special casing.
> Unfortunately, this fails CompletionTest.EnclosingScopeComesFirst and 
> CompletionTest.NoDuplicatedQueryScopes, I think because of anonymous 
> namespaces (where printNameSpaceScope would return an empty string, but 
> (printQualifiedName(*ND) + "::" does not). 
i see. taking a closer look at this `getQueryScopes` is used for two things:
- The scopes to query with fuzzyfind requests, hence this should use the same 
"serialization" as symbolcollector (which only strips anon namespaces today, 
but initially it were to strip both anon & inline namespaces. it got changed 
inside clang without clangd tests catching it).
- The shortening of the fully qualified name in `CodeCompletionBuilder`. Not 
having inline namespaces spelled in the available namespaces implies getting 
wrong qualifiers (such as the bug you're fixing).

so considering the requirements here:
- when querying index, we actually want to hide inline namespaces (as 
`ns::hidden::Foo` should be a viable alternative even if only `ns::` is 
accessible). so we should actually fix `printQualifiedName` to set 
`SuppressInlineNamespace` in printing policy to restore the old behaviour (and 
keep using `printNamespaceScope` here).
- inside `CodeCompletionBuilder`, we shouldn't use the same scopes we use 
during index queries. we should use the visible namespaces while preserving 
inline namespace information and only ignoring the anonymous namespaces.

hence can we have 2 separate scopes in `CodeCompleteFlow` instead?
One called `QueryScopes`, which has the behavior we have today (fixing 
printQualifiedName is a separate issues).
Other called `AccessibleScopes`, which has accessible namespaces spelled 
**with** inline namespaces, so that we can get proper qualification during 
code-complete.

does that make sense?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140915

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


[PATCH] D139168: [C++20] [Modules] [ClangScanDeps] Enable to print make-style dependency file within P1689 format (4/4)

2023-01-05 Thread Ben Boeckel via Phabricator via cfe-commits
ben.boeckel added a comment.

In D139168#4027637 , @ChuanqiXu wrote:

> Currently, clang-scan-deps won't check for this. If we have multiple command 
> lines with different `-MF` value, the make-style dependency information will 
> be written to these different depfiles.

IMO, this is not suitable; there must be *one* depfile for Ninja to work 
(otherwise build tools will need to manually collate all of this into one for 
`ninja`.

> I feel like we have 2 (or 3) options
>
> 1. (The current way) Extract `-MF` in the command line of clang (from 
> compilation database or from the args after `--`)

See above; it works for the file-by-file, but falls over with batch scanning.

> 2. (The original way) Specify `-MF` in the command line of clang-scan-deps.

I feel this scales and communicates what is happening much better because it 
actually is a flag for `clang-scan-deps` itself.

> 3. (Not good) Do nothing. I feel like it is possible for build systems to get 
> the make-style dependency information by scanning twice. One for P1689 
>  format and one for make-format. It may be 
> workable but it sounds a little bit silly.

In what mode will `clang` output `#include` information without erroring about 
missing `.pcm` files for `import` statements? `-E -fdirectives-only` perhaps? 
This further exacerbates the need for "fake" command lines and costs on 
platforms with expensive process execution.

> the make-style dependency information of input_file in  will be 
> overwritten. Or would cmake like to concat the results manually?

Every command gets its own unique ``. Scanning, compilation, etc. 
Overlapping is just asking for race conditions in the build.


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

https://reviews.llvm.org/D139168

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


[clang-tools-extra] b06b248 - [clang-tidy] Implement CppCoreGuideline CP.53

2023-01-05 Thread Carlos Galvez via cfe-commits

Author: Chris Cotter
Date: 2023-01-05T13:57:22Z
New Revision: b06b248ad9dc1b50dcf474616c3d586d47270a01

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

LOG: [clang-tidy] Implement CppCoreGuideline CP.53

Implement CppCoreGuideline CP.53 to warn when a coroutine accepts
references parameters. Although the guideline mentions that it is safe
to access a reference parameter before suspension points, the guideline
recommends flagging all coroutine parameter references.

Reviewed By: carlosgalvezp

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

Added: 

clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp

clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.rst

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-reference-coroutine-parameters.cpp

Modified: 
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp
new file mode 100644
index 0..018aaad9a8d7a
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp
@@ -0,0 +1,38 @@
+//===--- AvoidReferenceCoroutineParametersCheck.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 "AvoidReferenceCoroutineParametersCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+void AvoidReferenceCoroutineParametersCheck::registerMatchers(
+MatchFinder *Finder) {
+  auto IsCoroMatcher =
+  hasDescendant(expr(anyOf(coyieldExpr(), coreturnStmt(), coawaitExpr(;
+  Finder->addMatcher(parmVarDecl(hasType(type(referenceType())),
+ hasAncestor(functionDecl(IsCoroMatcher)))
+ .bind("param"),
+ this);
+}
+
+void AvoidReferenceCoroutineParametersCheck::check(
+const MatchFinder::MatchResult &Result) {
+  if (const auto *Param = Result.Nodes.getNodeAs("param")) {
+diag(Param->getBeginLoc(), "coroutine parameters should not be 
references");
+  }
+}
+
+} // namespace cppcoreguidelines
+} // namespace tidy
+} // namespace clang

diff  --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h
new file mode 100644
index 0..502b5717893b3
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h
@@ -0,0 +1,40 @@
+//===--- AvoidReferenceCoroutineParametersCheck.h - clang-tidy --*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDREFERENCECOROUTINEPARAMETERSCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_AVOIDREFERENCECOROUTINEPARAMETERSCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+/// Warns on coroutines that accept reference parameters. Accessing a reference
+/// after a coroutine suspension point is not safe since the reference may no
+/// longer be valid. This implements CppCoreGuideline CP.53.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.html
+class AvoidReferenceCoroutineParametersCheck : public ClangTidyCheck {
+public:
+  AvoidReferenceCoroutineParametersCheck(StringRef Name,
+ ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  vo

[PATCH] D140793: [clang-tidy] Implement CppCoreGuideline CP.53

2023-01-05 Thread Carlos Galvez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb06b248ad9dc: [clang-tidy] Implement CppCoreGuideline CP.53 
(authored by ccotter, committed by carlosgalvezp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140793

Files:
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidReferenceCoroutineParametersCheck.h
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-reference-coroutine-parameters.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-reference-coroutine-parameters.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-reference-coroutine-parameters.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy -std=c++20 %s cppcoreguidelines-avoid-reference-coroutine-parameters %t
+
+// NOLINTBEGIN
+namespace std {
+  template 
+  struct coroutine_traits {
+using promise_type = typename T::promise_type;
+  };
+  template 
+  struct coroutine_handle;
+  template <>
+  struct coroutine_handle {
+coroutine_handle() noexcept;
+coroutine_handle(decltype(nullptr)) noexcept;
+static constexpr coroutine_handle from_address(void*);
+  };
+  template 
+  struct coroutine_handle {
+coroutine_handle() noexcept;
+coroutine_handle(decltype(nullptr)) noexcept;
+static constexpr coroutine_handle from_address(void*);
+operator coroutine_handle<>() const noexcept;
+  };
+} // namespace std
+
+struct Awaiter {
+  bool await_ready() noexcept;
+  void await_suspend(std::coroutine_handle<>) noexcept;
+  void await_resume() noexcept;
+};
+
+struct Coro {
+  struct promise_type {
+Awaiter initial_suspend();
+Awaiter final_suspend() noexcept;
+void return_void();
+Coro get_return_object();
+void unhandled_exception();
+  };
+};
+// NOLINTEND
+
+struct Obj {};
+
+Coro no_args() {
+  co_return;
+}
+
+Coro no_references(int x, int* y, Obj z, const Obj w) {
+  co_return;
+}
+
+Coro accepts_references(int& x, const int &y) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: coroutine parameters should not be references [cppcoreguidelines-avoid-reference-coroutine-parameters]
+  // CHECK-MESSAGES: :[[@LINE-2]]:33: warning: coroutine parameters should not be references [cppcoreguidelines-avoid-reference-coroutine-parameters]
+  co_return;
+}
+
+Coro accepts_references_and_non_references(int& x, int y) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:44: warning: coroutine parameters should not be references [cppcoreguidelines-avoid-reference-coroutine-parameters]
+  co_return;
+}
+
+Coro accepts_references_to_objects(Obj& x) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: coroutine parameters should not be references [cppcoreguidelines-avoid-reference-coroutine-parameters]
+  co_return;
+}
+
+Coro non_coro_accepts_references(int& x) {
+  if (x);
+  return Coro{};
+}
+
+void defines_a_lambda() {
+  auto NoArgs = [](int x) -> Coro { co_return; };
+
+  auto NoReferences = [](int x) -> Coro { co_return; };
+
+  auto WithReferences = [](int& x) -> Coro { co_return; };
+  // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: coroutine parameters should not be references [cppcoreguidelines-avoid-reference-coroutine-parameters]
+
+  auto WithReferences2 = [](int&) -> Coro { co_return; };
+  // CHECK-MESSAGES: :[[@LINE-1]]:29: warning: coroutine parameters should not be references [cppcoreguidelines-avoid-reference-coroutine-parameters]
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -182,6 +182,7 @@
`cppcoreguidelines-avoid-do-while `_,
`cppcoreguidelines-avoid-goto `_,
`cppcoreguidelines-avoid-non-const-global-variables `_,
+   `cppcoreguidelines-avoid-reference-coroutine-parameters `_,
`cppcoreguidelines-init-variables `_, "Yes"
`cppcoreguidelines-interfaces-global-init `_,
`cppcoreguidelines-macro-usage `_,
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-reference-coroutine-parameters.rst
@@ -0,0 +1,20 @@
+.. title:: clang-tidy - cppcoreguidelines-avoid-reference-coroutine-parameters
+
+cppcoreguideli

[PATCH] D141047: build: with -DCLANGD_ENABLE_REMOTE=ON, search for grpc++ dependencies too

2023-01-05 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru created this revision.
sylvestre.ledru added a reviewer: serge-sans-paille.
Herald added subscribers: bmahjour, kadircet, arphaman.
Herald added a project: All.
sylvestre.ledru requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang.

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


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141047

Files:
  clang/cmake/modules/AddGRPC.cmake
  cmake/Modules/FindGRPC.cmake


Index: cmake/Modules/FindGRPC.cmake
===
--- cmake/Modules/FindGRPC.cmake
+++ cmake/Modules/FindGRPC.cmake
@@ -82,11 +82,28 @@
 endif()
   endif()
   if(NOT TARGET grpc++)
+find_library(GPR_LIBRARY gpr $GRPC_OPTS REQUIRED)
+add_library(gpr UNKNOWN IMPORTED GLOBAL)
+message(STATUS "Using gpr: " ${GPR_LIBRARY})
+set_target_properties(gpr PROPERTIES IMPORTED_LOCATION ${GPR_LIBRARY})
+
 find_library(GRPC_LIBRARY grpc++ ${GRPC_OPTS} REQUIRED)
 add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
 message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
 set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
 target_include_directories(grpc++ INTERFACE ${GRPC_INCLUDE_PATHS})
+find_library(GRPC2_LIBRARY grpc $GRPC_OPTS REQUIRED)
+add_library(grpc UNKNOWN IMPORTED GLOBAL)
+message(STATUS "Using grpc: " ${GRPC2_LIBRARY})
+set_target_properties(grpc PROPERTIES IMPORTED_LOCATION ${GRPC2_LIBRARY})
+
+find_library(ABSL_SYNCHRONIZATION_LIBRARY absl_synchronization $GRPC_OPTS 
QUIET)
+if (ABSL_SYNCHRONIZATION_LIBRARY)
+  add_library(absl_synchronization UNKNOWN IMPORTED GLOBAL)
+  message(STATUS "Using absl_synchronization: " 
${ABSL_SYNCHRONIZATION_LIBRARY})
+  set_target_properties(absl_synchronization PROPERTIES IMPORTED_LOCATION 
${ABSL_SYNCHRONIZATION_LIBRARY})
+endif()
+
 if (ENABLE_GRPC_REFLECTION)
   find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection ${GRPC_OPTS} 
REQUIRED)
   add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
Index: clang/cmake/modules/AddGRPC.cmake
===
--- clang/cmake/modules/AddGRPC.cmake
+++ clang/cmake/modules/AddGRPC.cmake
@@ -4,8 +4,13 @@
   # Take the first two args and forward the remaining to 
generate_proto_sources.
   cmake_parse_arguments(PARSE_ARGV 2 PROTO "" "" "")
   generate_proto_sources(ProtoSource ${ProtoFile} ${PROTO_UNPARSED_ARGUMENTS})
+  set(LINKED_GRPC_LIBRARIES protobuf gpr grpc grpc++)
 
+  if (ABSL_SYNCHRONIZATION_LIBRARY)
+list(APPEND LINKED_GRPC_LIBRARIES absl_synchronization)
+  endif()
   add_clang_library(${LibraryName} ${ProtoSource}
 PARTIAL_SOURCES_INTENDED
-LINK_LIBS PUBLIC grpc++ protobuf)
+LINK_LIBS PUBLIC  ${LINKED_GRPC_LIBRARIES})
+
 endfunction()


Index: cmake/Modules/FindGRPC.cmake
===
--- cmake/Modules/FindGRPC.cmake
+++ cmake/Modules/FindGRPC.cmake
@@ -82,11 +82,28 @@
 endif()
   endif()
   if(NOT TARGET grpc++)
+find_library(GPR_LIBRARY gpr $GRPC_OPTS REQUIRED)
+add_library(gpr UNKNOWN IMPORTED GLOBAL)
+message(STATUS "Using gpr: " ${GPR_LIBRARY})
+set_target_properties(gpr PROPERTIES IMPORTED_LOCATION ${GPR_LIBRARY})
+
 find_library(GRPC_LIBRARY grpc++ ${GRPC_OPTS} REQUIRED)
 add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
 message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
 set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
 target_include_directories(grpc++ INTERFACE ${GRPC_INCLUDE_PATHS})
+find_library(GRPC2_LIBRARY grpc $GRPC_OPTS REQUIRED)
+add_library(grpc UNKNOWN IMPORTED GLOBAL)
+message(STATUS "Using grpc: " ${GRPC2_LIBRARY})
+set_target_properties(grpc PROPERTIES IMPORTED_LOCATION ${GRPC2_LIBRARY})
+
+find_library(ABSL_SYNCHRONIZATION_LIBRARY absl_synchronization $GRPC_OPTS QUIET)
+if (ABSL_SYNCHRONIZATION_LIBRARY)
+  add_library(absl_synchronization UNKNOWN IMPORTED GLOBAL)
+  message(STATUS "Using absl_synchronization: " ${ABSL_SYNCHRONIZATION_LIBRARY})
+  set_target_properties(absl_synchronization PROPERTIES IMPORTED_LOCATION ${ABSL_SYNCHRONIZATION_LIBRARY})
+endif()
+
 if (ENABLE_GRPC_REFLECTION)
   find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection ${GRPC_OPTS} REQUIRED)
   add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
Index: clang/cmake/modules/AddGRPC.cmake
===
--- clang/cmake/modules/AddGRPC.cmake
+++ clang/cmake/modules/AddGRPC.cmake
@@ -4,8 +4,13 @@
   # Take the first two args and forward the remaining to generate_proto_sources.
   cmake_parse_arguments(PARSE_ARGV 2 PROTO "" "" "")
   generate_proto_sources(ProtoSource ${ProtoFile} ${PROTO_UNPARSED_ARGUMENTS})
+  set(LINKED_GRPC_LIBRARIES protobuf gpr grpc grpc++)
 
+  i

[PATCH] D140868: [C] Make (c ? e1 : e2) noreturn only if both e1 and e2 are noreturn

2023-01-05 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.

In D140868#4027635 , @rjmccall wrote:

> In D140868#4027480 , @MaskRay wrote:
>
>> I am not a C language lawyer :) I wonder what else should be done to move 
>> this patch forward.
>> The https://github.com/llvm/llvm-project/issues/59792 has got some traction 
>> and has been added a candidate for the next 15.x patch release 
>> https://github.com/llvm/llvm-project/milestone/18
>
> We should test that this doesn't affect functions declared using the standard 
> C attributes.  Otherwise, I think we can go forward with this change.  Aaron, 
> does that seem reasonable to you?  For better or worse, the different 
> spellings of `noreturn` do have different behavior already, since the 
> standard spellings aren't supposed to be type-affecting.  And I feel like the 
> suggested rule here is clearly correct if we have the flexibility to set it 
> on our own.

Yeah, I think this is the right approach. I was worried about the inconsistency 
with function declaration merging, but `[[noreturn]]` is required to be on the 
first declaration (6.7.12.6p3) and so there's no merging issue there. 
`_Noreturn` does not have the same requirement but neither `_Noreturn` nor 
`[[noreturn]]` are part of the function type anyway. So yeah, this seems like 
the right way to go in this case, thank you!

Please add a release note for the changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140868

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


[PATCH] D140835: [clang-format] Improve UnwrappedLineParser::mightFitOnOneLine()

2023-01-05 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

In D140835#4028274 , @owenpan wrote:

> If `RemoveBracesLLVM` is false, the line is too long and will wrap.

That's what I fail to see, but if you say so.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140835

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


[PATCH] D141047: build: with -DCLANGD_ENABLE_REMOTE=ON, search for grpc++ dependencies too

2023-01-05 Thread serge via Phabricator via cfe-commits
serge-sans-paille added inline comments.



Comment at: cmake/Modules/FindGRPC.cmake:85
   if(NOT TARGET grpc++)
+find_library(GPR_LIBRARY gpr $GRPC_OPTS REQUIRED)
+add_library(gpr UNKNOWN IMPORTED GLOBAL)

Shouldn't this be `${GPRC_OPTS}`?



Comment at: cmake/Modules/FindGRPC.cmake:95
 target_include_directories(grpc++ INTERFACE ${GRPC_INCLUDE_PATHS})
+find_library(GRPC2_LIBRARY grpc $GRPC_OPTS REQUIRED)
+add_library(grpc UNKNOWN IMPORTED GLOBAL)

same here



Comment at: cmake/Modules/FindGRPC.cmake:100
+
+find_library(ABSL_SYNCHRONIZATION_LIBRARY absl_synchronization $GRPC_OPTS 
QUIET)
+if (ABSL_SYNCHRONIZATION_LIBRARY)

and here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141047

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


[PATCH] D141047: build: with -DCLANGD_ENABLE_REMOTE=ON, search for grpc++ dependencies too

2023-01-05 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru updated this revision to Diff 486546.
sylvestre.ledru added a comment.

add the missing {}


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141047

Files:
  clang/cmake/modules/AddGRPC.cmake
  cmake/Modules/FindGRPC.cmake


Index: cmake/Modules/FindGRPC.cmake
===
--- cmake/Modules/FindGRPC.cmake
+++ cmake/Modules/FindGRPC.cmake
@@ -82,11 +82,28 @@
 endif()
   endif()
   if(NOT TARGET grpc++)
+find_library(GPR_LIBRARY gpr ${GRPC_OPTS} REQUIRED)
+add_library(gpr UNKNOWN IMPORTED GLOBAL)
+message(STATUS "Using gpr: " ${GPR_LIBRARY})
+set_target_properties(gpr PROPERTIES IMPORTED_LOCATION ${GPR_LIBRARY})
+
 find_library(GRPC_LIBRARY grpc++ ${GRPC_OPTS} REQUIRED)
 add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
 message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
 set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
 target_include_directories(grpc++ INTERFACE ${GRPC_INCLUDE_PATHS})
+find_library(GRPC2_LIBRARY grpc ${GRPC_OPTS} REQUIRED)
+add_library(grpc UNKNOWN IMPORTED GLOBAL)
+message(STATUS "Using grpc: " ${GRPC2_LIBRARY})
+set_target_properties(grpc PROPERTIES IMPORTED_LOCATION ${GRPC2_LIBRARY})
+
+find_library(ABSL_SYNCHRONIZATION_LIBRARY absl_synchronization 
${GRPC_OPTS} QUIET)
+if (ABSL_SYNCHRONIZATION_LIBRARY)
+  add_library(absl_synchronization UNKNOWN IMPORTED GLOBAL)
+  message(STATUS "Using absl_synchronization: " 
${ABSL_SYNCHRONIZATION_LIBRARY})
+  set_target_properties(absl_synchronization PROPERTIES IMPORTED_LOCATION 
${ABSL_SYNCHRONIZATION_LIBRARY})
+endif()
+
 if (ENABLE_GRPC_REFLECTION)
   find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection ${GRPC_OPTS} 
REQUIRED)
   add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
Index: clang/cmake/modules/AddGRPC.cmake
===
--- clang/cmake/modules/AddGRPC.cmake
+++ clang/cmake/modules/AddGRPC.cmake
@@ -4,8 +4,13 @@
   # Take the first two args and forward the remaining to 
generate_proto_sources.
   cmake_parse_arguments(PARSE_ARGV 2 PROTO "" "" "")
   generate_proto_sources(ProtoSource ${ProtoFile} ${PROTO_UNPARSED_ARGUMENTS})
+  set(LINKED_GRPC_LIBRARIES protobuf gpr grpc grpc++)
 
+  if (ABSL_SYNCHRONIZATION_LIBRARY)
+list(APPEND LINKED_GRPC_LIBRARIES absl_synchronization)
+  endif()
   add_clang_library(${LibraryName} ${ProtoSource}
 PARTIAL_SOURCES_INTENDED
-LINK_LIBS PUBLIC grpc++ protobuf)
+LINK_LIBS PUBLIC  ${LINKED_GRPC_LIBRARIES})
+
 endfunction()


Index: cmake/Modules/FindGRPC.cmake
===
--- cmake/Modules/FindGRPC.cmake
+++ cmake/Modules/FindGRPC.cmake
@@ -82,11 +82,28 @@
 endif()
   endif()
   if(NOT TARGET grpc++)
+find_library(GPR_LIBRARY gpr ${GRPC_OPTS} REQUIRED)
+add_library(gpr UNKNOWN IMPORTED GLOBAL)
+message(STATUS "Using gpr: " ${GPR_LIBRARY})
+set_target_properties(gpr PROPERTIES IMPORTED_LOCATION ${GPR_LIBRARY})
+
 find_library(GRPC_LIBRARY grpc++ ${GRPC_OPTS} REQUIRED)
 add_library(grpc++ UNKNOWN IMPORTED GLOBAL)
 message(STATUS "Using grpc++: " ${GRPC_LIBRARY})
 set_target_properties(grpc++ PROPERTIES IMPORTED_LOCATION ${GRPC_LIBRARY})
 target_include_directories(grpc++ INTERFACE ${GRPC_INCLUDE_PATHS})
+find_library(GRPC2_LIBRARY grpc ${GRPC_OPTS} REQUIRED)
+add_library(grpc UNKNOWN IMPORTED GLOBAL)
+message(STATUS "Using grpc: " ${GRPC2_LIBRARY})
+set_target_properties(grpc PROPERTIES IMPORTED_LOCATION ${GRPC2_LIBRARY})
+
+find_library(ABSL_SYNCHRONIZATION_LIBRARY absl_synchronization ${GRPC_OPTS} QUIET)
+if (ABSL_SYNCHRONIZATION_LIBRARY)
+  add_library(absl_synchronization UNKNOWN IMPORTED GLOBAL)
+  message(STATUS "Using absl_synchronization: " ${ABSL_SYNCHRONIZATION_LIBRARY})
+  set_target_properties(absl_synchronization PROPERTIES IMPORTED_LOCATION ${ABSL_SYNCHRONIZATION_LIBRARY})
+endif()
+
 if (ENABLE_GRPC_REFLECTION)
   find_library(GRPC_REFLECTION_LIBRARY grpc++_reflection ${GRPC_OPTS} REQUIRED)
   add_library(grpc++_reflection UNKNOWN IMPORTED GLOBAL)
Index: clang/cmake/modules/AddGRPC.cmake
===
--- clang/cmake/modules/AddGRPC.cmake
+++ clang/cmake/modules/AddGRPC.cmake
@@ -4,8 +4,13 @@
   # Take the first two args and forward the remaining to generate_proto_sources.
   cmake_parse_arguments(PARSE_ARGV 2 PROTO "" "" "")
   generate_proto_sources(ProtoSource ${ProtoFile} ${PROTO_UNPARSED_ARGUMENTS})
+  set(LINKED_GRPC_LIBRARIES protobuf gpr grpc grpc++)
 
+  if (ABSL_SYNCHRONIZATION_LIBRARY)
+list(APPEND LINKED_GRPC_LIBRARIES absl_synchronization)
+  endif()
   add_clang_library(${LibraryName} ${ProtoSource}
 PARTIAL_SOURCES_INTENDED
-LIN

[PATCH] D141050: [standalone-build] outsource, simplify and unify repetitive CMake code

2023-01-05 Thread Konrad Wilhelm Kleine via Phabricator via cfe-commits
kwk created this revision.
kwk added reviewers: tstellar, phosek.
Herald added subscribers: bzcheeseman, rriddle.
Herald added a project: All.
kwk requested review of this revision.
Herald added subscribers: cfe-commits, stephenneuendorffer.
Herald added a project: clang.

Rationale
=

This is an opinionated change for the standalone build mode CMake code.

The rationale behind this change is to unify the parts of standalone
builds that historically had to be kept in each and every project. With
the advent of the top-level `cmake` directory inside the LLVM source
tree, it is now possible to bundle the CMake instructions into a file,
aka `cmake/Modules/StandaloneBuildHelpers.cmake`, and include that file
in each project that wants to build in standalone-mode.

Historically the standalone build mode is used mostly by Linux
distributions. Certainly not every LLVM contributor cares about Linux
distributions. To reduce the frictions it makes even more sense to have
a unified place where to keep the specialities of building in standalone
mode.

Affected projects (so far)
--

This change brings the unified standalone build mode to the clang and
lld project.

Assumptions
===

One radical assumption for this change is that in order to build clang
or ldd in standalone mode, you have to first build the `llvm` subproject
and *install* it into any location. You can assist the build process to
find LLVM using `find_package(LLVM)` by specifying
`-DCMAKE_PREFIX_PATH=${LLVM_INSTALL_DIR}/lib/cmake/llvm` in the cmake
configuration process.
You have to build the `llvm subproject with utilies included and
installed
(`-DLLVM_INCLUDE_UTILS:BOOL=ON` and `-DLLVM_INSTALL_UTILS:BOOL=ON`. But
I'm sure that this is done most of the time anyways, no?

Don't build as you go: No more cross-project dependencies on LLVM utilties
--

Another assumption is that in standalone build mode it makes no sense to
build clang and try to build an LLVM utility binary like `FileCheck` if
that is missing. This only adds noise to the cmake files and creates an
indirect dependency on the LLVM utilities directory which doesn't exist
in the the clang source tarball. Therefore we go and search for

Don't silently turn off tests
-

Before this change, we would silently turn off tests if a binary like
`FileCheck`, `count` or `not` was missing. This is not only dangerous
but IMHO not helpful. If someone asks for tests by passing
`-DLLVM_INCLUDE_TESTS=On` we should error out at configure time because
we cannot fulfil this request when a binary is missing. This is exactly
what this tests does. If you want to check if an LLVM utility binary
exists and what the path to it is, you can call
`get_llvm_utility_binary_path("FileCheck" "FileCheck_EXE")` and it will
get the import location for the target, aka the path to the binary that
was found when we did `find_package(LLVM)`.

NOTE: You can take a look at this small example project which shows you
how importing of an installed project works:
https://github.com/kwk/cmake-export-binary-example/blob/2b429fccef97eb93c1717ceddb27bbe0022339d2/project-b/CMakeLists.txt#L7-L10



Require external LIT in standalone mode
---

We also think that in standalone mode you always want to use an external
lit and not build it as you go. That's why the `find_external_lit` macro
checks if `LLVM_EXTERNAL_LIT` is set and the path exists. If one of
these conditions doesn't hold true, we error out.

TODO:

( ) make sure the correct binaries of `FileCheck` and `count` and `not`
get substituted in lit test files.
( ) get feedback on this change or just opinions
( ) extend usage to other projects like `mlir`, `libomp` and so on.
( ) more encapsulation in `cmake/Modules/StandaloneBuildHelpers.cmake`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141050

Files:
  clang/CMakeLists.txt
  cmake/Modules/StandaloneBuildHelpers.cmake
  lld/CMakeLists.txt

Index: lld/CMakeLists.txt
===
--- lld/CMakeLists.txt
+++ lld/CMakeLists.txt
@@ -23,23 +23,16 @@
 # Must go below project(..)
 include(GNUInstallDirs)
 
-if(LLD_BUILT_STANDALONE)
-  set(CMAKE_CXX_STANDARD 17 CACHE STRING "C++ standard to conform to")
-  set(CMAKE_CXX_STANDARD_REQUIRED YES)
-  set(CMAKE_CXX_EXTENSIONS NO)
-
-  set(CMAKE_INCLUDE_CURRENT_DIR ON)
-
-  find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
-  list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
-
-  # Turn into CACHE PATHs for overwritting
-  set(LLVM_INCLUDE_DIRS ${LLVM_INCLUDE_DIRS} CACHE PATH "Path to llvm/include and any other header dirs needed")
-  set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}" CACHE PATH "Path to LLVM build tree")
-  set(LLVM_MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm" CACHE PATH "Path to LLVM source tree")
+# Make sure that our source directory is on th

[PATCH] D139837: [Clang] Implements CTAD for aggregates P1816R0 and P2082R1

2023-01-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a subscriber: hubert.reinterpretcast.
cor3ntin added a comment.

+ @hubert.reinterpretcast In case i missed something conformance wise.

Speaking of conformance, your implementation does not appear to gate the 
feature on C++20, which it should, so you should add a test that it doesn't 
compile in c++17 (I'm not sure we could support it as an extension... maybe?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139837

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


[PATCH] D141051: [CUDA]HIP] Add support for `--offload-arch=native` to CUDA and refactor

2023-01-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tra, yaxunl, MaskRay.
Herald added subscribers: kosarev, mattd, carlosgalvezp, asavonic, StephenFan, 
kerbowa, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

This patch adds basic support for `--offload-arch=native` to CUDA. This
is done using the `nvptx-arch` tool that was introduced previously. Some
of the logic for handling executing these tools was factored into a
common helper as well. This patch does not add support for OpenMP or the
"new" driver. That will be done later.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141051

Files:
  clang/include/clang/Basic/DiagnosticDriverKinds.td
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/ToolChain.h
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/AMDGPU.cpp
  clang/lib/Driver/ToolChains/AMDGPU.h
  clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h
  clang/test/Driver/Inputs/nvptx-arch/nvptx_arch_fail
  clang/test/Driver/Inputs/nvptx-arch/nvptx_arch_sm_70
  clang/test/Driver/amdgpu-hip-system-arch.c
  clang/test/Driver/amdgpu-openmp-system-arch-fail.c
  clang/test/Driver/nvptx-cuda-system-arch.c

Index: clang/test/Driver/nvptx-cuda-system-arch.c
===
--- /dev/null
+++ clang/test/Driver/nvptx-cuda-system-arch.c
@@ -0,0 +1,27 @@
+// REQUIRES: system-linux
+// REQUIRES: x86-registered-target
+// REQUIRES: nvptx-registered-target
+// REQUIRES: shell
+
+// RUN: mkdir -p %t
+// RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_fail %t/
+// RUN: cp %S/Inputs/nvptx-arch/nvptx_arch_sm_70 %t/
+// RUN: echo '#!/bin/sh' > %t/nvptx_arch_empty
+// RUN: chmod +x %t/nvptx_arch_fail
+// RUN: chmod +x %t/nvptx_arch_sm_70
+// RUN: chmod +x %t/nvptx_arch_empty
+
+// case when nvptx-arch returns nothing or fails
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_fail -x cuda %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
+// NO-OUTPUT-ERROR: error: cannot determine NVPTX architecture{{.*}}; consider passing it via '--offload-arch'
+
+// case when nvptx_arch does not return anything with successful execution
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_empty -x cuda %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=EMPTY-OUTPUT
+// EMPTY-OUTPUT: error: cannot determine NVPTX architecture: No NVIDIA GPU detected in the system; consider passing it via '--offload-arch'
+
+// case when nvptx_arch does not return anything with successful execution
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_sm_70 -x cuda %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=ARCH-sm_70
+// ARCH-sm_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
Index: clang/test/Driver/amdgpu-openmp-system-arch-fail.c
===
--- clang/test/Driver/amdgpu-openmp-system-arch-fail.c
+++ clang/test/Driver/amdgpu-openmp-system-arch-fail.c
@@ -15,14 +15,14 @@
 // case when amdgpu_arch returns nothing or fails
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -nogpulib --amdgpu-arch-tool=%t/amdgpu_arch_fail %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
-// NO-OUTPUT-ERROR: error: cannot determine AMDGPU architecture{{.*}}Exited with error code 1; consider passing it via '--march'
+// NO-OUTPUT-ERROR: error: cannot determine AMDGPU architecture{{.*}}; consider passing it via '-march'
 
 // case when amdgpu_arch returns multiple gpus but all are different
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -nogpulib --amdgpu-arch-tool=%t/amdgpu_arch_different %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=MULTIPLE-OUTPUT-ERROR
-// MULTIPLE-OUTPUT-ERROR: error: cannot determine AMDGPU architecture: Multiple AMD GPUs found with different archs; consider passing it via '--march'
+// MULTIPLE-OUTPUT-ERROR: error: cannot determine AMDGPU architecture: Multiple AMD GPUs found with different archs; consider passing it via '-march'
 
 // case when amdgpu_arch does not return anything with successful execution
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa -nogpulib --amdgpu-arch-tool=%t/amdgpu_arch_empty %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=EMPTY-OUTPUT
-// EMPTY-OUTPUT: error: cannot determine AMDGPU architecture: No AMD GPU detected in the system; consider passing it via '--march'
+// EMPTY-OUTPUT: error: cannot determine AMDGPU architecture: 

[PATCH] D140772: [clang-tidy] Fix minor bug in add_new_check.py

2023-01-05 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

@carlosgalvezp - could you also help commit this if it looks good?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140772

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


[clang] 85d049a - Implement support for option 'fexcess-precision'.

2023-01-05 Thread Zahira Ammarguellat via cfe-commits

Author: Zahira Ammarguellat
Date: 2023-01-05T09:35:28-05:00
New Revision: 85d049a089d4a6a4a67145429ea5d8e155651138

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

LOG: Implement support for option 'fexcess-precision'.

Differential revision: https://reviews.llvm.org/D136176

Added: 
clang/test/CodeGen/X86/fexcess-precision.c
clang/test/Driver/fexcess-precision.c

Modified: 
clang/docs/UsersManual.rst
clang/include/clang/AST/Type.h
clang/include/clang/Basic/FPOptions.def
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangOptions.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/Driver/Options.td
clang/lib/AST/Type.cpp
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGExprComplex.cpp
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/Driver/clang_f_opts.c

Removed: 




diff  --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index d4e5b3565ee0..7dd8ecb5fcc4 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -1746,6 +1746,47 @@ floating point semantic models: precise (the default), 
strict, and fast.
has no effect because the optimizer is prohibited from making unsafe
transformations.
 
+.. option:: -fexcess-precision:
+
+   The C and C++ standards allow floating-point expressions to be computed as 
if
+   intermediate results had more precision (and/or a wider range) than the type
+   of the expression strictly allows.  This is called excess precision
+   arithmetic.
+   Excess precision arithmetic can improve the accuracy of results (although 
not
+   always), and it can make computation significantly faster if the target 
lacks
+   direct hardware support for arithmetic in a particular type.  However, it 
can
+   also undermine strict floating-point reproducibility.
+
+   Under the standards, assignments and explicit casts force the operand to be
+   converted to its formal type, discarding any excess precision.  Because data
+   can only flow between statements via an assignment, this means that the use
+   of excess precision arithmetic is a reliable local property of a single
+   statement, and results do not change based on optimization.  However, when
+   excess precision arithmetic is in use, Clang does not guarantee strict
+   reproducibility, and future compiler releases may recognize more
+   opportunities to use excess precision arithmetic, e.g. with floating-point
+   builtins.
+
+   Clang does not use excess precision arithmetic for most types or on most
+   targets. For example, even on pre-SSE X86 targets where ``float`` and
+   ``double`` computations must be performed in the 80-bit X87 format, Clang
+   rounds all intermediate results correctly for their type.  Clang currently
+   uses excess precision arithmetic by default only for the following types and
+   targets:
+
+   * ``_Float16`` on X86 targets without ``AVX512-FP16``.
+
+   The ``-fexcess-precision=`` option can be used to control the use of
+   excess precision arithmetic.  Valid values are:
+
+   * ``standard`` - The default.  Allow the use of excess precision arithmetic
+ under the constraints of the C and C++ standards. Has no effect except on
+ the types and targets listed above.
+   * ``fast`` - Accepted for GCC compatibility, but currently treated as an
+ alias for ``standard``.
+   * ``16`` - Forces ``_Float16`` operations to be emitted without using excess
+ precision arithmetic.
+
 .. _crtfastmath.o:
 
 A note about ``crtfastmath.o``

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 8f7a4836381a..af6dbcf3988a 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -763,6 +763,8 @@ class QualType {
   unsigned getLocalFastQualifiers() const { return Value.getInt(); }
   void setLocalFastQualifiers(unsigned Quals) { Value.setInt(Quals); }
 
+  bool UseExcessPrecision(const ASTContext &Ctx);
+
   /// Retrieves a pointer to the underlying (unqualified) type.
   ///
   /// This function requires that the type not be NULL. If the type might be

diff  --git a/clang/include/clang/Basic/FPOptions.def 
b/clang/include/clang/Basic/FPOptions.def
index 1dfbbb549c87..0c687e3c3fa0 100644
--- a/clang/include/clang/Basic/FPOptions.def
+++ b/clang/include/clang/Basic/FPOptions.def
@@ -25,4 +25,5 @@ OPTION(NoSignedZero, bool, 1, NoHonorInfs)
 OPTION(AllowReciprocal, bool, 1, NoSignedZero)
 OPTION(AllowApproxFunc, bool, 1, AllowReciprocal)
 OPTION(FPEvalMethod, LangOptions::FPEvalMethodKind, 2, AllowApproxFunc)
+OPTION(Float16ExcessPrecision, LangOptions::ExcessPrecisionKind, 2, 
FPEvalMethod)
 #undef OPTION

diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/cla

[PATCH] D136176: Implement support for option 'fexcess-precision'.

2023-01-05 Thread Zahira Ammarguellat via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG85d049a089d4: Implement support for option 
'fexcess-precision'. (authored by zahiraam).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136176

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/FPOptions.def
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/Options.td
  clang/lib/AST/Type.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/X86/fexcess-precision.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fexcess-precision.c

Index: clang/test/Driver/fexcess-precision.c
===
--- /dev/null
+++ clang/test/Driver/fexcess-precision.c
@@ -0,0 +1,34 @@
+// RUN: %clang -### -target i386 -fexcess-precision=fast -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-FAST %s
+// RUN: %clang -### -target i386 -fexcess-precision=standard -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-STD %s
+// RUN: %clang -### -target i386 -fexcess-precision=16 -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang -### -target i386 -fexcess-precision=none -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-NONE %s
+
+// RUN: %clang -### -target x86_64 -fexcess-precision=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FAST %s
+// RUN: %clang -### -target x86_64 -fexcess-precision=standard -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-STD %s
+// RUN: %clang -### -target x86_64 -fexcess-precision=16 -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-NONE %s
+// RUN: %clang -### -target x86_64 -fexcess-precision=none -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefixes=CHECK-ERR-NONE %s
+
+// RUN: %clang -### -target aarch64 -fexcess-precision=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// RUN: %clang -### -target aarch64 -fexcess-precision=standard -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK %s
+// RUN: %clang -### -target aarch64 -fexcess-precision=16 -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-16 %s
+// RUN: %clang -### -target aarch64 -fexcess-precision=none -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-ERR-NONE %s
+
+// CHECK-FAST: "-ffloat16-excess-precision=fast"
+// CHECK-STD: "-ffloat16-excess-precision=standard"
+// CHECK-NONE: "-ffloat16-excess-precision=none"
+// CHECK-ERR-NONE: unsupported argument 'none' to option '-fexcess-precision='
+// CHECK: "-cc1"
+// CHECK-NOT: "-ffloat16-excess-precision=fast"
+// CHECK-ERR-16: unsupported argument '16' to option '-fexcess-precision='
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -398,7 +398,7 @@
 // CHECK-WARNING-DAG: optimization flag '-falign-loops' is not supported
 // CHECK-WARNING-DAG: optimization flag '-falign-jumps' is not supported
 // CHECK-WARNING-DAG: optimization flag '-falign-jumps=100' is not supported
-// CHECK-WARNING-DAG: optimization flag '-fexcess-precision=100' is not supported
+// CHECK-WARNING-DAG: unsupported argument '100' to option '-fexcess-precision='
 // CHECK-WARNING-DAG: optimization flag '-fbranch-count-reg' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fcaller-saves' is not supported
 // CHECK-WARNING-DAG: optimization flag '-fno-default-inline' is not supported
Index: clang/test/CodeGen/X86/fexcess-precision.c
===
--- /dev/null
+++ clang/test/CodeGen/X86/fexcess-precision.c
@@ -0,0 +1,387 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=fast -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefixes=CHECK-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=fast -target-feature +avx512fp16 \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=standard -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefixes=CHECK-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=standard -target-feature +avx512fp16 \
+// RUN: -emit-llvm -o - %s | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=none -emit-llvm -o - %s \
+// RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
+
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown \
+// RUN: -ffloat16-excess-precision=none -

[PATCH] D140956: [clang-format] Add an option for breaking after C++11 attributes

2023-01-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

In D140956#4028288 , @owenpan wrote:

> In D140956#4028147 , 
> @MyDeveloperDay wrote:
>
>> If someone wants to extend this to include the old form, then that can be a 
>> completely different review.
>
> Better yet, use another tool like clang-tidy to replace the old with the new.

indeed


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140956

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


[PATCH] D140968: [clang-tidy] Add check for passing the result of `std::string::c_str` to `strlen`

2023-01-05 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/readability/StrlenStringCStrCheck.h:1
+//===--- StrlenStringCStrCheck.h - clang-tidy *- C++ -*-===//
+//

Should be 80 characters long. See other checks as example.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140968

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


[PATCH] D140959: RFC: Multilib prototype

2023-01-05 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added inline comments.



Comment at: clang/include/clang/Driver/Multilib2.h:33-34
+private:
+  std::vector, 
std::vector>> Multilibs;
+  std::vector, 
std::vector>> RegexAttributes;
+};

phosek wrote:
> I think it'd really help readability and comprehension if this was modeled 
> using types (that is `struct`s and `class`es). It's not at all clear what 
> these strings are supposed to represent, and seeing expressions like 
> `std::get<0>` doesn't help either.
I fully agree. Sorry if I wasn't clear in the RFC but this is the kind of thing 
I meant when I said the code is not intended to be production quality.



Comment at: 
clang/test/Driver/Inputs/baremetal_multilib/arm-none-eabi/multilib.yaml:24
+- path: thumb/v6-m/nofp
+  args: [--target=arm-none-eabi, -mfloat-abi=soft, -march=armv6m]
+  attrs: [thumb, soft, v6m]

phosek wrote:
> I understand how the second section is used to match arguments passed to 
> `clang -cc1` and turn those into attributes which are then used to find the 
> right variant, but I don't understand what this list of arguments is used for?
Having these here permits `clang -print-multi-lib` to work, which would print 
out something like this:
```
thumb/nofp;@mthumb@mfloat-abi=soft
thumb/v7/nofp;@mthumb@march=armv7@mfloat-abi=soft
...
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140959

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


[PATCH] D140387: [clang][analyzer] Add stream related functions to StdLibraryFunctionsChecker.

2023-01-05 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 486558.
balazske added a comment.

Adding test for summary case, change of comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140387

Files:
  clang/lib/StaticAnalyzer/Checkers/ErrnoChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.cpp
  clang/lib/StaticAnalyzer/Checkers/ErrnoModeling.h
  clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  clang/test/Analysis/std-c-library-functions-POSIX.c
  clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
  clang/test/Analysis/std-c-library-functions-vs-stream-checker.c

Index: clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
===
--- clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
+++ clang/test/Analysis/std-c-library-functions-vs-stream-checker.c
@@ -45,12 +45,13 @@
   clang_analyzer_eval(x <= 10); // \
  // stream-warning{{TRUE}} \
  // stdLib-warning{{TRUE}} \
- // both-warning{{TRUE}} \
+ // both-warning{{TRUE}}
 
   clang_analyzer_eval(x == 10); // \
   // stream-warning{{TRUE}} \
   // stream-warning{{FALSE}} \
-  // stdLib-warning{{UNKNOWN}} \
+  // stdLib-warning{{TRUE}} \
+  // stdLib-warning{{FALSE}} \
   // both-warning{{TRUE}} \
   // both-warning{{FALSE}}
 
Index: clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
===
--- clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
+++ clang/test/Analysis/std-c-library-functions-arg-constraints-note-tags.cpp
@@ -49,3 +49,18 @@
   clang_analyzer_express(buf); // expected-warning {{}} // the message does not really matter \
// expected-note {{}}
 }
+
+int __test_case_note();
+
+int test_case_note_1(int y) {
+  int x = __test_case_note(); // expected-note{{Function returns 0}} \
+  // expected-note{{'x' initialized here}}
+  return y / x; // expected-warning{{Division by zero}} \
+// expected-note{{Division by zero}}
+}
+
+int test_case_note_2(int y) {
+  int x = __test_case_note(); // expected-note{{Function returns 1}}
+  return y / (x - 1); // expected-warning{{Division by zero}} \
+  // expected-note{{Division by zero}}
+}
Index: clang/test/Analysis/std-c-library-functions-POSIX.c
===
--- clang/test/Analysis/std-c-library-functions-POSIX.c
+++ clang/test/Analysis/std-c-library-functions-POSIX.c
@@ -7,6 +7,12 @@
 // RUN:   -analyzer-config eagerly-assume=false \
 // RUN:   -triple i686-unknown-linux 2>&1 | FileCheck %s
 
+// CHECK: Loaded summary for: FILE *fopen(const char *restrict pathname, const char *restrict mode)
+// CHECK: Loaded summary for: FILE *tmpfile(void)
+// CHECK: Loaded summary for: FILE *freopen(const char *restrict pathname, const char *restrict mode, FILE *restrict stream)
+// CHECK: Loaded summary for: int fclose(FILE *stream)
+// CHECK: Loaded summary for: int fseek(FILE *stream, long offset, int whence)
+// CHECK: Loaded summary for: int fileno(FILE *stream)
 // CHECK: Loaded summary for: long a64l(const char *str64)
 // CHECK: Loaded summary for: char *l64a(long value)
 // CHECK: Loaded summary for: int access(const char *pathname, int amode)
@@ -63,7 +69,6 @@
 // CHECK: Loaded summary for: void rewinddir(DIR *dir)
 // CHECK: Loaded summary for: void seekdir(DIR *dirp, long loc)
 // CHECK: Loaded summary for: int rand_r(unsigned int *seedp)
-// CHECK: Loaded summary for: int fileno(FILE *stream)
 // CHECK: Loaded summary for: int fseeko(FILE *stream, off_t offset, int whence)
 // CHECK: Loaded summary for: off_t ftello(FILE *stream)
 // CHECK: Loaded summary for: void *mmap(void *addr, size_t length, int prot, int flags, int fd, off_t offset)
@@ -121,6 +126,16 @@
 // CHECK: Loaded summary for: int pthread_mutex_trylock(pthread_mutex_t *mutex)
 // CHECK: Loaded summary for: int pthread_mutex_unlock(pthread_mutex_t *mutex)
 
+typedef struct {
+  int x;
+} FILE;
+FILE *fopen(const char *restrict pathname, const char *restrict mode);
+FILE *tmpfile(void);
+FILE *freopen(const char *restrict pathname, const char *restrict mode,
+  FILE *restrict stream);
+int fclose(FILE *stream);
+int fseek(FILE *stream, long offset, int whence);
+int fileno(FILE *stream);
 long a64l(const char *str64);
 char *l64a(long value);
 int access(const char *pathname, int amode);
@@ -181,9 +196,6 @@
 DIR *opendir(const char *name);
 DIR *fdopendir(int fd);
 int isatty(int fildes);
-typedef struct {
-  int x;
-} FILE;
 FILE *popen(const char *command, const char *type);
 int pclose(FILE *stream);
 int close(int fildes);
Index: clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
===
--- clang/lib/S

[PATCH] D140959: RFC: Multilib prototype

2023-01-05 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

Did you look at Yaml I/O ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140959

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


[PATCH] D140538: [Clang][CodeGen] Use poison instead of undef for dummy values in CGExpr [NFC]

2023-01-05 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito added a comment.

Ping


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

https://reviews.llvm.org/D140538

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


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2023-01-05 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo added a comment.

ping!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

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


[PATCH] D138870: clang/AMDGPU: Remove flat-address-space from feature map

2023-01-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 486561.
arsenm added a comment.

Rebase


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

https://reviews.llvm.org/D138870

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/test/CodeGenOpenCL/amdgpu-features.cl
  clang/test/OpenMP/amdgcn-attributes.cpp
  clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp

Index: clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
===
--- clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
+++ clang/test/OpenMP/metadirective_device_isa_codegen_amdgcn.cpp
@@ -14,7 +14,7 @@
: threadCount)
   {
 #pragma omp metadirective \
-when(device = {isa("flat-address-space")} \
+when(device = {isa("dpp")} \
  : parallel) default(single)
 threadCount++;
   }
Index: clang/test/OpenMP/amdgcn-attributes.cpp
===
--- clang/test/OpenMP/amdgcn-attributes.cpp
+++ clang/test/OpenMP/amdgcn-attributes.cpp
@@ -33,11 +33,11 @@
 }
 
 // DEFAULT: attributes #0 = { convergent noinline norecurse nounwind optnone "kernel" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
-// CPU: attributes #0 = { convergent noinline norecurse nounwind optnone "kernel" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" "uniform-work-group-size"="true" }
+// CPU: attributes #0 = { convergent noinline norecurse nounwind optnone "kernel" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" "uniform-work-group-size"="true" }
 // NOIEEE: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-ieee"="false" "kernel" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
 // UNSAFEATOMIC: attributes #0 = { convergent noinline norecurse nounwind optnone "amdgpu-unsafe-fp-atomics"="true" "kernel" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "uniform-work-group-size"="true" }
 
 // DEFAULT: attributes #1 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
-// CPU: attributes #1 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
+// CPU: attributes #1 = { convergent mustprogress noinline nounwind optnone "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="gfx900" "target-features"="+16-bit-insts,+ci-insts,+dpp,+gfx8-insts,+gfx9-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64" }
 // NOIEEE: attributes #1 = { convergent mustprogress noinline nounwind optnone "amdgpu-ieee"="false" "no-nans-fp-math"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
 // UNSAFEATOMIC: attributes #1 = { convergent mustprogress noinline nounwind optnone "amdgpu-unsafe-fp-atomics"="true" "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
Index: clang/test/CodeGenOpenCL/amdgpu-features.cl
===
--- clang/test/CodeGenOpenCL/amdgpu-features.cl
+++ clang/test/CodeGenOpenCL/amdgpu-features.cl
@@ -55,41 +55,41 @@
 // GFX600: "target-features"="+s-memtime-inst,+wavefrontsize64"
 // GFX601: "target-features"="+s-memtime-inst,+wavefrontsize64"
 // GFX602: "target-features"="+s-memtime-inst,+wavefrontsize64"
-// GFX700: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst,+wavefrontsize64"
-// GFX701: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst,+wavefrontsize64"
-// GFX702: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst,+wavefrontsize64"
-// GFX703: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst,+wavefrontsize64"
-// GFX704: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst,+wavefrontsize64"
-// GFX705: "target-features"="+ci-insts,+flat-address-space,+s-memtime-inst,+wavefrontsize64"
-// GFX801: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
-// GFX802: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
-// GFX803: "target-features"="+16-bit-insts,+ci-insts,+dpp,+flat-address-space,+gfx8-insts,+s-memrealtime,+s-memtime-inst,+wavefrontsize64"
-// GFX805: "target-features"="+16-bit-insts,+ci-ins

[PATCH] D138870: clang/AMDGPU: Remove flat-address-space from feature map

2023-01-05 Thread Joe Nash via Phabricator via cfe-commits
Joe_Nash accepted this revision.
Joe_Nash added a comment.
This revision is now accepted and ready to land.

In D138870#4020211 , @arsenm wrote:

> In D138870#4020204 , @Joe_Nash 
> wrote:
>
>> The code looks fine, but as you say, the change visible in user code and 
>> could break something. Do you want to handle that somehow? Maybe wait for 
>> @b-sumner
>
> OpenMP assumes flat pointers all over, so if someone was relying on this 
> behavior it wasn't doing anything useful. They had dead code

I can't verify the idea that users of the behavior had dead code, but assuming 
that's right LGTM.


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

https://reviews.llvm.org/D138870

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


[PATCH] D141056: [SVE][CGBuiltins] Remove need for instcombine from ACLE tests.

2023-01-05 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm created this revision.
Herald added subscribers: ctetreau, psnobl, arphaman, kristof.beyls, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: All.
paulwalker-arm requested review of this revision.
Herald added subscribers: cfe-commits, alextsao1999.
Herald added a project: clang.

The SVE builtins tests rely on optimisations to remove clutter from
the resulting IR that is not relevant to the tests. However, with
the increasing number of target intrinsic combines the clang tests
are moving further away from verifying what is relevant to clang.

During early SVE (or rather scalable vector) bringup, we chose to
mitigate bugs by minimising our usage of LLVM IR instructions then
later implemented the combines to lower the calls to generic IR once
scalable vector support had matured. With the mitigations no longer
required and the combines mostly trivial I have moved the logic into
CGBuiltins, which allows the existing tests to remain unchanged once
they stop using instcombine.

The optimisations include:

- Using shifts in place of multiplies by power-of-two values.
- Don't emit getelementptrs when offset is zero.
- Use IR based vector splats rather than calls to dup_x.
- Use IR based vector selects rather than calls to sel.
- Use i64 based indices for insertelement.

The test changes are the result of "sed -i -e 's/instcombine,//'",
with the exception of acle_sve_dupq.c which required regeneration
due to its previous reliance on a zext->tunc->zext combine.

The following tests still rely on instcombine because they require
changes beyond CGBuiltin.cpp:

  CodeGen/aarch64-sve-intrinsics/acle_sve_clasta.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_clastb.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_cntb.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_cntd.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_cnth.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_cntw.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_dup-bfloat.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_dup.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_ld1-bfloat.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_ld1.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sb.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sh.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_ld1sw.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_ld1ub.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uh.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_ld1uw.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_len-bfloat.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_len.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_rdffr.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_sel-bfloat.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_sel.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_st1-bfloat.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_st1.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_st1b.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_st1h.c
  CodeGen/aarch64-sve-intrinsics/acle_sve_st1w.c

Tests within aarch64-sve2-intrinsics don't use opt but instead use
-O1 to cleanup their output. These tests remain unchanged and will
be visited by a later patch.

Depends on D140983 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141056

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_abd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_abs.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acge.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acgt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_acle.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_aclt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_add.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adda.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_addv.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adrb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adrd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adrh.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_adrw.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_and.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_andv.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asr.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_asrd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfdot.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmlalt.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bfmmla.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_bic.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brka.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brkb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brkn.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brkpa.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_brkpb.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_cadd.c
  clang/test/CodeGen/aarch64-sve-intrinsics/acle_sve_clasta

[PATCH] D141058: [clang-tidy] fix wrong fixup for bugprone-implicit-widening-of-multiplication-result

2023-01-05 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry created this revision.
v1nh1shungry added reviewers: lebedev.ri, ymandel.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
v1nh1shungry requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Relevant issue: https://github.com/llvm/llvm-project/issues/56728


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141058

Files:
  
clang-tools-extra/clang-tidy/bugprone/ImplicitWideningOfMultiplicationResultCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-array-subscript-expression.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-int.cpp
  
clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-pointer-offset.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-pointer-offset.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-pointer-offset.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-pointer-offset.cpp
@@ -18,7 +18,7 @@
   // CHECK-NOTES-CXX:  static_cast( )
   // CHECK-NOTES-ALL: :[[@LINE-5]]:17: note: perform multiplication in a wider type
   // CHECK-NOTES-C:(ptrdiff_t)
-  // CHECK-NOTES-CXX:  static_cast()
+  // CHECK-NOTES-CXX:  static_cast( )
 }
 char *t1(char *base, int a, int b) {
   return a * b + base;
@@ -35,7 +35,7 @@
   // CHECK-NOTES-CXX:  static_cast( )
   // CHECK-NOTES-ALL: :[[@LINE-5]]:17: note: perform multiplication in a wider type
   // CHECK-NOTES-C:(size_t)
-  // CHECK-NOTES-CXX:  static_cast()
+  // CHECK-NOTES-CXX:  static_cast( )
 }
 
 char *t3(char *base, int a, unsigned int b) {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-int.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-int.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-int.cpp
@@ -18,7 +18,7 @@
   // CHECK-NOTES-CXX:  static_cast( )
   // CHECK-NOTES-ALL: :[[@LINE-5]]:10: note: perform multiplication in a wider type
   // CHECK-NOTES-C:(long)
-  // CHECK-NOTES-CXX:  static_cast()
+  // CHECK-NOTES-CXX:  static_cast( )
 }
 unsigned long t1(int a, int b) {
   return a * b;
@@ -28,7 +28,7 @@
   // CHECK-NOTES-CXX:  static_cast( )
   // CHECK-NOTES-ALL: :[[@LINE-5]]:10: note: perform multiplication in a wider type
   // CHECK-NOTES-C:(long)
-  // CHECK-NOTES-CXX:  static_cast()
+  // CHECK-NOTES-CXX:  static_cast( )
 }
 
 long t2(unsigned int a, int b) {
@@ -39,7 +39,7 @@
   // CHECK-NOTES-CXX:  static_cast( )
   // CHECK-NOTES-ALL: :[[@LINE-5]]:10: note: perform multiplication in a wider type
   // CHECK-NOTES-C:(unsigned long)
-  // CHECK-NOTES-CXX:  static_cast()
+  // CHECK-NOTES-CXX:  static_cast( )
 }
 unsigned long t3(unsigned int a, int b) {
   return a * b;
@@ -49,7 +49,7 @@
   // CHECK-NOTES-CXX:  static_cast( )
   // CHECK-NOTES-ALL: :[[@LINE-5]]:10: note: perform multiplication in a wider type
   // CHECK-NOTES-C:(unsigned long)
-  // CHECK-NOTES-CXX:  static_cast()
+  // CHECK-NOTES-CXX:  static_cast( )
 }
 
 long t4(int a, unsigned int b) {
Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-array-subscript-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-array-subscript-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/implicit-widening-of-multiplication-result-array-subscript-expression.cpp
@@ -18,7 +18,7 @@
   // CHECK-NOTES-CXX:  static_cast( )
   // CHECK-NOTES-ALL: :[[@LINE-5]]:16: note: perform multiplication in a wider type
   // CHECK-NOTES-C:(ptrdiff_t)
-  // CHECK-NOTES-CXX:  static_cast()
+  // CHECK-NOTES-CXX:  static_cast( )
 }
 void *t1(char *base, int a, int b) {
   return &((a * b)[base]);
@@ -35,7 +35,7 @@
   // CHECK-NOTES-CXX:  static_cast( )
   // CHECK-NOTES-ALL: :[[@LINE-5]]:16: note: perform multiplication in a wider type
   // CHECK-NOTES-C: 

[PATCH] D140772: [clang-tidy] Fix minor bug in add_new_check.py

2023-01-05 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

In D140772#4028570 , @ccotter wrote:

> @carlosgalvezp - could you also help commit this if it looks good?

Sure thing, thanks for the fix!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140772

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


[PATCH] D141058: [clang-tidy] fix wrong fixup for bugprone-implicit-widening-of-multiplication-result

2023-01-05 Thread Vincent Hong via Phabricator via cfe-commits
v1nh1shungry added a comment.

Sorry, I don't know how to add tests for such fixes. Could anyone please give 
me some hints? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141058

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


[PATCH] D140772: [clang-tidy] Fix minor bug in add_new_check.py

2023-01-05 Thread Carlos Galvez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG210b731c01b0: [clang-tidy] Fix minor bug in add_new_check.py 
(authored by ccotter, committed by carlosgalvezp).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140772

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/docs/ReleaseNotes.rst


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -99,6 +99,9 @@
 - Change to Python 3 in the shebang of `add_new_check.py` and 
`rename_check.py`,
   as the existing code is not compatible with Python 2.
 
+- Fix a minor bug in `add_new_check.py` to only traverse subdirectories
+  when updating the list of checks in the documentation.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -322,8 +322,7 @@
 lines = f.readlines()
   # Get all existing docs
   doc_files = []
-  for subdir in list(filter(lambda s: not s.endswith('.rst') and not 
s.endswith('.py'),
- os.listdir(docs_dir))):
+  for subdir in filter(lambda s: os.path.isdir(os.path.join(docs_dir, s)), 
os.listdir(docs_dir)):
 for file in filter(lambda s: s.endswith('.rst'), 
os.listdir(os.path.join(docs_dir, subdir))):
   doc_files.append([subdir, file])
   doc_files.sort()


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -99,6 +99,9 @@
 - Change to Python 3 in the shebang of `add_new_check.py` and `rename_check.py`,
   as the existing code is not compatible with Python 2.
 
+- Fix a minor bug in `add_new_check.py` to only traverse subdirectories
+  when updating the list of checks in the documentation.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -322,8 +322,7 @@
 lines = f.readlines()
   # Get all existing docs
   doc_files = []
-  for subdir in list(filter(lambda s: not s.endswith('.rst') and not s.endswith('.py'),
- os.listdir(docs_dir))):
+  for subdir in filter(lambda s: os.path.isdir(os.path.join(docs_dir, s)), os.listdir(docs_dir)):
 for file in filter(lambda s: s.endswith('.rst'), os.listdir(os.path.join(docs_dir, subdir))):
   doc_files.append([subdir, file])
   doc_files.sort()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 210b731 - [clang-tidy] Fix minor bug in add_new_check.py

2023-01-05 Thread Carlos Galvez via cfe-commits

Author: Chris Cotter
Date: 2023-01-05T15:28:57Z
New Revision: 210b731c01b020693aa8f53231c659ff5f60149e

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

LOG: [clang-tidy] Fix minor bug in add_new_check.py

While rebuilding the list of checks in add_new_check.py,
check is a file is a subdirectory before traversing it.

Test plan: Ran `./add_new_check.py --update-docs` and confirmed the list.rst 
file was unchanged.

Reviewed By: carlosgalvezp

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

Added: 


Modified: 
clang-tools-extra/clang-tidy/add_new_check.py
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/add_new_check.py 
b/clang-tools-extra/clang-tidy/add_new_check.py
index a85767acdce91..e3ad7a286a444 100755
--- a/clang-tools-extra/clang-tidy/add_new_check.py
+++ b/clang-tools-extra/clang-tidy/add_new_check.py
@@ -322,8 +322,7 @@ def update_checks_list(clang_tidy_path):
 lines = f.readlines()
   # Get all existing docs
   doc_files = []
-  for subdir in list(filter(lambda s: not s.endswith('.rst') and not 
s.endswith('.py'),
- os.listdir(docs_dir))):
+  for subdir in filter(lambda s: os.path.isdir(os.path.join(docs_dir, s)), 
os.listdir(docs_dir)):
 for file in filter(lambda s: s.endswith('.rst'), 
os.listdir(os.path.join(docs_dir, subdir))):
   doc_files.append([subdir, file])
   doc_files.sort()

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 989f4b52d4ac8..0f060f7f5fc7b 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -99,6 +99,9 @@ Improvements to clang-tidy
 - Change to Python 3 in the shebang of `add_new_check.py` and 
`rename_check.py`,
   as the existing code is not compatible with Python 2.
 
+- Fix a minor bug in `add_new_check.py` to only traverse subdirectories
+  when updating the list of checks in the documentation.
+
 New checks
 ^^
 



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


[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

2023-01-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

ping


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

https://reviews.llvm.org/D140639

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


[PATCH] D139458: [clangd] Full support for #import insertions

2023-01-05 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet requested changes to this revision.
kadircet added inline comments.
This revision now requires changes to proceed.



Comment at: clang-tools-extra/clangd/ParsedAST.cpp:572
+  // case where a header file contains ObjC decls but no #imports.
+  Symbol::IncludeDirective Directive = preferredIncludeDirective(
+  Filename, Clang->getLangOpts(), MainFileIncludes, {});

as discussed offline can you guard this with the `import-insertion` flag as 
well? we should pass it through ParseOptions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139458

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


[PATCH] D140968: [clang-tidy] Add check for passing the result of `std::string::c_str` to `strlen`

2023-01-05 Thread Alex Coster via Phabricator via cfe-commits
acoster updated this revision to Diff 486582.
acoster added a comment.

Fix length of comment at the top of StrlenStringCStrCheck.h


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140968

Files:
  clang-tools-extra/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/clang-tidy/readability/StrlenStringCStrCheck.cpp
  clang-tools-extra/clang-tidy/readability/StrlenStringCStrCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/readability/strlen-string-cstr.rst
  clang-tools-extra/test/clang-tidy/checkers/readability/strlen-string-cstr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability/strlen-string-cstr.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability/strlen-string-cstr.cpp
@@ -0,0 +1,117 @@
+// RUN: %check_clang_tidy %s readability-strlen-string-cstr %t
+int strlen(const char *);
+int strnlen(const char *, int);
+int strnlen_s(const char *, int);
+
+int wcslen(const wchar_t *);
+int wcsnlen_s(const wchar_t *, int);
+
+namespace std {
+template  class allocator {};
+template  class char_traits {};
+
+template >
+class basic_string_view {
+public:
+  basic_string_view();
+  basic_string_view(const basic_string_view &other);
+  const C *data() const;
+  int size() const;
+  int length() const;
+};
+
+using string_view = basic_string_view;
+using wstring_view = basic_string_view;
+
+template ,
+  typename A = std::allocator>
+class basic_string {
+public:
+  basic_string();
+  basic_string(const C *, unsigned int size);
+  basic_string(const C *, const A &allocator = A());
+  const C *c_str() const;
+  const C *data() const;
+  int size() const;
+  int length() const;
+  operator basic_string_view() const;
+};
+
+using wstring = basic_string;
+using string = basic_string;
+
+int strlen(const char *);
+int wcslen(const wchar_t *);
+} // namespace std
+
+void handlesBasicString() {
+  std::string str1("a", 1);
+  int length = strlen(str1.c_str());
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant call to 'strlen' {{.*}}
+  // CHECK-FIXES: {{^  }}int length = str1.size();{{$}}
+
+  length = strnlen(str1.data(), 30);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call to 'strnlen' {{.*}}
+  // CHECK-FIXES: {{^  }}length = str1.size();{{$}}
+
+  const std::string *p1 = &str1;
+  length = std::strlen(p1->c_str()) + 30;
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call {{.*}}
+  // CHECK-FIXES: {{^  }}length = p1->size() + 30;{{$}}
+
+  std::wstring wstr1;
+  length = wcslen(wstr1.c_str());
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call to 'wcslen' {{.*}}
+  // CHECK-FIXES: {{^  }}length = wstr1.size();{{$}}
+
+  const std::wstring &wstr2 = wstr1;
+  length = std::wcslen(wstr2.data());
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call to {{.*}}
+  // CHECK-FIXES: {{^  }}length = wstr2.size();{{$}}
+}
+
+void handlesStringView() {
+  std::string str1("foo");
+  std::string_view view = str1;
+  int length = strnlen_s(view.data(), 300);
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: redundant call to 'strnlen_s'
+  // {{.*}} CHECK-FIXES: {{^  }}int length = view.size();{{$}}
+
+  std::wstring wstr1;
+  std::wstring_view wview = wstr1;
+  length = wcsnlen_s(wview.data(), 300);
+  // CHECK-MESSAGES: [[@LINE-1]]:12: warning: redundant call to 'wcsnlen_s'
+  // {{.*}} CHECK-FIXES: {{^  }}length = wview.size();{{$}}
+}
+
+class CustomStringClass {
+public:
+  CustomStringClass(int, char);
+  const char *data() const;
+  int length() const;
+
+private:
+  int size() const;
+};
+
+void handlesStringLikeTypes() {
+  CustomStringClass str(123, 'f');
+  int size = strlen(str.data());
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: redundant call to
+  // CHECK-FIXES: {{^  }}int size = str.length();{{$}}
+}
+
+class StringWithoutPublicSizeMethod {
+public:
+  StringWithoutPublicSizeMethod(const char *);
+  const char *c_str();
+
+private:
+  int size() const;
+  int length() const;
+};
+
+void ignoresStringTypesWithoutPublicSizeMethod() {
+  StringWithoutPublicSizeMethod str("foo");
+  int length = strlen(str.c_str());
+}
Index: clang-tools-extra/docs/clang-tidy/checks/readability/strlen-string-cstr.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/readability/strlen-string-cstr.rst
@@ -0,0 +1,22 @@
+.. title:: clang-tidy - readability-strlen-string-cstr
+
+readability-strlen-string-cstr
+==
+
+Warns when the return value of ``c_str()`` or ``data()`` is used as an argument
+for ``strlen``, and suggests using ``size()``or ``length()`` if one of them is
+a member function.
+
+Example
+---
+
+.. code-blo

[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

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

1 nit, and 1 trying to see what is going on.  I don't have a good feeling what 
the purpose of this builtin is, nor whether it matches the desire/intent of 
this builtin, I'm hopeful one of the other reviewers has the ability to check 
that.




Comment at: clang/lib/Sema/SemaChecking.cpp:2048
+  if (!EltTy->isRealFloatingType()) {
+S.Diag(Loc, diag::err_builtin_invalid_arg_type)
+<< ArgIndex << /* vector or float ty*/ 5 << ArgTy;

you can just do "return S.Diag", which always returns 'true'.  This will save a 
line, and the need for curleys.



Comment at: clang/lib/Sema/SemaChecking.cpp:2660
+
+ExprResult Magnitude = UsualUnaryConversions(TheCall->getArg(0));
+ExprResult Sign = UsualUnaryConversions(TheCall->getArg(1));

What is the point of the Unary Conversions here?  Its a touch surprising to see 
a builtin do that?  Note that it does quite a bit of FP related conversions, so 
are you sure you want those?


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

https://reviews.llvm.org/D140639

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


[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

2023-01-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D140639#4028883 , @erichkeane 
wrote:

> 1 nit, and 1 trying to see what is going on.  I don't have a good feeling 
> what the purpose of this builtin is,

The point of every builtin is direct access to llvm intrinsics, in this case 
llvm.copysign. I need it on vectors and not the set of 3 scalars it handles now.




Comment at: clang/lib/Sema/SemaChecking.cpp:2660
+
+ExprResult Magnitude = UsualUnaryConversions(TheCall->getArg(0));
+ExprResult Sign = UsualUnaryConversions(TheCall->getArg(1));

erichkeane wrote:
> What is the point of the Unary Conversions here?  Its a touch surprising to 
> see a builtin do that?  Note that it does quite a bit of FP related 
> conversions, so are you sure you want those?
Copied from the other elementwise intrinsics, and this is at the edges of my 
frontend knowledge (I guess it's to avoid qualifiers mattering?). The tests 
seem to behave as I expect


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

https://reviews.llvm.org/D140639

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


[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

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

In D140639#4028900 , @arsenm wrote:

> In D140639#4028883 , @erichkeane 
> wrote:
>
>> 1 nit, and 1 trying to see what is going on.  I don't have a good feeling 
>> what the purpose of this builtin is,
>
> The point of every builtin is direct access to llvm intrinsics, in this case 
> llvm.copysign. I need it on vectors and not the set of 3 scalars it handles 
> now.

I'm unfamiliar with the semantics of that builtin other than what i can read 
here: https://llvm.org/docs/LangRef.html#llvm-copysign-intrinsic




Comment at: clang/lib/Sema/SemaChecking.cpp:2660
+
+ExprResult Magnitude = UsualUnaryConversions(TheCall->getArg(0));
+ExprResult Sign = UsualUnaryConversions(TheCall->getArg(1));

arsenm wrote:
> erichkeane wrote:
> > What is the point of the Unary Conversions here?  Its a touch surprising to 
> > see a builtin do that?  Note that it does quite a bit of FP related 
> > conversions, so are you sure you want those?
> Copied from the other elementwise intrinsics, and this is at the edges of my 
> frontend knowledge (I guess it's to avoid qualifiers mattering?). The tests 
> seem to behave as I expect
It really depends on what behavior you're looking to get out of this.  
UnaryConversions are usually for operators, not 'function like' things, so it 
is a touch jarring to me.

I guess I would have expected DefaultFunctionArrayLValueConversion (which calls 
DefaultLValueConversion after doing array-to-pointer conversions).

If the idea is for this builtin to act more like a variadic arg, I'd expect to 
see DefaultArgumentPromotion.

@aaron.ballman  I think is smarter than me in regards to how these should work, 
so perhaps he can comment here?

I DO note one of the things that UsualUnaryConversions is doing is removing 
'half' types on platforms without a 'native' half type.  I would expect those 
sorts of conversions wouldn't be right?



Comment at: clang/lib/Sema/SemaChecking.cpp:2674
+
+if (MagnitudeTy.getCanonicalType() != SignTy.getCanonicalType()) {
+  return Diag(Sign.get()->getBeginLoc(),

curleys not used for single-statement if-statement bodies.


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

https://reviews.llvm.org/D140639

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


[PATCH] D140554: [C++20] Determine the dependency of unevaluated lambdas more accurately

2023-01-05 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 486591.
lime added a comment.

Added release notes.


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

https://reviews.llvm.org/D140554

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/TreeTransform.h
  clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
  clang/test/SemaCXX/lambda-unevaluated.cpp


Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -61,9 +61,7 @@
 // Same.
 template void g(const char (*)[([]{ return N; })()]) {} // 
expected-note {{candidate}}
 template void g(const char (*)[([]{ return N; })()]) {} // 
expected-note {{candidate}}
-// FIXME: We instantiate the lambdas into the context of the function template,
-//  so we think they're dependent and can't evaluate a call to them.
-void use_g() { g<6>(&"hello"); } // expected-error {{no matching function}}
+void use_g() { g<6>(&"hello"); } // expected-error {{ambiguous}}
 }
 
 namespace GH51416 {
Index: clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm 
-o - | FileCheck %s
+
+// CHECK-LABEL: define linkonce_odr void 
@"_ZN10Issue579601EIiEENS_1FILNS_3$_0v"()
+namespace Issue57960 {
+template
+class F {};
+
+template
+F<[]{}> E() {
+return {};
+}
+
+static auto f = E();
+}
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -13234,10 +13234,11 @@
   // context that isn't a DeclContext (such as a variable template), or when
   // substituting an unevaluated lambda inside of a function's parameter's type
   // - as parameter types are not instantiated from within a function's DC. We
-  // use isUnevaluatedContext() to distinguish the function parameter case.
+  // use evaluation contexts to distinguish the function parameter case.
   CXXRecordDecl::LambdaDependencyKind DependencyKind =
   CXXRecordDecl::LDK_Unknown;
-  if (getSema().isUnevaluatedContext() &&
+  if ((getSema().isUnevaluatedContext() ||
+   getSema().isConstantEvaluatedContext()) &&
   (getSema().CurContext->isFileContext() ||
!getSema().CurContext->getParent()->isDependentContext()))
 DependencyKind = CXXRecordDecl::LDK_NeverDependent;
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -9624,6 +9624,12 @@
 return ExprEvalContexts.back().isUnevaluated();
   }
 
+  bool isConstantEvaluatedContext() const {
+assert(!ExprEvalContexts.empty() &&
+   "Must be in an expression evaluation context");
+return ExprEvalContexts.back().isConstantEvaluated();
+  }
+
   bool isImmediateFunctionContext() const {
 assert(!ExprEvalContexts.empty() &&
"Must be in an expression evaluation context");
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -331,6 +331,8 @@
   `Issue 58800 `_
 - Fix an issue that triggers a crash if we instantiate a hidden friend 
functions.
   This fixes `Issue 54457 `_
+- Fix an issue that makes Clang crash on lambda template parameters. This fixes
+  `Issue 57960 `_
 
 Improvements to Clang's diagnostics
 ^^^


Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -61,9 +61,7 @@
 // Same.
 template void g(const char (*)[([]{ return N; })()]) {} // expected-note {{candidate}}
 template void g(const char (*)[([]{ return N; })()]) {} // expected-note {{candidate}}
-// FIXME: We instantiate the lambdas into the context of the function template,
-//  so we think they're dependent and can't evaluate a call to them.
-void use_g() { g<6>(&"hello"); } // expected-error {{no matching function}}
+void use_g() { g<6>(&"hello"); } // expected-error {{ambiguous}}
 }
 
 namespace GH51416 {
Index: clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/cxx20-unevaluated-lambda-crash.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 %s -emit-llvm -o - | FileCheck %s
+
+// CHECK

[PATCH] D137531: [clang] Add the check of membership in decltype for the issue #58674

2023-01-05 Thread Liming Liu via Phabricator via cfe-commits
lime added a comment.

Is there a place to see the log of the powerpc64le self-built buildbot? 
@erichkeane


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137531

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


[PATCH] D137531: [clang] Add the check of membership in decltype for the issue #58674

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

In D137531#4028986 , @lime wrote:

> Is there a place to see the log of the powerpc64le self-built buildbot? 
> @erichkeane

It was sent via email to us: 
https://lab.llvm.org/buildbot#builders/121/builds/26738


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137531

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


[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

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



Comment at: clang/lib/Sema/SemaChecking.cpp:2660
+
+ExprResult Magnitude = UsualUnaryConversions(TheCall->getArg(0));
+ExprResult Sign = UsualUnaryConversions(TheCall->getArg(1));

erichkeane wrote:
> arsenm wrote:
> > erichkeane wrote:
> > > What is the point of the Unary Conversions here?  Its a touch surprising 
> > > to see a builtin do that?  Note that it does quite a bit of FP related 
> > > conversions, so are you sure you want those?
> > Copied from the other elementwise intrinsics, and this is at the edges of 
> > my frontend knowledge (I guess it's to avoid qualifiers mattering?). The 
> > tests seem to behave as I expect
> It really depends on what behavior you're looking to get out of this.  
> UnaryConversions are usually for operators, not 'function like' things, so it 
> is a touch jarring to me.
> 
> I guess I would have expected DefaultFunctionArrayLValueConversion (which 
> calls DefaultLValueConversion after doing array-to-pointer conversions).
> 
> If the idea is for this builtin to act more like a variadic arg, I'd expect 
> to see DefaultArgumentPromotion.
> 
> @aaron.ballman  I think is smarter than me in regards to how these should 
> work, so perhaps he can comment here?
> 
> I DO note one of the things that UsualUnaryConversions is doing is removing 
> 'half' types on platforms without a 'native' half type.  I would expect those 
> sorts of conversions wouldn't be right?
I think we need to do the usual unary conversions because that's what handles 
the floating point evaluation method stuff, and if I'm reading this properly, 
it seems that `copysign()` does perform these conversions: 
https://godbolt.org/z/eWjEqvvjd. I would not expect to handle this with default 
argument promotion given the signature of `copysign()`.


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

https://reviews.llvm.org/D140639

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


[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

2023-01-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:2660
+
+ExprResult Magnitude = UsualUnaryConversions(TheCall->getArg(0));
+ExprResult Sign = UsualUnaryConversions(TheCall->getArg(1));

aaron.ballman wrote:
> erichkeane wrote:
> > arsenm wrote:
> > > erichkeane wrote:
> > > > What is the point of the Unary Conversions here?  Its a touch 
> > > > surprising to see a builtin do that?  Note that it does quite a bit of 
> > > > FP related conversions, so are you sure you want those?
> > > Copied from the other elementwise intrinsics, and this is at the edges of 
> > > my frontend knowledge (I guess it's to avoid qualifiers mattering?). The 
> > > tests seem to behave as I expect
> > It really depends on what behavior you're looking to get out of this.  
> > UnaryConversions are usually for operators, not 'function like' things, so 
> > it is a touch jarring to me.
> > 
> > I guess I would have expected DefaultFunctionArrayLValueConversion (which 
> > calls DefaultLValueConversion after doing array-to-pointer conversions).
> > 
> > If the idea is for this builtin to act more like a variadic arg, I'd expect 
> > to see DefaultArgumentPromotion.
> > 
> > @aaron.ballman  I think is smarter than me in regards to how these should 
> > work, so perhaps he can comment here?
> > 
> > I DO note one of the things that UsualUnaryConversions is doing is removing 
> > 'half' types on platforms without a 'native' half type.  I would expect 
> > those sorts of conversions wouldn't be right?
> I think we need to do the usual unary conversions because that's what handles 
> the floating point evaluation method stuff, and if I'm reading this properly, 
> it seems that `copysign()` does perform these conversions: 
> https://godbolt.org/z/eWjEqvvjd. I would not expect to handle this with 
> default argument promotion given the signature of `copysign()`.
Got it, thanks for the clarification.


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

https://reviews.llvm.org/D140639

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


[PATCH] D140307: [clang-tidy] Match derived types in in modernize-loop-convert

2023-01-05 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp:258
+   hasMethod(cxxMethodDecl(hasName("begin"), isConst())),
+   hasMethod(cxxMethodDecl(hasName("end"),
+   isConst())) // 
hasDeclaration

Replace tabs with spaces



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:207
 
+- Improved :doc:`misc-redundant-expression 
`
+  to check for container functions ``begin``/``end`` etc on base classes of 
the container

Copy-paste typo?




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140307

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


[PATCH] D140983: [IRBuilder] Use canonical i64 type for insertelement index used by vector splats.

2023-01-05 Thread David Sherwood via Phabricator via cfe-commits
david-arm accepted this revision.
david-arm added a comment.
This revision is now accepted and ready to land.

LGTM! The change seems sensible to me, although perhaps worth waiting a day or 
two in case anyone else has objections? I noticed that we still create inserts 
using 32-bit indices in a few other places such as the SLPVectorizer, but I 
imagine these can be tidied up over time if necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140983

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


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2023-01-05 Thread Kiran Chandramohan via Phabricator via cfe-commits
kiranchandramohan added inline comments.



Comment at: mlir/test/Dialect/OpenMP/ops.mlir:124
 
+// CHECK-LABEL: omp_DistributeOp
+func.func @omp_DistributeOp(%lb : index, %ub : index, %step : index, %data_var 
: memref, %chunk_var : i32) -> () {

abidmalikwaterloo wrote:
> kiranchandramohan wrote:
> > kiranchandramohan wrote:
> > > Add a pretty-print test as well.
> > Nit: please add a pretty-print test.
> Just need clarification. Do you mean something similar to the following:
> 
> ```
> // CHECK-LABEL: omp_wsloop_pretty
> func.func @omp_wsloop_pretty(%lb : index, %ub : index, %step : index, 
> %data_var : memref, %linear_var : i32, %chunk_var : i32, %chunk_var2 : 
> i16) -> () {
> 
>   // CHECK: omp.wsloop ordered(2)
>   // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
>   omp.wsloop ordered(2)
>   for (%iv) : index = (%lb) to (%ub) step (%step) {
> omp.yield
>   }
> 
>   // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) 
> schedule(static)
>   // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
>   omp.wsloop schedule(static) linear(%data_var = %linear_var : memref)
>   for (%iv) : index = (%lb) to (%ub) step (%step) {
> omp.yield
>   }
> 
>   // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) 
> schedule(static = %{{.*}} : i32) ordered(2)
>   // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
>   omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) 
> schedule(static = %chunk_var : i32)
>   for (%iv) : index = (%lb) to (%ub) step (%step) {
> omp.yield
>   }
> 
>   // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) 
> schedule(dynamic = %{{.*}} : i32, nonmonotonic) ordered(2)
>   // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
>   omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) 
> schedule(dynamic = %chunk_var : i32, nonmonotonic)
>   for (%iv) : index = (%lb) to (%ub) step (%step)  {
> omp.yield
>   }
> 
>   // CHECK: omp.wsloop linear(%{{.*}} = %{{.*}} : memref) 
> schedule(dynamic = %{{.*}} : i16, monotonic) ordered(2)
>   // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
>   omp.wsloop ordered(2) linear(%data_var = %linear_var : memref) 
> schedule(dynamic = %chunk_var2 : i16, monotonic)
>   for (%iv) : index = (%lb) to (%ub) step (%step) {
> omp.yield
>   }
> 
>   // CHECK: omp.wsloop for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step 
> (%{{.*}})
>   omp.wsloop for (%iv) : index = (%lb) to (%ub) step (%step) {
> omp.yield
>   }
> 
>   // CHECK: omp.wsloop for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) 
> inclusive step (%{{.*}})
>   omp.wsloop for (%iv) : index = (%lb) to (%ub) inclusive step (%step) {
> omp.yield
>   }
> 
>   // CHECK: omp.wsloop nowait
>   // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
>   omp.wsloop nowait
>   for (%iv) : index = (%lb) to (%ub) step (%step) {
> omp.yield
>   }
> 
>   // CHECK: omp.wsloop nowait order(concurrent)
>   // CHECK-SAME: for (%{{.*}}) : index = (%{{.*}}) to (%{{.*}}) step (%{{.*}})
>   omp.wsloop order(concurrent) nowait
>   for (%iv) : index = (%lb) to (%ub) step (%step) {
> omp.yield
>   }
> 
>   return
> }
> ```
Yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

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


[PATCH] D140968: [clang-tidy] Add check for passing the result of `std::string::c_str` to `strlen`

2023-01-05 Thread Nathan James via Phabricator via cfe-commits
njames93 requested changes to this revision.
njames93 added a comment.
This revision now requires changes to proceed.

I don't see the appear of this check as its a situation that I doubt ever 
appears in code bases. If there are open source code bases where this is a 
known problem can you please provide links to them as well as running the 
run_clang_tidy script over them to verify the changes are good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140968

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


[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

2023-01-05 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:2674
+
+if (MagnitudeTy.getCanonicalType() != SignTy.getCanonicalType()) {
+  return Diag(Sign.get()->getBeginLoc(),

erichkeane wrote:
> curleys not used for single-statement if-statement bodies.
It covers 3 lines, it should have braces


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

https://reviews.llvm.org/D140639

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


[PATCH] D140639: clang: Fix handling of __builtin_elementwise_copysign

2023-01-05 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:2674
+
+if (MagnitudeTy.getCanonicalType() != SignTy.getCanonicalType()) {
+  return Diag(Sign.get()->getBeginLoc(),

arsenm wrote:
> erichkeane wrote:
> > curleys not used for single-statement if-statement bodies.
> It covers 3 lines, it should have braces
Our standard says 'statments' not 'lines'.  This is a single statement.

https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements


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

https://reviews.llvm.org/D140639

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


[PATCH] D140694: [clang][dataflow] Only model struct fields that are used in the function being analyzed.

2023-01-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

I realized I did not say this explicitly in my previous comment, but feel free 
to commit :)




Comment at: 
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysisContext.h:267
 
+  void addFieldsReferencedInScope(llvm::DenseSet Fields);
+

Is there any scenario where check authors might invoke this function? If no, I 
wonder if it would be better to make this private and make Environment a friend 
of this class. Keeping the number of public methods minimal could be a great 
service to future check authors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140694

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


[PATCH] D139534: [analyzer] Don't escape local static memregions on bind

2023-01-05 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Sorry, I got a bit swamped, will try to take a look next week. In the meantime, 
did you have a chance to run this over some open source projects? Did you find 
any interesting diffs?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139534

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


[PATCH] D141000: [clang-tidy] Introduce HeaderFileExtensions option

2023-01-05 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Can you explain the reasoning of why this approach is better than current 
approach where checks can use global 
options(`Options.getLocalOrGlobal("HeaderFileExtensions", 
utils::defaultHeaderFileExtensions())`) to access the same information?

Some checks also have the global option `ImplementationFileExtensions`, what's 
the proposal with that. Should checks that use this functionality carry on like 
that, use a negative match of this proposed option or should we also add that 
option to the `ClangTidyOptions`.

What is the migration plan for code-bases that currently use the old 
check-based option? We can't break their existing configs, likewise we have to 
be careful of projects with checked-in .clang-tidy files that make use of this 
new option when maintainers may still have an older version of clang-tidy.

Finally, Why would you make the option a semicolon delimited string. The only 
reason that's used for the current `CheckOptions` is there isn't currently a 
better alternative, For `ClangTidyOptions` we could set the type to be an 
`Optional>`. This would be more natural when writing 
the yaml file.

  HeaderFileExtensions: [ h, hh, hxx, hpp, "" ]
  # Or
  HeaderFileExtensions:
- h
- hh
- hxx
- hpp
- ""




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

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


[PATCH] D140547: Perform access checking to private members in simple requirement.

2023-01-05 Thread Utkarsh Saxena via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 486604.
usaxena95 added a comment.

Use ParsingDeclRAIIObject instead of ContextRAII.

This creates a separate diagnostic pool for diagnositcs associated to the 
RequiresExprBodyDecl.
This is important because dependent diagnostics should not leak to higher 
scopes (Eg. inside a template function or in a trailing requires). These 
dependent diagnstics must be attached to the DeclContext of the parameters of 
RequiresExpr (which is the BodyDecl in this case).
Non dependent diagnostics should not delayed and surfaced as hard errors.

This addresses the previously failing LibCXX failure as well.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140547

Files:
  clang/include/clang/AST/ExprConcepts.h
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaAccess.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp

Index: clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
===
--- clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
+++ clang/test/CXX/expr/expr.prim/expr.prim.req/simple-requirement.cpp
@@ -104,3 +104,138 @@
 constexpr bool b = requires (X &x) { static_cast(nullptr); };
 // expected-error@-1{{constraint variable 'x' cannot be used in an evaluated context}}
 // expected-note@-2{{'x' declared here}}
+
+namespace access_checks {
+namespace in_requires_expression {
+template
+struct A {
+static constexpr bool foo();
+static constexpr bool bar();
+static constexpr bool baz();
+static constexpr bool faz();
+};
+
+class C{};
+
+class B {
+void p() {}
+bool data_member = true;
+static const bool static_member = true;
+friend struct A<0>;
+};
+
+template
+constexpr bool A::foo() {
+return requires(B b) { b.p(); };
+}
+static_assert(!A<1>::foo());
+static_assert(A<0>::foo());
+
+template
+constexpr bool A::bar() {
+return requires() { B::static_member; };
+}
+static_assert(!A<1>::bar());
+static_assert(A<0>::bar());
+
+template
+constexpr bool A::baz() {
+return requires(B b) { b.data_member; };
+}
+static_assert(!A<1>::baz());
+static_assert(A<0>::baz());
+
+template
+constexpr bool A::faz() {
+return requires(B a, B b) { 
+  a.p();
+  b.data_member;
+  B::static_member;
+};
+}
+static_assert(!A<1>::faz());
+static_assert(A<0>::faz());
+} // namespace in_requires_expression
+
+namespace in_concepts {
+// Dependent access does not cause hard errors.
+template class A;
+
+template <> class A<0> {
+  static void f() {}
+};
+template
+concept C1 = requires() { A::f(); };
+static_assert(!C1<0>);
+
+template <> class A<1> {
+public: 
+  static void f() {}
+};
+static_assert(C1<1>);
+
+// Non-dependent access to private member is a hard error.
+class B{
+   static void f() {} // expected-note 2{{implicitly declared private here}}
+};
+template
+concept C2 = requires() { B::f(); }; // expected-error {{'f' is a private member}}
+
+constexpr bool non_template_func() {
+  return requires() {
+  B::f(); // expected-error {{'f' is a private member}}
+  };
+}
+template
+constexpr bool template_func() {
+  return requires() {
+  A::f();
+  };
+}
+static_assert(!template_func<0>());
+static_assert(template_func<1>());
+} // namespace in_concepts
+
+namespace in_trailing_requires {
+template  struct B;
+class A {
+   static void f();
+   friend struct B;
+};
+ 
+template  struct B {
+  static constexpr int index() requires requires{ A::f(); } {
+return 1;
+  }
+  static constexpr int index() {
+return 2;
+  }
+};
+
+static_assert(B::index() == 1);
+static_assert(B::index() == 2);
+
+namespace missing_member_function {
+template  struct Use;
+class X { 
+  int a;
+  static int B;
+  friend struct Use;
+};
+template  struct Use {
+  constexpr static int foo() requires requires(X x) { x.a; } {
+return 1;
+  }
+  constexpr static int bar() requires requires { X::B; } {
+return 1;
+  }
+};
+
+void test() {
+  // TODO: Propagate diagnostic.
+  Use::foo(); //expected-error {{invalid reference to function 'foo': constraints not satisfied}}
+  static_assert(Use::foo() == 1);
+}
+} // namespace missing_member_function
+} // namespace in_trailing_requires
+} // namespace access_check
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -15,6 +15,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTLambda.h"
 #include "clang/AST/ASTMutationListener.h"
+#include "clang/AST/DeclBase.h"
 #include "clang/AST/DeclTemplate.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprConcepts.h"
@@ -1363,7 +1364,17 @@
 
 ExprResult TransformRequiresExpr(RequiresExpr *E) {
 

[PATCH] D141070: [LoongArch] Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros

2023-01-05 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added reviewers: MaskRay, SixWeining, gonglingqin.
brad added a project: clang.
Herald added a subscriber: StephenFan.
Herald added a project: All.
brad requested review of this revision.

Define __GCC_HAVE_SYNC_COMPARE_AND_SWAP macros


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141070

Files:
  clang/lib/Basic/Targets/LoongArch.cpp
  clang/test/Preprocessor/init-loongarch.c
  clang/test/Preprocessor/predefined-arch-macros.c


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4366,3 +4366,20 @@
 // CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// Begin LoongArch tests 
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=loongarch32-unknown-linux-gnu \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_LA32_ATOMICS
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=loongarch64-unknown-linux-gnu \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_LA64_ATOMICS
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
Index: clang/test/Preprocessor/init-loongarch.c
===
--- clang/test/Preprocessor/init-loongarch.c
+++ clang/test/Preprocessor/init-loongarch.c
@@ -81,6 +81,9 @@
 // LA32: #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
 // LA32: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
 // LA32: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+// LA32: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// LA32: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// LA32: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // LA32: #define __ILP32__ 1
 // LA32: #define __INT16_C_SUFFIX__
 // LA32: #define __INT16_FMTd__ "hd"
@@ -394,6 +397,10 @@
 // LA64: #define __GCC_ATOMIC_SHORT_LOCK_FREE 2
 // LA64: #define __GCC_ATOMIC_TEST_AND_SET_TRUEVAL 1
 // LA64: #define __GCC_ATOMIC_WCHAR_T_LOCK_FREE 2
+// LA64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// LA64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// LA64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// LA64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
 // LA64: #define __INT16_C_SUFFIX__
 // LA64: #define __INT16_FMTd__ "hd"
 // LA64: #define __INT16_FMTi__ "hi"
Index: clang/lib/Basic/Targets/LoongArch.cpp
===
--- clang/lib/Basic/Targets/LoongArch.cpp
+++ clang/lib/Basic/Targets/LoongArch.cpp
@@ -158,6 +158,12 @@
   } else if (ABI == "lp64s" || ABI == "ilp32s") {
 Builder.defineMacro("__loongarch_soft_float");
   }
+
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_1");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_2");
+  Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4");
+  if (GRLen == 64)
+Builder.defineMacro("__GCC_HAVE_SYNC_COMPARE_AND_SWAP_8");
 }
 
 static constexpr Builtin::Info BuiltinInfo[] = {


Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -4366,3 +4366,20 @@
 // CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
 // CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // CHECK_WASM_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// Begin LoongArch tests 
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=loongarch32-unknown-linux-gnu \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_LA32_ATOMICS
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_LA32_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: --target=loongarch64-unknown-linux-gnu \
+// RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_LA64_ATOMICS
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_1 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_2 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
+// CHECK_LA64_ATOMICS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
Index: clang/test/Preprocessor/init-loong

[PATCH] D140507: Parse: handle another case of invalid handling for attributes

2023-01-05 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

I think that the current release note should be sufficient.  This is handling 
the same scenario in a different path.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140507

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


[PATCH] D141073: [Driver] move Fuchsia header search path management to the driver

2023-01-05 Thread Brad Smith via Phabricator via cfe-commits
brad created this revision.
brad added reviewers: MaskRay, abrachet, phosek.
brad added a project: clang.
Herald added a subscriber: StephenFan.
Herald added a project: All.
brad requested review of this revision.

Fuchsia already implements AddClangSystemIncludeArgs(). So it looks like we 
just have to switch over to using it.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141073

Files:
  clang/lib/Lex/InitHeaderSearch.cpp


Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -235,7 +235,6 @@
 case llvm::Triple::PS4:
 case llvm::Triple::PS5:
 case llvm::Triple::ELFIAMCU:
-case llvm::Triple::Fuchsia:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -338,7 +337,6 @@
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
   case llvm::Triple::ELFIAMCU:
-  case llvm::Triple::Fuchsia:
 break;
   case llvm::Triple::PS4:
   case llvm::Triple::PS5: {
@@ -413,6 +411,7 @@
   case llvm::Triple::FreeBSD:
   case llvm::Triple::NetBSD:
   case llvm::Triple::OpenBSD:
+  case llvm::Triple::Fuchsia:
   case llvm::Triple::Hurd:
   case llvm::Triple::Linux:
   case llvm::Triple::Solaris:


Index: clang/lib/Lex/InitHeaderSearch.cpp
===
--- clang/lib/Lex/InitHeaderSearch.cpp
+++ clang/lib/Lex/InitHeaderSearch.cpp
@@ -235,7 +235,6 @@
 case llvm::Triple::PS4:
 case llvm::Triple::PS5:
 case llvm::Triple::ELFIAMCU:
-case llvm::Triple::Fuchsia:
   break;
 case llvm::Triple::Win32:
   if (triple.getEnvironment() != llvm::Triple::Cygnus)
@@ -338,7 +337,6 @@
   case llvm::Triple::RTEMS:
   case llvm::Triple::NaCl:
   case llvm::Triple::ELFIAMCU:
-  case llvm::Triple::Fuchsia:
 break;
   case llvm::Triple::PS4:
   case llvm::Triple::PS5: {
@@ -413,6 +411,7 @@
   case llvm::Triple::FreeBSD:
   case llvm::Triple::NetBSD:
   case llvm::Triple::OpenBSD:
+  case llvm::Triple::Fuchsia:
   case llvm::Triple::Hurd:
   case llvm::Triple::Linux:
   case llvm::Triple::Solaris:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139534: [analyzer] Don't escape local static memregions on bind

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

In D139534#4029097 , @xazax.hun wrote:

> Sorry, I got a bit swamped, will try to take a look next week. In the 
> meantime, did you have a chance to run this over some open source projects? 
> Did you find any interesting diffs?

Yea I did. Check my response to Artem.  I no longer have the results, but the 
diff was surprisingly small. However, I feel confident about the measurment 
itself.

Thanks for your time. You don't need to rush.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139534

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


[clang] 3b1d455 - [clang] Correct -frewrite-includes generation of line control directives with mixed EOL forms.

2023-01-05 Thread Tom Honermann via cfe-commits

Author: Tom Honermann
Date: 2023-01-05T13:24:01-05:00
New Revision: 3b1d45518910b529104a269d5f6712a720cc3ff7

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

LOG: [clang] Correct -frewrite-includes generation of line control directives 
with mixed EOL forms.

Previously, if a header file and a source file used different end of line
(EOL) forms, preprocessed output generated with the -frewrite-includes option
would, in some cases, generate line control directives with the wrong line
number due to an error in how source file lines were counted.

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

Reviewed By: cor3ntin

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

Added: 
clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c
clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h
clang/test/Frontend/rewrite-includes-mixed-eol-lf.c
clang/test/Frontend/rewrite-includes-mixed-eol-lf.h

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Frontend/Rewrite/InclusionRewriter.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index b308dd6c87860..ba464df6c0d3b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -331,6 +331,10 @@ Bug Fixes
   `Issue 58800 `_
 - Fix an issue that triggers a crash if we instantiate a hidden friend 
functions.
   This fixes `Issue 54457 `_
+- Fix an issue where -frewrite-includes generated line control directives with
+  incorrect line numbers in some cases when a header file used an end of line
+  character sequence that 
diff ered from the primary source file.
+  `Issue 59736 `_
 
 Improvements to Clang's diagnostics
 ^^^

diff  --git a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp 
b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
index 810ec680448c5..d3a3db0139c6d 100644
--- a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -281,27 +281,33 @@ void InclusionRewriter::OutputContentUpTo(const 
MemoryBufferRef &FromFile,
 
   StringRef TextToWrite(FromFile.getBufferStart() + WriteFrom,
 WriteTo - WriteFrom);
+  // count lines manually, it's faster than getPresumedLoc()
+  Line += TextToWrite.count(LocalEOL);
 
   if (MainEOL == LocalEOL) {
 OS << TextToWrite;
-// count lines manually, it's faster than getPresumedLoc()
-Line += TextToWrite.count(LocalEOL);
-if (EnsureNewline && !TextToWrite.endswith(LocalEOL))
-  OS << MainEOL;
   } else {
 // Output the file one line at a time, rewriting the line endings as we go.
 StringRef Rest = TextToWrite;
 while (!Rest.empty()) {
-  StringRef LineText;
-  std::tie(LineText, Rest) = Rest.split(LocalEOL);
+  // Identify and output the next line excluding an EOL sequence if 
present.
+  size_t Idx = Rest.find(LocalEOL);
+  StringRef LineText = Rest.substr(0, Idx);
   OS << LineText;
-  Line++;
-  if (!Rest.empty())
+  if (Idx != StringRef::npos) {
+// An EOL sequence was present, output the EOL sequence for the
+// main source file and skip past the local EOL sequence.
 OS << MainEOL;
+Idx += LocalEOL.size();
+  }
+  // Strip the line just handled. If Idx is npos or matches the end of the
+  // text, Rest will be set to an empty string and the loop will terminate.
+  Rest = Rest.substr(Idx);
 }
-if (TextToWrite.endswith(LocalEOL) || EnsureNewline)
-  OS << MainEOL;
   }
+  if (EnsureNewline && !TextToWrite.endswith(LocalEOL))
+OS << MainEOL;
+
   WriteFrom = WriteTo;
 }
 

diff  --git a/clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c 
b/clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c
new file mode 100644
index 0..d672c0667
--- /dev/null
+++ b/clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -E -frewrite-includes %s | %clang_cc1 -
+// expected-no-diagnostics
+// Note: This source file has CRLF line endings.
+// This test validates that -frewrite-includes translates the end of line (EOL)
+// form used in header files to the EOL form used in the the primary source
+// file when the files use 
diff erent EOL forms.
+#include "rewrite-includes-mixed-eol-crlf.h"
+#include "rewrite-includes-mixed-eol-lf.h"

diff  --git a/clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h 
b/clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h
new file mode 100644
index 0..0439b88b75e2c
--- /dev/null
+++ b/clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h
@@ -0,0 +1,11 @

[PATCH] D140984: [clang] Correct -frewrite-includes generation of line control directives with mixed EOL forms.

2023-01-05 Thread Tom Honermann 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 rG3b1d45518910: [clang] Correct -frewrite-includes generation 
of line control directives with… (authored by tahonermann).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140984

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
  clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c
  clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h
  clang/test/Frontend/rewrite-includes-mixed-eol-lf.c
  clang/test/Frontend/rewrite-includes-mixed-eol-lf.h

Index: clang/test/Frontend/rewrite-includes-mixed-eol-lf.h
===
--- /dev/null
+++ clang/test/Frontend/rewrite-includes-mixed-eol-lf.h
@@ -0,0 +1,11 @@
+// Note: This header file has LF line endings.
+// The indentation in some of the conditional inclusion directives below is
+// intentional and is required for this test to function as a regression test
+// for GH59736.
+_Static_assert(__LINE__ == 5, "");
+#if 1
+_Static_assert(__LINE__ == 7, "");
+  #if 1
+  _Static_assert(__LINE__ == 9, "");
+  #endif
+#endif
Index: clang/test/Frontend/rewrite-includes-mixed-eol-lf.c
===
--- /dev/null
+++ clang/test/Frontend/rewrite-includes-mixed-eol-lf.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -E -frewrite-includes %s | %clang_cc1 -
+// expected-no-diagnostics
+// Note: This source file has LF line endings.
+// This test validates that -frewrite-includes translates the end of line (EOL)
+// form used in header files to the EOL form used in the the primary source
+// file when the files use different EOL forms.
+#include "rewrite-includes-mixed-eol-crlf.h"
+#include "rewrite-includes-mixed-eol-lf.h"
Index: clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h
===
--- /dev/null
+++ clang/test/Frontend/rewrite-includes-mixed-eol-crlf.h
@@ -0,0 +1,11 @@
+// Note: This header file has CRLF line endings.
+// The indentation in some of the conditional inclusion directives below is
+// intentional and is required for this test to function as a regression test
+// for GH59736.
+_Static_assert(__LINE__ == 5, "");
+#if 1
+_Static_assert(__LINE__ == 7, "");
+  #if 1
+  _Static_assert(__LINE__ == 9, "");
+  #endif
+#endif
Index: clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c
===
--- /dev/null
+++ clang/test/Frontend/rewrite-includes-mixed-eol-crlf.c
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -E -frewrite-includes %s | %clang_cc1 -
+// expected-no-diagnostics
+// Note: This source file has CRLF line endings.
+// This test validates that -frewrite-includes translates the end of line (EOL)
+// form used in header files to the EOL form used in the the primary source
+// file when the files use different EOL forms.
+#include "rewrite-includes-mixed-eol-crlf.h"
+#include "rewrite-includes-mixed-eol-lf.h"
Index: clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
===
--- clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -281,27 +281,33 @@
 
   StringRef TextToWrite(FromFile.getBufferStart() + WriteFrom,
 WriteTo - WriteFrom);
+  // count lines manually, it's faster than getPresumedLoc()
+  Line += TextToWrite.count(LocalEOL);
 
   if (MainEOL == LocalEOL) {
 OS << TextToWrite;
-// count lines manually, it's faster than getPresumedLoc()
-Line += TextToWrite.count(LocalEOL);
-if (EnsureNewline && !TextToWrite.endswith(LocalEOL))
-  OS << MainEOL;
   } else {
 // Output the file one line at a time, rewriting the line endings as we go.
 StringRef Rest = TextToWrite;
 while (!Rest.empty()) {
-  StringRef LineText;
-  std::tie(LineText, Rest) = Rest.split(LocalEOL);
+  // Identify and output the next line excluding an EOL sequence if present.
+  size_t Idx = Rest.find(LocalEOL);
+  StringRef LineText = Rest.substr(0, Idx);
   OS << LineText;
-  Line++;
-  if (!Rest.empty())
+  if (Idx != StringRef::npos) {
+// An EOL sequence was present, output the EOL sequence for the
+// main source file and skip past the local EOL sequence.
 OS << MainEOL;
+Idx += LocalEOL.size();
+  }
+  // Strip the line just handled. If Idx is npos or matches the end of the
+  // text, Rest will be set to an empty string and the loop will terminate.
+  Rest = Rest.substr(Idx);
 }
-if (TextToWrite.endswith(LocalEOL) || EnsureNewline)
-  OS << MainEOL;
   }
+  if (EnsureNewline && !TextToWrite.endswith(LocalEOL))
+OS << MainEOL;
+
   WriteFrom = WriteTo;

[PATCH] D137996: Add support for a backdoor driver option that enables emitting header usage information in JSON to a file

2023-01-05 Thread Sean via Phabricator via cfe-commits
SeanP added inline comments.



Comment at: clang/tools/driver/driver.cpp:251
+ std::string &OptFile) {
+  T OptVal = ::getenv(EnvOptSet);
+  if (OptVal) {

This change is not POSIX compliant.  If T is char *, the next call to getenv() 
on line 253 invalidates the value saved into OptVal.  getenv() is allowed to 
use the same buffer for the return value.  That means the value OptVal is 
pointing at will be overwritten by the next call.

When T is bool you need the `!!` operators to get the char * converted to bool 
correctly.

I suggest leaving this function as it was and calling getenv() directly for the 
scenario involving CC_PRINT_HEADERS_FORMAT.  Make sure you save the getenv() 
results into std::string so the value isn't overridden.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137996

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


[PATCH] D141078: [CUDA][HIP] Support '--offload-arch=native' for the new driver

2023-01-05 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tianshilei1992, tra, yaxunl.
Herald added subscribers: kosarev, mattd, asavonic, kerbowa, jvesely.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, sstefan1, MaskRay.
Herald added a project: clang.

This patch applies the same handling for the `--offload-arch=native'
string to the new driver. The support for OpenMP will require some extra
logic to infer the triples from the derived architecture strings.

Depends on D141051 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141078

Files:
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/amdgpu-hip-system-arch.c
  clang/test/Driver/nvptx-cuda-system-arch.c
  clang/test/Driver/openmp-offload-infer.c

Index: clang/test/Driver/openmp-offload-infer.c
===
--- clang/test/Driver/openmp-offload-infer.c
+++ clang/test/Driver/openmp-offload-infer.c
@@ -40,10 +40,10 @@
 // CHECK-ARCH-BINDINGS: "x86_64-unknown-linux-gnu" - "Offload::Linker", inputs: ["[[HOST_OBJ]]"], output: "a.out"
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp \
-// RUN: --offload-arch=sm_70 --offload-arch=gfx908 --offload-arch=native \
+// RUN: --offload-arch=sm_70 --offload-arch=gfx908 --offload-arch=skylake \
 // RUN: -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-FAILED
 
-// CHECK-FAILED: error: failed to deduce triple for target architecture 'native'; specify the triple using '-fopenmp-targets' and '-Xopenmp-target' instead.
+// CHECK-FAILED: error: failed to deduce triple for target architecture 'skylake'; specify the triple using '-fopenmp-targets' and '-Xopenmp-target' instead.
 
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -ccc-print-bindings -fopenmp \
 // RUN: --offload-arch=sm_70 --offload-arch=gfx908 -fno-openmp \
Index: clang/test/Driver/nvptx-cuda-system-arch.c
===
--- clang/test/Driver/nvptx-cuda-system-arch.c
+++ clang/test/Driver/nvptx-cuda-system-arch.c
@@ -14,14 +14,20 @@
 // case when nvptx-arch returns nothing or fails
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_fail -x cuda %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --offload-new-driver --nvptx-arch-tool=%t/nvptx_arch_fail -x cuda %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
 // NO-OUTPUT-ERROR: error: cannot determine NVPTX architecture{{.*}}; consider passing it via '--offload-arch'
 
 // case when nvptx_arch does not return anything with successful execution
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_empty -x cuda %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=EMPTY-OUTPUT
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --offload-new-driver --nvptx-arch-tool=%t/nvptx_arch_empty -x cuda %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=EMPTY-OUTPUT
 // EMPTY-OUTPUT: error: cannot determine NVPTX architecture: No NVIDIA GPU detected in the system; consider passing it via '--offload-arch'
 
 // case when nvptx_arch does not return anything with successful execution
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --nvptx-arch-tool=%t/nvptx_arch_sm_70 -x cuda %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=ARCH-sm_70
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --offload-new-driver --nvptx-arch-tool=%t/nvptx_arch_sm_70 -x cuda %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=ARCH-sm_70
 // ARCH-sm_70: "-cc1" "-triple" "nvptx64-nvidia-cuda"{{.*}}"-target-cpu" "sm_70"
Index: clang/test/Driver/amdgpu-hip-system-arch.c
===
--- clang/test/Driver/amdgpu-hip-system-arch.c
+++ clang/test/Driver/amdgpu-hip-system-arch.c
@@ -14,14 +14,20 @@
 // case when amdgpu-arch returns nothing or fails
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --amdgpu-arch-tool=%t/amdgpu_arch_fail -x hip %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
+// RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=native --offload-new-driver --amdgpu-arch-tool=%t/amdgpu_arch_fail -x hip %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=NO-OUTPUT-ERROR
 // NO-OUTPUT-ERROR: error: cannot determine AMDGPU architecture{{.*}}; consider passing it via '--offload-arch'
 
 // case when amdgpu_arch does not return anything with successful execution
 // RUN:   %clang -### --target=x86_64-unknown-linux-gnu -nogpulib --offload-arch=nativ

[clang] 108766f - Fix typos

2023-01-05 Thread Luke Drummond via cfe-commits

Author: Luke Drummond
Date: 2023-01-05T18:49:23Z
New Revision: 108766fc7ef83724ff4f66235bd561b217df0ff7

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

LOG: Fix typos

I found one typo of "implemnt", then some more.
s/implemnt/implement/g

Added: 


Modified: 
clang/lib/CodeGen/CGBuiltin.cpp
llvm/lib/CodeGen/MIRParser/MIParser.cpp
llvm/lib/MC/MCWin64EH.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
llvm/test/CodeGen/PowerPC/aix-alias.ll

Removed: 




diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index b1e8517460ce8..0afa25da7aee3 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -7999,7 +7999,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned 
BuiltinID,
 Value *Arg0 = EmitScalarExpr(E->getArg(0));
 Value *Arg1 = EmitScalarExpr(E->getArg(1));
 
-// crc32{c,}d intrinsics are implemnted as two calls to crc32{c,}w
+// crc32{c,}d intrinsics are implemented as two calls to crc32{c,}w
 // intrinsics, hence we need 
diff erent codegen for these cases.
 if (BuiltinID == clang::ARM::BI__builtin_arm_crc32d ||
 BuiltinID == clang::ARM::BI__builtin_arm_crc32cd) {

diff  --git a/llvm/lib/CodeGen/MIRParser/MIParser.cpp 
b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
index 56c5c58142388..8b27edee45fe5 100644
--- a/llvm/lib/CodeGen/MIRParser/MIParser.cpp
+++ b/llvm/lib/CodeGen/MIRParser/MIParser.cpp
@@ -1847,7 +1847,7 @@ bool MIParser::parseIRConstant(StringRef::iterator Loc, 
const Constant *&C) {
   return false;
 }
 
-// See LLT implemntation for bit size limits.
+// See LLT implementation for bit size limits.
 static bool verifyScalarSize(uint64_t Size) {
   return Size != 0 && isUInt<16>(Size);
 }

diff  --git a/llvm/lib/MC/MCWin64EH.cpp b/llvm/lib/MC/MCWin64EH.cpp
index 4b20959ee5d6c..1a55722133ccd 100644
--- a/llvm/lib/MC/MCWin64EH.cpp
+++ b/llvm/lib/MC/MCWin64EH.cpp
@@ -1282,9 +1282,9 @@ static void ARM64EmitUnwindInfoForSegment(MCStreamer 
&streamer,
 // FIXME: We should be able to split unwind info into multiple sections.
 if (CodeWords > 0xFF || EpilogCount > 0x)
   report_fatal_error(
-  "SEH unwind data splitting is only implemnted for large functions, "
-  "cases of too many code words or too many epilogs will be done later"
-  );
+  "SEH unwind data splitting is only implemented for large functions, "
+  "cases of too many code words or too many epilogs will be done "
+  "later");
 uint32_t row2 = 0x0;
 row2 |= (CodeWords & 0xFF) << 16;
 row2 |= (EpilogCount & 0x);

diff  --git a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h 
b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
index acb03f349e863..b3bce9960772e 100644
--- a/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
+++ b/llvm/lib/Target/AArch64/MCTargetDesc/AArch64TargetStreamer.h
@@ -30,7 +30,7 @@ class AArch64TargetStreamer : public MCTargetStreamer {
   /// MCExpr that can be used to refer to the constant pool location.
   const MCExpr *addConstantPoolEntry(const MCExpr *, unsigned Size, SMLoc Loc);
 
-  /// Callback used to implemnt the .ltorg directive.
+  /// Callback used to implement the .ltorg directive.
   /// Emit contents of constant pool for the current section.
   void emitCurrentConstantPool();
 

diff  --git a/llvm/test/CodeGen/PowerPC/aix-alias.ll 
b/llvm/test/CodeGen/PowerPC/aix-alias.ll
index a3f6d87ca85ff..0ec2118beb7aa 100644
--- a/llvm/test/CodeGen/PowerPC/aix-alias.ll
+++ b/llvm/test/CodeGen/PowerPC/aix-alias.ll
@@ -1,5 +1,5 @@
 ; TODO: Add object generation test when visibility for object generation
-;   is implemnted.
+;   is implemented.
 
 ; RUN: llc -verify-machineinstrs -mtriple powerpc-ibm-aix-xcoff -mcpu=pwr4 \
 ; RUN: -mattr=-altivec -data-sections=false -xcoff-traceback-table=false < 
%s | \



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


  1   2   3   >