[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -1219,6 +1219,9 @@ static int getInstructionID(struct InternalInstruction 
*insn,
 attrMask |= ATTR_EVEXKZ;
   if (bFromEVEX4of4(insn->vectorExtensionPrefix[3]))
 attrMask |= ATTR_EVEXB;
+  if (x2FromEVEX3of4(insn->vectorExtensionPrefix[2]) &&

phoebewang wrote:

Done.

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


[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

2024-08-01 Thread Max Winkler via cfe-commits

https://github.com/MaxEW707 updated 
https://github.com/llvm/llvm-project/pull/99833

>From c66fee7969fc4bd8b5ce79085f0fc09cbc4147da Mon Sep 17 00:00:00 2001
From: MaxEW707 
Date: Fri, 21 Jun 2024 20:37:40 -0700
Subject: [PATCH 01/12] Support MSVC lvalue to temporary reference binding

---
 clang/docs/ReleaseNotes.rst |   4 +
 clang/include/clang/Basic/LangOptions.def   |   1 +
 clang/include/clang/Driver/Options.td   |  12 +++
 clang/include/clang/Sema/Sema.h |   2 +
 clang/lib/Driver/ToolChains/Clang.cpp   |   5 +
 clang/lib/Driver/ToolChains/MSVC.cpp|   1 +
 clang/lib/Sema/SemaInit.cpp |  22 +++--
 clang/lib/Sema/SemaOverload.cpp |  16 ++-
 clang/test/Driver/cl-permissive.c   |   7 ++
 clang/test/Driver/cl-zc.cpp |   2 +
 clang/test/SemaCXX/ms-reference-binding.cpp | 102 
 11 files changed, 165 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/SemaCXX/ms-reference-binding.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..becf12fa62ec0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -104,6 +104,10 @@ C23 Feature Support
 New Compiler Flags
 --
 
+- ``-fms-reference-binding`` and its clang-cl counterpart 
``/Zc:referenceBinding``.
+  Implements the MSVC extension where expressions that bind a user-defined 
type temporary
+  to a non-const lvalue reference are allowed.
+
 Deprecated Compiler Flags
 -
 
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 0035092ce0d86..ff350410d598a 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -307,6 +307,7 @@ LANGOPT(HIPStdParInterposeAlloc, 1, 0, "Replace allocations 
/ deallocations with
 LANGOPT(OpenACC   , 1, 0, "OpenACC Enabled")
 
 LANGOPT(MSVCEnableStdcMacro , 1, 0, "Define __STDC__ with 
'-fms-compatibility'")
+LANGOPT(MSVCReferenceBinding , 1, 0, "Accept expressions that bind a non-const 
lvalue reference to a temporary")
 LANGOPT(SizedDeallocation , 1, 0, "sized deallocation")
 LANGOPT(AlignedAllocation , 1, 0, "aligned allocation")
 LANGOPT(AlignedAllocationUnavailable, 1, 0, "aligned allocation functions are 
unavailable")
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28..53a356d120e3a 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3034,6 +3034,12 @@ def fms_extensions : Flag<["-"], "fms-extensions">, 
Group,
   Visibility<[ClangOption, CC1Option, CLOption]>,
   HelpText<"Accept some non-standard constructs supported by the Microsoft 
compiler">,
   MarshallingInfoFlag>, 
ImpliedByAnyOf<[fms_compatibility.KeyPath]>;
+def fms_reference_binding : Flag<["-"], "fms-reference-binding">, 
Group,
+  Visibility<[ClangOption, CC1Option, CLOption]>,
+  HelpText<"Accept expressions that bind a non-const lvalue reference to a 
user-defined type temporary as supported by the Microsoft Compiler">,
+  MarshallingInfoFlag>;
+def fno_ms_reference_binding : Flag<["-"], "fno-ms-reference-binding">, 
Group,
+  Visibility<[ClangOption, CLOption]>;
 defm asm_blocks : BoolFOption<"asm-blocks",
   LangOpts<"AsmBlocks">, Default,
   PosFlag,
@@ -8492,6 +8498,12 @@ def _SLASH_Zc_wchar_t : CLFlag<"Zc:wchar_t">,
   HelpText<"Enable C++ builtin type wchar_t (default)">;
 def _SLASH_Zc_wchar_t_ : CLFlag<"Zc:wchar_t-">,
   HelpText<"Disable C++ builtin type wchar_t">;
+def _SLASH_Zc_referenceBinding : CLFlag<"Zc:referenceBinding">,
+  HelpText<"Do not accept expressions that bind a non-const lvalue reference 
to a user-defined type temporary">,
+  Alias;
+def _SLASH_Zc_referenceBinding_ : CLFlag<"Zc:referenceBinding-">,
+  HelpText<"Accept expressions that bind a non-const lvalue reference to a 
user-defined type temporary">,
+  Alias;
 def _SLASH_Z7 : CLFlag<"Z7">, Alias,
   HelpText<"Enable CodeView debug information in object files">;
 def _SLASH_ZH_MD5 : CLFlag<"ZH:MD5">,
diff --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 2ec6367eccea0..6bd575d105675 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -10161,6 +10161,8 @@ class Sema final : public SemaBase {
   CompareReferenceRelationship(SourceLocation Loc, QualType T1, QualType T2,
ReferenceConversions *Conv = nullptr);
 
+  bool AllowMSLValueReferenceBinding(Qualifiers Quals, QualType QT);
+
   /// AddOverloadCandidate - Adds the given function to the set of
   /// candidate functions, using the given function call arguments.  If
   /// @p SuppressUserConversions, then don't allow user-defined
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 843d68c85bc59..13867181b21c0 100644
--- a/clang/lib/Driver/ToolChains/Cla

[clang] [clang-cl] [Sema] Support MSVC non-const lvalue to user-defined temporary reference (PR #99833)

2024-08-01 Thread Max Winkler via cfe-commits

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


[clang] [llvm] [LV] Support generating masks for switch terminators. (PR #99808)

2024-08-01 Thread via cfe-commits


@@ -6,9 +6,43 @@ define void @switch_default_to_latch_common_dest(ptr %start, 
ptr %end) {
 ; IC1-LABEL: define void @switch_default_to_latch_common_dest(
 ; IC1-SAME: ptr [[START:%.*]], ptr [[END:%.*]]) #[[ATTR0:[0-9]+]] {
 ; IC1-NEXT:  [[ENTRY:.*]]:
+; IC1-NEXT:[[START2:%.*]] = ptrtoint ptr [[START]] to i64
+; IC1-NEXT:[[END1:%.*]] = ptrtoint ptr [[END]] to i64
+; IC1-NEXT:[[TMP0:%.*]] = add i64 [[END1]], -8
+; IC1-NEXT:[[TMP1:%.*]] = sub i64 [[TMP0]], [[START2]]
+; IC1-NEXT:[[TMP2:%.*]] = lshr i64 [[TMP1]], 3
+; IC1-NEXT:[[TMP3:%.*]] = add nuw nsw i64 [[TMP2]], 1
+; IC1-NEXT:[[MIN_ITERS_CHECK:%.*]] = icmp ult i64 [[TMP3]], 4
+; IC1-NEXT:br i1 [[MIN_ITERS_CHECK]], label %[[SCALAR_PH:.*]], label 
%[[VECTOR_PH:.*]]
+; IC1:   [[VECTOR_PH]]:
+; IC1-NEXT:[[N_MOD_VF:%.*]] = urem i64 [[TMP3]], 4
+; IC1-NEXT:[[N_VEC:%.*]] = sub i64 [[TMP3]], [[N_MOD_VF]]
+; IC1-NEXT:[[TMP4:%.*]] = mul i64 [[N_VEC]], 8
+; IC1-NEXT:[[IND_END:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP4]]
+; IC1-NEXT:br label %[[VECTOR_BODY:.*]]
+; IC1:   [[VECTOR_BODY]]:
+; IC1-NEXT:[[INDEX:%.*]] = phi i64 [ 0, %[[VECTOR_PH]] ], [ 
[[INDEX_NEXT:%.*]], %[[VECTOR_BODY]] ]
+; IC1-NEXT:[[OFFSET_IDX:%.*]] = mul i64 [[INDEX]], 8
+; IC1-NEXT:[[TMP5:%.*]] = add i64 [[OFFSET_IDX]], 0
+; IC1-NEXT:[[NEXT_GEP:%.*]] = getelementptr i8, ptr [[START]], i64 [[TMP5]]
+; IC1-NEXT:[[TMP6:%.*]] = getelementptr i64, ptr [[NEXT_GEP]], i32 0
+; IC1-NEXT:[[WIDE_LOAD:%.*]] = load <4 x i64>, ptr [[TMP6]], align 1
+; IC1-NEXT:[[TMP7:%.*]] = icmp eq <4 x i64> [[WIDE_LOAD]], 
+; IC1-NEXT:[[TMP8:%.*]] = icmp eq <4 x i64> [[WIDE_LOAD]], 
+; IC1-NEXT:[[TMP9:%.*]] = or <4 x i1> [[TMP7]], [[TMP8]]
+; IC1-NEXT:[[TMP10:%.*]] = or <4 x i1> [[TMP9]], [[TMP9]]

ayalz wrote:

Good catch!

This stems from having parallel {pred, succ} edges in the CFG for multiple 
switch cases that share a common succ destination, coupled with caching a 
single edge mask per {pred, succ} pair of VPBB's.

The in mask of a VPBB is created by ORing the edge masks from its predecessors 
- suffice to visit each predecessor once.

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/2] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/2] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

github-actions[bot] wrote:




:warning: C/C++ code formatter, clang-format found issues in your code. 
:warning:



You can test this locally with the following command:


``bash
git-clang-format --diff 03e1eb29e7169ddb0804b1d0b9d71d6d2aaf531d 
114a5721e593a9b57ef31ed9856d0bce4a62da94 --extensions cpp -- 
clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 9a540a5061..80acdc3366 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,7 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-  
+
   for (auto &Entry : USRToBitcode) {
 std::vector &Bitcode = Entry.second;
 std::sort(Bitcode.begin(), Bitcode.end(),

``




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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -1219,6 +1219,9 @@ static int getInstructionID(struct InternalInstruction 
*insn,
 attrMask |= ATTR_EVEXKZ;
   if (bFromEVEX4of4(insn->vectorExtensionPrefix[3]))
 attrMask |= ATTR_EVEXB;
+  if (x2FromEVEX3of4(insn->vectorExtensionPrefix[2]) &&
+  (insn->opcodeType != MAP4))

phoebewang wrote:

Thanks for the reminder. It's fully matched with AVX10.2 SPEC now.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -111,9 +111,9 @@ class X86OpcodePrefixHelper {
   //  0b11: F2
 
   // EVEX (4 bytes)
-  // +-+ +---+ ++ 
++
-  // | 62h | | RXBR' | B'mmm | | W |  | X' | pp | | z | L'L | b | v' | aaa 
|
-  // +-+ +---+ ++ 
++
+  // +-+ +---+ +---+ ++
+  // | 62h | | RXBR' | B'mmm | | W |  | U | pp | | z | L'L | b | v' | aaa |

phoebewang wrote:

Sure.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Freddy Ye via cfe-commits


@@ -0,0 +1,33 @@
+//===-- X86InstrAVX10.td - AVX10 Instruction Set ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the X86 AVX10 instruction set, defining the
+// instructions, and properties of the instructions which are needed for code
+// generation, machine code emission, and analysis.
+//
+//===--===//
+
+// VMPSADBW
+defm VMPSADBW : avx512_common_3Op_rm_imm8<0x42, X86Vmpsadbw, "vmpsadbw", 
SchedWritePSADBW,
+  avx512vl_i16_info, avx512vl_i8_info,
+  HasAVX10_2>,
+XS, EVEX_CD8<32, CD8VF>;
+
+// YMM Rounding
+multiclass avx256_fp_binop_p_round opc, string OpcodeStr, SDNode 
OpNodeRnd,

FreddyLeaf wrote:

`avx10_fp_binop_p_round` maybe better?

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


[clang] [clang] Generate nuw GEPs for struct member accesses (PR #99538)

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

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


[clang] [clang] Generate nuw GEPs for struct member accesses (PR #99538)

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

https://github.com/nikic commented:

As you already put in the test update work, I'm happy to take it :)

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


[clang] [clang] Generate nuw GEPs for struct member accesses (PR #99538)

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


@@ -1902,16 +1902,18 @@ class IRBuilderBase {
   }
 
   Value *CreateConstGEP2_32(Type *Ty, Value *Ptr, unsigned Idx0, unsigned Idx1,
-const Twine &Name = "") {
+const Twine &Name = "",
+GEPNoWrapFlags NWFlags = GEPNoWrapFlags::none()) {
 Value *Idxs[] = {
   ConstantInt::get(Type::getInt32Ty(Context), Idx0),
   ConstantInt::get(Type::getInt32Ty(Context), Idx1)
 };
 
-if (auto *V = Folder.FoldGEP(Ty, Ptr, Idxs, GEPNoWrapFlags::none()))
+if (auto *V =
+Folder.FoldGEP(Ty, Ptr, Idxs, /*IsInBounds=*/NWFlags.isInBounds()))

nikic wrote:

Shouldn't this be?
```suggestion
Folder.FoldGEP(Ty, Ptr, Idxs, NWFlags))
```


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


[clang-tools-extra] Create a new check to look for mis-use in calls that take iterators (PR #99917)

2024-08-01 Thread Nathan James via cfe-commits

https://github.com/njames93 updated 
https://github.com/llvm/llvm-project/pull/99917

>From e604ce226ddccd0ae11cf685adfed98be9b8223e Mon Sep 17 00:00:00 2001
From: Nathan James 
Date: Tue, 23 Jul 2024 10:59:45 +0100
Subject: [PATCH] Create a new check to look for mis-use in calls that take
 iterators

Looks for various patterns of functions that take arguments calling
begin/end or similar for common mistakes
---
 .../bugprone/BugproneTidyModule.cpp   |   3 +
 .../clang-tidy/bugprone/CMakeLists.txt|   1 +
 .../bugprone/IncorrectIteratorsCheck.cpp  | 997 ++
 .../bugprone/IncorrectIteratorsCheck.h|  45 +
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../checks/bugprone/incorrect-iterators.rst   | 131 +++
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../checkers/bugprone/incorrect-iterators.cpp | 373 +++
 8 files changed, 1557 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-iterators.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-iterators.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 689eb92a3d8d1..cea040b81878a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -33,6 +33,7 @@
 #include "InaccurateEraseCheck.h"
 #include "IncDecInConditionsCheck.h"
 #include "IncorrectEnableIfCheck.h"
+#include "IncorrectIteratorsCheck.h"
 #include "IncorrectRoundingsCheck.h"
 #include "InfiniteLoopCheck.h"
 #include "IntegerDivisionCheck.h"
@@ -139,6 +140,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-incorrect-iterators");
 CheckFactories.registerCheck(
 "bugprone-return-const-ref-from-parameter");
 CheckFactories.registerCheck(
diff --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index cb0d8ae98bac5..8425dbed0505a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -26,6 +26,7 @@ add_clang_library(clangTidyBugproneModule
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
   IncorrectEnableIfCheck.cpp
+  IncorrectIteratorsCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SuspiciousStringviewDataUsageCheck.cpp
   SwitchMissingDefaultCaseCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
new file mode 100644
index 0..c2759feb90384
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/IncorrectIteratorsCheck.cpp
@@ -0,0 +1,997 @@
+//===--- IncorrectIteratorsCheck.cpp - clang-tidy 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectIteratorsCheck.h"
+#include "../utils/Matchers.h"
+#include "../utils/OptionsUtils.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/Expr.h"
+#include "clang/AST/ExprCXX.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+#include "clang/Basic/LLVM.h"
+#include "clang/Basic/LangOptions.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator_range.h"
+#include "llvm/Support/ErrorHandling.h"
+#include 
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+using SVU = llvm::SmallVector;
+/// Checks to see if a all the parameters of a template function with a given
+/// index refer to the same type.
+AST_MATCHER_P(FunctionDecl, areParametersSameTemplateType, SVU, Indexes) {
+  const FunctionTemplateDecl *TemplateDecl = Node.getPrimaryTemplate();
+  if (!TemplateDecl)
+return false;
+  const FunctionDecl *FuncDecl = TemplateDecl->getTemplatedDecl();
+  if (!FuncDecl)
+return false;
+  assert(!Indexes.empty());
+  if (llvm::any_of(Indexes, [Count(FuncDecl->getNumParams())](unsi

[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread via cfe-commits

https://github.com/ivanaivanovska updated 
https://github.com/llvm/llvm-project/pull/100985

>From 8ee4d7bcdbc186e86d4ff2374b12a54f05d1fc38 Mon Sep 17 00:00:00 2001
From: Ivana Ivanovska 
Date: Mon, 29 Jul 2024 08:08:00 +
Subject: [PATCH 1/2] Surface error for plain return statement in coroutine
 earlier

---
 clang/lib/Sema/SemaCoroutine.cpp  |  2 +-
 clang/lib/Sema/SemaStmt.cpp   | 10 +
 clang/test/SemaCXX/coroutines.cpp | 35 +++
 3 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Sema/SemaCoroutine.cpp b/clang/lib/Sema/SemaCoroutine.cpp
index 81334c817b2af..87d0d44c5af66 100644
--- a/clang/lib/Sema/SemaCoroutine.cpp
+++ b/clang/lib/Sema/SemaCoroutine.cpp
@@ -1120,7 +1120,7 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, 
Stmt *&Body) {
 
   // [stmt.return.coroutine]p1:
   //   A coroutine shall not enclose a return statement ([stmt.return]).
-  if (Fn->FirstReturnLoc.isValid()) {
+  if (Fn->FirstReturnLoc.isValid() && Fn->FirstReturnLoc < 
Fn->FirstCoroutineStmtLoc) {
 assert(Fn->FirstCoroutineStmtLoc.isValid() &&
"first coroutine location not set");
 Diag(Fn->FirstReturnLoc, diag::err_return_in_coroutine);
diff --git a/clang/lib/Sema/SemaStmt.cpp b/clang/lib/Sema/SemaStmt.cpp
index 34d2d398f244d..3909892ef0a6f 100644
--- a/clang/lib/Sema/SemaStmt.cpp
+++ b/clang/lib/Sema/SemaStmt.cpp
@@ -3747,6 +3747,16 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr 
*RetValExp,
 Diag(ReturnLoc, diag::err_acc_branch_in_out_compute_construct)
 << /*return*/ 1 << /*out of */ 0);
 
+  // using plain return in a coroutine is not allowed.
+  FunctionScopeInfo *FSI = getCurFunction();
+  if (getLangOpts().Coroutines && FSI->isCoroutine()) {
+assert(FSI->FirstCoroutineStmtLoc.isValid() &&
+  "first coroutine location not set");
+Diag(ReturnLoc, diag::err_return_in_coroutine);
+Diag(FSI->FirstCoroutineStmtLoc, diag::note_declared_coroutine_here)
+<< FSI->getFirstCoroutineStmtKeyword();
+  }
+
   StmtResult R =
   BuildReturnStmt(ReturnLoc, RetVal.get(), /*AllowRecovery=*/true);
   if (R.isInvalid() || ExprEvalContexts.back().isDiscardedStatementContext())
diff --git a/clang/test/SemaCXX/coroutines.cpp 
b/clang/test/SemaCXX/coroutines.cpp
index 2292932583fff..b4f362c621929 100644
--- a/clang/test/SemaCXX/coroutines.cpp
+++ b/clang/test/SemaCXX/coroutines.cpp
@@ -154,12 +154,15 @@ namespace std {
 template 
 struct coroutine_handle {
   static coroutine_handle from_address(void *) noexcept;
+  static coroutine_handle from_promise(PromiseType &promise);
 };
 template <>
 struct coroutine_handle {
   template 
   coroutine_handle(coroutine_handle) noexcept;
   static coroutine_handle from_address(void *) noexcept;
+  template 
+  static coroutine_handle from_promise(PromiseType &promise);
 };
 } // namespace std
 
@@ -291,6 +294,38 @@ void mixed_coreturn_template2(bool b, T) {
 return; // expected-error {{not allowed in coroutine}}
 }
 
+struct promise_handle;
+
+struct Handle : std::coroutine_handle { // expected-note 
2{{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-1 2{{candidate constructor (the implicit move 
constructor) not viable}}
+using promise_type = promise_handle;
+};
+
+struct promise_handle {
+Handle get_return_object() noexcept {
+  { return 
Handle(std::coroutine_handle::from_promise(*this)); }
+}
+suspend_never initial_suspend() const noexcept { return {}; }
+suspend_never final_suspend() const noexcept { return {}; }
+void return_void() const noexcept {}
+void unhandled_exception() const noexcept {}
+};
+
+Handle mixed_return_value() {
+  co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+  return 0; // expected-error {{return statement not allowed in coroutine}}
+  // expected-error@-1 {{no viable conversion from returned value of type}}
+}
+
+Handle mixed_return_value_return_first(bool b) {
+   if (b) {
+return 0; // expected-error {{no viable conversion from returned value 
of type}}
+// expected-error@-1 {{return statement not allowed in coroutine}}
+}
+co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+co_return 0; // expected-error {{no member named 'return_value' in 
'promise_handle'}}
+}
+
 struct CtorDtor {
   CtorDtor() {
 co_yield 0; // expected-error {{'co_yield' cannot be used in a 
constructor}}

>From 8d2a30e3e0b32ef4b7db63d5f320eacf56c00610 Mon Sep 17 00:00:00 2001
From: Ivana Ivanovska 
Date: Thu, 1 Aug 2024 08:34:36 +
Subject: [PATCH 2/2] Applied fixes related to the comments in the PR.

---
 clang/lib/Sema/SemaCoroutine.cpp  | 27 +
 clang/lib/Sema/SemaStmt.cpp   |  2 +-
 clang/test/SemaCXX/coroutines.cpp | 40 +--
 3 files changed, 56 insertions(+), 13 deletions(-)

diff --git a/cl

[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-08-01 Thread Mital Ashok via cfe-commits

MitalAshok wrote:

I think the issue is here somewhere:

https://github.com/llvm/llvm-project/blob/7088a5ed880f29129ec844c66068e8cb61ca98bf/clang/lib/Sema/SemaDecl.cpp#L8753-L8764

An incomplete struct passes `CheckC23ConstexprVarType` (which it should, 
incomplete types should fail later) so it goes on to the next check. We should 
only check `RequireLiteralType` in C++. The cast isn't failing because it's 
expecting a complete type, it's failing because it's expecting a 
`CXXRecordDecl` when we only have a C `RecordDecl`.


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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-08-01 Thread Oleksandr T. via cfe-commits


@@ -9267,14 +9267,14 @@ bool Sema::RequireLiteralType(SourceLocation Loc, 
QualType T,
   if (!RT)
 return true;
 
-  const CXXRecordDecl *RD = cast(RT->getDecl());
-
   // A partially-defined class type can't be a literal type, because a literal
   // class type must have a trivial destructor (which can't be checked until
   // the class definition is complete).
   if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
 return true;
 
+  const CXXRecordDecl *RD = cast(RT->getDecl());

a-tarasyuk wrote:

> I am also curious why this does not show up in C++, we obtain a similar 
> diagnostic but no crash.

Please correct me if I'm wrong, the `CXXRecordDecl` is specific to C++ 
declarations, so the cast works as expected. In a C env, `RecordDecl` is used 
instead. We could wrap this in a condition to check specifically for C++, but 
`*RD` isn't required for `RequireCompleteType`. `RequireCompleteType` handles 
cases related to incomplete C types, so I'm not sure if we need to perform 
additional checks here.

```cpp
if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
return true;
```



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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-08-01 Thread Oleksandr T. via cfe-commits


@@ -9267,14 +9267,14 @@ bool Sema::RequireLiteralType(SourceLocation Loc, 
QualType T,
   if (!RT)
 return true;
 
-  const CXXRecordDecl *RD = cast(RT->getDecl());
-
   // A partially-defined class type can't be a literal type, because a literal
   // class type must have a trivial destructor (which can't be checked until
   // the class definition is complete).
   if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
 return true;
 
+  const CXXRecordDecl *RD = cast(RT->getDecl());

a-tarasyuk wrote:

@MitalAshok Thanks for the feedback. `RequireLiteralType` is called directly in 
the condition. Should we perform additional checks directly in the condition, 
or should we include them within `RequireLiteralType` to mark the declaration 
as invalid?

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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-08-01 Thread Oleksandr T. via cfe-commits

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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-08-01 Thread Mital Ashok via cfe-commits


@@ -9267,14 +9267,14 @@ bool Sema::RequireLiteralType(SourceLocation Loc, 
QualType T,
   if (!RT)
 return true;
 
-  const CXXRecordDecl *RD = cast(RT->getDecl());
-
   // A partially-defined class type can't be a literal type, because a literal
   // class type must have a trivial destructor (which can't be checked until
   // the class definition is complete).
   if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
 return true;
 
+  const CXXRecordDecl *RD = cast(RT->getDecl());

MitalAshok wrote:

You don't require a literal type for C23 `constexpr`, so part of the condition 
should be `if (getLangOpts().CPlusPlus && NewVD->isConstexpr() && ... && 
RequireLiteralType`, just like how `CheckC23ConstexprVarType` is gated behind 
`getLangOpts().C23 &&`. And add an assertion for `getLangOpts().CPlusPlus` in 
RequireLiteralType for good measure.

The declaration will be marked invalid later by the same code that marks 
`/*!constexpr*/ struct Incomplete s = {};` invalid.

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread via cfe-commits


@@ -291,6 +294,38 @@ void mixed_coreturn_template2(bool b, T) {
 return; // expected-error {{not allowed in coroutine}}
 }
 
+struct promise_handle;
+
+struct Handle : std::coroutine_handle { // expected-note 
2{{candidate constructor (the implicit copy constructor) not viable}}

ivanaivanovska wrote:

Done.

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


[clang] [clang][NFC] Add CWG882 test (Defining `main` as deleted) (PR #101382)

2024-08-01 Thread Mital Ashok via cfe-commits

MitalAshok wrote:

@Endilll Yes, thanks!

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread via cfe-commits


@@ -1120,7 +1120,7 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, 
Stmt *&Body) {
 
   // [stmt.return.coroutine]p1:
   //   A coroutine shall not enclose a return statement ([stmt.return]).
-  if (Fn->FirstReturnLoc.isValid()) {
+  if (Fn->FirstReturnLoc.isValid() && Fn->FirstReturnLoc < 
Fn->FirstCoroutineStmtLoc) {

ivanaivanovska wrote:

Done.

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread via cfe-commits


@@ -3747,6 +3747,16 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr 
*RetValExp,
 Diag(ReturnLoc, diag::err_acc_branch_in_out_compute_construct)
 << /*return*/ 1 << /*out of */ 0);
 
+  // using plain return in a coroutine is not allowed.
+  FunctionScopeInfo *FSI = getCurFunction();
+  if (getLangOpts().Coroutines && FSI->isCoroutine()) {

ivanaivanovska wrote:

Done.

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread via cfe-commits


@@ -291,6 +294,38 @@ void mixed_coreturn_template2(bool b, T) {
 return; // expected-error {{not allowed in coroutine}}
 }
 
+struct promise_handle;
+
+struct Handle : std::coroutine_handle { // expected-note 
2{{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-1 2{{candidate constructor (the implicit move 
constructor) not viable}}
+using promise_type = promise_handle;
+};
+
+struct promise_handle {
+Handle get_return_object() noexcept {
+  { return 
Handle(std::coroutine_handle::from_promise(*this)); }
+}
+suspend_never initial_suspend() const noexcept { return {}; }
+suspend_never final_suspend() const noexcept { return {}; }
+void return_void() const noexcept {}
+void unhandled_exception() const noexcept {}
+};
+
+Handle mixed_return_value() {
+  co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+  return 0; // expected-error {{return statement not allowed in coroutine}}
+  // expected-error@-1 {{no viable conversion from returned value of type}}

ivanaivanovska wrote:

Added tests for the order of the errors in the original file (coroutines.cpp) 
to keep the tests together and reuse the code.

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


[clang] [llvm] [RISCV] Add Syntacore SCR4 RV32/64 processors definition (PR #101321)

2024-08-01 Thread Anton Sidorenko via cfe-commits


@@ -106,6 +106,7 @@ Changes to the RISC-V Backend
 * `.balign N, 0`, `.p2align N, 0`, `.align N, 0` in code sections will now fill
   the required alignment space with a sequence of `0x0` bytes (the requested
   fill value) rather than NOPs.
+* Added Syntacore SCR4 CPUs: ``-mcpu=syntacore-scr4-rv32/64``

asi-sc wrote:

Hm, actually not sure. It looks like a change to RISC-V backend (which is 
propagated to the driver) and previously we mentioned such changes in llvm 
release notes e.g. 
https://github.com/llvm/llvm-project/blob/release/18.x/llvm/docs/ReleaseNotes.rst#changes-to-the-risc-v-backend
 or 
https://github.com/llvm/llvm-project/blob/release/19.x/llvm/docs/ReleaseNotes.rst#changes-to-the-risc-v-backend
 .  Although I don't have a strong opinion on this matter.

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


[clang] [llvm] [RISCV] Add Syntacore SCR4 RV32/64 processors definition (PR #101321)

2024-08-01 Thread Pengcheng Wang via cfe-commits

https://github.com/wangpc-pp approved this pull request.

LGTM.

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


[clang] [CLANG][AArch64]Add Neon vectors for mfloat8_t (PR #99865)

2024-08-01 Thread via cfe-commits

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


[clang] [clang][LoongArch] Align global symbol by size (PR #101309)

2024-08-01 Thread via cfe-commits

heiher wrote:

@nikic @s-barannikov Thanks for your guidance and help.

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread via cfe-commits


@@ -3747,6 +3747,16 @@ Sema::ActOnReturnStmt(SourceLocation ReturnLoc, Expr 
*RetValExp,
 Diag(ReturnLoc, diag::err_acc_branch_in_out_compute_construct)
 << /*return*/ 1 << /*out of */ 0);
 
+  // using plain return in a coroutine is not allowed.
+  FunctionScopeInfo *FSI = getCurFunction();
+  if (getLangOpts().Coroutines && FSI->isCoroutine()) {

ivanaivanovska wrote:

Done.

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


[clang] f3761a4 - [C++20][Modules] Allow using stdarg.h with header units (#100739)

2024-08-01 Thread via cfe-commits

Author: Dmitry Polukhin
Date: 2024-08-01T12:33:20+03:00
New Revision: f3761a4bd320e4334315c87b55f882a4ba864caa

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

LOG: [C++20][Modules] Allow using stdarg.h with header units (#100739)

Summary:
Macro like `va_start`/`va_end` marked as builtin functions that makes
these identifiers special and it results in redefinition of the
identifiers as builtins and it hides macro definitions during preloading
C++ modules. In case of modules Clang ignores special identifiers but
`PP.getCurrentModule()` was not set. This diff fixes IsModule detection
logic for this particular case.

Test Plan: check-clang

-

Co-authored-by: Chuanqi Xu 

Added: 
clang/test/Headers/stdarg-cxx-modules.cpp

Modified: 
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index 86fa96a91932f..85ff3ab8974ee 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -1051,10 +1051,10 @@ IdentifierID 
ASTIdentifierLookupTrait::ReadIdentifierID(const unsigned char *d)
   return Reader.getGlobalIdentifierID(F, RawID >> 1);
 }
 
-static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II) {
+static void markIdentifierFromAST(ASTReader &Reader, IdentifierInfo &II,
+  bool IsModule) {
   if (!II.isFromAST()) {
 II.setIsFromAST();
-bool IsModule = Reader.getPreprocessor().getCurrentModule() != nullptr;
 if (isInterestingIdentifier(Reader, II, IsModule))
   II.setChangedSinceDeserialization();
   }
@@ -1080,7 +1080,8 @@ IdentifierInfo *ASTIdentifierLookupTrait::ReadData(const 
internal_key_type& k,
 II = &Reader.getIdentifierTable().getOwn(k);
 KnownII = II;
   }
-  markIdentifierFromAST(Reader, *II);
+  bool IsModule = Reader.getPreprocessor().getCurrentModule() != nullptr;
+  markIdentifierFromAST(Reader, *II, IsModule);
   Reader.markIdentifierUpToDate(II);
 
   IdentifierID ID = Reader.getGlobalIdentifierID(F, RawID);
@@ -4547,7 +4548,7 @@ ASTReader::ASTReadResult ASTReader::ReadAST(StringRef 
FileName, ModuleKind Type,
 
   // Mark this identifier as being from an AST file so that we can track
   // whether we need to serialize it.
-  markIdentifierFromAST(*this, *II);
+  markIdentifierFromAST(*this, *II, /*IsModule=*/true);
 
   // Associate the ID with the identifier so that the writer can reuse it.
   auto ID = Trait.ReadIdentifierID(Data + KeyDataLen.first);
@@ -8966,7 +8967,8 @@ IdentifierInfo 
*ASTReader::DecodeIdentifierInfo(IdentifierID ID) {
 auto Key = Trait.ReadKey(Data, KeyDataLen.first);
 auto &II = PP.getIdentifierTable().get(Key);
 IdentifiersLoaded[Index] = &II;
-markIdentifierFromAST(*this,  II);
+bool IsModule = getPreprocessor().getCurrentModule() != nullptr;
+markIdentifierFromAST(*this, II, IsModule);
 if (DeserializationListener)
   DeserializationListener->IdentifierRead(ID, &II);
   }

diff  --git a/clang/test/Headers/stdarg-cxx-modules.cpp 
b/clang/test/Headers/stdarg-cxx-modules.cpp
new file mode 100644
index 0..113ece4fb64b3
--- /dev/null
+++ b/clang/test/Headers/stdarg-cxx-modules.cpp
@@ -0,0 +1,25 @@
+// RUN: rm -fR %t
+// RUN: split-file %s %t
+// RUN: cd %t
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header h1.h
+// RUN: %clang_cc1 -std=c++20 -emit-header-unit -xc++-user-header h2.h 
-fmodule-file=h1.pcm
+// RUN: %clang_cc1 -std=c++20 -fsyntax-only main.cpp -fmodule-file=h1.pcm 
-fmodule-file=h2.pcm
+
+//--- h1.h
+#include 
+// expected-no-diagnostics
+
+//--- h2.h
+import "h1.h";
+// expected-no-diagnostics
+
+//--- main.cpp
+import "h1.h";
+import "h2.h";
+
+void foo(int x, ...) {
+  va_list v;
+  va_start(v, x);
+  va_end(v);
+}
+// expected-no-diagnostics



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


[clang] [C++20][Modules] Allow using stdarg.h with header units (PR #100739)

2024-08-01 Thread Dmitry Polukhin via cfe-commits

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits

https://github.com/ilya-biryukov commented:

I have a lot of nitpicks, but otherwise LG, happy to approve as soon as they're 
fixed.

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits


@@ -291,6 +318,50 @@ void mixed_coreturn_template2(bool b, T) {
 return; // expected-error {{not allowed in coroutine}}
 }
 
+struct promise_handle;
+
+struct Handle : std::coroutine_handle { // expected-note 
4{{not viable}}
+// expected-note@-1 4{{not viable}}
+using promise_type = promise_handle;
+};
+
+struct promise_handle {
+Handle get_return_object() noexcept {
+  { return 
Handle(std::coroutine_handle::from_promise(*this)); }
+}
+suspend_never initial_suspend() const noexcept { return {}; }
+suspend_never final_suspend() const noexcept { return {}; }
+void return_void() const noexcept {}
+void unhandled_exception() const noexcept {}
+};
+
+Handle mixed_return_value() {
+  co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+  return 0; // expected-error {{return statement not allowed in coroutine}}
+  // expected-error@-1 {{no viable conversion from returned value of type}}
+  // CHECK-NOT: error: no viable conversion from returned value of type

ilya-biryukov wrote:

Could you add a comment explaining that we are testing the order of diagnostics 
here.

```
// Check that we first show that return is not allowed in coroutine, the error 
about bad conversion is
// most likely spurious so we prefer to have it afterwards.
```

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits


@@ -694,6 +706,10 @@ bool Sema::ActOnCoroutineBodyStart(Scope *SC, 
SourceLocation KWLoc,
   auto *ScopeInfo = getCurFunction();
   assert(ScopeInfo->CoroutinePromise);
 
+  if (ScopeInfo->FirstCoroutineStmtLoc == KWLoc) {

ilya-biryukov wrote:

NIT: remove braces from simple statements, see [LLVM Style 
Guide](https://llvm.org/docs/CodingStandards.html#don-t-use-braces-on-simple-single-statement-bodies-of-if-else-loop-statements)

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits


@@ -291,6 +318,50 @@ void mixed_coreturn_template2(bool b, T) {
 return; // expected-error {{not allowed in coroutine}}
 }
 
+struct promise_handle;
+
+struct Handle : std::coroutine_handle { // expected-note 
4{{not viable}}
+// expected-note@-1 4{{not viable}}
+using promise_type = promise_handle;
+};
+
+struct promise_handle {
+Handle get_return_object() noexcept {
+  { return 
Handle(std::coroutine_handle::from_promise(*this)); }
+}
+suspend_never initial_suspend() const noexcept { return {}; }
+suspend_never final_suspend() const noexcept { return {}; }
+void return_void() const noexcept {}
+void unhandled_exception() const noexcept {}
+};
+
+Handle mixed_return_value() {
+  co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+  return 0; // expected-error {{return statement not allowed in coroutine}}
+  // expected-error@-1 {{no viable conversion from returned value of type}}
+  // CHECK-NOT: error: no viable conversion from returned value of type
+  // CHECK: error: return statement not allowed in coroutine
+  // CHECK: error: no viable conversion from returned value of type
+}
+
+Handle mixed_return_value_return_first(bool b) {
+   if (b) {
+return 0; // expected-error {{no viable conversion from returned value 
of type}}
+// expected-error@-1 {{return statement not allowed in coroutine}}
+}
+co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+co_return 0; // expected-error {{no member named 'return_value' in 
'promise_handle'}}
+}
+
+Handle mixed_multiple_returns(bool b) {
+  if (b) {
+return 0; // expected-error {{no viable conversion from returned value of 
type}}
+// expected-error@-1 {{return statement not allowed in coroutine}}
+  }
+  co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+  return 0; // expected-error {{no viable conversion from returned value of 
type}}

ilya-biryukov wrote:

NIT: could you add a comment explaining that we do not want the duplicate error?
(it's easy for the reader to understand the expected warnings that are written 
in the code, but it's harder to understand the intention when it's not written)

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits


@@ -684,6 +684,18 @@ bool Sema::checkFinalSuspendNoThrow(const Stmt 
*FinalSuspend) {
   return ThrowingDecls.empty();
 }
 
+// [stmt.return.coroutine]p1:
+//   A coroutine shall not enclose a return statement ([stmt.return]).
+static void checkReturnStmtInCoroutine(Sema &S, FunctionScopeInfo *FSI) {
+  if (FSI && FSI->FirstReturnLoc.isValid()) {

ilya-biryukov wrote:

NIT: negate the condition to reduce nesting, see LLVM style guide on [using 
early 
exits](https://llvm.org/docs/CodingStandards.html#use-early-exits-and-continue-to-simplify-code)

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits


@@ -684,6 +684,18 @@ bool Sema::checkFinalSuspendNoThrow(const Stmt 
*FinalSuspend) {
   return ThrowingDecls.empty();
 }
 
+// [stmt.return.coroutine]p1:
+//   A coroutine shall not enclose a return statement ([stmt.return]).
+static void checkReturnStmtInCoroutine(Sema &S, FunctionScopeInfo *FSI) {
+  if (FSI && FSI->FirstReturnLoc.isValid()) {
+  assert(FSI->FirstCoroutineStmtLoc.isValid() &&

ilya-biryukov wrote:

NIT: we could move this assertion to the start of the function. As the name 
implies, the `checkReturnStmtInCoroutine` can only be called on coroutines, so 
validating this invariant is useful even if we don't report any diagnostics.

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits


@@ -291,6 +294,38 @@ void mixed_coreturn_template2(bool b, T) {
 return; // expected-error {{not allowed in coroutine}}
 }
 
+struct promise_handle;
+
+struct Handle : std::coroutine_handle { // expected-note 
2{{candidate constructor (the implicit copy constructor) not viable}}
+// expected-note@-1 2{{candidate constructor (the implicit move 
constructor) not viable}}
+using promise_type = promise_handle;
+};
+
+struct promise_handle {
+Handle get_return_object() noexcept {
+  { return 
Handle(std::coroutine_handle::from_promise(*this)); }
+}
+suspend_never initial_suspend() const noexcept { return {}; }
+suspend_never final_suspend() const noexcept { return {}; }
+void return_void() const noexcept {}
+void unhandled_exception() const noexcept {}
+};
+
+Handle mixed_return_value() {
+  co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+  return 0; // expected-error {{return statement not allowed in coroutine}}
+  // expected-error@-1 {{no viable conversion from returned value of type}}

ilya-biryukov wrote:

LG, thanks!

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits


@@ -3,6 +3,7 @@
 
 // RUN: %clang_cc1 -std=c++23 -fsyntax-only -verify=expected,cxx20_23,cxx23
%s -fcxx-exceptions -fexceptions -Wunused-result
 // RUN: %clang_cc1 -std=c++20 -fsyntax-only -verify=expected,cxx14_20,cxx20_23 
%s -fcxx-exceptions -fexceptions -Wunused-result
+// RUN: not %clang_cc1 -std=c++20 -fsyntax-only %s -fcxx-exceptions 
-fexceptions -Wunused-result 2>&1 | FileCheck %s

ilya-biryukov wrote:

Could you add a comment here explaining to the reader why we need this? It's 
unusual to have `-verify` on some `RUN` lines and not have it on others.

Something like

```
// Run without -verify to check the order of errors we show.
// RUN: not ...
```

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


[clang] Surface error for plain return statement in coroutine earlier (PR #100985)

2024-08-01 Thread Ilya Biryukov via cfe-commits


@@ -291,6 +318,50 @@ void mixed_coreturn_template2(bool b, T) {
 return; // expected-error {{not allowed in coroutine}}
 }
 
+struct promise_handle;
+
+struct Handle : std::coroutine_handle { // expected-note 
4{{not viable}}
+// expected-note@-1 4{{not viable}}
+using promise_type = promise_handle;
+};
+
+struct promise_handle {
+Handle get_return_object() noexcept {
+  { return 
Handle(std::coroutine_handle::from_promise(*this)); }
+}
+suspend_never initial_suspend() const noexcept { return {}; }
+suspend_never final_suspend() const noexcept { return {}; }
+void return_void() const noexcept {}
+void unhandled_exception() const noexcept {}
+};
+
+Handle mixed_return_value() {
+  co_await a; // expected-note {{function is a coroutine due to use of 
'co_await' here}}
+  return 0; // expected-error {{return statement not allowed in coroutine}}
+  // expected-error@-1 {{no viable conversion from returned value of type}}
+  // CHECK-NOT: error: no viable conversion from returned value of type
+  // CHECK: error: return statement not allowed in coroutine
+  // CHECK: error: no viable conversion from returned value of type
+}
+
+Handle mixed_return_value_return_first(bool b) {
+   if (b) {
+return 0; // expected-error {{no viable conversion from returned value 
of type}}
+// expected-error@-1 {{return statement not allowed in coroutine}}

ilya-biryukov wrote:

Could you run `clang-format` over these lines? (E.g. via `git-clang-format` or 
"Format Lines" action from VSCode with Clangd installed). The `// 
expected-error@-1` should get nicely aligned with the previous lines.

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/4] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/4] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/4] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-08-01 Thread Donát Nagy via cfe-commits

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

LGTM, thanks for the updates!

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/5] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/5] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/5] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/6] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/6] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/6] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang] [Clang] Implement C++26’s P2893R3 ‘Variadic friends’ (PR #101448)

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

Endilll wrote:

> Still need to add tests for [CWG 
> 2917](https://cplusplus.github.io/CWG/issues/2917.html), which I filed while 
> working on this, to the DR test suite proper. (@Endilll Sorry for asking this 
> again, but do I need to run the script that updates the DR tests as part of 
> this, or should that be done in a separate pr before this?)

If you do this now, you'll get a lot of non-trivial updates. Ideally you should 
wait for #97200 (@MitalAshok any blockers there?).

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/7] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/7] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/7] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/5] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/5] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/5] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang] 3b3b891 - [clang][NFC] Add CWG882 test (Defining `main` as deleted) (#101382)

2024-08-01 Thread via cfe-commits

Author: Mital Ashok
Date: 2024-08-01T13:59:00+04:00
New Revision: 3b3b89105ee33214654677a02ab30a62eedbd338

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

LOG: [clang][NFC] Add CWG882 test (Defining `main` as deleted) (#101382)

https://cplusplus.github.io/CWG/issues/882.html

This was implemented for Clang 3.5 by
b63b6ee9a00ef0710d899df6cfda78a1b8bd762a

Added: 


Modified: 
clang/test/CXX/drs/cwg8xx.cpp
clang/www/cxx_dr_status.html

Removed: 




diff  --git a/clang/test/CXX/drs/cwg8xx.cpp b/clang/test/CXX/drs/cwg8xx.cpp
index c8cbdfcee3f4d..38bff3adf262a 100644
--- a/clang/test/CXX/drs/cwg8xx.cpp
+++ b/clang/test/CXX/drs/cwg8xx.cpp
@@ -30,3 +30,9 @@ void g(int i) {
 }
 #endif
 } // namespace cwg873
+
+// cwg882: 3.5
+#if __cplusplus >= 201103L
+int main() = delete;
+// since-cxx11-error@-1 {{'main' is not allowed to be deleted}}
+#endif

diff  --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 937f67981e296..0b3477fbd217b 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -5161,7 +5161,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/882.html";>882
 CD2
 Defining main as deleted
-Unknown
+Clang 3.5
   
   
 https://cplusplus.github.io/CWG/issues/883.html";>883



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


[clang] [clang][NFC] Add CWG882 test (Defining `main` as deleted) (PR #101382)

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

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


[clang] [Clang] prevent assertion failure by avoiding casts on type declarations that require complete types (PR #101426)

2024-08-01 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/101426

>From 9aa69a721af265c6e7414f61331395197c398e3e Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Thu, 1 Aug 2024 13:00:04 +0300
Subject: [PATCH] [Clang] prevent assertion failure by avoiding required
 literal type checking in C context

---
 clang/docs/ReleaseNotes.rst | 1 +
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 clang/lib/Sema/SemaType.cpp | 4 ++--
 clang/test/Sema/constexpr.c | 3 +++
 4 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..1a25d270e9509 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -156,6 +156,7 @@ Bug Fixes in This Version
 
 - Fixed the definition of ``ATOMIC_FLAG_INIT`` in  so it can
   be used in C++.
+- Fixed a failed assertion when checking required literal types in C context. 
(#GH101304).
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a3f8126a9f915..4fea38d1b02a9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8756,7 +8756,8 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
 return;
   }
 
-  if (NewVD->isConstexpr() && !T->isDependentType() &&
+  if (getLangOpts().CPlusPlus && NewVD->isConstexpr() &&
+  !T->isDependentType() &&
   RequireLiteralType(NewVD->getLocation(), T,
  diag::err_constexpr_var_non_literal)) {
 NewVD->setInvalidDecl();
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 6fa39cdccef2b..75e1b116e2043 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -9267,14 +9267,14 @@ bool Sema::RequireLiteralType(SourceLocation Loc, 
QualType T,
   if (!RT)
 return true;
 
-  const CXXRecordDecl *RD = cast(RT->getDecl());
-
   // A partially-defined class type can't be a literal type, because a literal
   // class type must have a trivial destructor (which can't be checked until
   // the class definition is complete).
   if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
 return true;
 
+  const CXXRecordDecl *RD = cast(RT->getDecl());
+
   // [expr.prim.lambda]p3:
   //   This class type is [not] a literal type.
   if (RD->isLambda() && !getLangOpts().CPlusPlus17) {
diff --git a/clang/test/Sema/constexpr.c b/clang/test/Sema/constexpr.c
index 8286cd2107d2f..5ea2ac24a503a 100644
--- a/clang/test/Sema/constexpr.c
+++ b/clang/test/Sema/constexpr.c
@@ -357,3 +357,6 @@ void infsNaNs() {
   constexpr double db5 = LD_SNAN; // expected-error {{constexpr initializer 
evaluates to nan which is not exactly representable in type 'const double'}}
   constexpr double db6 = INF;
 }
+
+constexpr struct S9 s9 = {  }; // expected-error {{variable has incomplete 
type 'const struct S9'}} \
+   // expected-note {{forward declaration of 
'struct S9'}}

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


[clang] [Clang] prevent assertion failure by avoiding required literal type checking in C context (PR #101426)

2024-08-01 Thread Oleksandr T. via cfe-commits

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


[clang] [Clang] prevent assertion failure by avoiding required literal type checking in C context (PR #101426)

2024-08-01 Thread Oleksandr T. via cfe-commits


@@ -9267,14 +9267,14 @@ bool Sema::RequireLiteralType(SourceLocation Loc, 
QualType T,
   if (!RT)
 return true;
 
-  const CXXRecordDecl *RD = cast(RT->getDecl());
-
   // A partially-defined class type can't be a literal type, because a literal
   // class type must have a trivial destructor (which can't be checked until
   // the class definition is complete).
   if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
 return true;
 
+  const CXXRecordDecl *RD = cast(RT->getDecl());

a-tarasyuk wrote:

@MitalAshok Oke, I've added changes. BTW, should I move const `CXXRecordDecl 
*RD` back to its original position after `RequireCompleteType`? Thanks



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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/6] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/6] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/6] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang] [Clang] prevent assertion failure by avoiding required literal type checking in C context (PR #101426)

2024-08-01 Thread Mariya Podchishchaeva via cfe-commits


@@ -9267,14 +9267,14 @@ bool Sema::RequireLiteralType(SourceLocation Loc, 
QualType T,
   if (!RT)
 return true;
 
-  const CXXRecordDecl *RD = cast(RT->getDecl());
-
   // A partially-defined class type can't be a literal type, because a literal
   // class type must have a trivial destructor (which can't be checked until
   // the class definition is complete).
   if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
 return true;
 
+  const CXXRecordDecl *RD = cast(RT->getDecl());

Fznamznon wrote:

> should I move const CXXRecordDecl *RD back to its original position after 
> RequireCompleteType?

I think yes. It also makes sense to add `assert(LangOpts.CPlusPlus)` in the 
beginning of `RequireLiteralType` as @MitalAshok already mentioned.

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/7] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/7] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/7] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/8] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/8] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/8] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 1/9] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 2/9] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 3/9] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace
 // M

[clang] [Clang] prevent assertion failure by avoiding required literal type checking in C context (PR #101426)

2024-08-01 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/101426

>From 314766a02c096bd5c867383b55e75451961af231 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Thu, 1 Aug 2024 13:00:04 +0300
Subject: [PATCH] [Clang] prevent assertion failure by avoiding required
 literal type checking in C context

---
 clang/docs/ReleaseNotes.rst | 1 +
 clang/lib/Sema/SemaDecl.cpp | 3 ++-
 clang/test/Sema/constexpr.c | 3 +++
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3c2e0282d1c72..1a25d270e9509 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -156,6 +156,7 @@ Bug Fixes in This Version
 
 - Fixed the definition of ``ATOMIC_FLAG_INIT`` in  so it can
   be used in C++.
+- Fixed a failed assertion when checking required literal types in C context. 
(#GH101304).
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index a3f8126a9f915..4fea38d1b02a9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -8756,7 +8756,8 @@ void Sema::CheckVariableDeclarationType(VarDecl *NewVD) {
 return;
   }
 
-  if (NewVD->isConstexpr() && !T->isDependentType() &&
+  if (getLangOpts().CPlusPlus && NewVD->isConstexpr() &&
+  !T->isDependentType() &&
   RequireLiteralType(NewVD->getLocation(), T,
  diag::err_constexpr_var_non_literal)) {
 NewVD->setInvalidDecl();
diff --git a/clang/test/Sema/constexpr.c b/clang/test/Sema/constexpr.c
index 8286cd2107d2f..5ea2ac24a503a 100644
--- a/clang/test/Sema/constexpr.c
+++ b/clang/test/Sema/constexpr.c
@@ -357,3 +357,6 @@ void infsNaNs() {
   constexpr double db5 = LD_SNAN; // expected-error {{constexpr initializer 
evaluates to nan which is not exactly representable in type 'const double'}}
   constexpr double db6 = INF;
 }
+
+constexpr struct S9 s9 = {  }; // expected-error {{variable has incomplete 
type 'const struct S9'}} \
+   // expected-note {{forward declaration of 
'struct S9'}}

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


[clang] [Clang] prevent assertion failure by avoiding required literal type checking in C context (PR #101426)

2024-08-01 Thread Oleksandr T. via cfe-commits


@@ -9267,14 +9267,14 @@ bool Sema::RequireLiteralType(SourceLocation Loc, 
QualType T,
   if (!RT)
 return true;
 
-  const CXXRecordDecl *RD = cast(RT->getDecl());
-
   // A partially-defined class type can't be a literal type, because a literal
   // class type must have a trivial destructor (which can't be checked until
   // the class definition is complete).
   if (RequireCompleteType(Loc, ElemType, diag::note_non_literal_incomplete, T))
 return true;
 
+  const CXXRecordDecl *RD = cast(RT->getDecl());

a-tarasyuk wrote:

@Fznamznon Thanks. I've reverted. Yep, this isn't necessary to fix the issue., 
it's more about code cleanup.

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


[clang] [clang][CGRecordLayout] Remove dependency on isZeroSize (PR #96422)

2024-08-01 Thread Michael Buch via cfe-commits


@@ -137,6 +137,16 @@ bool isEmptyField(ASTContext &Context, const FieldDecl 
*FD, bool AllowArrays,
 bool isEmptyRecord(ASTContext &Context, QualType T, bool AllowArrays,
bool AsIfNoUniqueAddr = false);
 
+/// isEmptyFieldForLayout - Return true iff the field is "empty", that is,
+/// either a zero-width bit-field or an \ref isEmptyRecordForLayout.
+bool isEmptyFieldForLayout(const ASTContext &Context, const FieldDecl *FD);
+
+/// isEmptyRecordForLayout - Return true iff a structure contains only empty
+/// base classes (per \ref isEmptyRecordForLayout) and fields (per
+/// \ref isEmptyFieldForLayout). Note, C++ record fields are considered empty
+/// if the [[no_unique_address]] attribute would have made them empty.
+bool isEmptyRecordForLayout(const ASTContext &Context, QualType T);

Michael137 wrote:

I put those here just to have them next to `isEmptyRecord`/`isEmptyField`, 
which are used outside the implementation of `ABIInfo`. But agree with your 
point. These should probably all live in `CGRecordLayout` instead

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 01/10] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 02/10] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 03/10] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace

[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

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


[clang] [clang] Fix crash with multiple non-parenthsized `sizeof` (PR #101297)

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

https://github.com/Endilll updated 
https://github.com/llvm/llvm-project/pull/101297

>From d75b3cef41c370fef939a347935a4f3ed53c46ea Mon Sep 17 00:00:00 2001
From: Vlad Serebrennikov 
Date: Wed, 31 Jul 2024 10:29:04 +0300
Subject: [PATCH 1/4] [clang] Fix crash with multiple non-parenthsized `sizeof`

---
 clang/lib/Parse/ParseExpr.cpp |  14 +-
 .../parser-overflow-non-parenthesized.c   | 135 ++
 2 files changed, 148 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Parser/parser-overflow-non-parenthesized.c

diff --git a/clang/lib/Parse/ParseExpr.cpp b/clang/lib/Parse/ParseExpr.cpp
index e82b565272831..e501d5e91e77d 100644
--- a/clang/lib/Parse/ParseExpr.cpp
+++ b/clang/lib/Parse/ParseExpr.cpp
@@ -2479,7 +2479,19 @@ Parser::ParseExprAfterUnaryExprOrTypeTrait(const Token 
&OpTok,
   return ExprError();
 }
 
-Operand = ParseCastExpression(UnaryExprOnly);
+// If we're parsing a chain that consists of keywords that could be
+// followed by a non-parenthesized expression, BalancedDelimiterTracker
+// is not going to help when the nesting is too deep. In this corner case
+// we continue to parse with sufficient stack space to avoid crashing.
+if (OpTok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
+  tok::kw_alignof, tok::kw__Alignof) &&
+Tok.isOneOf(tok::kw_sizeof, tok::kw___datasizeof, tok::kw___alignof,
+tok::kw_alignof, tok::kw__Alignof))
+  Actions.runWithSufficientStackSpace(Tok.getLocation(), [&] {
+Operand = ParseCastExpression(UnaryExprOnly);
+  });
+else
+  Operand = ParseCastExpression(UnaryExprOnly);
   } else {
 // If it starts with a '(', we know that it is either a parenthesized
 // type-name, or it is a unary-expression that starts with a compound
diff --git a/clang/test/Parser/parser-overflow-non-parenthesized.c 
b/clang/test/Parser/parser-overflow-non-parenthesized.c
new file mode 100644
index 0..b6c7485274090
--- /dev/null
+++ b/clang/test/Parser/parser-overflow-non-parenthesized.c
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 %s 2>&1 | FileCheck %s
+
+void f(void) {
+  // 600 sizeof's
+  int a =
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof
+  sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeof sizeo

[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 01/11] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 02/11] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 03/11] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace

[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

https://github.com/PeterChou1 updated 
https://github.com/llvm/llvm-project/pull/101387

>From 3ec4d5b9e5bc24bfb466d65fd9c45c51fa6d3e94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Wed, 31 Jul 2024 14:52:11 -0400
Subject: [PATCH 01/11] [clang-doc] uncomment unsupported

---
 clang-tools-extra/test/clang-doc/basic-project.test | 3 ---
 1 file changed, 3 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 38569d824f1f0..51d3ac6ce6dcd 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -1,6 +1,3 @@
-// See https://github.com/llvm/llvm-project/issues/97507.
-// UNSUPPORTED: target={{.*}}
-
 // RUN: rm -rf %t && mkdir -p %t/docs %t/build
 // RUN: sed 's|$test_dir|%/S|g' %S/Inputs/basic-project/database_template.json 
> %t/build/compile_commands.json
 // RUN: clang-doc --format=html --output=%t/docs --executor=all-TUs 
%t/build/compile_commands.json

>From 114a5721e593a9b57ef31ed9856d0bce4a62da94 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 03:24:42 -0400
Subject: [PATCH 02/11] [clang-doc] fix non-determinism

---
 clang-tools-extra/clang-doc/tool/ClangDocMain.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp 
b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
index 3363cafeded5e..9a540a5061b6a 100644
--- a/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
+++ b/clang-tools-extra/clang-doc/tool/ClangDocMain.cpp
@@ -287,7 +287,14 @@ Example usage for a project using a compile commands 
database:
 auto R = USRToBitcode.try_emplace(Key, std::vector());
 R.first->second.emplace_back(Value);
   });
-
+  
+  for (auto &Entry : USRToBitcode) {
+std::vector &Bitcode = Entry.second;
+std::sort(Bitcode.begin(), Bitcode.end(),
+  [](const llvm::StringRef &A, const llvm::StringRef &B) {
+return A < B;
+  });
+  }
   // Collects all Infos according to their unique USR value. This map is added
   // to from the thread pool below and is protected by the USRToInfoMutex.
   llvm::sys::Mutex USRToInfoMutex;

>From 556adbf8e1219d73c4ae859036be7ac21abd3762 Mon Sep 17 00:00:00 2001
From: PeterChou1 
Date: Thu, 1 Aug 2024 04:11:45 -0400
Subject: [PATCH 03/11] [clang-doc] fix tests

---
 .../test/clang-doc/basic-project.test | 12 +++
 .../test/clang-doc/namespace.cpp  |  6 ++--
 .../test/clang-doc/templates.cpp  | 34 +--
 3 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/clang-tools-extra/test/clang-doc/basic-project.test 
b/clang-tools-extra/test/clang-doc/basic-project.test
index 51d3ac6ce6dcd..ee80493f6d7fa 100644
--- a/clang-tools-extra/test/clang-doc/basic-project.test
+++ b/clang-tools-extra/test/clang-doc/basic-project.test
@@ -73,12 +73,12 @@
 // HTML-CALC:  add
 // HTML-CALC:  public int add(int a, int b)
 // HTML-CALC:  Defined at line 3 of file {{.*}}Calculator.cpp
-// HTML-CALC:  subtract
-// HTML-CALC:  public int subtract(int a, int b)
-// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  multiply
 // HTML-CALC:  public int multiply(int a, int b)
 // HTML-CALC:  Defined at line 11 of file {{.*}}Calculator.cpp
+// HTML-CALC:  subtract
+// HTML-CALC:  public int subtract(int a, int b)
+// HTML-CALC:  Defined at line 7 of file {{.*}}Calculator.cpp
 // HTML-CALC:  divide
 // HTML-CALC:  public double divide(int a, int b)
 // HTML-CALC:  Defined at line 15 of file {{.*}}Calculator.cpp
@@ -114,15 +114,15 @@
 // HTML-CIRCLE: Members
 // HTML-CIRCLE: private double radius_
 // HTML-CIRCLE: Functions
-// HTML-CIRCLE: Circle
-// HTML-CIRCLE: public void Circle(double radius)
-// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: area
 // HTML-CIRCLE: public double area()
 // HTML-CIRCLE: Defined at line 5 of file {{.*}}Circle.cpp
 // HTML-CIRCLE: perimeter
 // HTML-CIRCLE: public double perimeter()
 // HTML-CIRCLE: Defined at line 9 of file {{.*}}Circle.cpp
+// HTML-CIRCLE: Circle
+// HTML-CIRCLE: public void Circle(double radius)
+// HTML-CIRCLE: Defined at line 3 of file {{.*}}Circle.cpp
 
 // MD-CALC: # class Calculator
 // MD-CALC: *Defined at .{{[\/]}}include{{[\/]}}Calculator.h#8*
diff --git a/clang-tools-extra/test/clang-doc/namespace.cpp 
b/clang-tools-extra/test/clang-doc/namespace.cpp
index 12f3cb8a84bc6..4881f942fe52a 100644
--- a/clang-tools-extra/test/clang-doc/namespace.cpp
+++ b/clang-tools-extra/test/clang-doc/namespace.cpp
@@ -271,15 +271,15 @@ namespace AnotherNamespace {
 // HTML-GLOBAL-INDEX: 
 // HTML-GLOBAL-INDEX: Global Namespace
 // HTML-GLOBAL-INDEX: Namespaces
-// HTML-GLOBAL-INDEX: @nonymous_namespace
 // HTML-GLOBAL-INDEX: PrimaryNamespace
 // HTML-GLOBAL-INDEX: AnotherNamespace
+// HTML-GLOBAL-INDEX: @nonymous_namespace
 
 // MD-GLOBAL-INDEX: # Global Namespace

[clang] [Clang] Add [[clang::diagnose_specializations]] (PR #101469)

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

https://github.com/philnik777 created 
https://github.com/llvm/llvm-project/pull/101469

This can be used to inform users when a template should not be specialized. For 
example, this is the case for the standard type traits (except for 
`common_type` and `common_reference`, which have more complicated rules).


>From 82ab798fc72c6de64ae527d96393f0dc67307e98 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Thu, 1 Aug 2024 12:30:22 +0200
Subject: [PATCH] [Clang] Add [[clang::diagnose_specializations]]

---
 clang/include/clang/Basic/Attr.td | 13 ++-
 clang/include/clang/Basic/AttrDocs.td | 14 ++--
 clang/include/clang/Basic/DiagnosticGroups.td |  1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  3 ++
 clang/lib/Sema/SemaDeclAttr.cpp   |  9 +
 clang/lib/Sema/SemaTemplate.cpp   |  6 
 .../SemaCXX/attr-diagnose-specializations.cpp | 34 +++
 7 files changed, 76 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/SemaCXX/attr-diagnose-specializations.cpp

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 8ac2079099c85..e074cc8b285a9 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -103,6 +103,9 @@ def NonParmVar : SubsetSubjecthasLocalStorage()}],
 "variables with non-local storage">;
+def VarTmpl : SubsetSubjectgetDescribedVarTemplate()}],
+"variable template">;
+
 def NonBitField : SubsetSubjectisBitField()}],
 "non-bit-field non-static data members">;
@@ -3327,6 +3330,14 @@ def DiagnoseIf : InheritableAttr {
   let Documentation = [DiagnoseIfDocs];
 }
 
+def DiagnoseSpecializations : InheritableAttr {
+  let Spellings = [Clang<"diagnose_specializations", /*AllowInC*/0>];
+  let Subjects = SubjectList<[ClassTmpl, VarTmpl]>;
+  let Documentation = [DiagnoseSpecializationsDocs];
+  let MeaningfulToClassTemplateDefinition = 1;
+  let TemplateDependent = 1;
+}
+
 def ArcWeakrefUnavailable : InheritableAttr {
   let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
@@ -4581,7 +4592,7 @@ def HLSLResource : InheritableAttr {
   let Spellings = [];
   let Subjects = SubjectList<[Struct]>;
   let LangOpts = [HLSL];
-  let Args = [
+  let Args = [
 EnumArgument<
 "ResourceKind", "llvm::hlsl::ResourceKind",
 /*is_string=*/0,
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 94c284fc73158..4ca67a63714d4 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -975,6 +975,15 @@ Query for this feature with 
``__has_attribute(diagnose_if)``.
   }];
 }
 
+def DiagnoseSpecializationsDocs : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+``clang::diagnose_specializations`` can be appied to class templates which
+should not be specialized by users. This is primarily used to diagnose user
+specializations of standard library type traits.
+  }];
+}
+
 def PassObjectSizeDocs : Documentation {
   let Category = DocCatVariable; // Technically it's a parameter doc, but eh.
   let Heading = "pass_object_size, pass_dynamic_object_size";
@@ -7388,10 +7397,10 @@ def HLSLLoopHintDocs : Documentation {
   let Content = [{
 The ``[loop]`` directive allows loop optimization hints to be
 specified for the subsequent loop. The directive allows unrolling to
-be disabled and is not compatible with [unroll(x)]. 
+be disabled and is not compatible with [unroll(x)].
 
 Specifying the parameter, ``[loop]``, directs the
-unroller to not unroll the loop. 
+unroller to not unroll the loop.
 
 .. code-block:: hlsl
 
@@ -8306,4 +8315,3 @@ Declares that a function potentially allocates heap 
memory, and prevents any pot
 of ``nonallocating`` by the compiler.
   }];
 }
-
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 19c3f1e043349..d6f6111f70868 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -472,6 +472,7 @@ def ExpansionToDefined : DiagGroup<"expansion-to-defined">;
 def FlagEnum : DiagGroup<"flag-enum">;
 def IncrementBool : DiagGroup<"increment-bool", [DeprecatedIncrementBool]>;
 def InfiniteRecursion : DiagGroup<"infinite-recursion">;
+def InvalidSpecialization : DiagGroup<"invalid-specialization">;
 def PureVirtualCallFromCtorDtor: 
DiagGroup<"call-to-pure-virtual-from-ctor-dtor">;
 def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">;
 def IgnoredGCH : DiagGroup<"ignored-gch">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 581434d33c5c9..5972d630347ec 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5407,6 

[clang] [Clang] Add [[clang::diagnose_specializations]] (PR #101469)

2024-08-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nikolas Klauser (philnik777)


Changes

This can be used to inform users when a template should not be specialized. For 
example, this is the case for the standard type traits (except for 
`common_type` and `common_reference`, which have more complicated rules).


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


7 Files Affected:

- (modified) clang/include/clang/Basic/Attr.td (+12-1) 
- (modified) clang/include/clang/Basic/AttrDocs.td (+11-3) 
- (modified) clang/include/clang/Basic/DiagnosticGroups.td (+1) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+3) 
- (modified) clang/lib/Sema/SemaDeclAttr.cpp (+9) 
- (modified) clang/lib/Sema/SemaTemplate.cpp (+6) 
- (added) clang/test/SemaCXX/attr-diagnose-specializations.cpp (+34) 


``diff
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 8ac2079099c85..e074cc8b285a9 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -103,6 +103,9 @@ def NonParmVar : SubsetSubjecthasLocalStorage()}],
 "variables with non-local storage">;
+def VarTmpl : SubsetSubjectgetDescribedVarTemplate()}],
+"variable template">;
+
 def NonBitField : SubsetSubjectisBitField()}],
 "non-bit-field non-static data members">;
@@ -3327,6 +3330,14 @@ def DiagnoseIf : InheritableAttr {
   let Documentation = [DiagnoseIfDocs];
 }
 
+def DiagnoseSpecializations : InheritableAttr {
+  let Spellings = [Clang<"diagnose_specializations", /*AllowInC*/0>];
+  let Subjects = SubjectList<[ClassTmpl, VarTmpl]>;
+  let Documentation = [DiagnoseSpecializationsDocs];
+  let MeaningfulToClassTemplateDefinition = 1;
+  let TemplateDependent = 1;
+}
+
 def ArcWeakrefUnavailable : InheritableAttr {
   let Spellings = [Clang<"objc_arc_weak_reference_unavailable">];
   let Subjects = SubjectList<[ObjCInterface], ErrorDiag>;
@@ -4581,7 +4592,7 @@ def HLSLResource : InheritableAttr {
   let Spellings = [];
   let Subjects = SubjectList<[Struct]>;
   let LangOpts = [HLSL];
-  let Args = [
+  let Args = [
 EnumArgument<
 "ResourceKind", "llvm::hlsl::ResourceKind",
 /*is_string=*/0,
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 94c284fc73158..4ca67a63714d4 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -975,6 +975,15 @@ Query for this feature with 
``__has_attribute(diagnose_if)``.
   }];
 }
 
+def DiagnoseSpecializationsDocs : Documentation {
+  let Category = DocCatDecl;
+  let Content = [{
+``clang::diagnose_specializations`` can be appied to class templates which
+should not be specialized by users. This is primarily used to diagnose user
+specializations of standard library type traits.
+  }];
+}
+
 def PassObjectSizeDocs : Documentation {
   let Category = DocCatVariable; // Technically it's a parameter doc, but eh.
   let Heading = "pass_object_size, pass_dynamic_object_size";
@@ -7388,10 +7397,10 @@ def HLSLLoopHintDocs : Documentation {
   let Content = [{
 The ``[loop]`` directive allows loop optimization hints to be
 specified for the subsequent loop. The directive allows unrolling to
-be disabled and is not compatible with [unroll(x)]. 
+be disabled and is not compatible with [unroll(x)].
 
 Specifying the parameter, ``[loop]``, directs the
-unroller to not unroll the loop. 
+unroller to not unroll the loop.
 
 .. code-block:: hlsl
 
@@ -8306,4 +8315,3 @@ Declares that a function potentially allocates heap 
memory, and prevents any pot
 of ``nonallocating`` by the compiler.
   }];
 }
-
diff --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 19c3f1e043349..d6f6111f70868 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -472,6 +472,7 @@ def ExpansionToDefined : DiagGroup<"expansion-to-defined">;
 def FlagEnum : DiagGroup<"flag-enum">;
 def IncrementBool : DiagGroup<"increment-bool", [DeprecatedIncrementBool]>;
 def InfiniteRecursion : DiagGroup<"infinite-recursion">;
+def InvalidSpecialization : DiagGroup<"invalid-specialization">;
 def PureVirtualCallFromCtorDtor: 
DiagGroup<"call-to-pure-virtual-from-ctor-dtor">;
 def GNUImaginaryConstant : DiagGroup<"gnu-imaginary-constant">;
 def IgnoredGCH : DiagGroup<"ignored-gch">;
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 581434d33c5c9..5972d630347ec 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5407,6 +5407,9 @@ def note_dependent_function_template_spec_discard_reason 
: Note<
   "candidate ignored: %select{not a function template|"
   "not a member of the enclosing %select{class template|"
   "namespace; di

[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

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


[clang] RFC: [cmake] Export CLANG_RESOURCE_DIR in ClangConfig (PR #97197)

2024-08-01 Thread Kim Gräsman via cfe-commits

kimgr wrote:

@llvm-beanz 

> @etcwilde's point above is that the CLANG_RESOURCE_DIR is already available 
> in CMake for projects
> that import the Clang package or are built in-tree with Clang. 

I don't think so. As far as I can tell:

* `clang-resource-headers` interface header dir would be the full path to the 
builtin headers dir, e.g. `/usr/lib/llvm-19/lib/clang/19/include`
* Unfortunately the Debian packages from apt.llvm.org don't define 
`clang-resource-headers`, though the target name is listed in 
`CLANG_EXPORTED_TARGETS`
* `clang-19 -print-resource-dir` prints the effective resource dir: 
`/usr/lib/llvm-19/lib/clang/19`
* `CLANG_RESOURCE_DIR` appears to be designed to be a relative path appended to 
`/usr/lib/llvm-19/{bin,lib}`

So I'm thinking even if the `clang-resource-headers` target was available, it 
would not give the path to the resource dir, but rather the path to the subdir 
containing the builtin headers. That might be fine, i.e. I could take that path 
and add it with `-isystem ...`, but if the resource dir is already implicitly 
on the header search path, that seems preferable.


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


[clang-tools-extra] [clang-doc] fix flaky test in clang-doc (PR #101387)

2024-08-01 Thread via cfe-commits

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


[clang] [Clang][Sema][OpenMP] Allow `num_teams` to accept multiple expressions (PR #99732)

2024-08-01 Thread Alexey Bataev via cfe-commits

https://github.com/alexey-bataev commented:

Update OpenMPSupport.rst and include info about changes to release notes

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


[clang] [C11] Claim conformance to WG14 N1396 (PR #101214)

2024-08-01 Thread via cfe-commits


@@ -501,7 +501,13 @@ C11 implementation status
 
   Wide function returns (alternate proposal)
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1396.htm";>N1396
-  Unknown
+  
+Yes*
+Clang conforms to this paper on all targets except 32-bit x86 without
+SSE2. However, Clang does not claim conformance or intend to conform to
+Annex F on that target, so we vacuously conform.

h-vetinari wrote:

The "or" IMO breaks the link to "does not" (spoken language is much more 
fungible with operator precedence...), so I'd formulate this as `not X and not 
Y`, rather than `not (X or Y)`. Also, I wouldn't call "support on all but one 
niche target" to be "vacuous".
```suggestion
SSE2. However, Clang does not claim conformance (nor intends to conform)
to Annex F on that target, so overall we can still claim full 
conformance.
```

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


[clang] cab91ec - [clang][analyzer] Improve PointerSubChecker (#96501)

2024-08-01 Thread via cfe-commits

Author: Balázs Kéri
Date: 2024-08-01T12:56:25+02:00
New Revision: cab91ecffd7a6cb94fa27e7fe8cd93dfc4d9a672

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

LOG: [clang][analyzer] Improve PointerSubChecker (#96501)

The checker could report false positives if pointer arithmetic was done
on pointers to non-array data before pointer subtraction. Another
problem is fixed that could cause false positive if members of the same
structure but in different memory objects are subtracted.

Added: 


Modified: 
clang/docs/analyzer/checkers.rst
clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
clang/test/Analysis/pointer-sub.c

Removed: 




diff  --git a/clang/docs/analyzer/checkers.rst 
b/clang/docs/analyzer/checkers.rst
index 05d3f4d4018f7..55832d20bd27a 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2498,15 +2498,49 @@ Check for pointer arithmetic on locations other than 
array elements.
 
 alpha.core.PointerSub (C)
 "
-Check for pointer subtractions on two pointers pointing to 
diff erent memory chunks.
+Check for pointer subtractions on two pointers pointing to 
diff erent memory
+chunks. According to the C standard §6.5.6 only subtraction of pointers that
+point into (or one past the end) the same array object is valid (for this
+purpose non-array variables are like arrays of size 1).
 
 .. code-block:: c
 
  void test() {
-   int x, y;
-   int d = &y - &x; // warn
+   int a, b, c[10], d[10];
+   int x = &c[3] - &c[1];
+   x = &d[4] - &c[1]; // warn: 'c' and 'd' are 
diff erent arrays
+   x = (&a + 1) - &a;
+   x = &b - &a; // warn: 'a' and 'b' are 
diff erent variables
+   x = (&a + 2) - &a; // warn: for a variable it is only valid to have a 
pointer
+  // to one past the address of it
+   x = &c[10] - &c[0];
+   x = &c[11] - &c[0]; // warn: index larger than one past the end
+   x = &c[-1] - &c[0]; // warn: negative index
  }
 
+ struct S {
+   int x[10];
+   int y[10];
+ };
+
+ void test1() {
+   struct S a[10];
+   struct S b;
+   int d = &a[4] - &a[6];
+   d = &a[0].x[3] - &a[0].x[1];
+   d = a[0].y - a[0].x; // warn: 'S.b' and 'S.a' are 
diff erent objects
+   d = (char *)&b.y - (char *)&b.x; // warn: 
diff erent members of the same object
+   d = (char *)&b.y - (char *)&b; // warn: object of type S is not the same 
array as a member of it
+ }
+
+There may be existing applications that use code like above for calculating
+offsets of members in a structure, using pointer subtractions. This is still
+undefined behavior according to the standard and code like this can be replaced
+with the `offsetof` macro.
+
+The checker only reports cases where stack-allocated objects are involved (no
+warnings on pointers to memory allocated by `malloc`).
+
 .. _alpha-core-StackAddressAsyncEscape:
 
 alpha.core.StackAddressAsyncEscape (C)

diff  --git a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
index eea93a41f1384..b856b0edc6151 100644
--- a/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/PointerSubChecker.cpp
@@ -19,6 +19,7 @@
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicExtent.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FormatVariadic.h"
 
 using namespace clang;
 using namespace ento;
@@ -40,6 +41,11 @@ class PointerSubChecker
   "Indexing the address of a variable with other than 1 at this place "
   "is undefined behavior.";
 
+  /// Check that an array is indexed in the allowed range that is 0 to "one
+  /// after the end". The "array" can be address of a non-array variable.
+  /// @param E Expression of the pointer subtraction.
+  /// @param ElemReg An indexed region in the subtraction expression.
+  /// @param Reg Region of the other side of the expression.
   bool checkArrayBounds(CheckerContext &C, const Expr *E,
 const ElementRegion *ElemReg,
 const MemRegion *Reg) const;
@@ -49,12 +55,28 @@ class PointerSubChecker
 };
 }
 
+static bool isArrayVar(const MemRegion *R) {
+  while (R) {
+if (isa(R))
+  return true;
+if (const auto *ER = dyn_cast(R))
+  R = ER->getSuperRegion();
+else
+  return false;
+  }
+  return false;
+}
+
 bool PointerSubChecker::checkArrayBounds(CheckerContext &C, const Expr *E,
  const ElementRegion *ElemReg,
  const MemRegion *Reg) const {
   if (!ElemReg)
 return true;
 
+  const MemRegion *SuperReg = ElemReg->getSuperRegion();
+  if (!isArrayVar(SuperReg))
+return true;
+
   auto R

[clang] [clang][analyzer] Improve PointerSubChecker (PR #96501)

2024-08-01 Thread Balázs Kéri via cfe-commits

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


[clang] [clang][ASTImporter] Remove trailing return testing on lambda proto (PR #101031)

2024-08-01 Thread Balázs Kéri via cfe-commits

balazske wrote:

My concern was only that the return type check check can be too much overhead 
now if done for all C++11 lambdas but probably this type of lambda can not be 
recognized in other way (maybe from source locations?). But it is only the 
C++11 (not newer) case and it is more safe to check the type all times so I can 
accept it.

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


[clang] [clang][ASTImporter] Remove trailing return testing on lambda proto (PR #101031)

2024-08-01 Thread Balázs Kéri via cfe-commits

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


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


[clang] [flang] [Flang][Driver] Introduce -fopenmp-targets offloading option (PR #100152)

2024-08-01 Thread Sergio Afonso via cfe-commits

https://github.com/skatrak updated 
https://github.com/llvm/llvm-project/pull/100152

>From e59c38db58ba5ca2eef66d3b3477d5ad81043228 Mon Sep 17 00:00:00 2001
From: Sergio Afonso 
Date: Tue, 23 Jul 2024 16:19:55 +0100
Subject: [PATCH] [Flang][Driver] Introduce -fopenmp-targets offloading option

This patch modifies the flang driver to introduce the `-fopenmp-targets` option
to the frontend compiler invocations corresponding to the OpenMP host device on
offloading-enabled compilations.

This option holds the list of offloading triples associated to the compilation
and is used by clang to determine whether offloading calls should be generated
for the host.
---
 clang/include/clang/Driver/Options.td  |  2 +-
 clang/lib/Driver/ToolChains/Clang.cpp  | 12 +---
 clang/lib/Driver/ToolChains/CommonArgs.cpp | 19 +++
 clang/lib/Driver/ToolChains/CommonArgs.h   |  5 +
 clang/lib/Driver/ToolChains/Flang.cpp  |  2 ++
 flang/test/Driver/omp-driver-offload.f90   | 18 ++
 6 files changed, 46 insertions(+), 12 deletions(-)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index c8c56dbb51b28..59c6bb70d75a2 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -3532,7 +3532,7 @@ def fopenmp_use_tls : Flag<["-"], "fopenmp-use-tls">, 
Group,
 def fnoopenmp_use_tls : Flag<["-"], "fnoopenmp-use-tls">, Group,
   Flags<[NoArgumentUnused, HelpHidden]>, Visibility<[ClangOption, CC1Option]>;
 def fopenmp_targets_EQ : CommaJoined<["-"], "fopenmp-targets=">,
-  Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option, FlangOption]>,
+  Flags<[NoXarchOption]>, Visibility<[ClangOption, CC1Option, FlangOption, 
FC1Option]>,
   HelpText<"Specify comma-separated list of triples OpenMP offloading targets 
to be supported">;
 def fopenmp_relocatable_target : Flag<["-"], "fopenmp-relocatable-target">,
   Group, Flags<[NoArgumentUnused, HelpHidden]>,
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 843d68c85bc59..0f1141ed8bcd9 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7789,17 +7789,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction 
&JA,
options::OPT_mno_amdgpu_ieee);
   }
 
-  // For all the host OpenMP offloading compile jobs we need to pass the 
targets
-  // information using -fopenmp-targets= option.
-  if (JA.isHostOffloading(Action::OFK_OpenMP)) {
-SmallString<128> Targets("-fopenmp-targets=");
-
-SmallVector Triples;
-auto TCRange = C.getOffloadToolChains();
-std::transform(TCRange.first, TCRange.second, std::back_inserter(Triples),
-   [](auto TC) { return TC.second->getTripleString(); });
-CmdArgs.push_back(Args.MakeArgString(Targets + llvm::join(Triples, ",")));
-  }
+  addOpenMPHostOffloadingArgs(C, JA, Args, CmdArgs);
 
   bool VirtualFunctionElimination =
   Args.hasFlag(options::OPT_fvirtual_function_elimination,
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 3d0714286139d..6e9744607d9eb 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1244,6 +1244,25 @@ bool tools::addOpenMPRuntime(const Compilation &C, 
ArgStringList &CmdArgs,
   return true;
 }
 
+void tools::addOpenMPHostOffloadingArgs(const Compilation &C,
+const JobAction &JA,
+const llvm::opt::ArgList &Args,
+llvm::opt::ArgStringList &CmdArgs) {
+  if (!JA.isHostOffloading(Action::OFK_OpenMP))
+return;
+
+  // For all the host OpenMP offloading compile jobs we need to pass the 
targets
+  // information using -fopenmp-targets= option.
+  constexpr llvm::StringLiteral Targets("-fopenmp-targets=");
+
+  SmallVector Triples;
+  auto TCRange = C.getOffloadToolChains();
+  std::transform(TCRange.first, TCRange.second, std::back_inserter(Triples),
+ [](auto TC) { return TC.second->getTripleString(); });
+  CmdArgs.push_back(
+  Args.MakeArgString(Twine(Targets) + llvm::join(Triples, ",")));
+}
+
 /// Add Fortran runtime libs
 void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.h 
b/clang/lib/Driver/ToolChains/CommonArgs.h
index 0d3b4d6b783ba..0c97398dfcfa3 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.h
+++ b/clang/lib/Driver/ToolChains/CommonArgs.h
@@ -119,6 +119,11 @@ bool addOpenMPRuntime(const Compilation &C, 
llvm::opt::ArgStringList &CmdArgs,
   bool ForceStaticHostRuntime = false,
   bool IsOffloadingHost = false, bool GompNeedsRT = false);
 
+/// Adds offloading options for OpenMP host compilation to 

[clang] [RISCV] Allow YAML file to control multilib selection (PR #98856)

2024-08-01 Thread Alex Bradbury via cfe-commits

asb wrote:

CC @MaskRay and @petrhosek - might you be able to help review this, or nominate 
someone else who can? Thanks!

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


[clang] [C11] Claim conformance to WG14 N1396 (PR #101214)

2024-08-01 Thread Aaron Ballman via cfe-commits


@@ -501,7 +501,13 @@ C11 implementation status
 
   Wide function returns (alternate proposal)
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n1396.htm";>N1396
-  Unknown
+  
+Yes*
+Clang conforms to this paper on all targets except 32-bit x86 without
+SSE2. However, Clang does not claim conformance or intend to conform to
+Annex F on that target, so we vacuously conform.

AaronBallman wrote:

Good call on reformulation as `not X and not Y`, I'll take care of that. I'll 
also try to reword the "vacuously conform" to be more clear. The intent is: 
because the changes in the paper only apply to Annex F, and Annex F support is 
optional, and we don't claim to conform to Annex F on any target (and we will 
never claim to conform to Annex F for that particular target), we conform to 
the paper by doing nothing.

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


[clang] [compiler-rt] [llvm] [X86][AVX10.2] Support AVX10.2 option and VMPSADBW/VADDP[D,H,S] new instructions (PR #101452)

2024-08-01 Thread Phoebe Wang via cfe-commits


@@ -0,0 +1,33 @@
+//===-- X86InstrAVX10.td - AVX10 Instruction Set ---*- tablegen 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file describes the X86 AVX10 instruction set, defining the
+// instructions, and properties of the instructions which are needed for code
+// generation, machine code emission, and analysis.
+//
+//===--===//
+
+// VMPSADBW
+defm VMPSADBW : avx512_common_3Op_rm_imm8<0x42, X86Vmpsadbw, "vmpsadbw", 
SchedWritePSADBW,
+  avx512vl_i16_info, avx512vl_i8_info,
+  HasAVX10_2>,
+XS, EVEX_CD8<32, CD8VF>;
+
+// YMM Rounding
+multiclass avx256_fp_binop_p_round opc, string OpcodeStr, SDNode 
OpNodeRnd,

phoebewang wrote:

I think for brand new instructions, it's better to use avx10 prefix. Here I 
want to highlight they are for YMM rounding only. So avx256 should be better.

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


[clang] [clang-format] Fix a misannotation of PointerOrReference (PR #101291)

2024-08-01 Thread via cfe-commits

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


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


[clang] [llvm] [Clang] Fix definition of layout-compatible to ignore empty classes (PR #92103)

2024-08-01 Thread Mital Ashok via cfe-commits

https://github.com/MitalAshok updated 
https://github.com/llvm/llvm-project/pull/92103

>From 5908130604728b9aa9b70eeb2523d368df08e68d Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Tue, 14 May 2024 08:28:19 +0100
Subject: [PATCH 1/6] [Clang] Fix definition of layout-compatible to ignore
 empty classes

Also changes the behaviour of __builtin_is_layout_compatible

None of the historic nor the current definition of layout-compatible classes 
mention anything about base classes (other than implicitly through being 
standard-layout) and are defined in terms of members, not direct members.
---
 clang/include/clang/AST/DeclCXX.h  |  7 
 clang/lib/AST/DeclCXX.cpp  | 36 +
 clang/lib/Sema/SemaChecking.cpp| 63 +-
 clang/test/SemaCXX/type-traits.cpp | 11 ++
 llvm/include/llvm/ADT/STLExtras.h  |  6 +++
 5 files changed, 79 insertions(+), 44 deletions(-)

diff --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index fb52ac804849d..60a5005c51a5e 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1229,6 +1229,13 @@ class CXXRecordDecl : public RecordDecl {
   /// C++11 [class]p7, specifically using the C++11 rules without any DRs.
   bool isCXX11StandardLayout() const { return data().IsCXX11StandardLayout; }
 
+  /// If this is a standard-layout class or union, any and all data members 
will
+  /// be declared in the same type.
+  ///
+  /// This retrieves the type if this class has any data members,
+  /// or the current class if there is no class with fields.
+  const CXXRecordDecl *getStandardLayoutBaseWithFields() const;
+
   /// Determine whether this class, or any of its class subobjects,
   /// contains a mutable field.
   bool hasMutableFields() const { return data().HasMutableFields; }
diff --git a/clang/lib/AST/DeclCXX.cpp b/clang/lib/AST/DeclCXX.cpp
index 75c441293d62e..ab032a4595d46 100644
--- a/clang/lib/AST/DeclCXX.cpp
+++ b/clang/lib/AST/DeclCXX.cpp
@@ -561,6 +561,42 @@ void CXXRecordDecl::addedClassSubobject(CXXRecordDecl 
*Subobj) {
 data().StructuralIfLiteral = false;
 }
 
+const CXXRecordDecl *CXXRecordDecl::getStandardLayoutBaseWithFields() const {
+#ifndef NDEBUG
+  {
+assert(
+isStandardLayout() &&
+"getStandardLayoutBaseWithFields called on a non-standard-layout 
type");
+unsigned NumberOfBasesWithFields = 0;
+if (!field_empty())
+  ++NumberOfBasesWithFields;
+std::set UniqueBases;
+forallBases([&](const CXXRecordDecl *Base) -> bool {
+  if (!Base->field_empty())
+++NumberOfBasesWithFields;
+  assert(
+  UniqueBases.insert(Base->getCanonicalDecl()).second &&
+  "Standard layout struct has multiple base classes of the same type");
+  return true;
+});
+assert(NumberOfBasesWithFields <= 1 &&
+   "Standard layout struct has fields declared in more than one 
class");
+  }
+#endif
+  if (!field_empty())
+return this;
+  const CXXRecordDecl *Result = this;
+  forallBases([&](const CXXRecordDecl *Base) -> bool {
+if (!Base->field_empty()) {
+  // This is the base where the fields are declared; return early
+  Result = Base;
+  return false;
+}
+return true;
+  });
+  return Result;
+}
+
 bool CXXRecordDecl::hasConstexprDestructor() const {
   auto *Dtor = getDestructor();
   return Dtor ? Dtor->isConstexpr() : defaultedDestructorIsConstexpr();
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index ecd1821651140..acd142c1932ad 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -19084,7 +19084,8 @@ void Sema::DiagnoseSelfMove(const Expr *LHSExpr, const 
Expr *RHSExpr,
 static bool isLayoutCompatible(ASTContext &C, QualType T1, QualType T2);
 
 /// Check if two enumeration types are layout-compatible.
-static bool isLayoutCompatible(ASTContext &C, EnumDecl *ED1, EnumDecl *ED2) {
+static bool isLayoutCompatible(ASTContext &C, const EnumDecl *ED1,
+   const EnumDecl *ED2) {
   // C++11 [dcl.enum] p8:
   // Two enumeration types are layout-compatible if they have the same
   // underlying type.
@@ -19095,8 +19096,8 @@ static bool isLayoutCompatible(ASTContext &C, EnumDecl 
*ED1, EnumDecl *ED2) {
 /// Check if two fields are layout-compatible.
 /// Can be used on union members, which are exempt from alignment requirement
 /// of common initial sequence.
-static bool isLayoutCompatible(ASTContext &C, FieldDecl *Field1,
-   FieldDecl *Field2,
+static bool isLayoutCompatible(ASTContext &C, const FieldDecl *Field1,
+   const FieldDecl *Field2,
bool AreUnionMembers = false) {
   [[maybe_unused]] const Type *Field1Parent =
   Field1->getParent()->getTypeForDecl();
@@ -19139,52 +19140,26 @@ static bool isLayoutCompatible(ASTContext &C, 
FieldDecl *Field1,
 
 /// Check if two standa

[clang] [clang-format] Use double hyphen for multiple-letter flags (PR #100978)

2024-08-01 Thread via cfe-commits

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


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


[clang] [clang-format] Rename variable more sensitively (PR #100943)

2024-08-01 Thread via cfe-commits

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


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


[clang] [llvm] [AArch64] Add updated FEAT_SVE_B16B16 and begin replacement of 'b16b16' flag (PR #101480)

2024-08-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-aarch64

Author: None (SpencerAbson)


Changes

This patch adds FeatureSVEB16B16 to represent the new behavior of 
FEAT_SVE_B16B16 as described in the latest 
[Armv9.4 extensions 
documentation](https://developer.arm.com/documentation/109697/0100/Feature-descriptions/The-Armv9-4-architecture-extension?lang=en#md461-the-armv94-architecture-extension__FEAT_SVE_B16B16),
 as well as a 'sve-b16b16' flag to enable it. The predication of SVE BFloat16 
to BFloat16 instructions has changed to reflect the new behavior of 
FEAT_SVE_B16B16. This change weakens the existing 'b16b16' flag used to enable 
the old version of FEAT_SVE_B16B16; it is partially replaced by the new 
'sve-b16b16' flag. Existing tests that are effected by this have been modified 
to use and/or expect 'sve-b16b16', and new tests have been added to verify the 
behavior and implementation of 'sve-b16b16'. 

This patch is in response to the response to the following changes.

The architecture features previously enabled by FEAT_SVE_B16B16 have been 
relaxed such that it now implements:
  - With FEAT_SVE2 : SVE non-widening BFloat16 instructions in 
Non-streaming SVE mode
  - With FEAT_SME2: SVE non-widening BFloat16 instructions when the PE is 
in Streaming SVE mode and SVE
    Z-targeting multi-vector non-widening BFloat16 instructions.
  - **It no longer implements** SME ZA-targeting non-widening BFloat16 
instructions.      

The SME ZA-targeting non-widening BFloat16 instructions are implemented by the 
new FEAT_SME_B16B16, **this patch does not change how this architecture feature 
is enabled** ('+b16b16+sme2'). Only those that are implemented by 
FEAT_SVE_B16B16 have been changed to require 'sve-b16b16' instead of 'b16b16'.

New flags must be created to represent FEAT_SVE_B16B16 and FEAT_SME_B16B16:
  - 'sve-b16b16' enables the updated FEAT_SVE_B16B16 (described here)
  - 'sme-b16b16' will enable the new FEAT_SME_B16B16
  - **This patch includes only 'sve-b16b16'**
   
A future patch will add 'sme-b16b16', SME ZA-targeting non-widening BFloat16 
instructions would then be guarded by '+sme-b16b16+sme2', and 'b16b16' can be 
removed.

---

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


84 Files Affected:

- (modified) clang/include/clang/Basic/arm_sve.td (+2-2) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_clamp.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_max.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_maxnm.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_min.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sme2-intrinsics/acle_sme2_minnm.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfadd.c 
(+6-6) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfclamp.c 
(+5-5) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmax.c 
(+6-6) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmaxnm.c 
(+6-6) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmin.c 
(+6-6) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfminnm.c 
(+6-6) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmla.c 
(+6-6) 
- (modified) 
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmla_lane.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmls.c 
(+6-6) 
- (modified) 
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmls_lane.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmul.c 
(+6-6) 
- (modified) 
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfmul_lane.c (+5-5) 
- (modified) clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_bfsub.c 
(+6-6) 
- (modified) clang/test/Driver/print-supported-extensions-aarch64.c (+2-1) 
- (modified) clang/test/Sema/aarch64-sme2-intrinsics/acle_sme2_b16b16.cpp 
(+2-2) 
- (modified) clang/test/Sema/aarch64-sve2-intrinsics/acle_sve2_bfloat.cpp 
(+1-1) 
- (added) clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_b16b16.cpp 
(+49) 
- (added) 
clang/test/Sema/aarch64-sve2p1-intrinsics/acle_sve2p1_b16b16_streaming.cpp 
(+50) 
- (modified) llvm/lib/Target/AArch64/AArch64Features.td (+5-2) 
- (modified) llvm/lib/Target/AArch64/AArch64InstrInfo.td (+2) 
- (modified) llvm/lib/Target/AArch64/AArch64SMEInstrInfo.td (+7-3) 
- (modified) llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td (+4-4) 
- (modified) llvm/lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp (+1) 
- (modified) llvm/test/CodeGen/AArch64/sme2-intrinsics-max.ll (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/sme2-intrinsics-min.ll (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/sve2-min-max-clamp.ll (+1-1) 
- (modified) llvm/test/CodeGen/AArch64/sve2p1-intrinsics-b

[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)

2024-08-01 Thread Julian Brown via cfe-commits


@@ -7668,6 +7669,47 @@ struct LoopIterationSpace final {
   Expr *FinalCondition = nullptr;
 };
 
+class ForSubExprChecker : public RecursiveASTVisitor {
+  const llvm::SmallSet *CollapsedLoopVarDecls;
+  VarDecl *ForbiddenVar;
+  SourceRange ErrLoc;
+
+public:
+  explicit ForSubExprChecker(
+  const llvm::SmallSet *CollapsedLoopVarDecls)
+  : CollapsedLoopVarDecls(CollapsedLoopVarDecls), ForbiddenVar(nullptr) {}
+
+  bool shouldVisitImplicitCode() const { return true; }

jtb20 wrote:

Which bit do you think is unused? The next revision includes a comment on the 
shouldVisitImplicitCode definition (which is needed).

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


[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)

2024-08-01 Thread Julian Brown via cfe-commits


@@ -7668,6 +7669,47 @@ struct LoopIterationSpace final {
   Expr *FinalCondition = nullptr;
 };
 
+class ForSubExprChecker : public RecursiveASTVisitor {
+  const llvm::SmallSet *CollapsedLoopVarDecls;
+  VarDecl *ForbiddenVar;
+  SourceRange ErrLoc;
+
+public:
+  explicit ForSubExprChecker(
+  const llvm::SmallSet *CollapsedLoopVarDecls)
+  : CollapsedLoopVarDecls(CollapsedLoopVarDecls), ForbiddenVar(nullptr) {}
+
+  bool shouldVisitImplicitCode() const { return true; }
+
+  bool VisitDeclRefExpr(DeclRefExpr *E) {
+ValueDecl *VD = E->getDecl();
+if (!isa(VD))
+  return true;
+VarDecl *V = VD->getPotentiallyDecomposedVarDecl();
+if (V->getType()->isReferenceType()) {
+  VarDecl *VD = V->getDefinition();
+  if (VD->hasInit()) {
+Expr *I = VD->getInit();
+DeclRefExpr *DRE = dyn_cast(I);
+if (!DRE)
+  return true;
+V = DRE->getDecl()->getPotentiallyDecomposedVarDecl();
+  }
+}
+Decl *Canon = V->getCanonicalDecl();
+if (CollapsedLoopVarDecls->contains(Canon)) {
+  ForbiddenVar = V;
+  ErrLoc = E->getSourceRange();
+  return false;
+}
+
+return true;
+  }
+
+  VarDecl *getForbiddenVar() { return ForbiddenVar; }
+  SourceRange &getErrRange() { return ErrLoc; }

jtb20 wrote:

OK but then getErrRange needs to return SourceRange by value, I think.

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


[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)

2024-08-01 Thread Julian Brown via cfe-commits


@@ -7668,6 +7669,47 @@ struct LoopIterationSpace final {
   Expr *FinalCondition = nullptr;
 };
 
+class ForSubExprChecker : public RecursiveASTVisitor {
+  const llvm::SmallSet *CollapsedLoopVarDecls;
+  VarDecl *ForbiddenVar;
+  SourceRange ErrLoc;
+
+public:
+  explicit ForSubExprChecker(
+  const llvm::SmallSet *CollapsedLoopVarDecls)

jtb20 wrote:

There isn't a SmallSetImpl, so I've changed all these to SmallPtrSet{,Impl} 
instead.

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


[clang] [NFC] [Clang] Some core issues have changed status from tentatively ready -> ready / review (PR #97200)

2024-08-01 Thread Mital Ashok via cfe-commits

https://github.com/MitalAshok updated 
https://github.com/llvm/llvm-project/pull/97200

>From 0dea95701ca4dfca9b7d0bd889003fc35aa3017e Mon Sep 17 00:00:00 2001
From: Mital Ashok 
Date: Sun, 30 Jun 2024 10:39:15 +0100
Subject: [PATCH 01/14] [NFC] [Clang] Some core issues have changed status from
 tentatively ready -> ready / review

---
 clang/test/CXX/drs/cwg25xx.cpp |   2 +-
 clang/test/CXX/drs/cwg28xx.cpp |  16 ++--
 clang/www/cxx_dr_status.html   | 130 +++--
 clang/www/make_cxx_dr_status   |   6 +-
 4 files changed, 104 insertions(+), 50 deletions(-)

diff --git a/clang/test/CXX/drs/cwg25xx.cpp b/clang/test/CXX/drs/cwg25xx.cpp
index 0934f0cc19c6a..5f8a058f8157a 100644
--- a/clang/test/CXX/drs/cwg25xx.cpp
+++ b/clang/test/CXX/drs/cwg25xx.cpp
@@ -139,7 +139,7 @@ struct D3 : B {
 #endif
 
 #if __cplusplus >= 202302L
-namespace cwg2561 { // cwg2561: no tentatively ready 2024-03-18
+namespace cwg2561 { // cwg2561: no ready 2024-03-18
 struct C {
 constexpr C(auto) { }
 };
diff --git a/clang/test/CXX/drs/cwg28xx.cpp b/clang/test/CXX/drs/cwg28xx.cpp
index c77bd433d8e21..524e67b52de51 100644
--- a/clang/test/CXX/drs/cwg28xx.cpp
+++ b/clang/test/CXX/drs/cwg28xx.cpp
@@ -30,7 +30,7 @@ using U2 = decltype(&main);
 #endif
 } // namespace cwg2811
 
-namespace cwg2819 { // cwg2819: 19 tentatively ready 2023-12-01
+namespace cwg2819 { // cwg2819: 19 ready 2023-12-01
 #if __cpp_constexpr >= 202306L
   constexpr void* p = nullptr;
   constexpr int* q = static_cast(p);
@@ -111,7 +111,7 @@ struct D : N::B {
 #endif
 } // namespace cwg2857
 
-namespace cwg2858 { // cwg2858: 19 tentatively ready 2024-04-05
+namespace cwg2858 { // cwg2858: 19 ready 2024-04-05
 
 #if __cplusplus > 202302L
 
@@ -134,7 +134,7 @@ struct A {
 
 } // namespace cwg2858
 
-namespace cwg2877 { // cwg2877: 19 tentatively ready 2024-05-31
+namespace cwg2877 { // cwg2877: 19 ready 2024-05-31
 #if __cplusplus >= 202002L
 enum E { x };
 void f() {
@@ -150,7 +150,7 @@ void g() {
 #endif
 } // namespace cwg2877
 
-namespace cwg2881 { // cwg2881: 19 tentatively ready 2024-04-19
+namespace cwg2881 { // cwg2881: 19 ready 2024-04-19
 
 #if __cplusplus >= 202302L
 
@@ -220,7 +220,7 @@ void f() {
 
 } // namespace cwg2881
 
-namespace cwg2882 { // cwg2882: 2.7 tentatively ready 2024-05-31
+namespace cwg2882 { // cwg2882: 2.7 ready 2024-05-31
 struct C {
   operator void() = delete;
   // expected-warning@-1 {{conversion function converting 'cwg2882::C' to 
'void' will never be used}}
@@ -232,7 +232,7 @@ void f(C c) {
 }
 } // namespace cwg2882
 
-namespace cwg2883 { // cwg2883: no tentatively ready 2024-05-31
+namespace cwg2883 { // cwg2883: no ready 2024-05-31
 #if __cplusplus >= 201103L
 void f() {
   int x;
@@ -257,7 +257,7 @@ void g() {
 #endif
 } // namespace cwg2883
 
-namespace cwg2885 { // cwg2885: 16 tentatively ready 2024-05-31
+namespace cwg2885 { // cwg2885: 16 review 2024-05-31
 #if __cplusplus >= 202002L
 template 
 struct A {
@@ -271,7 +271,7 @@ static_assert(!__is_trivially_constructible(B));
 #endif
 } // namespace cwg2885
 
-namespace cwg2886 { // cwg2886: 9 tentatively ready 2024-05-31
+namespace cwg2886 { // cwg2886: 9 ready 2024-05-31
 #if __cplusplus >= 201103L
 struct C {
   C() = default;
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 937f67981e296..64b361976a5a5 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -1442,7 +1442,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/233.html";>233
-tentatively ready
+ready
 References vs pointers in UDC overload resolution
 Not resolved
   
@@ -7329,11 +7329,11 @@ C++ defect report implementation 
status
 Overloading member function templates based on dependent return 
type
 Unknown
   
-  
+  
 https://cplusplus.github.io/CWG/issues/1253.html";>1253
-open
+C++17
 Generic non-template members
-Not resolved
+Unknown
   
   
 https://cplusplus.github.io/CWG/issues/1254.html";>1254
@@ -12677,7 +12677,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2144.html";>2144
-tentatively ready
+ready
 Function/variable declaration ambiguity
 Not resolved
   
@@ -15179,7 +15179,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2561.html";>2561
-tentatively ready
+ready
 Conversion to function pointer for lambda with explicit object 
parameter
 Not Resolved*
   
@@ -15341,7 +15341,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2588.html";>2588
-tentatively ready
+ready
 friend declarations and module linkage
 Not resolved
   
@@ -15541,7 +15541,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2621.html";>2621
 C++23
 Kind of lookup for using enum declarations
-Superseded by 287

[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)

2024-08-01 Thread Julian Brown via cfe-commits

https://github.com/jtb20 updated 
https://github.com/llvm/llvm-project/pull/101305

>From 2d318c6504b43d8a9521dc5567c1da4d6cd986a4 Mon Sep 17 00:00:00 2001
From: Julian Brown 
Date: Wed, 26 Jun 2024 11:21:01 -0500
Subject: [PATCH] [clang][OpenMP] Diagnose badly-formed collapsed imperfect
 loop nests (#60678)

This patch fixes a couple of cases where Clang aborts with loop nests
that are being collapsed (via the relevant OpenMP clause) into a new,
combined loop.

The problematic cases happen when a variable declared within the
loop nest is used in the (init, condition, iter) statement of a more
deeply-nested loop.  I don't think these cases (generally?) fall under
the non-rectangular loop nest rules as defined in OpenMP 5.0+, but I
could be wrong (and anyway, emitting an error is better than crashing).

In terms of implementation: the crash happens because (to a first
approximation) all the loop bounds calculations are pulled out to the
start of the new, combined loop, but variables declared in the loop nest
"haven't been seen yet".  I believe there is special handling for
iteration variables declared in "for" init statements, but not for
variables declared elsewhere in the "imperfect" parts of a loop nest.

So, this patch tries to diagnose the troublesome cases before they can
cause a crash.  This is slightly awkward because at the point where we
want to do the diagnosis (SemaOpenMP.cpp), we don't have scope information
readily available.  Instead we "manually" scan through the AST of the
loop nest looking for var decls (ForVarDeclFinder), then we ensure we're
not using any of those in loop control subexprs (ForSubExprChecker).
All that is only done when we have a "collapse" clause.

Range-for loops can also cause crashes at present without this patch,
so are handled too.
---
 .../clang/Basic/DiagnosticSemaKinds.td|   2 +
 clang/lib/AST/StmtOpenMP.cpp  |   3 +-
 clang/lib/Sema/SemaOpenMP.cpp | 140 +-
 clang/test/OpenMP/loop_collapse_1.c   |  40 +
 clang/test/OpenMP/loop_collapse_2.cpp |  80 ++
 5 files changed, 256 insertions(+), 9 deletions(-)
 create mode 100644 clang/test/OpenMP/loop_collapse_1.c
 create mode 100644 clang/test/OpenMP/loop_collapse_2.cpp

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 581434d33c5c9..beb78eb0a4ef4 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11152,6 +11152,8 @@ def err_omp_loop_diff_cxx : Error<
   "upper and lower loop bounds">;
 def err_omp_loop_cannot_use_stmt : Error<
   "'%0' statement cannot be used in OpenMP for loop">;
+def err_omp_loop_bad_collapse_var : Error<
+  "cannot use variable %1 in collapsed imperfectly-nested loop 
%select{init|condition|increment}0 statement">;
 def err_omp_simd_region_cannot_use_stmt : Error<
   "'%0' statement cannot be used in OpenMP simd region">;
 def warn_omp_loop_64_bit_var : Warning<
diff --git a/clang/lib/AST/StmtOpenMP.cpp b/clang/lib/AST/StmtOpenMP.cpp
index 451a9fe9fe3d2..e41c26bb60252 100644
--- a/clang/lib/AST/StmtOpenMP.cpp
+++ b/clang/lib/AST/StmtOpenMP.cpp
@@ -10,8 +10,9 @@
 //
 
//===--===//
 
-#include "clang/AST/ASTContext.h"
 #include "clang/AST/StmtOpenMP.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 
 using namespace clang;
 using namespace llvm::omp;
diff --git a/clang/lib/Sema/SemaOpenMP.cpp b/clang/lib/Sema/SemaOpenMP.cpp
index 4f50efda155fb..631dc2a33c3a3 100644
--- a/clang/lib/Sema/SemaOpenMP.cpp
+++ b/clang/lib/Sema/SemaOpenMP.cpp
@@ -21,6 +21,7 @@
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclOpenMP.h"
 #include "clang/AST/OpenMPClause.h"
+#include "clang/AST/RecursiveASTVisitor.h"
 #include "clang/AST/StmtCXX.h"
 #include "clang/AST/StmtOpenMP.h"
 #include "clang/AST/StmtVisitor.h"
@@ -7668,6 +7669,52 @@ struct LoopIterationSpace final {
   Expr *FinalCondition = nullptr;
 };
 
+/// Scan an AST subtree, checking that no decls in the CollapsedLoopVarDecls
+/// set are referenced.  Used for verifying loop nest structure before
+/// performing a loop collapse operation.
+class ForSubExprChecker final : public RecursiveASTVisitor {
+  const llvm::SmallPtrSetImpl &CollapsedLoopVarDecls;
+  VarDecl *ForbiddenVar = nullptr;
+  SourceRange ErrLoc;
+
+public:
+  explicit ForSubExprChecker(
+  const llvm::SmallPtrSetImpl &CollapsedLoopVarDecls)
+  : CollapsedLoopVarDecls(CollapsedLoopVarDecls) {}
+
+  // We want to visit implicit code, i.e. synthetic initialisation statements
+  // created during range-for lowering.
+  bool shouldVisitImplicitCode() const { return true; }
+
+  bool VisitDeclRefExpr(DeclRefExpr *E) {
+ValueDecl *VD = E->getDecl();
+if (!isa(VD))
+  return true;
+VarDecl *V = VD->getPotentiallyDecomposedVarDecl();
+if (V->getType

[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)

2024-08-01 Thread Julian Brown via cfe-commits

jtb20 wrote:

OpenMPIterationSpaceChecker is still passed a pointer to CollapsedLoopDecls, 
because one caller passes a nullptr, and we don't want to do the analysis in 
that case.

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


[clang] [NFC] [Clang] Some core issues have changed status from tentatively ready -> ready / review (PR #97200)

2024-08-01 Thread Mital Ashok via cfe-commits

MitalAshok wrote:

@Endilll It should be good to merge after the last quick commit (which just ran 
cxx_make_dr_status). Could you please merge this for me? Thanks!

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


[clang] [compiler-rt] [RISCV][compiler-rt] Update __init_riscv_feature_bits prototype (PR #101472)

2024-08-01 Thread Piyou Chen via cfe-commits

BeMg wrote:

> Alongside #101449, this seems to be extending the interface beyond what is 
> described in the [current draft 
> spec](https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74). Is there 
> some other source of truth I should be looking for? Is this a proposal to 
> change the spec, or an implementation of something that was already decided 
> (at least tentatively)?

I will soon update these changes in 
https://github.com/riscv-non-isa/riscv-c-api-doc/pull/74. These changes are 
based on discussions with @kito-cheng and @preames.

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


[clang] [analyzer] Assert Callee is FunctionDecl in doesFnIntendToHandleOwnership() (PR #101066)

2024-08-01 Thread via cfe-commits

smanna12 wrote:

> Already under fix in #100719, I'm just a lazy bum and haven't fixed the 
> buildbots. I'll try to speed things up!

@Szelethus, would it possible to speed up this? Thanks

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


[clang] [Clang] prevent assertion failure by avoiding required literal type checking in C context (PR #101426)

2024-08-01 Thread Mariya Podchishchaeva via cfe-commits

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

LGTM

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


[clang] [clang][OpenMP] Diagnose badly-formed collapsed imperfect loop nests (#60678) (PR #101305)

2024-08-01 Thread Alexey Bataev via cfe-commits

alexey-bataev wrote:

> OpenMPIterationSpaceChecker is still passed a pointer to CollapsedLoopDecls, 
> because one caller passes a nullptr, and we don't want to do the analysis in 
> that case.

Still pass by reference, just pass empty where it is not required

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


  1   2   3   4   5   6   >