[clang] [polly] [llvm] [polly][ScheduleOptimizer] Fix long compile time(hang) reported in polly (PR #75141)

2024-01-01 Thread Karthika Devi C via cfe-commits

kartcq wrote:

ping @efriedma-quic @xgupta 

https://github.com/llvm/llvm-project/pull/75141
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[mlir] [flang] [clang] [compiler-rt] [llvm] [clang-tools-extra] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-01 Thread Rik Huijzer via cfe-commits

https://github.com/rikhuijzer edited 
https://github.com/llvm/llvm-project/pull/76292
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[mlir] [flang] [clang] [compiler-rt] [llvm] [clang-tools-extra] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-01 Thread Rik Huijzer via cfe-commits

https://github.com/rikhuijzer edited 
https://github.com/llvm/llvm-project/pull/76292
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[mlir] [flang] [clang] [compiler-rt] [llvm] [clang-tools-extra] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-01 Thread Rik Huijzer via cfe-commits

https://github.com/rikhuijzer edited 
https://github.com/llvm/llvm-project/pull/76292
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] check for synthesized symbols when tracking include locations (PR #75128)

2024-01-01 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet edited 
https://github.com/llvm/llvm-project/pull/75128
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] check for synthesized symbols when tracking include locations (PR #75128)

2024-01-01 Thread kadir çetinkaya via cfe-commits


@@ -821,7 +821,8 @@ void SymbolCollector::setIncludeLocation(const Symbol , 
SourceLocation DefLoc,
 
   // Use the expansion location to get the #include header since this is
   // where the symbol is exposed.
-  IncludeFiles[S.ID] = SM.getDecomposedExpansionLoc(DefLoc).first;
+  if (FileID FID = SM.getDecomposedExpansionLoc(DefLoc).first; FID.isValid())

kadircet wrote:

i still think it's wasteful to check both in both places, but now that you do a 
`lookup` instead of `at` below, i'll leave this to you.

https://github.com/llvm/llvm-project/pull/75128
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] check for synthesized symbols when tracking include locations (PR #75128)

2024-01-01 Thread kadir çetinkaya via cfe-commits

https://github.com/kadircet approved this pull request.

thanks and sorry for leaving this out there, I was busy with other things and 
then OOO.

https://github.com/llvm/llvm-project/pull/75128
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] [Propeller] Add new flag option '-basic-block-sections=listwithlabels=' to support to use Propeller iteratively. (PR #76497)

2024-01-01 Thread via cfe-commits

https://github.com/lifengxiang1025 updated 
https://github.com/llvm/llvm-project/pull/76497

>From 4ae12256cfe621e3051ac4deee60cd1da6c54a65 Mon Sep 17 00:00:00 2001
From: lifengxiang 
Date: Thu, 28 Dec 2023 16:57:54 +0800
Subject: [PATCH 1/3] [Propeller] Add new flag option
 '-basic-block-sections=listwithlabels=' to support to use Propeller
 iteratively.

---
 clang/docs/UsersManual.rst|  2 +-
 clang/include/clang/Basic/CodeGenOptions.h|  2 +
 clang/include/clang/Driver/Options.td |  2 +-
 clang/lib/CodeGen/BackendUtil.cpp |  8 ++-
 clang/lib/Driver/ToolChains/Clang.cpp |  2 +-
 clang/test/CodeGen/basic-block-sections.c |  3 +-
 clang/test/Driver/fbasic-block-sections.c | 26 ++
 lld/ELF/Driver.cpp|  2 +-
 lld/ELF/LTO.cpp   |  8 ++-
 llvm/include/llvm/CodeGen/MachineFunction.h   |  6 ++-
 llvm/include/llvm/Target/TargetOptions.h  |  3 +-
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 50 ---
 llvm/lib/CodeGen/BasicBlockPathCloning.cpp|  4 +-
 llvm/lib/CodeGen/BasicBlockSections.cpp   |  6 ++-
 llvm/lib/CodeGen/CommandFlags.cpp |  6 ++-
 llvm/lib/CodeGen/MachineFunction.cpp  |  3 +-
 llvm/lib/CodeGen/TargetPassConfig.cpp |  3 +-
 .../CodeGen/X86/basic-block-sections-cold.ll  |  8 +++
 18 files changed, 96 insertions(+), 48 deletions(-)

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 7c30570437e8b0..0a8a2381082a3f 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2292,7 +2292,7 @@ are listed below.
  $ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c
  $ cd $P && clang foo/name_conflict.o && bar/name_conflict.o
 
-.. option:: -fbasic-block-sections=[labels, all, list=, none]
+.. option:: -fbasic-block-sections=[labels, all, list=, 
listwithlabels=, none]
 
   Controls how Clang emits text sections for basic blocks. With values ``all``
   and ``list=``, each basic block or a subset of basic blocks can be 
placed
diff --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 6952b48e898a81..dbf550a6d1df24 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -117,6 +117,8 @@ class CodeGenOptions : public CodeGenOptionsBase {
   // "list=": Generate basic block sections for a subset of basic blocks.
   //The functions and the machine basic block ids are specified
   //in the file.
+  // "listwithlabels=":
+  //Mix of list and labels.
   // "none":Disable sections/labels for basic blocks.
   std::string BBSections;
 
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2b93ddf033499c..286956122f424e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3956,7 +3956,7 @@ def fbasic_block_sections_EQ : Joined<["-"], 
"fbasic-block-sections=">, Group,
   HelpText<"Place each function's basic blocks in unique sections (ELF Only)">,
   DocBrief<[{Generate labels for each basic block or place each basic block or 
a subset of basic blocks in its own section.}]>,
-  Values<"all,labels,none,list=">,
+  Values<"all,labels,none,list=,listwithlabels=">,
   MarshallingInfoString, [{"none"}]>;
 defm data_sections : BoolFOption<"data-sections",
   CodeGenOpts<"DataSections">, DefaultFalse,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index a6142d99f3b688..b248ae3c56ae78 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -380,11 +380,15 @@ static bool initTargetOptions(DiagnosticsEngine ,
   .Case("labels", llvm::BasicBlockSection::Labels)
   .StartsWith("list=", llvm::BasicBlockSection::List)
   .Case("none", llvm::BasicBlockSection::None)
+  .StartsWith("listwithlabels=",
+  llvm::BasicBlockSection::ListWithLabels)
   .Default(llvm::BasicBlockSection::None);
 
-  if (Options.BBSections == llvm::BasicBlockSection::List) {
+  if (Options.BBSections == llvm::BasicBlockSection::List ||
+  Options.BBSections == llvm::BasicBlockSection::ListWithLabels) {
 ErrorOr> MBOrErr =
-MemoryBuffer::getFile(CodeGenOpts.BBSections.substr(5));
+MemoryBuffer::getFile(CodeGenOpts.BBSections.substr(
+Options.BBSections == llvm::BasicBlockSection::List ? 5 : 15));
 if (!MBOrErr) {
   Diags.Report(diag::err_fe_unable_to_load_basic_block_sections_file)
   << MBOrErr.getError().message();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index acfa119805068d..038c24d46fdd36 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5888,7 +5888,7 @@ void 

[clang] [llvm] [mlir] [compiler-rt] [clang-tools-extra] [flang] [mlir][vector] Fix invalid `LoadOp` indices being created (PR #76292)

2024-01-01 Thread Rik Huijzer via cfe-commits

https://github.com/rikhuijzer updated 
https://github.com/llvm/llvm-project/pull/76292

>From 0ff5a0ec09f7c26824bd90e6c7656222ee2448ae Mon Sep 17 00:00:00 2001
From: Rik Huijzer 
Date: Sat, 23 Dec 2023 16:32:27 +0100
Subject: [PATCH] [mlir][vector] Fix invalid `LoadOp` indices being created

---
 .../Conversion/VectorToSCF/VectorToSCF.cpp| 48 +--
 .../Conversion/VectorToSCF/vector-to-scf.mlir | 37 ++
 2 files changed, 71 insertions(+), 14 deletions(-)

diff --git a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp 
b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
index 2ee314e9fedfe3..13d2513a88804c 100644
--- a/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
+++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp
@@ -866,6 +866,31 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
 this->setHasBoundedRewriteRecursion();
   }
 
+  static void getMaskBufferLoadIndices(OpTy xferOp, Value castedMaskBuffer,
+   SmallVector ,
+   Value iv) {
+assert(xferOp.getMask() && "Expected transfer op to have mask");
+
+// Add load indices from the previous iteration.
+// The mask buffer depends on the permutation map, which makes determining
+// the indices quite complex, so this is why we need to "look back" to the
+// previous iteration to find the right indices.
+Value maskBuffer = getMaskBuffer(xferOp);
+for (OpOperand  : maskBuffer.getUses()) {
+  // If there is no previous load op, then the indices are empty.
+  if (auto loadOp = dyn_cast(use.getOwner())) {
+Operation::operand_range prevIndices = loadOp.getIndices();
+loadIndices.append(prevIndices.begin(), prevIndices.end());
+break;
+  }
+}
+
+// In case of broadcast: Use same indices to load from memref
+// as before.
+if (!xferOp.isBroadcastDim(0))
+  loadIndices.push_back(iv);
+  }
+
   LogicalResult matchAndRewrite(OpTy xferOp,
 PatternRewriter ) const override {
 if (!xferOp->hasAttr(kPassLabel))
@@ -873,9 +898,9 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
 
 // Find and cast data buffer. How the buffer can be found depends on OpTy.
 ImplicitLocOpBuilder locB(xferOp.getLoc(), rewriter);
-auto dataBuffer = Strategy::getBuffer(xferOp);
+Value dataBuffer = Strategy::getBuffer(xferOp);
 auto dataBufferType = dyn_cast(dataBuffer.getType());
-auto castedDataType = unpackOneDim(dataBufferType);
+FailureOr castedDataType = unpackOneDim(dataBufferType);
 if (failed(castedDataType))
   return failure();
 
@@ -885,8 +910,7 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
 // If the xferOp has a mask: Find and cast mask buffer.
 Value castedMaskBuffer;
 if (xferOp.getMask()) {
-  auto maskBuffer = getMaskBuffer(xferOp);
-  auto maskBufferType = dyn_cast(maskBuffer.getType());
+  Value maskBuffer = getMaskBuffer(xferOp);
   if (xferOp.isBroadcastDim(0) || xferOp.getMaskType().getRank() == 1) {
 // Do not unpack a dimension of the mask, if:
 // * To-be-unpacked transfer op dimension is a broadcast.
@@ -897,7 +921,8 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
   } else {
 // It's safe to assume the mask buffer can be unpacked if the data
 // buffer was unpacked.
-auto castedMaskType = *unpackOneDim(maskBufferType);
+auto maskBufferType = dyn_cast(maskBuffer.getType());
+MemRefType castedMaskType = *unpackOneDim(maskBufferType);
 castedMaskBuffer =
 locB.create(castedMaskType, maskBuffer);
   }
@@ -929,21 +954,16 @@ struct TransferOpConversion : public 
VectorToSCFPattern {
 
 // If old transfer op has a mask: Set mask on new transfer op.
 // Special case: If the mask of the old transfer op is 1D and
-// the
-//   unpacked dim is not a broadcast, no mask is
-//   needed on the new transfer op.
+// the unpacked dim is not a broadcast, no mask is needed on
+// the new transfer op.
 if (xferOp.getMask() && (xferOp.isBroadcastDim(0) ||
  xferOp.getMaskType().getRank() > 1)) {
   OpBuilder::InsertionGuard guard(b);
   b.setInsertionPoint(newXfer); // Insert load before newXfer.
 
   SmallVector loadIndices;
-  Strategy::getBufferIndices(xferOp, loadIndices);
-  // In case of broadcast: Use same indices to load from memref
-  // as before.
-  if (!xferOp.isBroadcastDim(0))
-loadIndices.push_back(iv);
-
+  getMaskBufferLoadIndices(xferOp, castedMaskBuffer,
+   loadIndices, iv);

[clang] [llvm] [openmp] [mlir] [libcxx] [libc] [lldb] [compiler-rt] [clang-tools-extra] [flang] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Hristo Hristov via cfe-commits

Zingam wrote:

Thank you very much for the review. I'll wait a few days for addional feedback 
before I land this PR.

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [llvm] [Propeller] Add new flag option '-basic-block-sections=listwithlabels=' to support to use Propeller iteratively. (PR #76497)

2024-01-01 Thread via cfe-commits

https://github.com/lifengxiang1025 updated 
https://github.com/llvm/llvm-project/pull/76497

>From 4ae12256cfe621e3051ac4deee60cd1da6c54a65 Mon Sep 17 00:00:00 2001
From: lifengxiang 
Date: Thu, 28 Dec 2023 16:57:54 +0800
Subject: [PATCH 1/2] [Propeller] Add new flag option
 '-basic-block-sections=listwithlabels=' to support to use Propeller
 iteratively.

---
 clang/docs/UsersManual.rst|  2 +-
 clang/include/clang/Basic/CodeGenOptions.h|  2 +
 clang/include/clang/Driver/Options.td |  2 +-
 clang/lib/CodeGen/BackendUtil.cpp |  8 ++-
 clang/lib/Driver/ToolChains/Clang.cpp |  2 +-
 clang/test/CodeGen/basic-block-sections.c |  3 +-
 clang/test/Driver/fbasic-block-sections.c | 26 ++
 lld/ELF/Driver.cpp|  2 +-
 lld/ELF/LTO.cpp   |  8 ++-
 llvm/include/llvm/CodeGen/MachineFunction.h   |  6 ++-
 llvm/include/llvm/Target/TargetOptions.h  |  3 +-
 llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp| 50 ---
 llvm/lib/CodeGen/BasicBlockPathCloning.cpp|  4 +-
 llvm/lib/CodeGen/BasicBlockSections.cpp   |  6 ++-
 llvm/lib/CodeGen/CommandFlags.cpp |  6 ++-
 llvm/lib/CodeGen/MachineFunction.cpp  |  3 +-
 llvm/lib/CodeGen/TargetPassConfig.cpp |  3 +-
 .../CodeGen/X86/basic-block-sections-cold.ll  |  8 +++
 18 files changed, 96 insertions(+), 48 deletions(-)

diff --git a/clang/docs/UsersManual.rst b/clang/docs/UsersManual.rst
index 7c30570437e8b0..0a8a2381082a3f 100644
--- a/clang/docs/UsersManual.rst
+++ b/clang/docs/UsersManual.rst
@@ -2292,7 +2292,7 @@ are listed below.
  $ cd $P/bar && clang -c -funique-internal-linkage-names name_conflict.c
  $ cd $P && clang foo/name_conflict.o && bar/name_conflict.o
 
-.. option:: -fbasic-block-sections=[labels, all, list=, none]
+.. option:: -fbasic-block-sections=[labels, all, list=, 
listwithlabels=, none]
 
   Controls how Clang emits text sections for basic blocks. With values ``all``
   and ``list=``, each basic block or a subset of basic blocks can be 
placed
diff --git a/clang/include/clang/Basic/CodeGenOptions.h 
b/clang/include/clang/Basic/CodeGenOptions.h
index 6952b48e898a81..dbf550a6d1df24 100644
--- a/clang/include/clang/Basic/CodeGenOptions.h
+++ b/clang/include/clang/Basic/CodeGenOptions.h
@@ -117,6 +117,8 @@ class CodeGenOptions : public CodeGenOptionsBase {
   // "list=": Generate basic block sections for a subset of basic blocks.
   //The functions and the machine basic block ids are specified
   //in the file.
+  // "listwithlabels=":
+  //Mix of list and labels.
   // "none":Disable sections/labels for basic blocks.
   std::string BBSections;
 
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 2b93ddf033499c..286956122f424e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3956,7 +3956,7 @@ def fbasic_block_sections_EQ : Joined<["-"], 
"fbasic-block-sections=">, Group,
   HelpText<"Place each function's basic blocks in unique sections (ELF Only)">,
   DocBrief<[{Generate labels for each basic block or place each basic block or 
a subset of basic blocks in its own section.}]>,
-  Values<"all,labels,none,list=">,
+  Values<"all,labels,none,list=,listwithlabels=">,
   MarshallingInfoString, [{"none"}]>;
 defm data_sections : BoolFOption<"data-sections",
   CodeGenOpts<"DataSections">, DefaultFalse,
diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index a6142d99f3b688..b248ae3c56ae78 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -380,11 +380,15 @@ static bool initTargetOptions(DiagnosticsEngine ,
   .Case("labels", llvm::BasicBlockSection::Labels)
   .StartsWith("list=", llvm::BasicBlockSection::List)
   .Case("none", llvm::BasicBlockSection::None)
+  .StartsWith("listwithlabels=",
+  llvm::BasicBlockSection::ListWithLabels)
   .Default(llvm::BasicBlockSection::None);
 
-  if (Options.BBSections == llvm::BasicBlockSection::List) {
+  if (Options.BBSections == llvm::BasicBlockSection::List ||
+  Options.BBSections == llvm::BasicBlockSection::ListWithLabels) {
 ErrorOr> MBOrErr =
-MemoryBuffer::getFile(CodeGenOpts.BBSections.substr(5));
+MemoryBuffer::getFile(CodeGenOpts.BBSections.substr(
+Options.BBSections == llvm::BasicBlockSection::List ? 5 : 15));
 if (!MBOrErr) {
   Diags.Report(diag::err_fe_unable_to_load_basic_block_sections_file)
   << MBOrErr.getError().message();
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index acfa119805068d..038c24d46fdd36 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5888,7 +5888,7 @@ void 

[clang] Clang/MIPS: Use -mnan value for -mabs if not specified (PR #71157)

2024-01-01 Thread Brad Smith via cfe-commits

brad0 wrote:

@MaskRay Ping.

https://github.com/llvm/llvm-project/pull/71157
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] [C++20] [Modules] Introduce initial support for C++20 Modules (PR #66462)

2024-01-01 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

@sam-mccall ping~ what's the fate of the patch?

https://github.com/llvm/llvm-project/pull/66462
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][Darwin] Remove legacy framework search path logic in the frontend (PR #75841)

2024-01-01 Thread Petr Hosek via cfe-commits

petrhosek wrote:

This appears to have broken the LSan build which is now failing with the 
following error:
```
FAILED: 
compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o
 
/Volumes/Work/s/w/ir/x/w/llvm_build/./bin/clang++ 
--target=x86_64-apple-darwin22.6.0 
--sysroot=/Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk
 -DCOMPILER_RT_SHARED_LIB -D_DEBUG -D_GLIBCXX_ASSERTIONS 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-Dclang_rt_lsan_osx_dynamic_EXPORTS 
-I/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/.. -fPIC 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffile-prefix-map=/Volumes/Work/s/w/ir/x/w/llvm_build/runtimes/runtimes-bins=../../../llvm-llvm-project
 -ffile-prefix-map=/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/= 
-no-canonical-prefixes -Wall -Wno-unused-parameter -O3 -DNDEBUG -std=c++17 
-arch arm64 -arch x86_64 -isysroot 
/Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk
 -fPIC -stdlib=libc++ -mmacosx-version-min=10.10 -isysroot 
/Volumes/Work/s/w/ir/cache/macos_sdk/XCode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk
 -fno-lto -fPIC -fno-builtin -fno-exceptions -funwind-tables 
-fno-stack-protector -fno-sanitize=safe-stack -fvisibility=hidden 
-Wthread-safety -Wthread-safety-reference -Wthread-safety-beta -O3 -g -Wno-gnu 
-Wno-variadic-macros -Wno-c99-extensions -nostdinc++ -fno-rtti -Wno-format -MD 
-MT 
compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o
 -MF 
compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o.d
 -o 
compiler-rt/lib/lsan/CMakeFiles/clang_rt.lsan_osx_dynamic.dir/lsan_malloc_mac.cpp.o
 -c 
/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp
In file included from 
/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/lsan_malloc_mac.cpp:57:
/Volumes/Work/s/w/ir/x/w/llvm-llvm-project/compiler-rt/lib/lsan/../sanitizer_common/sanitizer_malloc_mac.inc:20:10:
 fatal error: 'CoreFoundation/CFBase.h' file not found
   20 | #include 
  |  ^
1 error generated.
```

https://github.com/llvm/llvm-project/pull/75841
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits

https://github.com/jamesg-nz edited 
https://github.com/llvm/llvm-project/pull/76673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits


@@ -366,8 +366,14 @@ bool ContinuationIndenter::mustBreak(const LineState 
) {
   const auto  = State.Stack.back();
   if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore &&
   Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) {
-auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
-return LambdaBodyLength > getColumnLimit(State);
+if (Current.MatchingParen->MustBreakBefore)

jamesg-nz wrote:

I noticed there is code in `TokenAnnotator` than can set `MustBreakBefore` on 
the lambda left brace token:
https://github.com/llvm/llvm-project/blob/0e01c72c5645259d9a08a1a7ed39cb5cc41ce311/clang/lib/Format/TokenAnnotator.cpp#L5297-L5299
Introduced in 37c2233097ac44697b87228d86eef1fce10ea5c1 seemingly for code like 
this:

```cpp
auto select = [this]() -> std::unique_ptr { return 
MyAssignment::SelectFromList(this); }
```

Both before this current PR and here the `MustBreakBefore` state of the token 
is ignored. Should behavior change to observe this and thus force a break?

Would seem the _BraceWrapping.BeforeLambdaBody_ setting would then force lambda 
across multiple lines if on, but not if off.

Should the code in `TokenAnnotator` be changed and maybe only set 
`CanBreakBefore`?

https://github.com/llvm/llvm-project/pull/76673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][LoongArch] Do not pass vector arguments via vector registers (PR #74990)

2024-01-01 Thread Lu Weining via cfe-commits

https://github.com/SixWeining closed 
https://github.com/llvm/llvm-project/pull/74990
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][LoongArch] Do not pass vector arguments via vector registers (PR #74990)

2024-01-01 Thread Lu Weining via cfe-commits

https://github.com/SixWeining approved this pull request.


https://github.com/llvm/llvm-project/pull/74990
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][LoongArch] Do not pass vector arguments via vector registers (PR #74990)

2024-01-01 Thread Lu Weining via cfe-commits

https://github.com/SixWeining edited 
https://github.com/llvm/llvm-project/pull/74990
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][LoongArch] Do not pass vector arguments via vector registers (PR #74990)

2024-01-01 Thread Lu Weining via cfe-commits

https://github.com/SixWeining edited 
https://github.com/llvm/llvm-project/pull/74990
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [PowerPC] Implement fence builtin (PR #76495)

2024-01-01 Thread Chen Zheng via cfe-commits

https://github.com/chenzheng1030 approved this pull request.

LGTM with nits.

https://github.com/llvm/llvm-project/pull/76495
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [PowerPC] Implement fence builtin (PR #76495)

2024-01-01 Thread Chen Zheng via cfe-commits


@@ -944,6 +944,9 @@ TARGET_BUILTIN(__builtin_pack_vector_int128, 
"V1LLLiULLiULLi", "", "vsx")
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Barrier for instruction motion
+BUILTIN(__builtin_ppc_fence, "v", "")

chenzheng1030 wrote:

nit: maybe we can put this builtin around line 100, together with other XL 
Compatibility built-ins.

https://github.com/llvm/llvm-project/pull/76495
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [PowerPC] Implement fence builtin (PR #76495)

2024-01-01 Thread Chen Zheng via cfe-commits

https://github.com/chenzheng1030 edited 
https://github.com/llvm/llvm-project/pull/76495
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [PowerPC] Implement fence builtin (PR #76495)

2024-01-01 Thread Chen Zheng via cfe-commits


@@ -944,6 +944,9 @@ TARGET_BUILTIN(__builtin_pack_vector_int128, 
"V1LLLiULLiULLi", "", "vsx")
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Barrier for instruction motion

chenzheng1030 wrote:

Can we add some comments here to emphasize that `__fence` will stop code motion 
for register based instructions?

https://github.com/llvm/llvm-project/pull/76495
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Avoid printing overly large integer. (PR #75902)

2024-01-01 Thread Nhat Nguyen via cfe-commits
=?utf-8?q?“Nhat?= ,
=?utf-8?q?“Nhat?= ,
=?utf-8?q?“Nhat?= ,
=?utf-8?q?“Nhat?= 
Message-ID:
In-Reply-To: 



@@ -17132,6 +17132,10 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
+  if (V.getInt() > std::numeric_limits::max() ||

changkhothuychung wrote:

@ShamrockLee 

thanks for letting me know! I have moved the code overthere, however it looks 
like there are some failed tests, is it because of my code which causes the 
error? 

https://github.com/llvm/llvm-project/pull/75902
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Fix is spelled in source bug (PR #76668)

2024-01-01 Thread Andrew Schenk via cfe-commits

schenka0 wrote:

I struggled to rebase my changes around some merges and accidently included 
additional changes at one point which triggered the llvmbot to add extra tags. 
Sorry!

https://github.com/llvm/llvm-project/pull/76668
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Fix is spelled in source bug (PR #76668)

2024-01-01 Thread Andrew Schenk via cfe-commits


@@ -813,6 +813,21 @@ TEST(SourceCodeTests, isKeywords) {
   EXPECT_FALSE(isKeyword("override", LangOpts));
 }
 
+TEST(SourceCodeTests, isSpelledInSource) {
+  Annotations Test(R"cpp(
+int abc = 1;
+)cpp");
+
+  ParsedAST AST = TestTU::withCode(Test.code()).build();
+  llvm::errs() << Test.code();

schenka0 wrote:

Thanks for the review. Not familiar with this codebase/standards so was just 
copying surrounding code. I've simplified the test code.

https://github.com/llvm/llvm-project/pull/76668
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Fix is spelled in source bug (PR #76668)

2024-01-01 Thread Andrew Schenk via cfe-commits

https://github.com/schenka0 updated 
https://github.com/llvm/llvm-project/pull/76668

>From fd5e586d807fa4532f26188822ac5790202673bc Mon Sep 17 00:00:00 2001
From: schenka0 <154034018+schen...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 01:31:05 -0500
Subject: [PATCH 1/3] Check for invalid SLocEntry before getting spelling

---
 clang-tools-extra/clangd/SourceCode.cpp   |  7 ++-
 .../clangd/unittests/SourceCodeTests.cpp  | 15 +++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 835038423fdf37..8c573cc6fc064a 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -232,7 +232,12 @@ bool isSpelledInSource(SourceLocation Loc, const 
SourceManager ) {
   if (Loc.isFileID())
 return true;
   auto Spelling = SM.getDecomposedSpellingLoc(Loc);
-  StringRef SpellingFile = SM.getSLocEntry(Spelling.first).getFile().getName();
+  bool InvalidSLocEntry = false;
+  const auto SLocEntry = SM.getSLocEntry(Spelling.first, );
+  if (InvalidSLocEntry) {
+return false;
+  }
+  const StringRef SpellingFile = SLocEntry.getFile().getName();
   if (SpellingFile == "")
 return false;
   if (SpellingFile == "")
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 08abde87df6d4d..5dced4d317c605 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -813,6 +813,21 @@ TEST(SourceCodeTests, isKeywords) {
   EXPECT_FALSE(isKeyword("override", LangOpts));
 }
 
+TEST(SourceCodeTests, isSpelledInSource) {
+  Annotations Test(R"cpp(
+int abc = 1;
+)cpp");
+
+  ParsedAST AST = TestTU::withCode(Test.code()).build();
+  llvm::errs() << Test.code();
+  const SourceManager  = AST.getSourceManager();
+
+  EXPECT_TRUE(
+  isSpelledInSource(SM.getLocForStartOfFile(SM.getMainFileID()), SM));
+  EXPECT_TRUE(isSpelledInSource(SourceLocation(), SM));
+  EXPECT_FALSE(isSpelledInSource(SourceLocation::getFromRawEncoding(-1), SM));
+}
+
 struct IncrementalTestStep {
   llvm::StringRef Src;
   llvm::StringRef Contents;

>From 612c1fea8de7dfea67d5b4fdd23d6f13b9851607 Mon Sep 17 00:00:00 2001
From: schenka0 <154034018+schen...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 11:49:24 -0500
Subject: [PATCH 2/3] Update clang-tools-extra/clangd/SourceCode.cpp

Co-authored-by: Younan Zhang 
---
 clang-tools-extra/clangd/SourceCode.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 8c573cc6fc064a..58a0d142777d00 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -234,9 +234,8 @@ bool isSpelledInSource(SourceLocation Loc, const 
SourceManager ) {
   auto Spelling = SM.getDecomposedSpellingLoc(Loc);
   bool InvalidSLocEntry = false;
   const auto SLocEntry = SM.getSLocEntry(Spelling.first, );
-  if (InvalidSLocEntry) {
+  if (InvalidSLocEntry)
 return false;
-  }
   const StringRef SpellingFile = SLocEntry.getFile().getName();
   if (SpellingFile == "")
 return false;

>From d05e29bb46e2d19317fc667ba37e4549e551496a Mon Sep 17 00:00:00 2001
From: schenka0 <154034018+schen...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 21:49:59 -0500
Subject: [PATCH 3/3] Update invalid SourceLocation in testpoint. Use a value
 with the MSB set to 1 (so it is not a FileID) and the remaining bits 0

Address review feedback on formatting and const
---
 clang-tools-extra/clangd/SourceCode.cpp| 2 +-
 clang-tools-extra/clangd/unittests/SourceCodeTests.cpp | 9 +++--
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 58a0d142777d00..3e741f6e0b536b 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -236,7 +236,7 @@ bool isSpelledInSource(SourceLocation Loc, const 
SourceManager ) {
   const auto SLocEntry = SM.getSLocEntry(Spelling.first, );
   if (InvalidSLocEntry)
 return false;
-  const StringRef SpellingFile = SLocEntry.getFile().getName();
+  StringRef SpellingFile = SLocEntry.getFile().getName();
   if (SpellingFile == "")
 return false;
   if (SpellingFile == "")
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 5dced4d317c605..a8593512578997 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -814,18 +814,15 @@ TEST(SourceCodeTests, isKeywords) {
 }
 
 TEST(SourceCodeTests, isSpelledInSource) {
-  Annotations Test(R"cpp(
-int abc = 1;
-)cpp");
-
+  Annotations Test("");
   ParsedAST AST = 

[clang] [AVR] make the AVR ABI Swift compatible (PR #72298)

2024-01-01 Thread Ben Shi via cfe-commits

benshi001 wrote:

I am not familiar with swift. So is there an official document for the SWIFT 
specific ABI on AVR? I think this is necessary, just like C++: 
https://gcc.gnu.org/wiki/avr-gcc.

And what's more, tests are required to be committed with functional changes, 
this is a requirement for all llvm commits with few exception.

https://github.com/llvm/llvm-project/pull/72298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [llvm] [FuncAttrs] Deduce `noundef` attributes for return values (PR #76553)

2024-01-01 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> Can you please fix or revert 
> https://lab.llvm.org/buildbot/#/builders/74/builds/24592 ?

Should be fixed by 
https://github.com/llvm/llvm-project/commit/7e405eb722e40c79b7726201d0f76b5dab34ba0f.
https://lab.llvm.org/buildbot/#/builders/74/builds/24613

https://github.com/llvm/llvm-project/pull/76553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Avoid printing overly large integer. (PR #75902)

2024-01-01 Thread Nhat Nguyen via cfe-commits
=?utf-8?q?“Nhat?= ,
=?utf-8?q?“Nhat?= ,
=?utf-8?q?“Nhat?= ,
=?utf-8?q?“Nhat?= 
Message-ID:
In-Reply-To: 


https://github.com/changkhothuychung updated 
https://github.com/llvm/llvm-project/pull/75902

>From 4939edb1cb2b73f9c60c4cce0803fab4888beb6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 20:59:26 -0500
Subject: [PATCH 1/5] return false if the value is too large

---
 clang/lib/Sema/SemaDeclCXX.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a3f68d4ffc0f6e..18631ec7dac152 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,6 +17132,9 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
+  if (V.getInt() >= (1 << 64)) {
+return false;
+  }
   uint32_t CodeUnit = static_cast(V.getInt().getZExtValue());
   WriteCharTypePrefix(BTy->getKind(), OS);
   OS << '\'';

>From 1932765f174e187a79144c4fd69657dc7bae480a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 20:59:27 -0500
Subject: [PATCH 2/5] Update clang/lib/Sema/SemaDeclCXX.cpp

Co-authored-by: Yueh-Shun Li 
---
 clang/lib/Sema/SemaDeclCXX.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 18631ec7dac152..196e32a4a349f2 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,7 +17132,7 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
-  if (V.getInt() >= (1 << 64)) {
+  if (V.getInt() > std::numeric_limits::max() || V.getInt() 
< std::numeric_limits::min()) {
 return false;
   }
   uint32_t CodeUnit = static_cast(V.getInt().getZExtValue());

>From 69e21b2bf76b51914f835c74af9e2b3c685ffae0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 20:59:28 -0500
Subject: [PATCH 3/5] clang format

---
 clang/lib/Sema/SemaDeclCXX.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 196e32a4a349f2..323890b38daeec 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,7 +17132,8 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
-  if (V.getInt() > std::numeric_limits::max() || V.getInt() 
< std::numeric_limits::min()) {
+  if (V.getInt() > std::numeric_limits::max() || 
+  V.getInt() < std::numeric_limits::min()) {
 return false;
   }
   uint32_t CodeUnit = static_cast(V.getInt().getZExtValue());

>From ac93beb74cbe6e0cb6383ece6b72b59b00aeca0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 20:59:29 -0500
Subject: [PATCH 4/5] clang format

---
 clang/lib/Sema/SemaDeclCXX.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 323890b38daeec..80e6cd9ee07420 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,7 +17132,7 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
-  if (V.getInt() > std::numeric_limits::max() || 
+  if (V.getInt() > std::numeric_limits::max() ||
   V.getInt() < std::numeric_limits::min()) {
 return false;
   }

>From 35773add17d8b4e884daac0e3e7dc312f1947911 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 21:09:21 -0500
Subject: [PATCH 5/5] move the condition right under toString

---
 clang/lib/Sema/SemaDeclCXX.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 80e6cd9ee07420..d3b68c9aa95645 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,10 +17132,6 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
-  if (V.getInt() > 

[clang] [clang-format] Don't apply severe penalty if no possible column formats (PR #76675)

2024-01-01 Thread James Grant via cfe-commits

jamesg-nz wrote:

> I think that's not the right way to fix the issue.
> 
> Why are the 2 lines formatted differently? It seems to me that this fixes the 
> symptom, not the cause.

Because for the line where brackets are used it meets the condition in the next 
`if` statement down: 
https://github.com/llvm/llvm-project/blob/7e405eb722e40c79b7726201d0f76b5dab34ba0f/clang/lib/Format/FormatToken.cpp#L122

... and a penalty of zero is returned. Similar exclusion exists for 
precomputing the column formats: 
https://github.com/llvm/llvm-project/blob/7e405eb722e40c79b7726201d0f76b5dab34ba0f/clang/lib/Format/FormatToken.cpp#L191

But this ultimately ends up simply as performance optimization as they're never 
considered later in any case.

Whereas if the braces are used instead of brackets it does not meet the _not a 
left brace_ condition, and gets to the severe penalty return: 
https://github.com/llvm/llvm-project/blob/7e405eb722e40c79b7726201d0f76b5dab34ba0f/clang/lib/Format/FormatToken.cpp#L140
 . This is because suitable column formats are not found, as there was less 
than 5 commas found in the list when precomputing the column formats, and so 
none are generated: 
https://github.com/llvm/llvm-project/blob/7e405eb722e40c79b7726201d0f76b5dab34ba0f/clang/lib/Format/FormatToken.cpp#L273

Seems a little odd to return severe penalty if no column formats are available 
as opposed to having them, but none fit right now.

But I'm thinking maybe better to somehow add a condition that if the left brace 
appears within a short lambda body that'll end up on a single line then a 
penalty of zero is also returned. More/better targeted change.

Ultimately I believe comes down to finding a good justification to return zero 
penalty when the braces are used inside lambda bodies. Maybe affects other 
_short_ functions too like inlines - need to check.

https://github.com/llvm/llvm-project/pull/76675
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Avoid printing overly large integer. (PR #75902)

2024-01-01 Thread Nhat Nguyen via cfe-commits
=?utf-8?q?“Nhat?= ,
=?utf-8?q?“Nhat?= ,
=?utf-8?q?“Nhat?= 
Message-ID:
In-Reply-To: 


https://github.com/changkhothuychung updated 
https://github.com/llvm/llvm-project/pull/75902

>From 4939edb1cb2b73f9c60c4cce0803fab4888beb6e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 20:59:26 -0500
Subject: [PATCH 1/4] return false if the value is too large

---
 clang/lib/Sema/SemaDeclCXX.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index a3f68d4ffc0f6e..18631ec7dac152 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,6 +17132,9 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
+  if (V.getInt() >= (1 << 64)) {
+return false;
+  }
   uint32_t CodeUnit = static_cast(V.getInt().getZExtValue());
   WriteCharTypePrefix(BTy->getKind(), OS);
   OS << '\'';

>From 1932765f174e187a79144c4fd69657dc7bae480a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 20:59:27 -0500
Subject: [PATCH 2/4] Update clang/lib/Sema/SemaDeclCXX.cpp

Co-authored-by: Yueh-Shun Li 
---
 clang/lib/Sema/SemaDeclCXX.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 18631ec7dac152..196e32a4a349f2 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,7 +17132,7 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
-  if (V.getInt() >= (1 << 64)) {
+  if (V.getInt() > std::numeric_limits::max() || V.getInt() 
< std::numeric_limits::min()) {
 return false;
   }
   uint32_t CodeUnit = static_cast(V.getInt().getZExtValue());

>From 69e21b2bf76b51914f835c74af9e2b3c685ffae0 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 20:59:28 -0500
Subject: [PATCH 3/4] clang format

---
 clang/lib/Sema/SemaDeclCXX.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 196e32a4a349f2..323890b38daeec 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,7 +17132,8 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
-  if (V.getInt() > std::numeric_limits::max() || V.getInt() 
< std::numeric_limits::min()) {
+  if (V.getInt() > std::numeric_limits::max() || 
+  V.getInt() < std::numeric_limits::min()) {
 return false;
   }
   uint32_t CodeUnit = static_cast(V.getInt().getZExtValue());

>From ac93beb74cbe6e0cb6383ece6b72b59b00aeca0d Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E2=80=9CNhat?= 
Date: Mon, 1 Jan 2024 20:59:29 -0500
Subject: [PATCH 4/4] clang format

---
 clang/lib/Sema/SemaDeclCXX.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 323890b38daeec..80e6cd9ee07420 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -17132,7 +17132,7 @@ static bool ConvertAPValueToString(const APValue , 
QualType T,
 case BuiltinType::WChar_U: {
   unsigned TyWidth = Context.getIntWidth(T);
   assert(8 <= TyWidth && TyWidth <= 32 && "Unexpected integer width");
-  if (V.getInt() > std::numeric_limits::max() || 
+  if (V.getInt() > std::numeric_limits::max() ||
   V.getInt() < std::numeric_limits::min()) {
 return false;
   }

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


[clang] [OpenMP][CodeGen] Improved codegen for combined loop directives (PR #72417)

2024-01-01 Thread David Pagan via cfe-commits

ddpagan wrote:

Ping.

https://github.com/llvm/llvm-project/pull/72417
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-01 Thread Lu Weining via cfe-commits

SixWeining wrote:

LGTM. I have checked with 
https://gcc.gnu.org/onlinedocs/gccint/Machine-Constraints.html. 'G' stands for 
"A floating point constant 0.0". But I'd like to wait others' opinion.

https://github.com/llvm/llvm-project/pull/76561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-01 Thread Ben Shi via cfe-commits

https://github.com/benshi001 edited 
https://github.com/llvm/llvm-project/pull/76561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][AVR] Restrict range of assembly constraint 'G' (PR #76561)

2024-01-01 Thread Ben Shi via cfe-commits

https://github.com/benshi001 updated 
https://github.com/llvm/llvm-project/pull/76561

>From 75164dccb2697ad5468700a9f23a0bc7d8ab49e8 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Fri, 29 Dec 2023 17:58:21 +0800
Subject: [PATCH] [clang][AVR] Restrict range of assembly constraint 'G'

According to https://www.nongnu.org/avr-libc/user-manual/inline_asm.html,
"G" only represents floating point constant '0.0'. And avr-gcc also
rejects other non-zero FP values.
---
 clang/lib/Basic/Targets/AVR.h | 4 +++-
 clang/test/CodeGen/avr/avr-inline-asm-constraints.c   | 4 ++--
 .../test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c | 1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/clang/lib/Basic/Targets/AVR.h b/clang/lib/Basic/Targets/AVR.h
index 854a51d78c393b..9376c46cd98ca1 100644
--- a/clang/lib/Basic/Targets/AVR.h
+++ b/clang/lib/Basic/Targets/AVR.h
@@ -146,7 +146,9 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public 
TargetInfo {
 case 'R': // Integer constant (Range: -6 to 5)
   Info.setRequiresImmediate(-6, 5);
   return true;
-case 'G': // Floating point constant
+case 'G': // Floating point constant 0.0
+  Info.setRequiresImmediate(0);
+  return true;
 case 'Q': // A memory address based on Y or Z pointer with displacement.
   return true;
 }
diff --git a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
index 96774861feb228..3a956de8db48f0 100644
--- a/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-inline-asm-constraints.c
@@ -109,8 +109,8 @@ void R() {
 }
 
 void G() {
-  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 50)
-  asm("subi r30, %0" :: "G"(50));
+  // CHECK: call addrspace(0) void asm sideeffect "subi r30, $0", "G"(i16 0)
+  asm("subi r30, %0" :: "G"(0));
 }
 
 void Q() {
diff --git a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c 
b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
index ceea59229f736a..29f0b69285fa88 100644
--- a/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
+++ b/clang/test/CodeGen/avr/avr-unsupported-inline-asm-constraints.c
@@ -5,4 +5,5 @@ const unsigned char val = 0;
 int foo(void) {
   __asm__ volatile("foo %0, 1" : : "fo" (val)); // expected-error {{invalid 
input constraint 'fo' in asm}}
   __asm__ volatile("foo %0, 1" : : "Nd" (val)); // expected-error {{invalid 
input constraint 'Nd' in asm}}
+  __asm__ volatile("subi r30, %0" : : "G" (1)); // expected-error {{value '1' 
out of range for constraint 'G'}}
 }

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


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-01 Thread Ben Shi via cfe-commits

benshi001 wrote:

> LGTM

Thanks for your help!

https://github.com/llvm/llvm-project/pull/76671
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits


@@ -22965,6 +22965,84 @@ TEST_F(FormatTest, EmptyLinesInLambdas) {
"};");
 }
 
+TEST_F(FormatTest, BreakBeforeLambdaBodyWrapping) {
+  verifyFormat("connect([]() {\n"
+   "  foo();\n"
+   "  bar();\n"
+   "});");
+
+  auto Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeLambdaBody = true;
+
+  verifyFormat("connect(\n"
+   "[]()\n"
+   "{\n"
+   "  foo();\n"
+   "  bar();\n"
+   "});",
+   Style);
+
+  for (unsigned l : {0, 41}) {

jamesg-nz wrote:

Now testing ColumnLimit = 0 once separately. Unrolled remaining loop (that 
doesn't test = 0) into two verifications.

Loops make it hard to see in test results for what value it is failing for, I 
guess. Although saw other people had used them in that file.

https://github.com/llvm/llvm-project/pull/76673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread James Grant via cfe-commits

https://github.com/jamesg-nz updated 
https://github.com/llvm/llvm-project/pull/76673

>From 04885844162b5390d8041a44a1895ad6ac160228 Mon Sep 17 00:00:00 2001
From: James Grant <42079499+jamesg...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 20:27:41 +1300
Subject: [PATCH 1/2] [clang-format] Fix erroneous
 BraceWrapping.BeforeLambdaBody column calcs

Firstly, must check ColumnLimit > 0 before comparing calculated columns
to the limit. Otherwise it always breaks before the brace if ColumnLimit
= 0 (no limit). Fixes #50275

Secondly, the lambda body length alone is currently compared with the
column limit. Should instead be comparing a column position, which
includes everything before the lambda body, the body length itself, and
any unbreakable tail. Fixes #59724

Thirdly, if must break before the lambda right brace, e.g. line comment
in body, then must also break before the left brace. Can't use column
calculation in this instance.
---
 clang/lib/Format/ContinuationIndenter.cpp | 10 ++-
 clang/unittests/Format/FormatTest.cpp | 78 +++
 2 files changed, 86 insertions(+), 2 deletions(-)

diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index 102504182c4505..f4f8b694f7ff51 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -366,8 +366,14 @@ bool ContinuationIndenter::mustBreak(const LineState 
) {
   const auto  = State.Stack.back();
   if (Style.BraceWrapping.BeforeLambdaBody && Current.CanBreakBefore &&
   Current.is(TT_LambdaLBrace) && Previous.isNot(TT_LineComment)) {
-auto LambdaBodyLength = getLengthToMatchingParen(Current, State.Stack);
-return LambdaBodyLength > getColumnLimit(State);
+if (Current.MatchingParen->MustBreakBefore)
+  return true;
+
+auto LambdaEnd = getLengthToMatchingParen(Current, State.Stack) +
+ Current.MatchingParen->UnbreakableTailLength +
+ State.Column - 1;
+
+return Style.ColumnLimit > 0 && LambdaEnd > getColumnLimit(State);
   }
   if (Current.MustBreakBefore ||
   (Current.is(TT_InlineASMColon) &&
diff --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 881993ede17c3d..f5aadec3500ccb 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -22965,6 +22965,84 @@ TEST_F(FormatTest, EmptyLinesInLambdas) {
"};");
 }
 
+TEST_F(FormatTest, BreakBeforeLambdaBodyWrapping) {
+  verifyFormat("connect([]() {\n"
+   "  foo();\n"
+   "  bar();\n"
+   "});");
+
+  auto Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeLambdaBody = true;
+
+  verifyFormat("connect(\n"
+   "[]()\n"
+   "{\n"
+   "  foo();\n"
+   "  bar();\n"
+   "});",
+   Style);
+
+  for (unsigned l : {0, 41}) {
+Style.ColumnLimit = l;
+verifyFormat("auto lambda = []() { return foo + bar; };", Style);
+  }
+  for (unsigned l : {40, 22}) {
+Style.ColumnLimit = l;
+verifyFormat("auto lambda = []()\n"
+ "{ return foo + bar; };",
+ Style);
+  }
+  Style.ColumnLimit = 21;
+  verifyFormat("auto lambda = []()\n"
+   "{\n"
+   "  return foo + bar;\n"
+   "};",
+   Style);
+
+  for (unsigned l : {0, 67}) {
+Style.ColumnLimit = l;
+verifyFormat(
+"auto result = [](int foo, int bar) { return foo + bar; }(foo, bar);",
+Style);
+  }
+  Style.ColumnLimit = 66;
+  verifyFormat("auto result = [](int foo, int bar)\n"
+   "{ return foo + bar; }(foo, bar);",
+   Style);
+
+  Style.ColumnLimit = 36;
+  verifyFormat("myFunc([&]() { return foo + bar; });", Style);
+  Style.ColumnLimit = 35;
+  verifyFormat("myFunc([&]()\n"
+   "   { return foo + bar; });",
+   Style);
+
+  Style = getGoogleStyleWithColumns(100);
+  Style.BreakBeforeBraces = FormatStyle::BS_Allman;
+  Style.IndentWidth = 4;
+  verifyFormat(
+  "void Func()\n"
+  "{\n"
+  "[]()\n"
+  "{\n"
+  "return TestVeryLongThingName::TestVeryLongFunctionName()\n"
+  ".TestAnotherVeryVeryLongFunctionName();\n"
+  "}\n"
+  "}\n",
+  Style);
+  verifyFormat(
+  "void Func()\n"
+  "{\n"
+  "[]()\n"
+  "{\n"
+  "return TestVeryLongThingName::TestVeryLongFunctionName()\n"
+  ".TestAnotherVeryVeryVeryLongFunctionName();\n"
+  "}\n"
+  "}\n",
+  Style);
+}
+
 TEST_F(FormatTest, FormatsBlocks) {
   FormatStyle ShortBlocks = getLLVMStyle();
   ShortBlocks.AllowShortBlocksOnASingleLine = FormatStyle::SBS_Always;

>From 346e7da1f6eb184f7fc5212af94f5e7c83d5a494 Mon Sep 17 00:00:00 2001
From: James Grant 

[lld] [llvm] [clang] [FuncAttrs] Deduce `noundef` attributes for return values (PR #76553)

2024-01-01 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> > Yeah, we should skip this inference for functions with the sanitize_memory 
> > attribute.
> 
> I will post a patch later.

Candidate patch: https://github.com/llvm/llvm-project/pull/76691

https://github.com/llvm/llvm-project/pull/76553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [AVR] make the AVR ABI Swift compatible (PR #72298)

2024-01-01 Thread John McCall via cfe-commits

rjmccall wrote:

> That makes a lot of sense. Thank you John. I guess here are my thoughts. As I 
> understand it, the `SwiftABIInfo` by default does something like "if 
> something can be passed in 4 registers or fewer then pass by register, 
> otherwise pass indirectly"? I think that sweet spot (also sort of reflected 
> in Existential Containers I believe?) makes sense for 32 bit or 64 bit 
> registers (and presumably the sorts of caching you'd expect in modern 
> intel/arm larger machine architectures). We have 8 bit registers, which is 
> quite different...

Yes, I see.  Pointers are 16-bit and would be passed in two registers, right?  
You need to do more accurate counting than the default implementation.  The 
default implementation breaks up "large" integers (also specified by the ABI) 
when determining the scalar sequence, and then it assumes that all scalars 
count the same towards the limit.  You probably want to keep e.g. `i16`s and 
`ptr`s in the scalar sequence instead of splitting them into `i8`s, but you 
want to count them properly as two registers rather than one.  And then, yeah, 
maybe it makes sense to put the cap at something like 6 or even 4 registers.

> In our case, one complication is stack manipulation is fairly painful, we may 
> be able to improve the AVR back end a bit but at the moment, just moving the 
> stack pointer down for something like an alloca is 8 instructions (and then 
> again 8 bytes in the function epilog).

On most architectures, functions that include calls will need to perform a 
stack adjustment on entry anyway — at the very least, for the function's own 
frame — but you don't need an extra adjustment for individual call sites 
because you include space for the maximum stack argument space usage of all the 
calls in the function in that initial adjustment.  Is that not how it's done on 
AVR?

> But, equally, the default C ABI (avr gcc abi) allows a struct to be split 
> over as many as 18 registers, and we are often producing pretty inefficient 
> code like this when we have large structs, moving registers around a lot 
> either side of a call site. Which is something I really wanted to find a way 
> to solve "one day" with Swift for Arduino/Microswift/Swift for AVR.

Yeah, 18 registers seems like it'd be way higher than you want.  I usually 
approach this from a code-size optimization perspective.  Passing in registers 
is great in the ideal situation: the caller is able to efficiently produce the 
argument into whatever argument register is convenient (e.g. loading, or 
loading an immediate, or taking the address of a local variable), and the 
callee is going to immediately use the component values of argument in whatever 
register it came in.  When that *isn't* true, you don't want passing in 
registers to be a highly punitive mistake.  That's why the cap is normally 
expressed in terms of the number of scalars involved rather than the size of 
the data: the assumption is that each scalar will require a separate load/store 
if we're not in the ideal case.  And for ISAs like AVR with non-orthogonal 
register use, I feel like the chances that taking complex data in registers 
will be useful to the callee are somewhat lower; and if spilling an argument to 
the stack retroactively is expensive, that also changes the balance.  So having 
a relatively low cap seems like the right thing to do.

> Probably it's reasonable to say that ideally, when lowering to AVR assembly 
> from Swift, any struct larger than 8 bytes should be passed on the stack in 
> our case. Do you think we can implement that?

It's important to distinguish the three ways of passing an argument: you can 
pass it in registers, you can pass it in the stack argument area, and you can 
pass a pointer to it.  I am generally of the opinion that passing arguments in 
the stack argument area is a waste and should only be used if you don't have a 
better choice available, e.g. because you have too many arguments and you've 
run out of registers.  This is because you usually can't forward such an 
argument efficiently: you have to copy it into a *new* stack argument area for 
the next call.  So the Swift CC usually says that if an argument is too big for 
the cap, it gets passed by pointer.

So I guess it depends on what you mean by "passed on the stack".  I would not 
recommend passing in the stack argument area.  But triggering pass-by-pointer 
on relatively small structures makes sense to me.

https://github.com/llvm/llvm-project/pull/72298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [lld] [clang] [FuncAttrs] Deduce `noundef` attributes for return values (PR #76553)

2024-01-01 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> Yeah, we should skip this inference for functions with the sanitize_memory 
> attribute.

I will post a patch later.

https://github.com/llvm/llvm-project/pull/76553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [lld] [FuncAttrs] Deduce `noundef` attributes for return values (PR #76553)

2024-01-01 Thread Nikita Popov via cfe-commits

nikic wrote:

Yeah, we should skip this inference for functions with the sanitize_memory 
attribute.

https://github.com/llvm/llvm-project/pull/76553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [lld] [FuncAttrs] Deduce `noundef` attributes for return values (PR #76553)

2024-01-01 Thread Yingwei Zheng via cfe-commits

dtcxzyw wrote:

> Can you please fix or revert 
> https://lab.llvm.org/buildbot/#/builders/74/builds/24592 ?

Thank you for reporting this! I will check the error log.


https://github.com/llvm/llvm-project/pull/76553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [lld] [FuncAttrs] Deduce `noundef` attributes for return values (PR #76553)

2024-01-01 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Another problem is that there was assumption that definition and declaration 
will be consistent, for msan is a part of ABI.
Clang will generate them consistently for all modules, with declaration and 
definition of the function.

Is possible that after this patch some definitions will get noundef, but 
declarations in other modules will still have none? If that is so, it breaks 
msan.

https://github.com/llvm/llvm-project/pull/76553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [clang] [lld] [FuncAttrs] Deduce `noundef` attributes for return values (PR #76553)

2024-01-01 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

```
This patch deduces noundef attributes for return values.
IIUC, a function returns noundef values iff all of its return values are 
guaranteed not to be undef or poison.
```

https://github.com/llvm/llvm-project/pull/76553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [lld] [FuncAttrs] Deduce `noundef` attributes for return values (PR #76553)

2024-01-01 Thread Vitaly Buka via cfe-commits

vitalybuka wrote:

Can you please fix or revert 
https://lab.llvm.org/buildbot/#/builders/74/builds/24592 ?

https://github.com/llvm/llvm-project/pull/76553
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Take small objects by value (PR #76688)

2024-01-01 Thread Balazs Benics via cfe-commits

https://github.com/steakhal closed 
https://github.com/llvm/llvm-project/pull/76688
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Take small objects by value (PR #76688)

2024-01-01 Thread Balazs Benics via cfe-commits

steakhal wrote:

Pushed as 7619050cd7c3715f34c1d13ea048c092299037bb and 
8ee3dfd74653e30f48dd9f49ba24f43547e6a549 respectively.

https://github.com/llvm/llvm-project/pull/76688
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 8ee3dfd - [analyzer][NFC] Take SVal and NonLoc by value

2024-01-01 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2024-01-01T22:00:32+01:00
New Revision: 8ee3dfd74653e30f48dd9f49ba24f43547e6a549

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

LOG: [analyzer][NFC] Take SVal and NonLoc by value

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/Checker.h
clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp
clang/lib/StaticAnalyzer/Checkers/Iterator.cpp
clang/lib/StaticAnalyzer/Checkers/Iterator.h
clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp
clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
clang/lib/StaticAnalyzer/Checkers/TaggedUnionModeling.h
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h

clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
clang/lib/StaticAnalyzer/Core/Environment.cpp
clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/Checker.h 
b/clang/include/clang/StaticAnalyzer/Core/Checker.h
index 8a46282a595eae..2ec54a837c42c9 100644
--- a/clang/include/clang/StaticAnalyzer/Core/Checker.h
+++ b/clang/include/clang/StaticAnalyzer/Core/Checker.h
@@ -193,9 +193,8 @@ class PostCall {
 
 class Location {
   template 
-  static void _checkLocation(void *checker,
- const SVal , bool isLoad, const Stmt *S,
- CheckerContext ) {
+  static void _checkLocation(void *checker, SVal location, bool isLoad,
+ const Stmt *S, CheckerContext ) {
 ((const CHECKER *)checker)->checkLocation(location, isLoad, S, C);
   }
 
@@ -209,8 +208,7 @@ class Location {
 
 class Bind {
   template 
-  static void _checkBind(void *checker,
- const SVal , const SVal , const Stmt *S,
+  static void _checkBind(void *checker, SVal location, SVal val, const Stmt *S,
  CheckerContext ) {
 ((const CHECKER *)checker)->checkBind(location, val, S, C);
   }
@@ -456,10 +454,8 @@ namespace eval {
 
 class Assume {
   template 
-  static ProgramStateRef _evalAssume(void *checker,
- ProgramStateRef state,
- const SVal ,
- bool assumption) {
+  static ProgramStateRef _evalAssume(void *checker, ProgramStateRef state,
+ SVal cond, bool assumption) {
 return ((const CHECKER *)checker)->evalAssume(state, cond, assumption);
   }
 

diff  --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
index 39583c443eda54..a45ba1bc573e1e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -488,13 +488,11 @@ class CheckerManager {
   using CheckCallFunc =
   CheckerFn;
 
-  using CheckLocationFunc =
-  CheckerFn;
+  using CheckLocationFunc = CheckerFn;
 
   using CheckBindFunc =
-  CheckerFn;
+  CheckerFn;
 
   using CheckEndAnalysisFunc =
   CheckerFn;
@@ -530,8 +528,7 @@ class CheckerManager {
  RegionAndSymbolInvalidationTraits *ITraits)>;
 
   using EvalAssumeFunc =
-  CheckerFn;
+  CheckerFn;
 
   using EvalCallFunc = CheckerFn;
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
index ea74256935ca87..f2e1f69c32cfdc 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -125,9 +125,8 @@ class CallAndMessageChecker
 if (!BT)
   BT.reset(new BugType(OriginalName, desc));
   }
-  bool uninitRefOrPointer(CheckerContext , const SVal ,
-  SourceRange ArgRange, const Expr *ArgEx,
-  std::unique_ptr ,
+  bool uninitRefOrPointer(CheckerContext , SVal V, SourceRange ArgRange,
+  const Expr *ArgEx, std::unique_ptr ,
   const ParmVarDecl *ParamDecl, const char *BD,
   int ArgumentNumber) const;
 };
@@ -185,7 +184,7 @@ static void describeUninitializedArgumentInCall(const 
CallEvent ,
 }
 
 bool CallAndMessageChecker::uninitRefOrPointer(
-CheckerContext , const SVal , SourceRange ArgRange, const Expr *ArgEx,
+CheckerContext , SVal V, SourceRange ArgRange, const Expr *ArgEx,
 std::unique_ptr , const ParmVarDecl 

[clang] 7619050 - [analyzer][NFC] Take StringRef by value

2024-01-01 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2024-01-01T22:00:32+01:00
New Revision: 7619050cd7c3715f34c1d13ea048c092299037bb

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

LOG: [analyzer][NFC] Take StringRef by value

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
index f966ea63da2181..f9263f439b1e3d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -43,7 +43,7 @@ class IteratorRangeChecker
   void verifyAdvance(CheckerContext , SVal LHS, SVal RHS) const;
   void verifyPrev(CheckerContext , SVal LHS, SVal RHS) const;
   void verifyNext(CheckerContext , SVal LHS, SVal RHS) const;
-  void reportBug(const StringRef , SVal Val, CheckerContext ,
+  void reportBug(StringRef Message, SVal Val, CheckerContext ,
  ExplodedNode *ErrNode) const;
 
 public:
@@ -269,7 +269,7 @@ void IteratorRangeChecker::verifyNext(CheckerContext , 
SVal LHS,
   verifyRandomIncrOrDecr(C, OO_Plus, LHS, RHS);
 }
 
-void IteratorRangeChecker::reportBug(const StringRef , SVal Val,
+void IteratorRangeChecker::reportBug(StringRef Message, SVal Val,
  CheckerContext ,
  ExplodedNode *ErrNode) const {
   auto R = std::make_unique(OutOfRangeBugType, Message,

diff  --git a/clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
index 38f80ba5e1ff39..8116105a50eb08 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
@@ -38,12 +38,10 @@ class MismatchedIteratorChecker
const MemRegion *Cont) const;
   void verifyMatch(CheckerContext , const SVal ,
const SVal ) const;
-  void reportBug(const StringRef , const SVal ,
- const SVal , CheckerContext ,
- ExplodedNode *ErrNode) const;
-  void reportBug(const StringRef , const SVal ,
- const MemRegion *Reg, CheckerContext ,
- ExplodedNode *ErrNode) const;
+  void reportBug(StringRef Message, const SVal , const SVal ,
+ CheckerContext , ExplodedNode *ErrNode) const;
+  void reportBug(StringRef Message, const SVal , const MemRegion *Reg,
+ CheckerContext , ExplodedNode *ErrNode) const;
 
 public:
   void checkPreCall(const CallEvent , CheckerContext ) const;
@@ -271,10 +269,8 @@ void MismatchedIteratorChecker::verifyMatch(CheckerContext 
,
   }
 }
 
-void MismatchedIteratorChecker::reportBug(const StringRef ,
-  const SVal ,
-  const SVal ,
-  CheckerContext ,
+void MismatchedIteratorChecker::reportBug(StringRef Message, const SVal ,
+  const SVal , CheckerContext ,
   ExplodedNode *ErrNode) const {
   auto R = std::make_unique(MismatchedBugType, Message,
 ErrNode);
@@ -283,8 +279,8 @@ void MismatchedIteratorChecker::reportBug(const StringRef 
,
   C.emitReport(std::move(R));
 }
 
-void MismatchedIteratorChecker::reportBug(const StringRef ,
-  const SVal , const MemRegion 
*Reg,
+void MismatchedIteratorChecker::reportBug(StringRef Message, const SVal ,
+  const MemRegion *Reg,
   CheckerContext ,
   ExplodedNode *ErrNode) const {
   auto R = std::make_unique(MismatchedBugType, Message,



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


[lldb] [llvm] [openmp] [libc] [libcxx] [clang-tools-extra] [mlir] [flang] [clang] [compiler-rt] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,136 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr void testSpanAt(auto span, int idx, int expectedValue) {
+  // non-const
+  {
+std::same_as decltype(auto) elem = 
span.at(idx);
+assert(elem == expectedValue);
+  }
+
+  // const
+  {
+std::same_as decltype(auto) elem = 
std::as_const(span).at(idx);
+assert(elem == expectedValue);
+  }
+}
+
+constexpr bool test() {
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084};
+std::span arrSpan{arr};
+
+assert(std::dynamic_extent != arrSpan.extent);
+
+testSpanAt(arrSpan, 0, 0);
+testSpanAt(arrSpan, 1, 1);
+testSpanAt(arrSpan, 6, 9084);
+  }
+
+  // With dynamic extent
+  {
+std::vector vec{0, 1, 2, 3, 4, 5, 9084};
+std::span vecSpan{vec};
+
+assert(std::dynamic_extent == vecSpan.extent);
+
+testSpanAt(vecSpan, 0, 0);
+testSpanAt(vecSpan, 1, 1);
+testSpanAt(vecSpan, 6, 9084);
+  }
+
+  return true;
+}
+
+void test_exceptions() {

H-G-Hristov wrote:

Sorry, I missed your comment!

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lldb] [llvm] [openmp] [libc] [libcxx] [clang-tools-extra] [mlir] [flang] [clang] [compiler-rt] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/74994

>From 6e26ca239c49e1b7d9ab72217db7339e92df163f Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sun, 10 Dec 2023 14:16:02 +0200
Subject: [PATCH 01/18] [libc++][span] P2821R5: span.at()

---
 libcxx/include/span   |  30 +++
 .../views/views.span/span.elem/at.pass.cpp| 246 ++
 .../views.span/span.elem/op_idx.pass.cpp  |   1 -
 3 files changed, 276 insertions(+), 1 deletion(-)
 create mode 100644 
libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp

diff --git a/libcxx/include/span b/libcxx/include/span
index 69b0a2875e26cc..b015d7cf1c15b6 100644
--- a/libcxx/include/span
+++ b/libcxx/include/span
@@ -92,6 +92,7 @@ public:
 
 // [span.elem], span element access
 constexpr reference operator[](size_type idx) const;
+constexpr reference at(size_type idx) const; // since C++26
 constexpr reference front() const;
 constexpr reference back() const;
 constexpr pointer data() const noexcept;
@@ -146,6 +147,9 @@ template
 #include <__utility/forward.h>
 #include // for array
 #include   // for byte
+#if _LIBCPP_STD_VER >= 26
+#  include 
+#endif
 #include 
 
 // standard-mandated includes
@@ -343,6 +347,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -383,6 +396,10 @@ public:
 
 private:
 pointer__data_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 
@@ -510,6 +527,15 @@ public:
 return __data_[__idx];
 }
 
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_HIDE_FROM_ABI constexpr reference at(size_type __idx) const {
+  if (__idx >= size()) {
+__throw_out_of_range();
+  }
+  return *(data() + __idx);
+}
+#  endif
+
 _LIBCPP_INLINE_VISIBILITY constexpr reference front() const noexcept
 {
 _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(!empty(), "span::front() on 
empty span");
@@ -552,6 +578,10 @@ public:
 private:
 pointer   __data_;
 size_type __size_;
+
+#  if _LIBCPP_STD_VER >= 26
+_LIBCPP_NORETURN _LIBCPP_HIDE_FROM_ABI void __throw_out_of_range() const { 
std::__throw_out_of_range("span"); }
+#  endif
 };
 
 template 
diff --git a/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp 
b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
new file mode 100644
index 00..2a9ce2baeec1a5
--- /dev/null
+++ b/libcxx/test/std/containers/views/views.span/span.elem/at.pass.cpp
@@ -0,0 +1,246 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+// template 
+// constexpr bool testConstexprSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// return r1 == r2;
+// }
+
+// template 
+// void testRuntimeSpan(Span sp, std::size_t idx)
+// {
+// LIBCPP_ASSERT(noexcept(sp[idx]));
+
+// typename Span::reference r1 = sp[idx];
+// typename Span::reference r2 = *(sp.data() + idx);
+
+// assert(r1 == r2);
+// }
+
+// struct A{};
+// constexpr int iArr1[] = { 0,  1,  2,  3,  4,  5,  6,  7,  8,  9};
+//   int iArr2[] = {10, 11, 12, 13, 14, 15, 16, 17, 18, 19};
+
+// int main(int, char**)
+// {
+// static_assert(testConstexprSpan(std::span(iArr1, 1), 0), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 2), 1), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 3), 2), "");
+
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 0), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 1), "");
+// static_assert(testConstexprSpan(std::span(iArr1, 4), 2), "");
+// 

[clang] [clang] Fix clang++ crash on assertions when compiling source (PR #70594)

2024-01-01 Thread Rajveer Singh Bharadwaj via cfe-commits

Rajveer100 wrote:

@cor3ntin 
Could you help me in closing this?

https://github.com/llvm/llvm-project/pull/70594
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Take small objects by value (PR #76688)

2024-01-01 Thread Gábor Horváth via cfe-commits

https://github.com/Xazax-hun approved this pull request.

LGTM! Thanks!

https://github.com/llvm/llvm-project/pull/76688
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-01 Thread Balazs Benics via cfe-commits

https://github.com/steakhal approved this pull request.

LGTM

https://github.com/llvm/llvm-project/pull/76671
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp' (PR #76671)

2024-01-01 Thread Balazs Benics via cfe-commits

https://github.com/steakhal updated 
https://github.com/llvm/llvm-project/pull/76671

>From 0c586914ac977920140472d172ee357dea43f2c5 Mon Sep 17 00:00:00 2001
From: Ben Shi 
Date: Mon, 1 Jan 2024 18:48:27 +0800
Subject: [PATCH 1/2] [clang][analyzer] Improve 'errno' modeling of 'mkdtemp'

---
 .../Checkers/StdLibraryFunctionsChecker.cpp   |  6 ++--
 .../test/Analysis/errno-stdlibraryfunctions.c | 29 +++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
index 4ca49b9c0546d9..6f249b6b880283 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
@@ -2511,10 +2511,12 @@ void StdLibraryFunctionsChecker::initFunctionSummaries(
 .ArgConstraint(NotNull(ArgNo(0;
 
 // char *mkdtemp(char *template);
-// FIXME: Improve for errno modeling.
 addToFunctionSummaryMap(
 "mkdtemp", Signature(ArgTypes{CharPtrTy}, RetType{CharPtrTy}),
-Summary(NoEvalCall).ArgConstraint(NotNull(ArgNo(0;
+Summary(NoEvalCall)
+.Case({NotNull(Ret)}, ErrnoMustNotBeChecked, GenericSuccessMsg)
+.Case({IsNull(Ret)}, ErrnoNEZeroIrrelevant, GenericFailureMsg)
+.ArgConstraint(NotNull(ArgNo(0;
 
 // char *getcwd(char *buf, size_t size);
 // FIXME: Improve for errno modeling.
diff --git a/clang/test/Analysis/errno-stdlibraryfunctions.c 
b/clang/test/Analysis/errno-stdlibraryfunctions.c
index dafda764af9f38..de31de8cfea39b 100644
--- a/clang/test/Analysis/errno-stdlibraryfunctions.c
+++ b/clang/test/Analysis/errno-stdlibraryfunctions.c
@@ -7,12 +7,9 @@
 // RUN:   -analyzer-config unix.StdCLibraryFunctions:ModelPOSIX=true
 
 #include "Inputs/errno_var.h"
+#include "Inputs/std-c-library-functions-POSIX.h"
 
-typedef typeof(sizeof(int)) size_t;
-typedef __typeof(sizeof(int)) off_t;
-typedef size_t ssize_t;
-ssize_t send(int sockfd, const void *buf, size_t len, int flags);
-off_t lseek(int fildes, off_t offset, int whence);
+#define NULL ((void *) 0)
 
 void clang_analyzer_warnIfReached();
 void clang_analyzer_eval(int);
@@ -54,3 +51,25 @@ int errno_lseek(int fildes, off_t offset) {
   }
   return 0;
 }
+
+void errno_mkstemp(char *template) {
+  int FD = mkstemp(template);
+  if (FD >= 0) {
+if (errno) {}// expected-warning{{An undefined value 
may be read from 'errno'}}
+close(FD);
+  } else {
+clang_analyzer_eval(FD == -1);   // expected-warning{{TRUE}}
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+if (errno) {}// no warning
+  }
+}
+
+void errno_mkdtemp(char *template) {
+  char *Dir = mkdtemp(template);
+  if (Dir == NULL) {
+clang_analyzer_eval(errno != 0); // expected-warning{{TRUE}}
+if (errno) {}// no warning
+  } else {
+if (errno) {}// expected-warning{{An undefined value 
may be read from 'errno'}}
+  }
+}

>From c24e09d2108ebe4da92e100aa7f8d3a53ef8f326 Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Mon, 1 Jan 2024 19:12:57 +0100
Subject: [PATCH 2/2] Add to the release notes

---
 clang/docs/ReleaseNotes.rst | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 0c8fec691bf3c9..ffe482f16e2fbe 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1127,11 +1127,12 @@ Improvements
 
 
 - Improved the ``unix.StdCLibraryFunctions`` checker by modeling more
-  functions like ``send``, ``recv``, ``readlink``, ``fflush`` and
-  ``errno`` behavior.
+  functions like ``send``, ``recv``, ``readlink``, ``fflush``, ``mkdtemp``
+  and ``errno`` behavior.
   (`52ac71f92d38 
`_,
   `#71373 `_,
   `#76557 `_,
+  `#76671 `_,
   `#71392 `_)
 
 - Fixed a false negative for when accessing a nonnull property (ObjC).

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


[lld] [llvm] [clang] [mlir] [libcxx] [flang] [analyzer][NFC] Cleanup BugType lazy-init patterns (PR #76655)

2024-01-01 Thread Balazs Benics via cfe-commits


@@ -31,14 +31,14 @@ class InvalidatedIteratorChecker
check::PreStmt,
check::PreStmt> {
 
-  std::unique_ptr InvalidatedBugType;
+  const BugType InvalidatedBugType{this, "Iterator invalidated",
+   "Misuse of STL APIs"};
 
   void verifyAccess(CheckerContext , const SVal ) const;
-  void reportBug(const StringRef , const SVal ,
- CheckerContext , ExplodedNode *ErrNode) const;
-public:
-  InvalidatedIteratorChecker();
+  void reportBug(const StringRef , const SVal , CheckerContext ,

steakhal wrote:

Followup PR for the analyzer-wide refactor: #76688

https://github.com/llvm/llvm-project/pull/76655
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Take small objects by value (PR #76688)

2024-01-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-static-analyzer-1

Author: Balazs Benics (steakhal)


Changes



---

Patch is 28.26 KiB, truncated to 20.00 KiB below, full version: 
https://github.com/llvm/llvm-project/pull/76688.diff


14 Files Affected:

- (modified) clang/include/clang/StaticAnalyzer/Core/Checker.h (+5-9) 
- (modified) clang/include/clang/StaticAnalyzer/Core/CheckerManager.h (+4-7) 
- (modified) clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp (+4-5) 
- (modified) clang/lib/StaticAnalyzer/Checkers/InvalidatedIteratorChecker.cpp 
(+3-2) 
- (modified) clang/lib/StaticAnalyzer/Checkers/Iterator.cpp (+6-8) 
- (modified) clang/lib/StaticAnalyzer/Checkers/Iterator.h (+6-9) 
- (modified) clang/lib/StaticAnalyzer/Checkers/IteratorModeling.cpp (+23-26) 
- (modified) clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp (+4-4) 
- (modified) clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp 
(+12-19) 
- (modified) clang/lib/StaticAnalyzer/Checkers/TaggedUnionModeling.h (+1-1) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObject.h 
(+1-1) 
- (modified) 
clang/lib/StaticAnalyzer/Checkers/UninitializedObject/UninitializedObjectChecker.cpp
 (+1-1) 
- (modified) clang/lib/StaticAnalyzer/Core/Environment.cpp (+1-1) 
- (modified) clang/lib/StaticAnalyzer/Core/RegionStore.cpp (+3-3) 


``diff
diff --git a/clang/include/clang/StaticAnalyzer/Core/Checker.h 
b/clang/include/clang/StaticAnalyzer/Core/Checker.h
index 8a46282a595eae..2ec54a837c42c9 100644
--- a/clang/include/clang/StaticAnalyzer/Core/Checker.h
+++ b/clang/include/clang/StaticAnalyzer/Core/Checker.h
@@ -193,9 +193,8 @@ class PostCall {
 
 class Location {
   template 
-  static void _checkLocation(void *checker,
- const SVal , bool isLoad, const Stmt *S,
- CheckerContext ) {
+  static void _checkLocation(void *checker, SVal location, bool isLoad,
+ const Stmt *S, CheckerContext ) {
 ((const CHECKER *)checker)->checkLocation(location, isLoad, S, C);
   }
 
@@ -209,8 +208,7 @@ class Location {
 
 class Bind {
   template 
-  static void _checkBind(void *checker,
- const SVal , const SVal , const Stmt *S,
+  static void _checkBind(void *checker, SVal location, SVal val, const Stmt *S,
  CheckerContext ) {
 ((const CHECKER *)checker)->checkBind(location, val, S, C);
   }
@@ -456,10 +454,8 @@ namespace eval {
 
 class Assume {
   template 
-  static ProgramStateRef _evalAssume(void *checker,
- ProgramStateRef state,
- const SVal ,
- bool assumption) {
+  static ProgramStateRef _evalAssume(void *checker, ProgramStateRef state,
+ SVal cond, bool assumption) {
 return ((const CHECKER *)checker)->evalAssume(state, cond, assumption);
   }
 
diff --git a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h 
b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
index 39583c443eda54..a45ba1bc573e1e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
+++ b/clang/include/clang/StaticAnalyzer/Core/CheckerManager.h
@@ -488,13 +488,11 @@ class CheckerManager {
   using CheckCallFunc =
   CheckerFn;
 
-  using CheckLocationFunc =
-  CheckerFn;
+  using CheckLocationFunc = CheckerFn;
 
   using CheckBindFunc =
-  CheckerFn;
+  CheckerFn;
 
   using CheckEndAnalysisFunc =
   CheckerFn;
@@ -530,8 +528,7 @@ class CheckerManager {
  RegionAndSymbolInvalidationTraits *ITraits)>;
 
   using EvalAssumeFunc =
-  CheckerFn;
+  CheckerFn;
 
   using EvalCallFunc = CheckerFn;
 
diff --git a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
index ea74256935ca87..f2e1f69c32cfdc 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CallAndMessageChecker.cpp
@@ -125,9 +125,8 @@ class CallAndMessageChecker
 if (!BT)
   BT.reset(new BugType(OriginalName, desc));
   }
-  bool uninitRefOrPointer(CheckerContext , const SVal ,
-  SourceRange ArgRange, const Expr *ArgEx,
-  std::unique_ptr ,
+  bool uninitRefOrPointer(CheckerContext , SVal V, SourceRange ArgRange,
+  const Expr *ArgEx, std::unique_ptr ,
   const ParmVarDecl *ParamDecl, const char *BD,
   int ArgumentNumber) const;
 };
@@ -185,7 +184,7 @@ static void describeUninitializedArgumentInCall(const 
CallEvent ,
 }
 
 bool CallAndMessageChecker::uninitRefOrPointer(
-CheckerContext , const SVal , SourceRange ArgRange, const Expr *ArgEx,
+CheckerContext , SVal V, SourceRange ArgRange, const Expr *ArgEx,
 

[clang] [analyzer][NFC] Take small objects by value (PR #76688)

2024-01-01 Thread Balazs Benics via cfe-commits

https://github.com/steakhal created 
https://github.com/llvm/llvm-project/pull/76688

None

>From 70c03932cad401f477674881050a8f0c4b573cdb Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Mon, 1 Jan 2024 18:59:46 +0100
Subject: [PATCH 1/2] [analyzer][NFC] Take StringRef by value

---
 .../Checkers/IteratorRangeChecker.cpp |  4 ++--
 .../Checkers/MismatchedIteratorChecker.cpp| 20 ---
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
index f966ea63da2181..f9263f439b1e3d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/IteratorRangeChecker.cpp
@@ -43,7 +43,7 @@ class IteratorRangeChecker
   void verifyAdvance(CheckerContext , SVal LHS, SVal RHS) const;
   void verifyPrev(CheckerContext , SVal LHS, SVal RHS) const;
   void verifyNext(CheckerContext , SVal LHS, SVal RHS) const;
-  void reportBug(const StringRef , SVal Val, CheckerContext ,
+  void reportBug(StringRef Message, SVal Val, CheckerContext ,
  ExplodedNode *ErrNode) const;
 
 public:
@@ -269,7 +269,7 @@ void IteratorRangeChecker::verifyNext(CheckerContext , 
SVal LHS,
   verifyRandomIncrOrDecr(C, OO_Plus, LHS, RHS);
 }
 
-void IteratorRangeChecker::reportBug(const StringRef , SVal Val,
+void IteratorRangeChecker::reportBug(StringRef Message, SVal Val,
  CheckerContext ,
  ExplodedNode *ErrNode) const {
   auto R = std::make_unique(OutOfRangeBugType, Message,
diff --git a/clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
index 38f80ba5e1ff39..8116105a50eb08 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MismatchedIteratorChecker.cpp
@@ -38,12 +38,10 @@ class MismatchedIteratorChecker
const MemRegion *Cont) const;
   void verifyMatch(CheckerContext , const SVal ,
const SVal ) const;
-  void reportBug(const StringRef , const SVal ,
- const SVal , CheckerContext ,
- ExplodedNode *ErrNode) const;
-  void reportBug(const StringRef , const SVal ,
- const MemRegion *Reg, CheckerContext ,
- ExplodedNode *ErrNode) const;
+  void reportBug(StringRef Message, const SVal , const SVal ,
+ CheckerContext , ExplodedNode *ErrNode) const;
+  void reportBug(StringRef Message, const SVal , const MemRegion *Reg,
+ CheckerContext , ExplodedNode *ErrNode) const;
 
 public:
   void checkPreCall(const CallEvent , CheckerContext ) const;
@@ -271,10 +269,8 @@ void MismatchedIteratorChecker::verifyMatch(CheckerContext 
,
   }
 }
 
-void MismatchedIteratorChecker::reportBug(const StringRef ,
-  const SVal ,
-  const SVal ,
-  CheckerContext ,
+void MismatchedIteratorChecker::reportBug(StringRef Message, const SVal ,
+  const SVal , CheckerContext ,
   ExplodedNode *ErrNode) const {
   auto R = std::make_unique(MismatchedBugType, Message,
 ErrNode);
@@ -283,8 +279,8 @@ void MismatchedIteratorChecker::reportBug(const StringRef 
,
   C.emitReport(std::move(R));
 }
 
-void MismatchedIteratorChecker::reportBug(const StringRef ,
-  const SVal , const MemRegion 
*Reg,
+void MismatchedIteratorChecker::reportBug(StringRef Message, const SVal ,
+  const MemRegion *Reg,
   CheckerContext ,
   ExplodedNode *ErrNode) const {
   auto R = std::make_unique(MismatchedBugType, Message,

>From c0a3df172d1b1ba1d6330e336e7c38ba32370204 Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Mon, 1 Jan 2024 19:00:13 +0100
Subject: [PATCH 2/2] [analyzer][NFC] Take SVal and NonLoc by value

---
 .../clang/StaticAnalyzer/Core/Checker.h   | 14 ++
 .../StaticAnalyzer/Core/CheckerManager.h  | 11 ++---
 .../Checkers/CallAndMessageChecker.cpp|  9 ++--
 .../Checkers/InvalidatedIteratorChecker.cpp   |  5 +-
 .../lib/StaticAnalyzer/Checkers/Iterator.cpp  | 14 +++---
 clang/lib/StaticAnalyzer/Checkers/Iterator.h  | 15 +++---
 .../Checkers/IteratorModeling.cpp | 49 +--
 .../Checkers/IteratorRangeChecker.cpp |  4 +-
 .../Checkers/MismatchedIteratorChecker.cpp| 25 +-
 .../Checkers/TaggedUnionModeling.h|  2 +-
 .../UninitializedObject/UninitializedObject.h |  2 +-
 .../UninitializedObjectChecker.cpp|  2 +-
 

[flang] [lld] [mlir] [llvm] [libcxx] [clang] [analyzer][NFC] Cleanup BugType lazy-init patterns (PR #76655)

2024-01-01 Thread Balazs Benics via cfe-commits

https://github.com/steakhal closed 
https://github.com/llvm/llvm-project/pull/76655
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [lld] [mlir] [llvm] [libcxx] [clang] [analyzer][NFC] Cleanup BugType lazy-init patterns (PR #76655)

2024-01-01 Thread Balazs Benics via cfe-commits


@@ -52,10 +52,13 @@ class SimpleStreamChecker : public Checker {
-  CallDescription OpenFn, CloseFn;
+  const CallDescription OpenFn{{"fopen"}, 2};
+  const CallDescription CloseFn{{"fclose"}, 1};

steakhal wrote:

Here is why we can't have CallDescriptions constexpr:
It's an owning type, holding a `std::vector`, and they are 
themselves non-constexpr, until IDK cpp20+?
So, this is resolved.

https://github.com/llvm/llvm-project/pull/76655
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [lld] [mlir] [llvm] [libcxx] [clang] [analyzer][NFC] Cleanup BugType lazy-init patterns (PR #76655)

2024-01-01 Thread Balazs Benics via cfe-commits

https://github.com/steakhal edited 
https://github.com/llvm/llvm-project/pull/76655
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[flang] [lld] [mlir] [llvm] [libcxx] [clang] [analyzer][NFC] Cleanup BugType lazy-init patterns (PR #76655)

2024-01-01 Thread Balazs Benics via cfe-commits


@@ -52,10 +52,13 @@ class SimpleStreamChecker : public Checker {
-  CallDescription OpenFn, CloseFn;
+  const CallDescription OpenFn{{"fopen"}, 2};
+  const CallDescription CloseFn{{"fclose"}, 1};

steakhal wrote:

Well, it seems like `StringRef` is not constexpr for some reason - and I'm 
using that inside.
Consequently, that's a blocker.

https://github.com/llvm/llvm-project/pull/76655
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Cleanup BugType lazy-init patterns (PR #76655)

2024-01-01 Thread Balazs Benics via cfe-commits


@@ -17,19 +17,18 @@
 
 #include "MPITypes.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "llvm/ADT/StringRef.h"
 
 namespace clang {
 namespace ento {
 namespace mpi {
 
 class MPIBugReporter {
 public:
-  MPIBugReporter(const CheckerBase ) {
-UnmatchedWaitBugType.reset(new BugType(, "Unmatched wait", MPIError));
-DoubleNonblockingBugType.reset(
-new BugType(, "Double nonblocking", MPIError));
-MissingWaitBugType.reset(new BugType(, "Missing wait", MPIError));
-  }
+  MPIBugReporter(const CheckerBase )
+  : UnmatchedWaitBugType(, "Unmatched wait", MPIError),

steakhal wrote:

I considered that, but couldn't as `CB` is a ctor param. I don't have that in a 
field init context.

https://github.com/llvm/llvm-project/pull/76655
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer][NFC] Cleanup BugType lazy-init patterns (PR #76655)

2024-01-01 Thread Balazs Benics via cfe-commits


@@ -31,14 +31,14 @@ class InvalidatedIteratorChecker
check::PreStmt,
check::PreStmt> {
 
-  std::unique_ptr InvalidatedBugType;
+  const BugType InvalidatedBugType{this, "Iterator invalidated",
+   "Misuse of STL APIs"};
 
   void verifyAccess(CheckerContext , const SVal ) const;
-  void reportBug(const StringRef , const SVal ,
- CheckerContext , ExplodedNode *ErrNode) const;
-public:
-  InvalidatedIteratorChecker();
+  void reportBug(const StringRef , const SVal , CheckerContext ,

steakhal wrote:

Same for the `SVal`. Done.

https://github.com/llvm/llvm-project/pull/76655
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [compiler-rt] [libcxx] [libc] [openmp] [lldb] [mlir] [clang] [flang] [clang-tools-extra] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Nikolas Klauser via cfe-commits


@@ -0,0 +1,136 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20, c++23
+
+// 
+
+// constexpr reference at(size_type idx) const; // since C++26
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr void testSpanAt(auto span, int idx, int expectedValue) {
+  // non-const
+  {
+std::same_as decltype(auto) elem = 
span.at(idx);
+assert(elem == expectedValue);
+  }
+
+  // const
+  {
+std::same_as decltype(auto) elem = 
std::as_const(span).at(idx);
+assert(elem == expectedValue);
+  }
+}
+
+constexpr bool test() {
+  // With static extent
+  {
+std::array arr{0, 1, 2, 3, 4, 5, 9084};
+std::span arrSpan{arr};
+
+assert(std::dynamic_extent != arrSpan.extent);
+
+testSpanAt(arrSpan, 0, 0);
+testSpanAt(arrSpan, 1, 1);
+testSpanAt(arrSpan, 6, 9084);
+  }
+
+  // With dynamic extent
+  {
+std::vector vec{0, 1, 2, 3, 4, 5, 9084};
+std::span vecSpan{vec};
+
+assert(std::dynamic_extent == vecSpan.extent);
+
+testSpanAt(vecSpan, 0, 0);
+testSpanAt(vecSpan, 1, 1);
+testSpanAt(vecSpan, 6, 9084);
+  }
+
+  return true;
+}
+
+void test_exceptions() {

philnik777 wrote:

I don't think you've addressed this?

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [flang] [libcxx] [openmp] [llvm] [compiler-rt] [clang-tools-extra] [mlir] [libc] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 edited 
https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[compiler-rt] [clang] [libcxx] [lldb] [mlir] [llvm] [libc] [openmp] [flang] [clang-tools-extra] [libc++][span] P2821R5: `span.at()` (PR #74994)

2024-01-01 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 approved this pull request.

Other than the test this LGTM.

https://github.com/llvm/llvm-project/pull/74994
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [clangd] Fix is spelled in source bug (PR #76668)

2024-01-01 Thread via cfe-commits

https://github.com/schenka0 updated 
https://github.com/llvm/llvm-project/pull/76668

>From fd5e586d807fa4532f26188822ac5790202673bc Mon Sep 17 00:00:00 2001
From: schenka0 <154034018+schen...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 01:31:05 -0500
Subject: [PATCH 1/2] Check for invalid SLocEntry before getting spelling

---
 clang-tools-extra/clangd/SourceCode.cpp   |  7 ++-
 .../clangd/unittests/SourceCodeTests.cpp  | 15 +++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 835038423fdf37..8c573cc6fc064a 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -232,7 +232,12 @@ bool isSpelledInSource(SourceLocation Loc, const 
SourceManager ) {
   if (Loc.isFileID())
 return true;
   auto Spelling = SM.getDecomposedSpellingLoc(Loc);
-  StringRef SpellingFile = SM.getSLocEntry(Spelling.first).getFile().getName();
+  bool InvalidSLocEntry = false;
+  const auto SLocEntry = SM.getSLocEntry(Spelling.first, );
+  if (InvalidSLocEntry) {
+return false;
+  }
+  const StringRef SpellingFile = SLocEntry.getFile().getName();
   if (SpellingFile == "")
 return false;
   if (SpellingFile == "")
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 08abde87df6d4d..5dced4d317c605 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -813,6 +813,21 @@ TEST(SourceCodeTests, isKeywords) {
   EXPECT_FALSE(isKeyword("override", LangOpts));
 }
 
+TEST(SourceCodeTests, isSpelledInSource) {
+  Annotations Test(R"cpp(
+int abc = 1;
+)cpp");
+
+  ParsedAST AST = TestTU::withCode(Test.code()).build();
+  llvm::errs() << Test.code();
+  const SourceManager  = AST.getSourceManager();
+
+  EXPECT_TRUE(
+  isSpelledInSource(SM.getLocForStartOfFile(SM.getMainFileID()), SM));
+  EXPECT_TRUE(isSpelledInSource(SourceLocation(), SM));
+  EXPECT_FALSE(isSpelledInSource(SourceLocation::getFromRawEncoding(-1), SM));
+}
+
 struct IncrementalTestStep {
   llvm::StringRef Src;
   llvm::StringRef Contents;

>From 612c1fea8de7dfea67d5b4fdd23d6f13b9851607 Mon Sep 17 00:00:00 2001
From: schenka0 <154034018+schen...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 11:49:24 -0500
Subject: [PATCH 2/2] Update clang-tools-extra/clangd/SourceCode.cpp

Co-authored-by: Younan Zhang 
---
 clang-tools-extra/clangd/SourceCode.cpp | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 8c573cc6fc064a..58a0d142777d00 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -234,9 +234,8 @@ bool isSpelledInSource(SourceLocation Loc, const 
SourceManager ) {
   auto Spelling = SM.getDecomposedSpellingLoc(Loc);
   bool InvalidSLocEntry = false;
   const auto SLocEntry = SM.getSLocEntry(Spelling.first, );
-  if (InvalidSLocEntry) {
+  if (InvalidSLocEntry)
 return false;
-  }
   const StringRef SpellingFile = SLocEntry.getFile().getName();
   if (SpellingFile == "")
 return false;

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


[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-01 Thread Bhuminjay Soni via cfe-commits

11happy wrote:

I have added the tests as well.


https://github.com/llvm/llvm-project/pull/76680
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-01 Thread Bhuminjay Soni via cfe-commits

https://github.com/11happy updated 
https://github.com/llvm/llvm-project/pull/76680

>From 3c8dfcf96e732f4546f8019c0111fd873b233162 Mon Sep 17 00:00:00 2001
From: 11happy 
Date: Mon, 1 Jan 2024 19:53:45 +0530
Subject: [PATCH 1/2] Changed Checks from TriviallyCopyable to
 TriviallyCopyConstructible

Signed-off-by: 11happy 
---
 clang/include/clang/AST/DeclCXX.h |  3 +++
 clang/include/clang/AST/Type.h|  3 +++
 clang/lib/AST/DeclCXX.cpp | 13 ++
 clang/lib/AST/Type.cpp| 43 +++
 clang/lib/Sema/SemaStmt.cpp   |  2 +-
 5 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 432293583576b5..3ac0d6a9e083cd 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1425,6 +1425,9 @@ class CXXRecordDecl : public RecordDecl {
   /// (C++11 [class]p6).
   bool isTriviallyCopyable() const;
 
+  /// Determine whether this class is considered trivially copyable per
+  bool isTriviallyCopyConstructible() const;
+
   /// Determine whether this class is considered trivial.
   ///
   /// C++11 [class]p6:
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1afa693672860f..bce2256f96a828 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -917,6 +917,9 @@ class QualType {
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext ) const;
 
+  /// Return true if this is a trivially copyable type
+  bool isTriviallyCopyConstructibleType(const ASTContext ) const;
+
   /// Return true if this is a trivially relocatable type.
   bool isTriviallyRelocatableType(const ASTContext ) const;
 
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index c944862fcefeee..98b0a6dc28ea2f 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -587,6 +587,19 @@ bool CXXRecordDecl::isTriviallyCopyable() const {
   return true;
 }
 
+bool CXXRecordDecl::isTriviallyCopyConstructible() const {
+
+  //   A trivially copy constructible class is a class that:
+  //   -- has no non-trivial copy constructors,
+  if (hasNonTrivialCopyConstructor())
+return false;
+  //   -- has a trivial destructor.
+  if (!hasTrivialDestructor())
+return false;
+
+  return true;
+}
+
 void CXXRecordDecl::markedVirtualFunctionPure() {
   // C++ [class.abstract]p2:
   //   A class is abstract if it has at least one pure virtual function.
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 160a725939ccd4..9c8b25798a0a95 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2644,6 +2644,49 @@ bool QualType::isTriviallyCopyableType(const ASTContext 
) const {
   return false;
 }
 
+bool QualType::isTriviallyCopyConstructibleType(
+const ASTContext ) const {
+  if ((*this)->isArrayType())
+return Context.getBaseElementType(*this).isTriviallyCopyConstructibleType(
+Context);
+
+  if (hasNonTrivialObjCLifetime())
+return false;
+
+  // C++11 [basic.types]p9 - See Core 2094
+  //   Scalar types, trivially copyable class types, arrays of such types, and
+  //   cv-qualified versions of these types are collectively
+  //   called trivially copy constructible types.
+
+  QualType CanonicalType = getCanonicalType();
+  if (CanonicalType->isDependentType())
+return false;
+
+  if (CanonicalType->isSizelessBuiltinType())
+return true;
+
+  // Return false for incomplete types after skipping any incomplete array 
types
+  // which are expressly allowed by the standard and thus our API.
+  if (CanonicalType->isIncompleteType())
+return false;
+
+  // As an extension, Clang treats vector types as Scalar types.
+  if (CanonicalType->isScalarType() || CanonicalType->isVectorType())
+return true;
+
+  if (const auto *RT = CanonicalType->getAs()) {
+if (const auto *ClassDecl = dyn_cast(RT->getDecl())) {
+  if (!ClassDecl->isTriviallyCopyConstructible())
+return false;
+}
+
+return true;
+  }
+
+  // No other types can match.
+  return false;
+}
+
 bool QualType::isTriviallyRelocatableType(const ASTContext ) const {
   QualType BaseElementType = Context.getBaseElementType(*this);
 
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index f0b03db690843a..21efe25ed84a3d 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3200,7 +3200,7 @@ static void DiagnoseForRangeConstVariableCopies(Sema 
,
   // (The function `getTypeSize` returns the size in bits.)
   ASTContext  = SemaRef.Context;
   if (Ctx.getTypeSize(VariableType) <= 64 * 8 &&
-  (VariableType.isTriviallyCopyableType(Ctx) ||
+  (VariableType.isTriviallyCopyConstructibleType(Ctx) ||
hasTrivialABIAttr(VariableType)))
 return;
 

>From 57b50cb0fc242d994558ddcb8226c3a785763e87 Mon Sep 17 00:00:00 2001
From: 11happy 
Date: Mon, 1 Jan 

[clang] [clang-format] Don't apply severe penalty if no possible column formats (PR #76675)

2024-01-01 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

I think that's not the right way to fix the issue.

Why are the 2 lines formatted differently? It seems to me that this fixes the 
symptom, not the cause.

https://github.com/llvm/llvm-project/pull/76675
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-format] Fix erroneous BraceWrapping.BeforeLambdaBody column calcs (PR #76673)

2024-01-01 Thread Björn Schäpers via cfe-commits


@@ -22965,6 +22965,84 @@ TEST_F(FormatTest, EmptyLinesInLambdas) {
"};");
 }
 
+TEST_F(FormatTest, BreakBeforeLambdaBodyWrapping) {
+  verifyFormat("connect([]() {\n"
+   "  foo();\n"
+   "  bar();\n"
+   "});");
+
+  auto Style = getLLVMStyle();
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeLambdaBody = true;
+
+  verifyFormat("connect(\n"
+   "[]()\n"
+   "{\n"
+   "  foo();\n"
+   "  bar();\n"
+   "});",
+   Style);
+
+  for (unsigned l : {0, 41}) {

HazardyKnusperkeks wrote:

Don't loop. Pick some values.

https://github.com/llvm/llvm-project/pull/76673
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov updated 
https://github.com/llvm/llvm-project/pull/76632

>From 1165b11477ab59122a4db35221fcefe3c9505387 Mon Sep 17 00:00:00 2001
From: Zingam 
Date: Sat, 30 Dec 2023 17:34:56 +0200
Subject: [PATCH 01/16] [libc++][streams] P1759R6: Native handles and file
 streams

Implements: 
https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p1759r6.html

- https://eel.is/c++draft/filebuf
- https://eel.is/c++draft/ifstream
- https://eel.is/c++draft/ofstream
- https://eel.is/c++draft/fstream
---
 libcxx/docs/FeatureTestMacroTable.rst |  2 +-
 libcxx/docs/ReleaseNotes/18.rst   |  1 +
 libcxx/docs/Status/Cxx2cPapers.csv|  2 +-
 libcxx/include/fstream| 59 +++
 libcxx/include/version|  2 +-
 libcxx/src/CMakeLists.txt |  1 +
 libcxx/src/fstream.cpp| 33 +++
 .../fstream.version.compile.pass.cpp  | 16 ++---
 .../version.version.compile.pass.cpp  | 16 ++---
 .../generate_feature_test_macro_components.py |  1 -
 10 files changed, 107 insertions(+), 26 deletions(-)
 create mode 100644 libcxx/src/fstream.cpp

diff --git a/libcxx/docs/FeatureTestMacroTable.rst 
b/libcxx/docs/FeatureTestMacroTable.rst
index ad12b109023154..0427615a9636fd 100644
--- a/libcxx/docs/FeatureTestMacroTable.rst
+++ b/libcxx/docs/FeatureTestMacroTable.rst
@@ -418,7 +418,7 @@ Status
 --- -
 ``__cpp_lib_freestanding_variant``  *unimplemented*
 --- -
-``__cpp_lib_fstream_native_handle`` *unimplemented*
+``__cpp_lib_fstream_native_handle`` ``202306L``
 --- -
 ``__cpp_lib_function_ref``  *unimplemented*
 --- -
diff --git a/libcxx/docs/ReleaseNotes/18.rst b/libcxx/docs/ReleaseNotes/18.rst
index fa60a581652d6a..e6f1adf4d5529b 100644
--- a/libcxx/docs/ReleaseNotes/18.rst
+++ b/libcxx/docs/ReleaseNotes/18.rst
@@ -58,6 +58,7 @@ Implemented Papers
 - P2870R3 - Remove basic_string::reserve()
 - P2909R4 - Fix formatting of code units as integers (Dude, where’s my 
``char``?)
 - P0521R0 - Proposed Resolution for CA 14 (shared_ptr use_count/unique)
+- P1759R6 - Native handles and file streams
 
 
 Improvements and New Features
diff --git a/libcxx/docs/Status/Cxx2cPapers.csv 
b/libcxx/docs/Status/Cxx2cPapers.csv
index ff83648aa76830..1d7807a4291a99 100644
--- a/libcxx/docs/Status/Cxx2cPapers.csv
+++ b/libcxx/docs/Status/Cxx2cPapers.csv
@@ -19,7 +19,7 @@
 "`P2757R3 `__","LWG","Type-checking format 
args","Varna June 2023","","","|format|"
 "`P2637R3 `__","LWG","Member ``visit``","Varna June 
2023","","","|format|"
 "`P2641R4 `__","CWG, LWG","Checking if a ``union`` 
alternative is active","Varna June 2023","","",""
-"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","","",""
+"`P1759R6 `__","LWG","Native handles and file 
streams","Varna June 2023","|Complete|","18.0",""
 "`P2697R1 `__","LWG","Interfacing ``bitset`` with 
``string_view``","Varna June 2023","|Complete|","18.0",""
 "`P1383R2 `__","LWG","More ``constexpr`` for 
 and ","Varna June 2023","","",""
 "`P2734R0 `__","LWG","Adding the new SI 
prefixes","Varna June 2023","|Complete|","17.0",""
diff --git a/libcxx/include/fstream b/libcxx/include/fstream
index 7a4e15b55d56fe..9609ff420220fa 100644
--- a/libcxx/include/fstream
+++ b/libcxx/include/fstream
@@ -73,6 +73,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ifstream();
 explicit basic_ifstream(const char* s, ios_base::openmode mode = 
ios_base::in);
@@ -85,6 +86,7 @@ public:
 void swap(basic_ifstream& rhs);
 
 basic_filebuf* rdbuf() const;
+native_handle_type native_handle() const noexcept; // Since C++26
 bool is_open() const;
 void open(const char* s, ios_base::openmode mode = ios_base::in);
 void open(const string& s, ios_base::openmode mode = ios_base::in);
@@ -110,6 +112,7 @@ public:
 typedef typename traits_type::int_type int_type;
 typedef typename traits_type::pos_type pos_type;
 typedef typename traits_type::off_type off_type;
+using native_handle_type = typename basic_filebuf::native_handle_type; // Since C++26
 
 basic_ofstream();
 explicit basic_ofstream(const char* s, 

[clang-tools-extra] [clangd] Fix is spelled in source bug (PR #76668)

2024-01-01 Thread via cfe-commits

https://github.com/schenka0 updated 
https://github.com/llvm/llvm-project/pull/76668

>From fd5e586d807fa4532f26188822ac5790202673bc Mon Sep 17 00:00:00 2001
From: schenka0 <154034018+schen...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 01:31:05 -0500
Subject: [PATCH] Check for invalid SLocEntry before getting spelling

---
 clang-tools-extra/clangd/SourceCode.cpp   |  7 ++-
 .../clangd/unittests/SourceCodeTests.cpp  | 15 +++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 835038423fdf37..8c573cc6fc064a 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -232,7 +232,12 @@ bool isSpelledInSource(SourceLocation Loc, const 
SourceManager ) {
   if (Loc.isFileID())
 return true;
   auto Spelling = SM.getDecomposedSpellingLoc(Loc);
-  StringRef SpellingFile = SM.getSLocEntry(Spelling.first).getFile().getName();
+  bool InvalidSLocEntry = false;
+  const auto SLocEntry = SM.getSLocEntry(Spelling.first, );
+  if (InvalidSLocEntry) {
+return false;
+  }
+  const StringRef SpellingFile = SLocEntry.getFile().getName();
   if (SpellingFile == "")
 return false;
   if (SpellingFile == "")
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 08abde87df6d4d..5dced4d317c605 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -813,6 +813,21 @@ TEST(SourceCodeTests, isKeywords) {
   EXPECT_FALSE(isKeyword("override", LangOpts));
 }
 
+TEST(SourceCodeTests, isSpelledInSource) {
+  Annotations Test(R"cpp(
+int abc = 1;
+)cpp");
+
+  ParsedAST AST = TestTU::withCode(Test.code()).build();
+  llvm::errs() << Test.code();
+  const SourceManager  = AST.getSourceManager();
+
+  EXPECT_TRUE(
+  isSpelledInSource(SM.getLocForStartOfFile(SM.getMainFileID()), SM));
+  EXPECT_TRUE(isSpelledInSource(SourceLocation(), SM));
+  EXPECT_FALSE(isSpelledInSource(SourceLocation::getFromRawEncoding(-1), SM));
+}
+
 struct IncrementalTestStep {
   llvm::StringRef Src;
   llvm::StringRef Contents;

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


[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

H-G-Hristov wrote:

This test is failing but I have no idea how to fix it:  
@github-actions
Build and Test libc++ / stage3 (generic-no-localization, libcxx-runners-8-set, 
OFF) (pull_request) Failing after 1m

https://github.com/llvm/llvm-project/actions/runs/7377144646/job/20072043476?pr=76632#step:3:1467

https://github.com/llvm/llvm-project/pull/76632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[llvm] [libcxx] [flang] [clang] [lld] [libc++][streams] P1759R6: Native handles and file streams (PR #76632)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov ready_for_review 
https://github.com/llvm/llvm-project/pull/76632
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [ARM] arm_acle.h add Coprocessor Instrinsics (PR #75440)

2024-01-01 Thread via cfe-commits

https://github.com/hstk30-hw updated 
https://github.com/llvm/llvm-project/pull/75440

>From ce9db667e6567532fe119ff8d793281215f223dc Mon Sep 17 00:00:00 2001
From: hstk30-hw 
Date: Thu, 14 Dec 2023 15:40:03 +0800
Subject: [PATCH] feat: arm_acle.h add Coprocessor Instrinsics

---
 clang/lib/Basic/Targets/ARM.cpp   |  65 
 clang/lib/Basic/Targets/ARM.h |  13 +
 clang/lib/Headers/arm_acle.h  |  52 +++
 clang/test/CodeGen/arm-acle-coproc.c  | 346 ++
 .../Preprocessor/aarch64-target-features.c|   1 +
 5 files changed, 477 insertions(+)
 create mode 100644 clang/test/CodeGen/arm-acle-coproc.c

diff --git a/clang/lib/Basic/Targets/ARM.cpp b/clang/lib/Basic/Targets/ARM.cpp
index ce7e4d4639ceac..d68ae21b219535 100644
--- a/clang/lib/Basic/Targets/ARM.cpp
+++ b/clang/lib/Basic/Targets/ARM.cpp
@@ -17,6 +17,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSwitch.h"
+#include "llvm/TargetParser/ARMTargetParser.h"
 
 using namespace clang;
 using namespace clang::targets;
@@ -836,6 +837,70 @@ void ARMTargetInfo::getTargetDefines(const LangOptions 
,
   if (Opts.RWPI)
 Builder.defineMacro("__ARM_RWPI", "1");
 
+  // Macros for enabling co-proc intrinsics
+  uint64_t FeatureCoprocBF = 0;
+  switch (ArchKind) {
+  default:
+break;
+  case llvm::ARM::ArchKind::ARMV4:
+// Filter __arm_ldcl and __arm_stcl in acle.h
+FeatureCoprocBF = FEATURE_COPROC_B1;
+break;
+  case llvm::ARM::ArchKind::ARM5T:
+FeatureCoprocBF = isThumb() ? 0 : FEATURE_COPROC_B1;
+break;
+  case llvm::ARM::ArchKind::ARMV5TE:
+  case llvm::ARM::ArchKind::ARMV5TEJ:
+if (!isThumb())
+  FeatureCoprocBF =
+  FEATURE_COPROC_B1 | FEATURE_COPROC_B2 | FEATURE_COPROC_B3;
+break;
+  case llvm::ARM::ArchKind::ARMV6:
+  case llvm::ARM::ArchKind::ARMV6K:
+  case llvm::ARM::ArchKind::ARMV6KZ:
+  case llvm::ARM::ArchKind::ARMV6T2:
+if (!isThumb() || ArchKind == llvm::ARM::ArchKind::ARMV6T2)
+  FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  case llvm::ARM::ArchKind::ARMV7A:
+  case llvm::ARM::ArchKind::ARMV7R:
+  case llvm::ARM::ArchKind::ARMV7M:
+  case llvm::ARM::ArchKind::ARMV7S:
+  case llvm::ARM::ArchKind::ARMV7EM:
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+  FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  case llvm::ARM::ArchKind::ARMV8A:
+  case llvm::ARM::ArchKind::ARMV8R:
+  case llvm::ARM::ArchKind::ARMV8_1A:
+  case llvm::ARM::ArchKind::ARMV8_2A:
+  case llvm::ARM::ArchKind::ARMV8_3A:
+  case llvm::ARM::ArchKind::ARMV8_4A:
+  case llvm::ARM::ArchKind::ARMV8_5A:
+  case llvm::ARM::ArchKind::ARMV8_6A:
+  case llvm::ARM::ArchKind::ARMV8_7A:
+  case llvm::ARM::ArchKind::ARMV8_8A:
+  case llvm::ARM::ArchKind::ARMV8_9A:
+// Filter __arm_cdp, __arm_ldcl, __arm_stcl in arm_acle.h
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B3;
+break;
+  case llvm::ARM::ArchKind::ARMV8MMainline:
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+  FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  case llvm::ARM::ArchKind::ARMV9A:
+  case llvm::ARM::ArchKind::ARMV9_1A:
+  case llvm::ARM::ArchKind::ARMV9_2A:
+  case llvm::ARM::ArchKind::ARMV9_3A:
+  case llvm::ARM::ArchKind::ARMV9_4A:
+FeatureCoprocBF = FEATURE_COPROC_B1 | FEATURE_COPROC_B2 |
+  FEATURE_COPROC_B3 | FEATURE_COPROC_B4;
+break;
+  }
+  Builder.defineMacro("__ARM_FEATURE_COPROC",
+  "0x" + Twine::utohexstr(FeatureCoprocBF));
+
   if (ArchKind == llvm::ARM::ArchKind::XSCALE)
 Builder.defineMacro("__XSCALE__");
 
diff --git a/clang/lib/Basic/Targets/ARM.h b/clang/lib/Basic/Targets/ARM.h
index b1aa2794c7e4c3..9802eb01abf3c4 100644
--- a/clang/lib/Basic/Targets/ARM.h
+++ b/clang/lib/Basic/Targets/ARM.h
@@ -100,6 +100,19 @@ class LLVM_LIBRARY_VISIBILITY ARMTargetInfo : public 
TargetInfo {
   };
   uint32_t HW_FP;
 
+  enum {
+/// __arm_cdp __arm_ldc, __arm_ldcl, __arm_stc,
+/// __arm_stcl, __arm_mcr and __arm_mrc
+FEATURE_COPROC_B1 = (1 << 0),
+/// __arm_cdp2, __arm_ldc2, __arm_stc2, __arm_ldc2l,
+/// __arm_stc2l, __arm_mcr2 and __arm_mrc2
+FEATURE_COPROC_B2 = (1 << 1),
+/// __arm_mcrr, __arm_mrrc
+FEATURE_COPROC_B3 = (1 << 2),
+/// __arm_mcrr2,  __arm_mrrc2
+FEATURE_COPROC_B4 = (1 << 3),
+  };
+
   void setABIAAPCS();
   void setABIAPCS(bool IsAAPCS16);
 
diff --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h
index 61d80258d166a1..8a7e9a7930920b 100644
--- a/clang/lib/Headers/arm_acle.h
+++ b/clang/lib/Headers/arm_acle.h
@@ -756,6 +756,58 @@ __arm_st64bv0(void *__addr, data512_t __value) {
   __builtin_arm_mops_memset_tag(__tagged_address, __value, __size)
 #endif
 
+/* Coprocessor Intrinsics */
+#if defined(__ARM_FEATURE_COPROC)
+
+#if 

[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-01 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

> Sure I can , I have also tested the code that was giving erroneous warnings, 
> so should I add that example as well??

Yes. Clang has a special mode which check which diagnostics are emitted: 
https://clang.llvm.org/docs/InternalsManual.html#verifying-diagnostics

https://github.com/llvm/llvm-project/pull/76680
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-01 Thread Bhuminjay Soni via cfe-commits

11happy wrote:

Sure I can , I have also tested the code that was giving erroneous warnings, so 
should I add that example as well?? 

https://github.com/llvm/llvm-project/pull/76680
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-01 Thread Pol M via cfe-commits


@@ -302,3 +302,64 @@ extern __typeof__(__builtin_expect(0, 0)) bi0;
 // Strings
 int array1[__builtin_strlen("ab\0cd")];
 int array2[(sizeof(array1)/sizeof(int)) == 2? 1 : -1];
+
+typedef double vector4double __attribute__((__vector_size__(32)));
+typedef float vector4float __attribute__((__vector_size__(16)));
+typedef long long vector4long __attribute__((__vector_size__(32)));
+typedef int vector4int __attribute__((__vector_size__(16)));
+typedef short vector4short __attribute__((__vector_size__(8)));
+typedef char vector4char __attribute__((__vector_size__(4)));
+typedef double vector8double __attribute__((__vector_size__(64)));
+typedef float vector8float __attribute__((__vector_size__(32)));
+typedef long long vector8long __attribute__((__vector_size__(64)));
+typedef int vector8int __attribute__((__vector_size__(32)));
+typedef short vector8short __attribute__((__vector_size__(16)));
+typedef char vector8char __attribute__((__vector_size__(8)));
+
+// Convert vector
+#define CHECK_NUM(__size, __typeFrom, __typeTo, ...)   
 \
+  vector##__size##__typeTo 
 \
+  from_##vector##__size##__typeFrom##_to_##vector##__size##__typeTo##_var 
= \
+  __builtin_convertvector((vector##__size##__typeFrom){__VA_ARGS__},   
 \
+  vector##__size##__typeTo);
+#define CHECK_TO_ALL_TYPES(__size, __typeFrom, ...)
\
+  CHECK_NUM(__size, __typeFrom, double, __VA_ARGS__)   
\
+  CHECK_NUM(__size, __typeFrom, float, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, long, __VA_ARGS__) 
\
+  CHECK_NUM(__size, __typeFrom, int, __VA_ARGS__)  
\
+  CHECK_NUM(__size, __typeFrom, short, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, char, __VA_ARGS__)
+
+#define CHECK_ALL_COMBINATIONS(__size, ...)
\
+  CHECK_TO_ALL_TYPES(__size, double, __VA_ARGS__)  
\
+  CHECK_TO_ALL_TYPES(__size, float, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, long, __VA_ARGS__)
\
+  CHECK_TO_ALL_TYPES(__size, int, __VA_ARGS__) 
\
+  CHECK_TO_ALL_TYPES(__size, short, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, char, __VA_ARGS__)
+
+CHECK_ALL_COMBINATIONS(4, 0, 1, 2, 3);
+CHECK_ALL_COMBINATIONS(8, 0, 1, 2, 3, 4, 5, 6, 7);
+#undef CHECK_ALL_COMBINATIONS
+#undef CHECK_TO_ALL_TYPES
+#undef CHECK_NUM
+
+// Shuffle vector
+vector4int const vector4intConst1 = {0, 1, 2, 3};
+vector4int const vector4intConst2 = {4, 5, 6, 7};
+vector8int const vector8intConst = {};
+
+vector4int vectorShuffle1 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 1, 2, 3);
+vector4int vectorShuffle2 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 4, 5, 6, 7);
+vector4int vectorShuffle3 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, -1, -1, -1, 
-1);
+vector4int vectorShuffle4 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6);
+vector8int vectorShuffle5 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6, 8, 10, 12, 14);
+vector4int vectorShuffle6 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6);
+vector8int vectorShuffle7 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6, 1, 
3, 5, 7);

Destroyerrrocket wrote:

But just for this validation, I'd definitiely take the bitcast approach

https://github.com/llvm/llvm-project/pull/76615
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-01 Thread Pol M via cfe-commits


@@ -302,3 +302,64 @@ extern __typeof__(__builtin_expect(0, 0)) bi0;
 // Strings
 int array1[__builtin_strlen("ab\0cd")];
 int array2[(sizeof(array1)/sizeof(int)) == 2? 1 : -1];
+
+typedef double vector4double __attribute__((__vector_size__(32)));
+typedef float vector4float __attribute__((__vector_size__(16)));
+typedef long long vector4long __attribute__((__vector_size__(32)));
+typedef int vector4int __attribute__((__vector_size__(16)));
+typedef short vector4short __attribute__((__vector_size__(8)));
+typedef char vector4char __attribute__((__vector_size__(4)));
+typedef double vector8double __attribute__((__vector_size__(64)));
+typedef float vector8float __attribute__((__vector_size__(32)));
+typedef long long vector8long __attribute__((__vector_size__(64)));
+typedef int vector8int __attribute__((__vector_size__(32)));
+typedef short vector8short __attribute__((__vector_size__(16)));
+typedef char vector8char __attribute__((__vector_size__(8)));
+
+// Convert vector
+#define CHECK_NUM(__size, __typeFrom, __typeTo, ...)   
 \
+  vector##__size##__typeTo 
 \
+  from_##vector##__size##__typeFrom##_to_##vector##__size##__typeTo##_var 
= \
+  __builtin_convertvector((vector##__size##__typeFrom){__VA_ARGS__},   
 \
+  vector##__size##__typeTo);
+#define CHECK_TO_ALL_TYPES(__size, __typeFrom, ...)
\
+  CHECK_NUM(__size, __typeFrom, double, __VA_ARGS__)   
\
+  CHECK_NUM(__size, __typeFrom, float, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, long, __VA_ARGS__) 
\
+  CHECK_NUM(__size, __typeFrom, int, __VA_ARGS__)  
\
+  CHECK_NUM(__size, __typeFrom, short, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, char, __VA_ARGS__)
+
+#define CHECK_ALL_COMBINATIONS(__size, ...)
\
+  CHECK_TO_ALL_TYPES(__size, double, __VA_ARGS__)  
\
+  CHECK_TO_ALL_TYPES(__size, float, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, long, __VA_ARGS__)
\
+  CHECK_TO_ALL_TYPES(__size, int, __VA_ARGS__) 
\
+  CHECK_TO_ALL_TYPES(__size, short, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, char, __VA_ARGS__)
+
+CHECK_ALL_COMBINATIONS(4, 0, 1, 2, 3);
+CHECK_ALL_COMBINATIONS(8, 0, 1, 2, 3, 4, 5, 6, 7);
+#undef CHECK_ALL_COMBINATIONS
+#undef CHECK_TO_ALL_TYPES
+#undef CHECK_NUM
+
+// Shuffle vector
+vector4int const vector4intConst1 = {0, 1, 2, 3};
+vector4int const vector4intConst2 = {4, 5, 6, 7};
+vector8int const vector8intConst = {};
+
+vector4int vectorShuffle1 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 1, 2, 3);
+vector4int vectorShuffle2 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 4, 5, 6, 7);
+vector4int vectorShuffle3 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, -1, -1, -1, 
-1);
+vector4int vectorShuffle4 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6);
+vector8int vectorShuffle5 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6, 8, 10, 12, 14);
+vector4int vectorShuffle6 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6);
+vector8int vectorShuffle7 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6, 1, 
3, 5, 7);

Destroyerrrocket wrote:

Yep, I'll copy that over.

Well, in that case I would have to care about lvalues (in my code I just needed 
the values to return a new copy, so I could ignore all that machinery for now). 
I'd have to learn how these work more in depth. I don't think they'd be 
necessarily super complicated, and that would make for an ideal follow-up for 
me! (looks like this would be part of: 
https://github.com/llvm/llvm-project/issues/41806, and also this also looks 
interesting: https://github.com/llvm/llvm-project/issues/30794)

I think this is a pretty interesting set of tasks to work on!

https://github.com/llvm/llvm-project/pull/76615
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-01 Thread Vlad Serebrennikov via cfe-commits

Endilll wrote:

Can you add some tests?

https://github.com/llvm/llvm-project/pull/76680
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-01 Thread Simon Pilgrim via cfe-commits


@@ -302,3 +302,64 @@ extern __typeof__(__builtin_expect(0, 0)) bi0;
 // Strings
 int array1[__builtin_strlen("ab\0cd")];
 int array2[(sizeof(array1)/sizeof(int)) == 2? 1 : -1];
+
+typedef double vector4double __attribute__((__vector_size__(32)));
+typedef float vector4float __attribute__((__vector_size__(16)));
+typedef long long vector4long __attribute__((__vector_size__(32)));
+typedef int vector4int __attribute__((__vector_size__(16)));
+typedef short vector4short __attribute__((__vector_size__(8)));
+typedef char vector4char __attribute__((__vector_size__(4)));
+typedef double vector8double __attribute__((__vector_size__(64)));
+typedef float vector8float __attribute__((__vector_size__(32)));
+typedef long long vector8long __attribute__((__vector_size__(64)));
+typedef int vector8int __attribute__((__vector_size__(32)));
+typedef short vector8short __attribute__((__vector_size__(16)));
+typedef char vector8char __attribute__((__vector_size__(8)));
+
+// Convert vector
+#define CHECK_NUM(__size, __typeFrom, __typeTo, ...)   
 \
+  vector##__size##__typeTo 
 \
+  from_##vector##__size##__typeFrom##_to_##vector##__size##__typeTo##_var 
= \
+  __builtin_convertvector((vector##__size##__typeFrom){__VA_ARGS__},   
 \
+  vector##__size##__typeTo);
+#define CHECK_TO_ALL_TYPES(__size, __typeFrom, ...)
\
+  CHECK_NUM(__size, __typeFrom, double, __VA_ARGS__)   
\
+  CHECK_NUM(__size, __typeFrom, float, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, long, __VA_ARGS__) 
\
+  CHECK_NUM(__size, __typeFrom, int, __VA_ARGS__)  
\
+  CHECK_NUM(__size, __typeFrom, short, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, char, __VA_ARGS__)
+
+#define CHECK_ALL_COMBINATIONS(__size, ...)
\
+  CHECK_TO_ALL_TYPES(__size, double, __VA_ARGS__)  
\
+  CHECK_TO_ALL_TYPES(__size, float, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, long, __VA_ARGS__)
\
+  CHECK_TO_ALL_TYPES(__size, int, __VA_ARGS__) 
\
+  CHECK_TO_ALL_TYPES(__size, short, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, char, __VA_ARGS__)
+
+CHECK_ALL_COMBINATIONS(4, 0, 1, 2, 3);
+CHECK_ALL_COMBINATIONS(8, 0, 1, 2, 3, 4, 5, 6, 7);
+#undef CHECK_ALL_COMBINATIONS
+#undef CHECK_TO_ALL_TYPES
+#undef CHECK_NUM
+
+// Shuffle vector
+vector4int const vector4intConst1 = {0, 1, 2, 3};
+vector4int const vector4intConst2 = {4, 5, 6, 7};
+vector8int const vector8intConst = {};
+
+vector4int vectorShuffle1 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 1, 2, 3);
+vector4int vectorShuffle2 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 4, 5, 6, 7);
+vector4int vectorShuffle3 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, -1, -1, -1, 
-1);
+vector4int vectorShuffle4 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6);
+vector8int vectorShuffle5 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6, 8, 10, 12, 14);
+vector4int vectorShuffle6 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6);
+vector8int vectorShuffle7 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6, 1, 
3, 5, 7);

RKSimon wrote:

Maybe use the same 'LITTLE_END' define approach used in 
clang\test\SemaCXX\constexpr-builtin-bit-cast.cpp?

How much work will it to be to eventually implement the vector operator[] as a 
constexpr as well do you think?

https://github.com/llvm/llvm-project/pull/76615
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] [llvm] [clang] [mlir] [clangd] Fix is spelled in source bug (PR #76668)

2024-01-01 Thread via cfe-commits

https://github.com/schenka0 updated 
https://github.com/llvm/llvm-project/pull/76668

>From c9e2b9ad57aa9bac52324c91fe6d4ec1aa39ff41 Mon Sep 17 00:00:00 2001
From: schenka0 <154034018+schen...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 01:31:05 -0500
Subject: [PATCH 1/2] Check for invalid SLocEntry before getting spelling

---
 clang-tools-extra/clangd/SourceCode.cpp|  7 ++-
 .../clangd/unittests/SourceCodeTests.cpp   | 14 ++
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 835038423fdf37..64e0acb322350c 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -232,7 +232,12 @@ bool isSpelledInSource(SourceLocation Loc, const 
SourceManager ) {
   if (Loc.isFileID())
 return true;
   auto Spelling = SM.getDecomposedSpellingLoc(Loc);
-  StringRef SpellingFile = SM.getSLocEntry(Spelling.first).getFile().getName();
+  bool InvalidSLocEntry = false;
+  const auto SLocEntry = SM.getSLocEntry(Spelling.first, );
+  if(InvalidSLocEntry) {
+return false;
+  }
+  const StringRef SpellingFile = SLocEntry.getFile().getName();
   if (SpellingFile == "")
 return false;
   if (SpellingFile == "")
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index 08abde87df6d4d..be052dd265e81f 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -813,6 +813,20 @@ TEST(SourceCodeTests, isKeywords) {
   EXPECT_FALSE(isKeyword("override", LangOpts));
 }
 
+TEST(SourceCodeTests, isSpelledInSource) {
+Annotations Test(R"cpp(
+int abc = 1;
+)cpp");
+
+  ParsedAST AST = TestTU::withCode(Test.code()).build();
+  llvm::errs() << Test.code();
+  const SourceManager  = AST.getSourceManager();
+
+  EXPECT_TRUE(isSpelledInSource(SM.getLocForStartOfFile(SM.getMainFileID()), 
SM));
+  EXPECT_TRUE(isSpelledInSource(SourceLocation(), SM));
+  EXPECT_FALSE(isSpelledInSource(SourceLocation::getFromRawEncoding(-1), SM));
+}
+
 struct IncrementalTestStep {
   llvm::StringRef Src;
   llvm::StringRef Contents;

>From 833e1dbb45a58e8c8b9d6a9087a92df19250e378 Mon Sep 17 00:00:00 2001
From: schenka0 <154034018+schen...@users.noreply.github.com>
Date: Mon, 1 Jan 2024 01:37:29 -0500
Subject: [PATCH 2/2] clang format changes

---
 clang-tools-extra/clangd/SourceCode.cpp| 2 +-
 clang-tools-extra/clangd/unittests/SourceCodeTests.cpp | 5 +++--
 2 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index 64e0acb322350c..8c573cc6fc064a 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -234,7 +234,7 @@ bool isSpelledInSource(SourceLocation Loc, const 
SourceManager ) {
   auto Spelling = SM.getDecomposedSpellingLoc(Loc);
   bool InvalidSLocEntry = false;
   const auto SLocEntry = SM.getSLocEntry(Spelling.first, );
-  if(InvalidSLocEntry) {
+  if (InvalidSLocEntry) {
 return false;
   }
   const StringRef SpellingFile = SLocEntry.getFile().getName();
diff --git a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp 
b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
index be052dd265e81f..5dced4d317c605 100644
--- a/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SourceCodeTests.cpp
@@ -814,7 +814,7 @@ TEST(SourceCodeTests, isKeywords) {
 }
 
 TEST(SourceCodeTests, isSpelledInSource) {
-Annotations Test(R"cpp(
+  Annotations Test(R"cpp(
 int abc = 1;
 )cpp");
 
@@ -822,7 +822,8 @@ TEST(SourceCodeTests, isSpelledInSource) {
   llvm::errs() << Test.code();
   const SourceManager  = AST.getSourceManager();
 
-  EXPECT_TRUE(isSpelledInSource(SM.getLocForStartOfFile(SM.getMainFileID()), 
SM));
+  EXPECT_TRUE(
+  isSpelledInSource(SM.getLocForStartOfFile(SM.getMainFileID()), SM));
   EXPECT_TRUE(isSpelledInSource(SourceLocation(), SM));
   EXPECT_FALSE(isSpelledInSource(SourceLocation::getFromRawEncoding(-1), SM));
 }

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


[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Bhuminjay Soni (11happy)


Changes

**Overview:**
This pull request fixes #47355 where in the Clang compiler's 
range-loop-analysis incorrectly checks for trivial copyability instead of 
trivial copy constructibility, leading to erroneous warnings.

**Changes Made:**
- The changes made in this commit address the issue by introducing a new member 
function `isTriviallyCopyConstructible` in the `CXXRecordDecl` class and 
implementing it in the associated files `(clang/include/clang/AST/DeclCXX.h, 
clang/lib/AST/DeclCXX.cpp)`. Additionally, modifications are made in 
`clang/include/clang/AST/Type.h` and `clang/lib/AST/Type.cpp` to support the 
new function. The implementation checks for trivial copy constructibility, 
distinguishing it from the existing `isTriviallyCopyable` check. The issue in 
`clang/lib/Sema/SemaStmt.cpp` is also addressed by updating the conditional 
check in the `DiagnoseForRangeConstVariableCopies` function to use the new 
`isTriviallyCopyConstructibleType` function. Overall, these changes aim to 
correct the range-loop-analysis by ensuring it checks for trivial copy 
constructibility rather than trivial copyability.

**Testing:**
- Tested the updated code.
- Verified that other functionalities remain unaffected.
![Screenshot from 2024-01-01 
19-50-20](https://github.com/llvm/llvm-project/assets/76656712/c664f01a-522e-45e4-8363-39f13d8cc241)


**Dependencies:**
- No dependencies on other pull requests.

**References:**
- https://cplusplus.com/reference/type_traits/is_trivially_copy_constructible/
- https://en.cppreference.com/w/cpp/named_req/CopyConstructible
- https://cplusplus.com/reference/type_traits/is_trivially_copyable/

**CC:**
- @Endilll , @r4nt , @AaronBallman 


---
Full diff: https://github.com/llvm/llvm-project/pull/76680.diff


5 Files Affected:

- (modified) clang/include/clang/AST/DeclCXX.h (+3) 
- (modified) clang/include/clang/AST/Type.h (+3) 
- (modified) clang/lib/AST/DeclCXX.cpp (+13) 
- (modified) clang/lib/AST/Type.cpp (+43) 
- (modified) clang/lib/Sema/SemaStmt.cpp (+1-1) 


``diff
diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 432293583576b5..3ac0d6a9e083cd 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1425,6 +1425,9 @@ class CXXRecordDecl : public RecordDecl {
   /// (C++11 [class]p6).
   bool isTriviallyCopyable() const;
 
+  /// Determine whether this class is considered trivially copyable per
+  bool isTriviallyCopyConstructible() const;
+
   /// Determine whether this class is considered trivial.
   ///
   /// C++11 [class]p6:
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1afa693672860f..bce2256f96a828 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -917,6 +917,9 @@ class QualType {
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext ) const;
 
+  /// Return true if this is a trivially copyable type
+  bool isTriviallyCopyConstructibleType(const ASTContext ) const;
+
   /// Return true if this is a trivially relocatable type.
   bool isTriviallyRelocatableType(const ASTContext ) const;
 
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index c944862fcefeee..98b0a6dc28ea2f 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -587,6 +587,19 @@ bool CXXRecordDecl::isTriviallyCopyable() const {
   return true;
 }
 
+bool CXXRecordDecl::isTriviallyCopyConstructible() const {
+
+  //   A trivially copy constructible class is a class that:
+  //   -- has no non-trivial copy constructors,
+  if (hasNonTrivialCopyConstructor())
+return false;
+  //   -- has a trivial destructor.
+  if (!hasTrivialDestructor())
+return false;
+
+  return true;
+}
+
 void CXXRecordDecl::markedVirtualFunctionPure() {
   // C++ [class.abstract]p2:
   //   A class is abstract if it has at least one pure virtual function.
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 160a725939ccd4..9c8b25798a0a95 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2644,6 +2644,49 @@ bool QualType::isTriviallyCopyableType(const ASTContext 
) const {
   return false;
 }
 
+bool QualType::isTriviallyCopyConstructibleType(
+const ASTContext ) const {
+  if ((*this)->isArrayType())
+return Context.getBaseElementType(*this).isTriviallyCopyConstructibleType(
+Context);
+
+  if (hasNonTrivialObjCLifetime())
+return false;
+
+  // C++11 [basic.types]p9 - See Core 2094
+  //   Scalar types, trivially copyable class types, arrays of such types, and
+  //   cv-qualified versions of these types are collectively
+  //   called trivially copy constructible types.
+
+  QualType CanonicalType = getCanonicalType();
+  if (CanonicalType->isDependentType())
+return false;
+
+  if (CanonicalType->isSizelessBuiltinType())

[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-01 Thread via cfe-commits

github-actions[bot] wrote:

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be
notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this 
page.

If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using `@` followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review
by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate
is once a week. Please remember that you are asking for valuable time from 
other developers.

If you have further questions, they may be answered by the [LLVM GitHub User 
Guide](https://llvm.org/docs/GitHub.html).

You can also ask questions in a comment on this PR, on the [LLVM 
Discord](https://discord.com/invite/xS7Z362) or on the 
[forums](https://discourse.llvm.org/).

https://github.com/llvm/llvm-project/pull/76680
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Changed Checks from TriviallyCopyable to TriviallyCopyConstructible (PR #76680)

2024-01-01 Thread Bhuminjay Soni via cfe-commits

https://github.com/11happy created 
https://github.com/llvm/llvm-project/pull/76680

**Overview:**
This pull request fixes #47355 where in the Clang compiler's 
range-loop-analysis incorrectly checks for trivial copyability instead of 
trivial copy constructibility, leading to erroneous warnings.

**Changes Made:**
- The changes made in this commit address the issue by introducing a new member 
function `isTriviallyCopyConstructible` in the `CXXRecordDecl` class and 
implementing it in the associated files `(clang/include/clang/AST/DeclCXX.h, 
clang/lib/AST/DeclCXX.cpp)`. Additionally, modifications are made in 
`clang/include/clang/AST/Type.h` and `clang/lib/AST/Type.cpp` to support the 
new function. The implementation checks for trivial copy constructibility, 
distinguishing it from the existing `isTriviallyCopyable` check. The issue in 
`clang/lib/Sema/SemaStmt.cpp` is also addressed by updating the conditional 
check in the `DiagnoseForRangeConstVariableCopies` function to use the new 
`isTriviallyCopyConstructibleType` function. Overall, these changes aim to 
correct the range-loop-analysis by ensuring it checks for trivial copy 
constructibility rather than trivial copyability.

**Testing:**
- Tested the updated code.
- Verified that other functionalities remain unaffected.
![Screenshot from 2024-01-01 
19-50-20](https://github.com/llvm/llvm-project/assets/76656712/c664f01a-522e-45e4-8363-39f13d8cc241)


**Dependencies:**
- No dependencies on other pull requests.

**References:**
- https://cplusplus.com/reference/type_traits/is_trivially_copy_constructible/
- https://en.cppreference.com/w/cpp/named_req/CopyConstructible
- https://cplusplus.com/reference/type_traits/is_trivially_copyable/

**CC:**
- @Endilll , @r4nt , @AaronBallman 


>From 3c8dfcf96e732f4546f8019c0111fd873b233162 Mon Sep 17 00:00:00 2001
From: 11happy 
Date: Mon, 1 Jan 2024 19:53:45 +0530
Subject: [PATCH] Changed Checks from TriviallyCopyable to
 TriviallyCopyConstructible

Signed-off-by: 11happy 
---
 clang/include/clang/AST/DeclCXX.h |  3 +++
 clang/include/clang/AST/Type.h|  3 +++
 clang/lib/AST/DeclCXX.cpp | 13 ++
 clang/lib/AST/Type.cpp| 43 +++
 clang/lib/Sema/SemaStmt.cpp   |  2 +-
 5 files changed, 63 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 432293583576b5..3ac0d6a9e083cd 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1425,6 +1425,9 @@ class CXXRecordDecl : public RecordDecl {
   /// (C++11 [class]p6).
   bool isTriviallyCopyable() const;
 
+  /// Determine whether this class is considered trivially copyable per
+  bool isTriviallyCopyConstructible() const;
+
   /// Determine whether this class is considered trivial.
   ///
   /// C++11 [class]p6:
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1afa693672860f..bce2256f96a828 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -917,6 +917,9 @@ class QualType {
   /// Return true if this is a trivially copyable type (C++0x [basic.types]p9)
   bool isTriviallyCopyableType(const ASTContext ) const;
 
+  /// Return true if this is a trivially copyable type
+  bool isTriviallyCopyConstructibleType(const ASTContext ) const;
+
   /// Return true if this is a trivially relocatable type.
   bool isTriviallyRelocatableType(const ASTContext ) const;
 
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index c944862fcefeee..98b0a6dc28ea2f 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -587,6 +587,19 @@ bool CXXRecordDecl::isTriviallyCopyable() const {
   return true;
 }
 
+bool CXXRecordDecl::isTriviallyCopyConstructible() const {
+
+  //   A trivially copy constructible class is a class that:
+  //   -- has no non-trivial copy constructors,
+  if (hasNonTrivialCopyConstructor())
+return false;
+  //   -- has a trivial destructor.
+  if (!hasTrivialDestructor())
+return false;
+
+  return true;
+}
+
 void CXXRecordDecl::markedVirtualFunctionPure() {
   // C++ [class.abstract]p2:
   //   A class is abstract if it has at least one pure virtual function.
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 160a725939ccd4..9c8b25798a0a95 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2644,6 +2644,49 @@ bool QualType::isTriviallyCopyableType(const ASTContext 
) const {
   return false;
 }
 
+bool QualType::isTriviallyCopyConstructibleType(
+const ASTContext ) const {
+  if ((*this)->isArrayType())
+return Context.getBaseElementType(*this).isTriviallyCopyConstructibleType(
+Context);
+
+  if (hasNonTrivialObjCLifetime())
+return false;
+
+  // C++11 [basic.types]p9 - See Core 2094
+  //   Scalar types, trivially copyable class types, arrays of such types, and
+  //   cv-qualified versions of these types are collectively
+  //   called 

[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-01 Thread Pol M via cfe-commits


@@ -302,3 +302,64 @@ extern __typeof__(__builtin_expect(0, 0)) bi0;
 // Strings
 int array1[__builtin_strlen("ab\0cd")];
 int array2[(sizeof(array1)/sizeof(int)) == 2? 1 : -1];
+
+typedef double vector4double __attribute__((__vector_size__(32)));
+typedef float vector4float __attribute__((__vector_size__(16)));
+typedef long long vector4long __attribute__((__vector_size__(32)));
+typedef int vector4int __attribute__((__vector_size__(16)));
+typedef short vector4short __attribute__((__vector_size__(8)));
+typedef char vector4char __attribute__((__vector_size__(4)));
+typedef double vector8double __attribute__((__vector_size__(64)));
+typedef float vector8float __attribute__((__vector_size__(32)));
+typedef long long vector8long __attribute__((__vector_size__(64)));
+typedef int vector8int __attribute__((__vector_size__(32)));
+typedef short vector8short __attribute__((__vector_size__(16)));
+typedef char vector8char __attribute__((__vector_size__(8)));
+
+// Convert vector
+#define CHECK_NUM(__size, __typeFrom, __typeTo, ...)   
 \
+  vector##__size##__typeTo 
 \
+  from_##vector##__size##__typeFrom##_to_##vector##__size##__typeTo##_var 
= \
+  __builtin_convertvector((vector##__size##__typeFrom){__VA_ARGS__},   
 \
+  vector##__size##__typeTo);
+#define CHECK_TO_ALL_TYPES(__size, __typeFrom, ...)
\
+  CHECK_NUM(__size, __typeFrom, double, __VA_ARGS__)   
\
+  CHECK_NUM(__size, __typeFrom, float, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, long, __VA_ARGS__) 
\
+  CHECK_NUM(__size, __typeFrom, int, __VA_ARGS__)  
\
+  CHECK_NUM(__size, __typeFrom, short, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, char, __VA_ARGS__)
+
+#define CHECK_ALL_COMBINATIONS(__size, ...)
\
+  CHECK_TO_ALL_TYPES(__size, double, __VA_ARGS__)  
\
+  CHECK_TO_ALL_TYPES(__size, float, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, long, __VA_ARGS__)
\
+  CHECK_TO_ALL_TYPES(__size, int, __VA_ARGS__) 
\
+  CHECK_TO_ALL_TYPES(__size, short, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, char, __VA_ARGS__)
+
+CHECK_ALL_COMBINATIONS(4, 0, 1, 2, 3);
+CHECK_ALL_COMBINATIONS(8, 0, 1, 2, 3, 4, 5, 6, 7);
+#undef CHECK_ALL_COMBINATIONS
+#undef CHECK_TO_ALL_TYPES
+#undef CHECK_NUM
+
+// Shuffle vector
+vector4int const vector4intConst1 = {0, 1, 2, 3};
+vector4int const vector4intConst2 = {4, 5, 6, 7};
+vector8int const vector8intConst = {};
+
+vector4int vectorShuffle1 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 1, 2, 3);
+vector4int vectorShuffle2 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 4, 5, 6, 7);
+vector4int vectorShuffle3 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, -1, -1, -1, 
-1);
+vector4int vectorShuffle4 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6);
+vector8int vectorShuffle5 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6, 8, 10, 12, 14);
+vector4int vectorShuffle6 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6);
+vector8int vectorShuffle7 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6, 1, 
3, 5, 7);

Destroyerrrocket wrote:

You're right! we can indeed make something like:
constexpr vector4char v = {1,2,3,4};
static_assert(std::bit_cast(v) == 0x4030201, "equal");
I had initially dismissed this as the operator[] is not implemented for 
vectors. This is endian dependent, is there a particular way I should handle 
this?

https://github.com/llvm/llvm-project/pull/76615
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-01 Thread Pol M via cfe-commits


@@ -10895,6 +10899,138 @@ bool VectorExprEvaluator::VisitUnaryOperator(const 
UnaryOperator *E) {
   return Success(APValue(ResultElements.data(), ResultElements.size()), E);
 }
 
+static bool EvaluateVectorOrLValue(APValue , EvalInfo ,
+   const Expr *E, const QualType ) {
+  if (!Evaluate(Result, Info, E))
+return false;
+
+  if (Result.isLValue()) {
+// Source of the data is an lvalue; Manually handle the lvalue as if
+// it was an rvalue to get the current APValue.
+LValue LValueFound;
+LValueFound.setFrom(Info.Ctx, Result);
+if (!handleLValueToRValueConversion(Info, E, Type, LValueFound, Result)) {
+  return false;
+}
+  }
+
+  if (!Result.isVector()) {
+return false;
+  }
+  return true;
+}
+
+static bool handleVectorConversion(EvalInfo , const FPOptions FPO,
+   const Expr *E, QualType SourceTy,
+   QualType DestTy, APValue const ,
+   APValue ) {
+  if (SourceTy->isIntegerType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = APValue(APFloat(0.0));
+  return HandleIntToFloatCast(Info, E, FPO, SourceTy, Original.getInt(),
+  DestTy, Result.getFloat());
+}
+if (DestTy->isIntegerType()) {
+  Result = APValue(
+  HandleIntToIntCast(Info, E, DestTy, SourceTy, Original.getInt()));
+  return true;
+}
+  } else if (SourceTy->isRealFloatingType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = Original;
+  return HandleFloatToFloatCast(Info, E, SourceTy, DestTy,
+Result.getFloat());
+}
+if (DestTy->isIntegerType()) {
+  Result = APValue(APSInt());
+  return HandleFloatToIntCast(Info, E, SourceTy, Original.getFloat(),
+  DestTy, Result.getInt());
+}
+  }
+  return false;
+}
+
+bool VectorExprEvaluator::VisitConvertVectorExpr(const ConvertVectorExpr *E) {
+  APValue Source;
+  QualType SourceVecType = E->getSrcExpr()->getType();
+  if (!EvaluateVectorOrLValue(Source, Info, E->getSrcExpr(), SourceVecType))
+return false;
+
+  QualType DestTy = E->getType()->castAs()->getElementType();
+  QualType SourceTy = SourceVecType->castAs()->getElementType();
+
+  const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
+
+  SmallVector ResultElements;
+  ResultElements.reserve(Source.getVectorLength());
+  for (unsigned EltNum = 0; EltNum < Source.getVectorLength(); ++EltNum) {
+APValue Elt;
+if (!handleVectorConversion(Info, FPO, E, SourceTy, DestTy,
+Source.getVectorElt(EltNum), Elt))
+  return false;
+ResultElements.push_back(std::move(Elt));
+  }
+
+  return Success(APValue(ResultElements.data(), ResultElements.size()), E);
+}
+
+static bool handleVectorShuffle(EvalInfo , const ShuffleVectorExpr *E,
+QualType ElemType, APValue const ,
+APValue const , unsigned EltNum,
+APValue ) {
+  unsigned const TotalElementsInAVector = VecVal1.getVectorLength();
+
+  Expr const *IndexExpr = E->getExpr(2 + EltNum);
+  APSInt IndexVal;
+  if (!EvaluateInteger(IndexExpr, IndexVal, Info)) {
+return false;
+  }
+
+  uint32_t index = IndexVal.getZExtValue();
+  // The spec says that -1 should be treated as undef for optimizations,
+  // but in constexpr we need to choose a value. We'll choose 0.
+  if (index >= TotalElementsInAVector * 2) {
+index = 0;
+  }

Destroyerrrocket wrote:

If there is, I unfortunately don't know how...

https://github.com/llvm/llvm-project/pull/76615
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [clang-tools-extra] [libcxx] [compiler-rt] [flang] [llvm] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-01 Thread Hristo Hristov via cfe-commits

https://github.com/H-G-Hristov edited 
https://github.com/llvm/llvm-project/pull/73617
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[lld] [clang] [clang-tools-extra] [libcxx] [compiler-rt] [flang] [llvm] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

2024-01-01 Thread Hristo Hristov via cfe-commits


@@ -0,0 +1,71 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// 
+
+// class enumerate_view
+
+// class enumerate_view::sentinel
+
+// template
+//   requires sentinel_for, 
iterator_t>>
+// friend constexpr bool operator==(const iterator& x, const 
sentinel& y);
+
+#include 
+
+#include 
+#include 
+#include 
+#include 
+
+#include "test_iterators.h"
+#include "../types.h"
+
+template >
+constexpr void test() {
+  using View = MinimalView;
+
+  std::array array{0, 1, 2, 3, 84};
+
+  View v(Iterator(array.begin()), Sentinel(Iterator(array.end(;
+  std::ranges::enumerate_view view(std::move(v));
+
+  auto const it = view.begin();
+  auto const s  = view.end();
+
+  std::same_as decltype(auto) eqItSResult = (it == s);
+  assert(!eqItSResult);
+  std::same_as decltype(auto) eqSItResult = (s == it);
+  assert(!eqSItResult);
+
+  std::same_as decltype(auto) neqItSResult = (it != s);
+  assert(neqItSResult);
+  std::same_as decltype(auto) neqSItResult = (s != it);
+  assert(neqSItResult);
+}
+
+constexpr bool tests() {
+  test>();

H-G-Hristov wrote:

I'll keep this as is for now. If we do the suggested changes, I'll prefer to do 
them after everything else is ironed out.

https://github.com/llvm/llvm-project/pull/73617
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Diagnose unexpanded packs in the template argument lists of function template specializations (PR #76677)

2024-01-01 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian edited 
https://github.com/llvm/llvm-project/pull/76677
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Diagnose unexpanded packs in the template argument lists of function template specializations (PR #76677)

2024-01-01 Thread Krystian Stasiowski via cfe-commits

sdkrystian wrote:

Ping @erichkeane 

https://github.com/llvm/llvm-project/pull/76677
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Diagnose unexpanded packs in the template argument lists of function template specializations (PR #76677)

2024-01-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Krystian Stasiowski (sdkrystian)


Changes

This diagnoses unexpanded packs in the _unqualified-id_ of a function template 
specialization's _declarator-id_, e.g.:
```cpp
templatetypename... Ts
struct A
{
templatetypename U
void f();

template
void fTs(); // error: explicit specialization contains unexpanded 
parameter pack 'Ts'
};
```

I moved the handling of template-id's so it happens right after we determine 
whether we are declaring a function template/function template specialization 
so diagnostics are issued in lexical order. 

---
Full diff: https://github.com/llvm/llvm-project/pull/76677.diff


2 Files Affected:

- (modified) clang/lib/Sema/SemaDecl.cpp (+43-46) 
- (modified) clang/test/CXX/temp/temp.decls/temp.variadic/p5.cpp (+12) 


``diff
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ffbe317d559995..e94637b4f053e0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9900,15 +9900,15 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 // Match up the template parameter lists with the scope specifier, then
 // determine whether we have a template or a template specialization.
 bool Invalid = false;
+TemplateIdAnnotation *TemplateId =
+D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId
+? D.getName().TemplateId
+: nullptr;
 TemplateParameterList *TemplateParams =
 MatchTemplateParametersToScopeSpecifier(
 D.getDeclSpec().getBeginLoc(), D.getIdentifierLoc(),
-D.getCXXScopeSpec(),
-D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId
-? D.getName().TemplateId
-: nullptr,
-TemplateParamLists, isFriend, isMemberSpecialization,
-Invalid);
+D.getCXXScopeSpec(), TemplateId, TemplateParamLists, isFriend,
+isMemberSpecialization, Invalid);
 if (TemplateParams) {
   // Check that we can declare a template here.
   if (CheckTemplateDeclScope(S, TemplateParams))
@@ -9921,6 +9921,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 if (Name.getNameKind() == DeclarationName::CXXDestructorName) {
   Diag(NewFD->getLocation(), diag::err_destructor_template);
   NewFD->setInvalidDecl();
+  // Function template with explicit template arguments.
+} else if (TemplateId) {
+  Diag(D.getIdentifierLoc(), diag::err_function_template_partial_spec)
+  << SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc);
+  NewFD->setInvalidDecl();
 }
 
 // If we're adding a template to a dependent context, we may need to
@@ -9973,6 +9978,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 << FixItHint::CreateRemoval(RemoveRange)
 << FixItHint::CreateInsertion(InsertLoc, "<>");
   Invalid = true;
+
+  // Recover by faking up an empty template argument list.
+  HasExplicitTemplateArgs = true;
+  TemplateArgs.setLAngleLoc(InsertLoc);
+  TemplateArgs.setRAngleLoc(InsertLoc);
 }
   }
 } else {
@@ -9986,6 +9996,33 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
   if (TemplateParamLists.size() > 0)
 // For source fidelity, store all the template param lists.
 NewFD->setTemplateParameterListsInfo(Context, TemplateParamLists);
+
+  // "friend void foo<>(int);" is an implicit specialization decl.
+  if (isFriend && TemplateId)
+isFunctionTemplateSpecialization = true;
+}
+
+// If this is a function template specialization and the unqualified-id of
+// the declarator-id is a template-id, convert the template argument list
+// into our AST format and check for unexpanded packs.
+if (isFunctionTemplateSpecialization && TemplateId) {
+  HasExplicitTemplateArgs = true;
+
+  TemplateArgs.setLAngleLoc(TemplateId->LAngleLoc);
+  TemplateArgs.setRAngleLoc(TemplateId->RAngleLoc);
+  ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
+ TemplateId->NumArgs);
+  translateTemplateArguments(TemplateArgsPtr, TemplateArgs);
+
+  // FIXME: Should we check for unexpanded packs if this was an (invalid)
+  // declaration of a function template partial specialization? Should we
+  // consider the unexpanded pack context to be a partial specialization?
+  for (const TemplateArgumentLoc  : TemplateArgs.arguments()) {
+if (DiagnoseUnexpandedParameterPack(
+ArgLoc, isFriend ? UPPC_FriendDeclaration
+ : UPPC_ExplicitSpecialization))
+  NewFD->setInvalidDecl();
+  }
 }
 
 if (Invalid) {
@@ -10438,46 +10475,6 @@ Sema::ActOnFunctionDeclarator(Scope *S, 

[clang] [Clang][Sema] Diagnose unexpanded packs in the template argument lists of function template specializations (PR #76677)

2024-01-01 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian created 
https://github.com/llvm/llvm-project/pull/76677

This diagnoses unexpanded packs in the _unqualified-id_ of a function template 
specialization's _declarator-id_, e.g.:
```cpp
template
struct A
{
template
void f();

template<>
void f(); // error: explicit specialization contains unexpanded 
parameter pack 'Ts'
};
```

I moved the handling of template-id's so it happens right after we determine 
whether we are declaring a function template/function template specialization 
so diagnostics are issued in lexical order. 

>From 7c53e9cd31601f59367879384ad3b1c6b0ae3a98 Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Mon, 1 Jan 2024 07:35:09 -0500
Subject: [PATCH] [Clang][Sema] Diagnose unexpanded packs in the template
 argument lists of function template specializations

---
 clang/lib/Sema/SemaDecl.cpp   | 89 +--
 .../CXX/temp/temp.decls/temp.variadic/p5.cpp  | 12 +++
 2 files changed, 55 insertions(+), 46 deletions(-)

diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index ffbe317d559995..e94637b4f053e0 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9900,15 +9900,15 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 // Match up the template parameter lists with the scope specifier, then
 // determine whether we have a template or a template specialization.
 bool Invalid = false;
+TemplateIdAnnotation *TemplateId =
+D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId
+? D.getName().TemplateId
+: nullptr;
 TemplateParameterList *TemplateParams =
 MatchTemplateParametersToScopeSpecifier(
 D.getDeclSpec().getBeginLoc(), D.getIdentifierLoc(),
-D.getCXXScopeSpec(),
-D.getName().getKind() == UnqualifiedIdKind::IK_TemplateId
-? D.getName().TemplateId
-: nullptr,
-TemplateParamLists, isFriend, isMemberSpecialization,
-Invalid);
+D.getCXXScopeSpec(), TemplateId, TemplateParamLists, isFriend,
+isMemberSpecialization, Invalid);
 if (TemplateParams) {
   // Check that we can declare a template here.
   if (CheckTemplateDeclScope(S, TemplateParams))
@@ -9921,6 +9921,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 if (Name.getNameKind() == DeclarationName::CXXDestructorName) {
   Diag(NewFD->getLocation(), diag::err_destructor_template);
   NewFD->setInvalidDecl();
+  // Function template with explicit template arguments.
+} else if (TemplateId) {
+  Diag(D.getIdentifierLoc(), diag::err_function_template_partial_spec)
+  << SourceRange(TemplateId->LAngleLoc, TemplateId->RAngleLoc);
+  NewFD->setInvalidDecl();
 }
 
 // If we're adding a template to a dependent context, we may need to
@@ -9973,6 +9978,11 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
 << FixItHint::CreateRemoval(RemoveRange)
 << FixItHint::CreateInsertion(InsertLoc, "<>");
   Invalid = true;
+
+  // Recover by faking up an empty template argument list.
+  HasExplicitTemplateArgs = true;
+  TemplateArgs.setLAngleLoc(InsertLoc);
+  TemplateArgs.setRAngleLoc(InsertLoc);
 }
   }
 } else {
@@ -9986,6 +9996,33 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator , 
DeclContext *DC,
   if (TemplateParamLists.size() > 0)
 // For source fidelity, store all the template param lists.
 NewFD->setTemplateParameterListsInfo(Context, TemplateParamLists);
+
+  // "friend void foo<>(int);" is an implicit specialization decl.
+  if (isFriend && TemplateId)
+isFunctionTemplateSpecialization = true;
+}
+
+// If this is a function template specialization and the unqualified-id of
+// the declarator-id is a template-id, convert the template argument list
+// into our AST format and check for unexpanded packs.
+if (isFunctionTemplateSpecialization && TemplateId) {
+  HasExplicitTemplateArgs = true;
+
+  TemplateArgs.setLAngleLoc(TemplateId->LAngleLoc);
+  TemplateArgs.setRAngleLoc(TemplateId->RAngleLoc);
+  ASTTemplateArgsPtr TemplateArgsPtr(TemplateId->getTemplateArgs(),
+ TemplateId->NumArgs);
+  translateTemplateArguments(TemplateArgsPtr, TemplateArgs);
+
+  // FIXME: Should we check for unexpanded packs if this was an (invalid)
+  // declaration of a function template partial specialization? Should we
+  // consider the unexpanded pack context to be a partial specialization?
+  for (const TemplateArgumentLoc  : TemplateArgs.arguments()) {
+if (DiagnoseUnexpandedParameterPack(
+ArgLoc, isFriend ? UPPC_FriendDeclaration
+  

[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-01 Thread Simon Pilgrim via cfe-commits


@@ -10895,6 +10899,138 @@ bool VectorExprEvaluator::VisitUnaryOperator(const 
UnaryOperator *E) {
   return Success(APValue(ResultElements.data(), ResultElements.size()), E);
 }
 
+static bool EvaluateVectorOrLValue(APValue , EvalInfo ,
+   const Expr *E, const QualType ) {
+  if (!Evaluate(Result, Info, E))
+return false;
+
+  if (Result.isLValue()) {
+// Source of the data is an lvalue; Manually handle the lvalue as if
+// it was an rvalue to get the current APValue.
+LValue LValueFound;
+LValueFound.setFrom(Info.Ctx, Result);
+if (!handleLValueToRValueConversion(Info, E, Type, LValueFound, Result)) {
+  return false;
+}
+  }
+
+  if (!Result.isVector()) {
+return false;
+  }
+  return true;
+}
+
+static bool handleVectorConversion(EvalInfo , const FPOptions FPO,
+   const Expr *E, QualType SourceTy,
+   QualType DestTy, APValue const ,
+   APValue ) {
+  if (SourceTy->isIntegerType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = APValue(APFloat(0.0));
+  return HandleIntToFloatCast(Info, E, FPO, SourceTy, Original.getInt(),
+  DestTy, Result.getFloat());
+}
+if (DestTy->isIntegerType()) {
+  Result = APValue(
+  HandleIntToIntCast(Info, E, DestTy, SourceTy, Original.getInt()));
+  return true;
+}
+  } else if (SourceTy->isRealFloatingType()) {
+if (DestTy->isRealFloatingType()) {
+  Result = Original;
+  return HandleFloatToFloatCast(Info, E, SourceTy, DestTy,
+Result.getFloat());
+}
+if (DestTy->isIntegerType()) {
+  Result = APValue(APSInt());
+  return HandleFloatToIntCast(Info, E, SourceTy, Original.getFloat(),
+  DestTy, Result.getInt());
+}
+  }
+  return false;
+}
+
+bool VectorExprEvaluator::VisitConvertVectorExpr(const ConvertVectorExpr *E) {
+  APValue Source;
+  QualType SourceVecType = E->getSrcExpr()->getType();
+  if (!EvaluateVectorOrLValue(Source, Info, E->getSrcExpr(), SourceVecType))
+return false;
+
+  QualType DestTy = E->getType()->castAs()->getElementType();
+  QualType SourceTy = SourceVecType->castAs()->getElementType();
+
+  const FPOptions FPO = E->getFPFeaturesInEffect(Info.Ctx.getLangOpts());
+
+  SmallVector ResultElements;
+  ResultElements.reserve(Source.getVectorLength());
+  for (unsigned EltNum = 0; EltNum < Source.getVectorLength(); ++EltNum) {

RKSimon wrote:

Pull out repeated Source.getVectorLength() calls?

https://github.com/llvm/llvm-project/pull/76615
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Constexpr for __builtin_shufflevector and __builtin_convertvector (PR #76615)

2024-01-01 Thread Simon Pilgrim via cfe-commits


@@ -302,3 +302,64 @@ extern __typeof__(__builtin_expect(0, 0)) bi0;
 // Strings
 int array1[__builtin_strlen("ab\0cd")];
 int array2[(sizeof(array1)/sizeof(int)) == 2? 1 : -1];
+
+typedef double vector4double __attribute__((__vector_size__(32)));
+typedef float vector4float __attribute__((__vector_size__(16)));
+typedef long long vector4long __attribute__((__vector_size__(32)));
+typedef int vector4int __attribute__((__vector_size__(16)));
+typedef short vector4short __attribute__((__vector_size__(8)));
+typedef char vector4char __attribute__((__vector_size__(4)));
+typedef double vector8double __attribute__((__vector_size__(64)));
+typedef float vector8float __attribute__((__vector_size__(32)));
+typedef long long vector8long __attribute__((__vector_size__(64)));
+typedef int vector8int __attribute__((__vector_size__(32)));
+typedef short vector8short __attribute__((__vector_size__(16)));
+typedef char vector8char __attribute__((__vector_size__(8)));
+
+// Convert vector
+#define CHECK_NUM(__size, __typeFrom, __typeTo, ...)   
 \
+  vector##__size##__typeTo 
 \
+  from_##vector##__size##__typeFrom##_to_##vector##__size##__typeTo##_var 
= \
+  __builtin_convertvector((vector##__size##__typeFrom){__VA_ARGS__},   
 \
+  vector##__size##__typeTo);
+#define CHECK_TO_ALL_TYPES(__size, __typeFrom, ...)
\
+  CHECK_NUM(__size, __typeFrom, double, __VA_ARGS__)   
\
+  CHECK_NUM(__size, __typeFrom, float, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, long, __VA_ARGS__) 
\
+  CHECK_NUM(__size, __typeFrom, int, __VA_ARGS__)  
\
+  CHECK_NUM(__size, __typeFrom, short, __VA_ARGS__)
\
+  CHECK_NUM(__size, __typeFrom, char, __VA_ARGS__)
+
+#define CHECK_ALL_COMBINATIONS(__size, ...)
\
+  CHECK_TO_ALL_TYPES(__size, double, __VA_ARGS__)  
\
+  CHECK_TO_ALL_TYPES(__size, float, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, long, __VA_ARGS__)
\
+  CHECK_TO_ALL_TYPES(__size, int, __VA_ARGS__) 
\
+  CHECK_TO_ALL_TYPES(__size, short, __VA_ARGS__)   
\
+  CHECK_TO_ALL_TYPES(__size, char, __VA_ARGS__)
+
+CHECK_ALL_COMBINATIONS(4, 0, 1, 2, 3);
+CHECK_ALL_COMBINATIONS(8, 0, 1, 2, 3, 4, 5, 6, 7);
+#undef CHECK_ALL_COMBINATIONS
+#undef CHECK_TO_ALL_TYPES
+#undef CHECK_NUM
+
+// Shuffle vector
+vector4int const vector4intConst1 = {0, 1, 2, 3};
+vector4int const vector4intConst2 = {4, 5, 6, 7};
+vector8int const vector8intConst = {};
+
+vector4int vectorShuffle1 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 1, 2, 3);
+vector4int vectorShuffle2 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 4, 5, 6, 7);
+vector4int vectorShuffle3 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, -1, -1, -1, 
-1);
+vector4int vectorShuffle4 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6);
+vector8int vectorShuffle5 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6, 8, 10, 12, 14);
+vector4int vectorShuffle6 = __builtin_shufflevector(
+vector8intConst, vector8intConst, 0, 2, 4, 6);
+vector8int vectorShuffle7 =
+__builtin_shufflevector(vector4intConst1, vector4intConst2, 0, 2, 4, 6, 1, 
3, 5, 7);

RKSimon wrote:

What could we do to check the result values of the constant expression? Could 
we bitcast a char4 to a uint value and static assert the result for instance?

https://github.com/llvm/llvm-project/pull/76615
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >