[clang] [clang][ASTImporter] import InstantiatedFromMember of ClassTemplateSpecializationDecl (PR #76493)

2023-12-28 Thread Qizhi Hu via cfe-commits

https://github.com/jcsxky updated 
https://github.com/llvm/llvm-project/pull/76493

>From 057f9324bb83141ea07c69beb3afe5158fb3f194 Mon Sep 17 00:00:00 2001
From: huqizhi 
Date: Thu, 28 Dec 2023 15:51:32 +0800
Subject: [PATCH] [clang][ASTImporter] import InstantiatedFromMember of
 ClassTemplateSpecializationDecl

---
 clang/lib/AST/ASTImporter.cpp   |  5 
 clang/unittests/AST/ASTImporterTest.cpp | 32 +
 2 files changed, 37 insertions(+)

diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index b61180c4f3491d..9ffae72346f2af 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -6141,6 +6141,11 @@ ExpectedDecl 
ASTNodeImporter::VisitClassTemplateSpecializationDecl(
   InsertPos))
   // Add this partial specialization to the class template.
   ClassTemplate->AddPartialSpecialization(PartSpec2, InsertPos);
+if (Expected ToInstOrErr =
+import(PartialSpec->getInstantiatedFromMember()))
+  PartSpec2->setInstantiatedFromMember(*ToInstOrErr);
+else
+  return ToInstOrErr.takeError();
 
 updateLookupTableForTemplateParameters(*ToTPList);
   } else { // Not a partial specialization.
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index ed8ecb080e268d..1221174326b90f 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -9342,6 +9342,38 @@ TEST_P(ASTImporterOptionSpecificTestBase, 
ImportConflictTypeAliasTemplate) {
   EXPECT_FALSE(ImportedCallable);
 }
 
+AST_MATCHER(ClassTemplateSpecializationDecl, hasInstantiatedFromMember) {
+  if (auto Instantiate = Node.getInstantiatedFrom()) {
+if (auto *FromPartialSpecialization =
+Instantiate.get()) {
+  return nullptr != FromPartialSpecialization->getInstantiatedFromMember();
+}
+  }
+  return false;
+}
+
+TEST_P(ASTImporterOptionSpecificTestBase, ImportInstantiatedFromMember) {
+  const char *Code =
+  R"(
+  template  struct B {
+template  union D;
+template  union D {};
+D d;
+  };
+  B b;
+  )";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX17);
+  auto *FromA = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl(hasName("D"),
+  hasInstantiatedFromMember()));
+  auto *FromPartialSpecialization =
+  cast(
+  FromA->getInstantiatedFrom());
+  auto *ImportedPartialSpecialization =
+  Import(FromPartialSpecialization, Lang_CXX17);
+  EXPECT_TRUE(ImportedPartialSpecialization->getInstantiatedFromMember());
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,
  DefaultTestValuesForRunOptions);
 

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


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

2023-12-28 Thread Qiu Chaofan via cfe-commits

https://github.com/ecnelises created 
https://github.com/llvm/llvm-project/pull/76495

This builtin will work as barrier for instruction motion (scheduling, etc.)

>From aaa11bc775b9aa3a0398ba2bbca4087e99f04243 Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Thu, 28 Dec 2023 16:54:25 +0800
Subject: [PATCH] [PowerPC] Implement fence builtin

---
 clang/include/clang/Basic/BuiltinsPPC.def |  3 +++
 clang/lib/Basic/Targets/PPC.cpp   |  1 +
 llvm/include/llvm/IR/IntrinsicsPowerPC.td |  5 +
 llvm/lib/Target/PowerPC/PPCInstrInfo.cpp  |  7 ++-
 llvm/lib/Target/PowerPC/PPCInstrInfo.td   |  4 
 .../CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll| 11 +++
 6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index a35488ed3dfa56..829c60defe17c6 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -944,6 +944,9 @@ TARGET_BUILTIN(__builtin_pack_vector_int128, 
"V1LLLiULLiULLi", "", "vsx")
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Barrier for instruction motion
+BUILTIN(__builtin_ppc_fence, "v", "")
+
 // Get content from current FPSCR
 BUILTIN(__builtin_readflm, "d", "")
 
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 045c273f03c7a0..41935abfb65d3b 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -212,6 +212,7 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
   Builder.defineMacro("__darn_32", "__builtin_darn_32");
   Builder.defineMacro("__darn_raw", "__builtin_darn_raw");
   Builder.defineMacro("__dcbf", "__builtin_dcbf");
+  Builder.defineMacro("__fence", "__builtin_ppc_fence");
   Builder.defineMacro("__fmadd", "__builtin_fma");
   Builder.defineMacro("__fmadds", "__builtin_fmaf");
   Builder.defineMacro("__abs", "__builtin_abs");
diff --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index 3ede2a3736bf30..6d1e8eb47405dd 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -29,6 +29,11 @@ let TargetPrefix = "ppc" in {  // All intrinsics start with 
"llvm.ppc.".
 [IntrArgMemOnly, NoCapture>, ImmArg>]>;
   def int_ppc_dcbzl : Intrinsic<[], [llvm_ptr_ty], []>;
 
+  // Emit pseudo instruction as fence of instruction motion
+  def int_ppc_fence : ClangBuiltin<"__builtin_ppc_fence">,
+  DefaultAttrsIntrinsic<[], [],
+[IntrNoMerge, IntrHasSideEffects]>;
+
   // Get content from current FPSCR register
   def int_ppc_readflm : ClangBuiltin<"__builtin_readflm">,
 DefaultAttrsIntrinsic<[llvm_double_ty], [],
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index aaced58defe603..af55c6cf337120 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -2155,11 +2155,16 @@ bool PPCInstrInfo::isPredicated(const MachineInstr &MI) 
const {
 bool PPCInstrInfo::isSchedulingBoundary(const MachineInstr &MI,
 const MachineBasicBlock *MBB,
 const MachineFunction &MF) const {
+  switch (MI.getOpcode()) {
+  default: break;
   // Set MFFS and MTFSF as scheduling boundary to avoid unexpected code motion
   // across them, since some FP operations may change content of FPSCR.
   // TODO: Model FPSCR in PPC instruction definitions and remove the workaround
-  if (MI.getOpcode() == PPC::MFFS || MI.getOpcode() == PPC::MTFSF)
+  case PPC::MFFS:
+  case PPC::MTFSF:
+  case PPC::FENCE:
 return true;
+  }
   return TargetInstrInfo::isSchedulingBoundary(MI, MBB, MF);
 }
 
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
index b1601739fd4569..c0344dfbf3a728 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -1328,6 +1328,9 @@ def SETFLM : PPCCustomInserterPseudo<(outs f8rc:$FRT), 
(ins f8rc:$FLM),
 "#SETFLM", [(set f64:$FRT, (int_ppc_setflm f8rc:$FLM))]>;
 }
 
+let isBarrier = 1, hasSideEffects = 1, Defs = [RM] in
+def FENCE : PPCEmitTimePseudo<(outs), (ins), "#FENCE", []>;
+
 let Defs = [LR] in
   def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
PPC970_Unit_BRU;
@@ -3187,6 +3190,7 @@ def : Pat<(PPCtc_return (i32 texternalsym:$dst), 
imm:$imm),
 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
   (TCRETURNri CTRRC:$dst, imm:$imm)>;
 
+def : Pat<(int_ppc_fence), (FENCE)>;
 def : Pat<(int_ppc_readflm), (MFFS)>;
 def : Pat<(int_ppc_mffsl), (MFFSL)>;
 
diff --git a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xl

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

2023-12-28 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 36fd7291cdd85b282950d3782758353d259e 
aaa11bc775b9aa3a0398ba2bbca4087e99f04243 -- clang/lib/Basic/Targets/PPC.cpp 
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
``





View the diff from clang-format here.


``diff
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index af55c6cf33..538e0e6b3d 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -2156,7 +2156,8 @@ bool PPCInstrInfo::isSchedulingBoundary(const 
MachineInstr &MI,
 const MachineBasicBlock *MBB,
 const MachineFunction &MF) const {
   switch (MI.getOpcode()) {
-  default: break;
+  default:
+break;
   // Set MFFS and MTFSF as scheduling boundary to avoid unexpected code motion
   // across them, since some FP operations may change content of FPSCR.
   // TODO: Model FPSCR in PPC instruction definitions and remove the workaround

``




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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits


@@ -1072,16 +1146,36 @@ Static Analyzer
   Read the PR for the details.
   (`#66086 `_)
 
+- Other taint-related improvements.
+  (`#66358 `_,
+  `#66074 `_,
+  `#66358 `_)
+
 - A few crashes have been found and fixed using randomized testing related
-  to the use of ``_BitInt()`` in tidy checks and in clang analysis. See
-  `#67212 `_,
+  to the use of ``_BitInt()`` in tidy checks and in clang analysis.
+  (`#67212 `_,
   `#66782 `_,
   `#65889 `_,
-  `#65888 `_, and
-  `#65887 `_
+  `#65888 `_,
+  `#65887 `_)
 
-- Move checker ``alpha.cplusplus.EnumCastOutOfRange`` out of the ``alpha``
-  package to ``optin.core.EnumCastOutOfRange``.
+- Fixed note links of the HTML output.
+  (`#64054 `_)
+
+- Allow widening rage-based for loops.
+  (`#70190 `_)
+
+- Fixed uninitialized base class with initializer list when ctor is not
+  declared in the base class.
+  (`#70464 `_,
+  `#59493 `_,
+  `#54533 `_)
+
+- Added support for the ``cleanup`` attribute.
+  `Documentation 
`__.

steakhal wrote:

My reasoning was to always leave a ref to the relevant change. Possibly, 
including the PR if present to be able to read the discussions.
Given that this release is the only one which is "in transit" from Phabricator 
to the GH PR workflow, PRs are not always present, hence I opted for linking 
the commit.
I wanted to avoid referencing Phabricator revisions, as its being phased out 
AFAIK.

The PR/change is helpful for the users to see concrete diffs/examples how test 
code was changed, or how certain flags were used. I figured, its not too 
intrusive, so I opted-in for those.

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


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

2023-12-28 Thread via cfe-commits

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

As discuss in 
https://discourse.llvm.org/t/is-it-possible-to-use-propeller-iteratively/67560. 
Add new option listwithlabels to emit llvm_bb_addr_map section when Propeller 
is enabled. This can be used for creating new profile by sampleing executable 
which has enabled Propeller. 

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

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

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

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

2023-12-28 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang-codegen

Author: None (lifengxiang1025)


Changes

As discuss in 
https://discourse.llvm.org/t/is-it-possible-to-use-propeller-iteratively/67560. 
Add new option listwithlabels to emit llvm_bb_addr_map section when Propeller 
is enabled. This can be used for creating new profile by sampleing executable 
which has enabled Propeller. 

---

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


18 Files Affected:

- (modified) clang/docs/UsersManual.rst (+1-1) 
- (modified) clang/include/clang/Basic/CodeGenOptions.h (+2) 
- (modified) clang/include/clang/Driver/Options.td (+1-1) 
- (modified) clang/lib/CodeGen/BackendUtil.cpp (+6-2) 
- (modified) clang/lib/Driver/ToolChains/Clang.cpp (+1-1) 
- (modified) clang/test/CodeGen/basic-block-sections.c (+2-1) 
- (modified) clang/test/Driver/fbasic-block-sections.c (+4) 
- (modified) lld/ELF/Driver.cpp (+1-1) 
- (modified) lld/ELF/LTO.cpp (+6-2) 
- (modified) llvm/include/llvm/CodeGen/MachineFunction.h (+4-2) 
- (modified) llvm/include/llvm/Target/TargetOptions.h (+2-1) 
- (modified) llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (+31-19) 
- (modified) llvm/lib/CodeGen/BasicBlockPathCloning.cpp (+3-1) 
- (modified) llvm/lib/CodeGen/BasicBlockSections.cpp (+4-2) 
- (modified) llvm/lib/CodeGen/CommandFlags.cpp (+5-1) 
- (modified) llvm/lib/CodeGen/MachineFunction.cpp (+2-1) 
- (modified) llvm/lib/CodeGen/TargetPassConfig.cpp (+2-1) 
- (modified) llvm/test/CodeGen/X86/basic-block-sections-cold.ll (+8) 


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

[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

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

>From a4a8704644067a7cf81bee601e4898bbc6b9d289 Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Wed, 27 Dec 2023 14:13:08 +0100
Subject: [PATCH 1/4] [analyzer][docs] Update the release notes for llvm-18

---
 clang/docs/ReleaseNotes.rst | 108 +---
 1 file changed, 101 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee211c16a48ac8..17b6e285a89ca2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1052,18 +1052,92 @@ libclang
 Static Analyzer
 ---
 
+- Implemented the ``[[clang::suppress]]`` attribute for suppressing diagnostics
+  of static analysis tools, such as the Clang Static Analyzer.
+  `Documentation 
`__.
+
+- Added a new experimental checker ``alpha.core.StdVariant`` to detect variant
+  accesses via wrong alternatives.
+  (`#66481 `_)
+
+- Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect
+  destructions of arrays of polymorphic objects that are destructed as their
+  base class (`CERT EXP51-CPP 
`_).
+  `Documentation 
`__.
+  (`0e246bb67573 
`_)
+
 - Added a new checker ``core.BitwiseShift`` which reports situations where
   bitwise shift operators produce undefined behavior (because some operand is
   negative or too large).
+  `Documentation 
`__.
+
+- Support "Deducing this" (P0847R7). (Worked out of the box)
+  (`af4751738db8 
`__)
 
 - Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
   to ``unix.Errno``.
+  `Documentation 
`__.
 
 - Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
   to ``unix.StdCLibraryFunctions``.
 
+- Added a new checker configuration option to
+  ``alpha.security.cert.InvalidPtrChecker``.
+  `Documentation 
`__.
+  (`#67663 `_)
+
+- Move checker ``alpha.security.cert.env.InvalidPtr`` out of the ``alpha``
+  package to ``security.cert.env.InvalidPtr``.
+  `Documentation 
`__.
+
+- Move checker ``alpha.cplusplus.EnumCastOutOfRange`` out of the ``alpha``
+  package to ``optin.core.EnumCastOutOfRange``.
+  `Documentation 
`__.
+
+- Improved the diagnostics of the ``optin.core.EnumCastOutOfRange`` checker.
+  It will display the name and the declaration of the enumeration along with
+  the concrete value being cast to the enum.
+  (`#74503 `_)
+
+- Improved the ``ArrayBoundV2`` checker for detecting buffer accesses prior
+  the buffer; and also reworked the diagnostic messages.
+  (`3e014038b373 
`_,
+  `#70056 `_,
+  `#72107 `_)
+
+- Improved the ``CStringChecker`` checking both ends of the buffers in more 
cases.
+  (`c3a87ddad62a 
`_,
+  `0954dc3fb921 
`_)
+
+- Improved the ``StreamChecker`` by modeling more functions like,
+  ``fflush``, ``fputs``, ``fgetc``, ``fputc``, ``fopen``, ``fopen``, ``fgets``.
+  (`#74296 `_,
+  `#73335 `_,
+  `#72627 `_,
+  `#71518 `_,
+  `#72016 `_,
+  `#70540 `_,
+  `#73638 `_)
+
+- Improved the ``unix.StdCLibraryFunctions`` checker by modeling more 
functions like ``send``, ``recv``, ``readlink`` and ``errno`` behavior.
+  (`52ac71f92d38 
`_,
+  `#71373 `_,

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

2023-12-28 Thread via cfe-commits

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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits


@@ -1052,18 +1052,92 @@ libclang
 Static Analyzer
 ---
 
+- Implemented the ``[[clang::suppress]]`` attribute for suppressing diagnostics
+  of static analysis tools, such as the Clang Static Analyzer.
+  `Documentation 
`__.
+
+- Added a new experimental checker ``alpha.core.StdVariant`` to detect variant
+  accesses via wrong alternatives.
+  (`#66481 `_)
+
+- Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect
+  destructions of arrays of polymorphic objects that are destructed as their
+  base class (`CERT EXP51-CPP 
`_).
+  `Documentation 
`__.
+  (`0e246bb67573 
`_)
+
 - Added a new checker ``core.BitwiseShift`` which reports situations where
   bitwise shift operators produce undefined behavior (because some operand is
   negative or too large).
+  `Documentation 
`__.
+
+- Support "Deducing this" (P0847R7). (Worked out of the box)
+  (`af4751738db8 
`__)
 
 - Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
   to ``unix.Errno``.
+  `Documentation 
`__.
 
 - Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
   to ``unix.StdCLibraryFunctions``.
 
+- Added a new checker configuration option to

steakhal wrote:

Done.

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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

steakhal wrote:

![image](https://github.com/llvm/llvm-project/assets/6280485/ca01806a-2983-4940-9b99-48da9c50449c)


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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

steakhal wrote:

@spaits Could you craft some docs for the experimental std::variant checker?

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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

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

>From a4a8704644067a7cf81bee601e4898bbc6b9d289 Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Wed, 27 Dec 2023 14:13:08 +0100
Subject: [PATCH 1/5] [analyzer][docs] Update the release notes for llvm-18

---
 clang/docs/ReleaseNotes.rst | 108 +---
 1 file changed, 101 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee211c16a48ac8..17b6e285a89ca2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1052,18 +1052,92 @@ libclang
 Static Analyzer
 ---
 
+- Implemented the ``[[clang::suppress]]`` attribute for suppressing diagnostics
+  of static analysis tools, such as the Clang Static Analyzer.
+  `Documentation 
`__.
+
+- Added a new experimental checker ``alpha.core.StdVariant`` to detect variant
+  accesses via wrong alternatives.
+  (`#66481 `_)
+
+- Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect
+  destructions of arrays of polymorphic objects that are destructed as their
+  base class (`CERT EXP51-CPP 
`_).
+  `Documentation 
`__.
+  (`0e246bb67573 
`_)
+
 - Added a new checker ``core.BitwiseShift`` which reports situations where
   bitwise shift operators produce undefined behavior (because some operand is
   negative or too large).
+  `Documentation 
`__.
+
+- Support "Deducing this" (P0847R7). (Worked out of the box)
+  (`af4751738db8 
`__)
 
 - Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
   to ``unix.Errno``.
+  `Documentation 
`__.
 
 - Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
   to ``unix.StdCLibraryFunctions``.
 
+- Added a new checker configuration option to
+  ``alpha.security.cert.InvalidPtrChecker``.
+  `Documentation 
`__.
+  (`#67663 `_)
+
+- Move checker ``alpha.security.cert.env.InvalidPtr`` out of the ``alpha``
+  package to ``security.cert.env.InvalidPtr``.
+  `Documentation 
`__.
+
+- Move checker ``alpha.cplusplus.EnumCastOutOfRange`` out of the ``alpha``
+  package to ``optin.core.EnumCastOutOfRange``.
+  `Documentation 
`__.
+
+- Improved the diagnostics of the ``optin.core.EnumCastOutOfRange`` checker.
+  It will display the name and the declaration of the enumeration along with
+  the concrete value being cast to the enum.
+  (`#74503 `_)
+
+- Improved the ``ArrayBoundV2`` checker for detecting buffer accesses prior
+  the buffer; and also reworked the diagnostic messages.
+  (`3e014038b373 
`_,
+  `#70056 `_,
+  `#72107 `_)
+
+- Improved the ``CStringChecker`` checking both ends of the buffers in more 
cases.
+  (`c3a87ddad62a 
`_,
+  `0954dc3fb921 
`_)
+
+- Improved the ``StreamChecker`` by modeling more functions like,
+  ``fflush``, ``fputs``, ``fgetc``, ``fputc``, ``fopen``, ``fopen``, ``fgets``.
+  (`#74296 `_,
+  `#73335 `_,
+  `#72627 `_,
+  `#71518 `_,
+  `#72016 `_,
+  `#70540 `_,
+  `#73638 `_)
+
+- Improved the ``unix.StdCLibraryFunctions`` checker by modeling more 
functions like ``send``, ``recv``, ``readlink`` and ``errno`` behavior.
+  (`52ac71f92d38 
`_,
+  `#71373 `_,

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

2023-12-28 Thread via cfe-commits

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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

steakhal wrote:

I've decided to fix the checker docs for the 
`security.insecureAPI.DeprecatedOrUnsafeBufferHandling`.
It turned out to be an easy one as the only missing function was `fprintf`, so 
it was already well in sync. I bundled that single word change with this PR for 
simplicity.

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


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

2023-12-28 Thread Qiu Chaofan via cfe-commits

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


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

2023-12-28 Thread Qiu Chaofan via cfe-commits

https://github.com/ecnelises updated 
https://github.com/llvm/llvm-project/pull/76495

>From aaa11bc775b9aa3a0398ba2bbca4087e99f04243 Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Thu, 28 Dec 2023 16:54:25 +0800
Subject: [PATCH 1/2] [PowerPC] Implement fence builtin

---
 clang/include/clang/Basic/BuiltinsPPC.def |  3 +++
 clang/lib/Basic/Targets/PPC.cpp   |  1 +
 llvm/include/llvm/IR/IntrinsicsPowerPC.td |  5 +
 llvm/lib/Target/PowerPC/PPCInstrInfo.cpp  |  7 ++-
 llvm/lib/Target/PowerPC/PPCInstrInfo.td   |  4 
 .../CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll| 11 +++
 6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index a35488ed3dfa56..829c60defe17c6 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -944,6 +944,9 @@ TARGET_BUILTIN(__builtin_pack_vector_int128, 
"V1LLLiULLiULLi", "", "vsx")
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Barrier for instruction motion
+BUILTIN(__builtin_ppc_fence, "v", "")
+
 // Get content from current FPSCR
 BUILTIN(__builtin_readflm, "d", "")
 
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 045c273f03c7a0..41935abfb65d3b 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -212,6 +212,7 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
   Builder.defineMacro("__darn_32", "__builtin_darn_32");
   Builder.defineMacro("__darn_raw", "__builtin_darn_raw");
   Builder.defineMacro("__dcbf", "__builtin_dcbf");
+  Builder.defineMacro("__fence", "__builtin_ppc_fence");
   Builder.defineMacro("__fmadd", "__builtin_fma");
   Builder.defineMacro("__fmadds", "__builtin_fmaf");
   Builder.defineMacro("__abs", "__builtin_abs");
diff --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index 3ede2a3736bf30..6d1e8eb47405dd 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -29,6 +29,11 @@ let TargetPrefix = "ppc" in {  // All intrinsics start with 
"llvm.ppc.".
 [IntrArgMemOnly, NoCapture>, ImmArg>]>;
   def int_ppc_dcbzl : Intrinsic<[], [llvm_ptr_ty], []>;
 
+  // Emit pseudo instruction as fence of instruction motion
+  def int_ppc_fence : ClangBuiltin<"__builtin_ppc_fence">,
+  DefaultAttrsIntrinsic<[], [],
+[IntrNoMerge, IntrHasSideEffects]>;
+
   // Get content from current FPSCR register
   def int_ppc_readflm : ClangBuiltin<"__builtin_readflm">,
 DefaultAttrsIntrinsic<[llvm_double_ty], [],
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index aaced58defe603..af55c6cf337120 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -2155,11 +2155,16 @@ bool PPCInstrInfo::isPredicated(const MachineInstr &MI) 
const {
 bool PPCInstrInfo::isSchedulingBoundary(const MachineInstr &MI,
 const MachineBasicBlock *MBB,
 const MachineFunction &MF) const {
+  switch (MI.getOpcode()) {
+  default: break;
   // Set MFFS and MTFSF as scheduling boundary to avoid unexpected code motion
   // across them, since some FP operations may change content of FPSCR.
   // TODO: Model FPSCR in PPC instruction definitions and remove the workaround
-  if (MI.getOpcode() == PPC::MFFS || MI.getOpcode() == PPC::MTFSF)
+  case PPC::MFFS:
+  case PPC::MTFSF:
+  case PPC::FENCE:
 return true;
+  }
   return TargetInstrInfo::isSchedulingBoundary(MI, MBB, MF);
 }
 
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
index b1601739fd4569..c0344dfbf3a728 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -1328,6 +1328,9 @@ def SETFLM : PPCCustomInserterPseudo<(outs f8rc:$FRT), 
(ins f8rc:$FLM),
 "#SETFLM", [(set f64:$FRT, (int_ppc_setflm f8rc:$FLM))]>;
 }
 
+let isBarrier = 1, hasSideEffects = 1, Defs = [RM] in
+def FENCE : PPCEmitTimePseudo<(outs), (ins), "#FENCE", []>;
+
 let Defs = [LR] in
   def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
PPC970_Unit_BRU;
@@ -3187,6 +3190,7 @@ def : Pat<(PPCtc_return (i32 texternalsym:$dst), 
imm:$imm),
 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
   (TCRETURNri CTRRC:$dst, imm:$imm)>;
 
+def : Pat<(int_ppc_fence), (FENCE)>;
 def : Pat<(int_ppc_readflm), (MFFS)>;
 def : Pat<(int_ppc_mffsl), (MFFSL)>;
 
diff --git a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll
index 2c9fd2034f887c..555de90c56c364 100644
--- a/llvm/te

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

2023-12-28 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-clang

Author: Qiu Chaofan (ecnelises)


Changes

This builtin will work as barrier for instruction motion (scheduling, etc.)

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


7 Files Affected:

- (modified) clang/include/clang/Basic/BuiltinsPPC.def (+3) 
- (modified) clang/lib/Basic/Targets/PPC.cpp (+1) 
- (modified) clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c (+24) 
- (modified) llvm/include/llvm/IR/IntrinsicsPowerPC.td (+5) 
- (modified) llvm/lib/Target/PowerPC/PPCInstrInfo.cpp (+6-1) 
- (modified) llvm/lib/Target/PowerPC/PPCInstrInfo.td (+4) 
- (added) llvm/test/CodeGen/PowerPC/fence.ll (+45) 


``diff
diff --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index a35488ed3dfa56..829c60defe17c6 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -944,6 +944,9 @@ TARGET_BUILTIN(__builtin_pack_vector_int128, 
"V1LLLiULLiULLi", "", "vsx")
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Barrier for instruction motion
+BUILTIN(__builtin_ppc_fence, "v", "")
+
 // Get content from current FPSCR
 BUILTIN(__builtin_readflm, "d", "")
 
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 045c273f03c7a0..41935abfb65d3b 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -212,6 +212,7 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
   Builder.defineMacro("__darn_32", "__builtin_darn_32");
   Builder.defineMacro("__darn_raw", "__builtin_darn_raw");
   Builder.defineMacro("__dcbf", "__builtin_dcbf");
+  Builder.defineMacro("__fence", "__builtin_ppc_fence");
   Builder.defineMacro("__fmadd", "__builtin_fma");
   Builder.defineMacro("__fmadds", "__builtin_fmaf");
   Builder.defineMacro("__abs", "__builtin_abs");
diff --git a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c 
b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c
index 9187bb855dac22..a5cc97161c56ac 100644
--- a/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c
+++ b/clang/test/CodeGen/PowerPC/builtins-ppc-xlcompat-sync.c
@@ -194,6 +194,18 @@ void test_dcbz() {
   __dcbz(c);
 }
 
+// CHECK-LABEL: @test_fence(
+// CHECK: call void @llvm.ppc.fence()
+// CHECK-NEXT:ret void
+//
+// CHECK-32-LABEL: @test_fence(
+// CHECK-32: call void @llvm.ppc.fence()
+// CHECK-32-NEXT:ret void
+//
+void test_fence() {
+  __fence();
+}
+
 // CHECK-LABEL: @test_builtin_ppc_popcntb(
 // CHECK:[[TMP0:%.*]] = load i64, ptr @a, align 8
 // CHECK-NEXT:[[POPCNTB:%.*]] = call i64 @llvm.ppc.popcntb.i64.i64(i64 
[[TMP0]])
@@ -375,3 +387,15 @@ void test_builtin_ppc_dcbtst() {
 void test_builtin_ppc_dcbz() {
   __builtin_ppc_dcbz(c);
 }
+
+// CHECK-LABEL: @test_builtin_ppc_fence(
+// CHECK: call void @llvm.ppc.fence()
+// CHECK-NEXT:ret void
+//
+// CHECK-32-LABEL: @test_builtin_ppc_fence(
+// CHECK-32: call void @llvm.ppc.fence()
+// CHECK-32-NEXT:ret void
+//
+void test_builtin_ppc_fence() {
+  __builtin_ppc_fence();
+}
diff --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index 3ede2a3736bf30..6d1e8eb47405dd 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -29,6 +29,11 @@ let TargetPrefix = "ppc" in {  // All intrinsics start with 
"llvm.ppc.".
 [IntrArgMemOnly, NoCapture>, ImmArg>]>;
   def int_ppc_dcbzl : Intrinsic<[], [llvm_ptr_ty], []>;
 
+  // Emit pseudo instruction as fence of instruction motion
+  def int_ppc_fence : ClangBuiltin<"__builtin_ppc_fence">,
+  DefaultAttrsIntrinsic<[], [],
+[IntrNoMerge, IntrHasSideEffects]>;
+
   // Get content from current FPSCR register
   def int_ppc_readflm : ClangBuiltin<"__builtin_readflm">,
 DefaultAttrsIntrinsic<[llvm_double_ty], [],
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index aaced58defe603..af55c6cf337120 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -2155,11 +2155,16 @@ bool PPCInstrInfo::isPredicated(const MachineInstr &MI) 
const {
 bool PPCInstrInfo::isSchedulingBoundary(const MachineInstr &MI,
 const MachineBasicBlock *MBB,
 const MachineFunction &MF) const {
+  switch (MI.getOpcode()) {
+  default: break;
   // Set MFFS and MTFSF as scheduling boundary to avoid unexpected code motion
   // across them, since some FP operations may change content of FPSCR.
   // TODO: Model FPSCR in PPC instruction definitions and remove the workaround
-  if (MI.getOpcode() == PPC::MFFS || MI.getOpcode() == PPC::MTFSF)
+  case PPC::MFFS:
+  case PPC::MTFSF:
+  case PPC::FE

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

2023-12-28 Thread Qiu Chaofan via cfe-commits

https://github.com/ecnelises updated 
https://github.com/llvm/llvm-project/pull/76495

>From aaa11bc775b9aa3a0398ba2bbca4087e99f04243 Mon Sep 17 00:00:00 2001
From: Qiu Chaofan 
Date: Thu, 28 Dec 2023 16:54:25 +0800
Subject: [PATCH 1/3] [PowerPC] Implement fence builtin

---
 clang/include/clang/Basic/BuiltinsPPC.def |  3 +++
 clang/lib/Basic/Targets/PPC.cpp   |  1 +
 llvm/include/llvm/IR/IntrinsicsPowerPC.td |  5 +
 llvm/lib/Target/PowerPC/PPCInstrInfo.cpp  |  7 ++-
 llvm/lib/Target/PowerPC/PPCInstrInfo.td   |  4 
 .../CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll| 11 +++
 6 files changed, 30 insertions(+), 1 deletion(-)

diff --git a/clang/include/clang/Basic/BuiltinsPPC.def 
b/clang/include/clang/Basic/BuiltinsPPC.def
index a35488ed3dfa56..829c60defe17c6 100644
--- a/clang/include/clang/Basic/BuiltinsPPC.def
+++ b/clang/include/clang/Basic/BuiltinsPPC.def
@@ -944,6 +944,9 @@ TARGET_BUILTIN(__builtin_pack_vector_int128, 
"V1LLLiULLiULLi", "", "vsx")
 // Set the floating point rounding mode
 BUILTIN(__builtin_setrnd, "di", "")
 
+// Barrier for instruction motion
+BUILTIN(__builtin_ppc_fence, "v", "")
+
 // Get content from current FPSCR
 BUILTIN(__builtin_readflm, "d", "")
 
diff --git a/clang/lib/Basic/Targets/PPC.cpp b/clang/lib/Basic/Targets/PPC.cpp
index 045c273f03c7a0..41935abfb65d3b 100644
--- a/clang/lib/Basic/Targets/PPC.cpp
+++ b/clang/lib/Basic/Targets/PPC.cpp
@@ -212,6 +212,7 @@ static void defineXLCompatMacros(MacroBuilder &Builder) {
   Builder.defineMacro("__darn_32", "__builtin_darn_32");
   Builder.defineMacro("__darn_raw", "__builtin_darn_raw");
   Builder.defineMacro("__dcbf", "__builtin_dcbf");
+  Builder.defineMacro("__fence", "__builtin_ppc_fence");
   Builder.defineMacro("__fmadd", "__builtin_fma");
   Builder.defineMacro("__fmadds", "__builtin_fmaf");
   Builder.defineMacro("__abs", "__builtin_abs");
diff --git a/llvm/include/llvm/IR/IntrinsicsPowerPC.td 
b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
index 3ede2a3736bf30..6d1e8eb47405dd 100644
--- a/llvm/include/llvm/IR/IntrinsicsPowerPC.td
+++ b/llvm/include/llvm/IR/IntrinsicsPowerPC.td
@@ -29,6 +29,11 @@ let TargetPrefix = "ppc" in {  // All intrinsics start with 
"llvm.ppc.".
 [IntrArgMemOnly, NoCapture>, ImmArg>]>;
   def int_ppc_dcbzl : Intrinsic<[], [llvm_ptr_ty], []>;
 
+  // Emit pseudo instruction as fence of instruction motion
+  def int_ppc_fence : ClangBuiltin<"__builtin_ppc_fence">,
+  DefaultAttrsIntrinsic<[], [],
+[IntrNoMerge, IntrHasSideEffects]>;
+
   // Get content from current FPSCR register
   def int_ppc_readflm : ClangBuiltin<"__builtin_readflm">,
 DefaultAttrsIntrinsic<[llvm_double_ty], [],
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
index aaced58defe603..af55c6cf337120 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -2155,11 +2155,16 @@ bool PPCInstrInfo::isPredicated(const MachineInstr &MI) 
const {
 bool PPCInstrInfo::isSchedulingBoundary(const MachineInstr &MI,
 const MachineBasicBlock *MBB,
 const MachineFunction &MF) const {
+  switch (MI.getOpcode()) {
+  default: break;
   // Set MFFS and MTFSF as scheduling boundary to avoid unexpected code motion
   // across them, since some FP operations may change content of FPSCR.
   // TODO: Model FPSCR in PPC instruction definitions and remove the workaround
-  if (MI.getOpcode() == PPC::MFFS || MI.getOpcode() == PPC::MTFSF)
+  case PPC::MFFS:
+  case PPC::MTFSF:
+  case PPC::FENCE:
 return true;
+  }
   return TargetInstrInfo::isSchedulingBoundary(MI, MBB, MF);
 }
 
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.td 
b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
index b1601739fd4569..c0344dfbf3a728 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.td
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.td
@@ -1328,6 +1328,9 @@ def SETFLM : PPCCustomInserterPseudo<(outs f8rc:$FRT), 
(ins f8rc:$FLM),
 "#SETFLM", [(set f64:$FRT, (int_ppc_setflm f8rc:$FLM))]>;
 }
 
+let isBarrier = 1, hasSideEffects = 1, Defs = [RM] in
+def FENCE : PPCEmitTimePseudo<(outs), (ins), "#FENCE", []>;
+
 let Defs = [LR] in
   def MovePCtoLR : PPCEmitTimePseudo<(outs), (ins), "#MovePCtoLR", []>,
PPC970_Unit_BRU;
@@ -3187,6 +3190,7 @@ def : Pat<(PPCtc_return (i32 texternalsym:$dst), 
imm:$imm),
 def : Pat<(PPCtc_return CTRRC:$dst, imm:$imm),
   (TCRETURNri CTRRC:$dst, imm:$imm)>;
 
+def : Pat<(int_ppc_fence), (FENCE)>;
 def : Pat<(int_ppc_readflm), (MFFS)>;
 def : Pat<(int_ppc_mffsl), (MFFSL)>;
 
diff --git a/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll 
b/llvm/test/CodeGen/PowerPC/builtins-ppc-xlcompat-msync.ll
index 2c9fd2034f887c..555de90c56c364 100644
--- a/llvm/te

[llvm] [clang] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-12-28 Thread Yeting Kuo via cfe-commits

https://github.com/yetingk updated 
https://github.com/llvm/llvm-project/pull/66043

>From 4a73535ec7206951c6b843e11c81e6c0c01cc1d0 Mon Sep 17 00:00:00 2001
From: Yeting Kuo 
Date: Tue, 12 Sep 2023 12:28:00 +0800
Subject: [PATCH 1/3] [RISCV] Add MC layer support for Zicfiss.

The patch adds the instructions in Zicfiss extension. Zicfiss extension is
to support shadow stack for control flow integrity.

Differential Revision: https://reviews.llvm.org/D152793
---
 .../test/Preprocessor/riscv-target-features.c |   9 ++
 llvm/docs/RISCVUsage.rst  |   2 +-
 llvm/lib/Support/RISCVISAInfo.cpp |   2 +
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |  25 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|   7 ++
 llvm/lib/Target/RISCV/RISCVInstrInfo.td   |  11 +-
 .../lib/Target/RISCV/RISCVInstrInfoZicfiss.td |  71 
 llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp   |   3 +
 llvm/lib/Target/RISCV/RISCVRegisterInfo.td|   7 ++
 llvm/test/MC/RISCV/attribute-arch.s   |   3 +
 llvm/test/MC/RISCV/compressed-zicfiss.s   |  53 +
 llvm/test/MC/RISCV/rv32zicfiss-invalid.s  |  17 +++
 llvm/test/MC/RISCV/rv64zicfiss-invalid.s  |  17 +++
 llvm/test/MC/RISCV/zicfiss-valid.s| 102 ++
 llvm/unittests/Support/RISCVISAInfoTest.cpp   |   1 +
 15 files changed, 324 insertions(+), 6 deletions(-)
 create mode 100644 llvm/lib/Target/RISCV/RISCVInstrInfoZicfiss.td
 create mode 100644 llvm/test/MC/RISCV/compressed-zicfiss.s
 create mode 100644 llvm/test/MC/RISCV/rv32zicfiss-invalid.s
 create mode 100644 llvm/test/MC/RISCV/rv64zicfiss-invalid.s
 create mode 100644 llvm/test/MC/RISCV/zicfiss-valid.s

diff --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 43fcb35aba039c..5605a5ed7f29cb 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -119,6 +119,7 @@
 // CHECK-NOT: __riscv_zfa {{.*$}}
 // CHECK-NOT: __riscv_zfbfmin {{.*$}}
 // CHECK-NOT: __riscv_zicfilp {{.*$}}
+// CHECK-NOT: __riscv_zicfiss {{.*$}}
 // CHECK-NOT: __riscv_zicond {{.*$}}
 // CHECK-NOT: __riscv_zimop {{.*$}}
 // CHECK-NOT: __riscv_zcmop {{.*$}}
@@ -1296,3 +1297,11 @@
 // RUN: %clang --target=riscv64-unknown-linux-gnu -march=rv64i -E -dM %s \
 // RUN:   -munaligned-access -o - | FileCheck %s 
--check-prefix=CHECK-MISALIGNED-FAST
 // CHECK-MISALIGNED-FAST: __riscv_misaligned_fast 1
+
+// RUN: %clang -target riscv32 -menable-experimental-extensions \
+// RUN: -march=rv32izicfiss0p4 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// RUN: %clang -target riscv64 -menable-experimental-extensions \
+// RUN: -march=rv64izicfiss0p4 -x c -E -dM %s \
+// RUN: -o - | FileCheck --check-prefix=CHECK-ZICFISS-EXT %s
+// CHECK-ZICFISS-EXT: __riscv_zicfiss 4000{{$}}
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 836a4e9ff08e55..53c56e3fb23018 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -212,7 +212,7 @@ The primary goal of experimental support is to assist in 
the process of ratifica
 ``experimental-zfbfmin``, ``experimental-zvfbfmin``, ``experimental-zvfbfwma``
   LLVM implements assembler support for the `0.8.0 draft specification 
`_.
 
-``experimental-zicfilp``
+``experimental-zicfilp``, ``experimental-zicfiss``
   LLVM implements the `0.4 draft specification 
`__.
 
 ``experimental-zicond``
diff --git a/llvm/lib/Support/RISCVISAInfo.cpp 
b/llvm/lib/Support/RISCVISAInfo.cpp
index 14079a0eb07603..052abc4a3a1063 100644
--- a/llvm/lib/Support/RISCVISAInfo.cpp
+++ b/llvm/lib/Support/RISCVISAInfo.cpp
@@ -196,6 +196,8 @@ static const RISCVSupportedExtension 
SupportedExperimentalExtensions[] = {
 {"zfbfmin", RISCVExtensionVersion{0, 8}},
 
 {"zicfilp", RISCVExtensionVersion{0, 4}},
+{"zicfiss", RISCVExtensionVersion{0, 4}},
+
 {"zicond", RISCVExtensionVersion{1, 0}},
 
 {"zimop", RISCVExtensionVersion{0, 1}},
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index 184000b48987e6..d23f60302f42c7 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -74,6 +74,17 @@ static DecodeStatus DecodeGPRRegisterClass(MCInst &Inst, 
uint32_t RegNo,
   return MCDisassembler::Success;
 }
 
+static DecodeStatus DecodeGPRX1X5RegisterClass(MCInst &Inst, uint32_t RegNo,
+   uint64_t Address,
+   const MCDisassembler *Decoder) {
+  MCRegister Reg = RISCV::X0 + RegNo;
+  if (Reg != RISCV::X1 && Reg != RISCV::X5)
+return MCDisassembler::Fail;
+
+  Inst.addOperand(MCOperand::createReg(Reg));
+  return MCDisassembler::Suc

[clang] [llvm] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-12-28 Thread Yeting Kuo via cfe-commits

yetingk wrote:

Rebase but I didn't use alias to Zimop and Zcmop ways to achieve this code, 
since using them will lose some information like `Uses = [SSP]`. 

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


[clang-tools-extra] [clangd] Avoid crash when summarizing pointer-to-member expr for block-end hint (PR #76492)

2023-12-28 Thread Haojian Wu via cfe-commits

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

Thanks. Can you add your analysis 
(https://github.com/clangd/clangd/issues/1873#issuecomment-1870902480) to the 
commit description, I think it is useful to have it in the commit log. 

btw, it looks like there is a FIXME 
(https://github.com/llvm/llvm-project/blob/main/clang/lib/AST/ExprCXX.cpp#L677) 
for supporting this particular case. 


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


[clang] [llvm] [RISCV] Add MC layer support for Zicfiss. (PR #66043)

2023-12-28 Thread Yeting Kuo via cfe-commits


@@ -60,12 +60,3 @@ defm SSAMOSWAP_W  : AMO_rr_aq_rl<0b01001, 0b010, 
"ssamoswap.w">;
 
 let Predicates = [HasStdExtZicfiss, IsRV64] in
 defm SSAMOSWAP_D  : AMO_rr_aq_rl<0b01001, 0b011, "ssamoswap.d">;
-
-//===--===/
-// Compress Instruction tablegen backend.
-//===--===//
-
-let Predicates = [HasStdExtZicfiss, HasStdExtCOrZca] in {

yetingk wrote:

I remove some CompressPat since I don't know how to test sspush/sspopchk 
without transforming to compressed ones. 

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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread via cfe-commits

https://github.com/DonatNagyE commented:

There are several changes that are only relevant for the users who use alpha 
checkers. Perhaps it would be a good idea to put those into a separate list (or 
to the end of the list?).

Either way, the update looks good to me, thanks for composing it!

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


[clang] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread via cfe-commits

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

(I didn't check all the links, but overall LGTM.)

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


[clang] [clang-format] Fix a bug in annotating function declaration names (PR #76206)

2023-12-28 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

> > `clang-format` doesn't know what are types, except for the keywords. So 
> > there is no way to decide if this is a function declaration without naming 
> > the parameters, or a variable declaration with a constructor call.
> 
> This is C so I guess it can only be a function declaration. Anyway, it's 
> minor to work around, thanks again.

This boils down to, that for `clang-format` C doesn't exist. It's all parsed as 
C++.

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


[clang] [clang-format] Add common attribute macros to Google style (PR #76239)

2023-12-28 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

> Who should have the final say on the Google code style if not Google?

That's also my point of view. Who ever decides to use google style, has to live 
with google changing its style.

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


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

2023-12-28 Thread via cfe-commits

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

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

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

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

[clang] [clang-format] Support of TableGen formatting. (PR #76059)

2023-12-28 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

> @rymiel @HazardyKnusperkeks Thank you for your review! I have fixed the 
> points. But for refactoring of the test base class in 
> [f8d10d5](https://github.com/llvm/llvm-project/commit/f8d10d5ac9ab4b45b388c74357fc82fb96562e66)
>  . I'm not sure I should do here, and if I should, I should do it in splitted 
> pull request.
> 
> Now I really understand I should split this pull request into some parts. At 
> first it is large and continue growing by adding documents. I'm wondering how 
> and current plan is separating semantically,
> 
> * Handling multi line string (~100 lines).
> 
> * Handling numeric like identifier (~100 lines).
> 
> * Handling TableGen specific keywords (~100 lines)
> 
> * Unwrapped line parsing(~100 lines).
> 
> * Parse TableGen values (about 500+ lines including unittest).
> 
> * Basic options (but for aligning ones) (about 500+ lines including the 
> document).
> 
> * Aligning options (about 100 lines including document).
> 
> * Refactor unittests.
> 
> 
> I'm not sure this is good plan. They may be complicated. Could you help me to 
> plan if you have some idea?
> 
> In addition, I do not know the appropriate way to split pull request after I 
> made one. Is it enough to refer each other, and abort this at last?

Just create a pull request per feature/bug. You can sill use this for one of 
them, or abandon this. If some of them build on each other there is, as far as 
I know, no good way. 

The few times I came to this I created multiple PRs and the top most commit(s) 
is/are part of multiple PRs and I mentioned this. Then we have to make sure 
that they are merged correctly. With multiple local branches you can still work 
on all of them in parallel.

My experience (here and at work) is, that smaller changes are easier to check 
and you get a faster response. Because 50~150 lines changes I can just review 
and move on. A 500+ change review will more likely be postponed.

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


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

2023-12-28 Thread via cfe-commits

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

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

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

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

[clang] [clang] Add basic support for #embed (PR #76480)

2023-12-28 Thread Timm Baeder via cfe-commits

tbaederr wrote:

We already have https://github.com/llvm/llvm-project/pull/68620 in the pipeline 
for this.

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


[openmp] [libc] [clang] [mlir] [llvm] [compiler-rt] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

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

>From a4a8704644067a7cf81bee601e4898bbc6b9d289 Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Wed, 27 Dec 2023 14:13:08 +0100
Subject: [PATCH 1/9] [analyzer][docs] Update the release notes for llvm-18

---
 clang/docs/ReleaseNotes.rst | 108 +---
 1 file changed, 101 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee211c16a48ac8..17b6e285a89ca2 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1052,18 +1052,92 @@ libclang
 Static Analyzer
 ---
 
+- Implemented the ``[[clang::suppress]]`` attribute for suppressing diagnostics
+  of static analysis tools, such as the Clang Static Analyzer.
+  `Documentation 
`__.
+
+- Added a new experimental checker ``alpha.core.StdVariant`` to detect variant
+  accesses via wrong alternatives.
+  (`#66481 `_)
+
+- Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect
+  destructions of arrays of polymorphic objects that are destructed as their
+  base class (`CERT EXP51-CPP 
`_).
+  `Documentation 
`__.
+  (`0e246bb67573 
`_)
+
 - Added a new checker ``core.BitwiseShift`` which reports situations where
   bitwise shift operators produce undefined behavior (because some operand is
   negative or too large).
+  `Documentation 
`__.
+
+- Support "Deducing this" (P0847R7). (Worked out of the box)
+  (`af4751738db8 
`__)
 
 - Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
   to ``unix.Errno``.
+  `Documentation 
`__.
 
 - Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
   to ``unix.StdCLibraryFunctions``.
 
+- Added a new checker configuration option to
+  ``alpha.security.cert.InvalidPtrChecker``.
+  `Documentation 
`__.
+  (`#67663 `_)
+
+- Move checker ``alpha.security.cert.env.InvalidPtr`` out of the ``alpha``
+  package to ``security.cert.env.InvalidPtr``.
+  `Documentation 
`__.
+
+- Move checker ``alpha.cplusplus.EnumCastOutOfRange`` out of the ``alpha``
+  package to ``optin.core.EnumCastOutOfRange``.
+  `Documentation 
`__.
+
+- Improved the diagnostics of the ``optin.core.EnumCastOutOfRange`` checker.
+  It will display the name and the declaration of the enumeration along with
+  the concrete value being cast to the enum.
+  (`#74503 `_)
+
+- Improved the ``ArrayBoundV2`` checker for detecting buffer accesses prior
+  the buffer; and also reworked the diagnostic messages.
+  (`3e014038b373 
`_,
+  `#70056 `_,
+  `#72107 `_)
+
+- Improved the ``CStringChecker`` checking both ends of the buffers in more 
cases.
+  (`c3a87ddad62a 
`_,
+  `0954dc3fb921 
`_)
+
+- Improved the ``StreamChecker`` by modeling more functions like,
+  ``fflush``, ``fputs``, ``fgetc``, ``fputc``, ``fopen``, ``fopen``, ``fgets``.
+  (`#74296 `_,
+  `#73335 `_,
+  `#72627 `_,
+  `#71518 `_,
+  `#72016 `_,
+  `#70540 `_,
+  `#73638 `_)
+
+- Improved the ``unix.StdCLibraryFunctions`` checker by modeling more 
functions like ``send``, ``recv``, ``readlink`` and ``errno`` behavior.
+  (`52ac71f92d38 
`_,
+  `#71373 `_,

[openmp] [libc] [clang] [mlir] [llvm] [compiler-rt] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

steakhal wrote:

Introduced subsub-sections and ordered them and their content by expected 
relevance.
The rule of thumb was:
 - released stuff comes first, then alpha. etc.
 Also, checkers are always fully named, and named by their user-facing names.
 
 Now the html looks like this: 
![image](https://github.com/llvm/llvm-project/assets/6280485/5f87a250-98a4-4860-a107-acd754aa7d1f)


I'm pretty happy with the result.

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


[llvm] [clang] [RFC][RISCV] Support RISC-V Profiles in -march option (PR #76357)

2023-12-28 Thread Wang Pengcheng via cfe-commits

https://github.com/wangpc-pp updated 
https://github.com/llvm/llvm-project/pull/76357

>From fa079e4be8b1b043b635a494b8c0bcc5aa79092b Mon Sep 17 00:00:00 2001
From: wangpc 
Date: Mon, 25 Dec 2023 18:52:36 +0800
Subject: [PATCH] [RFC][RISCV] Support RISC-V Profiles in -march option

This PR implements the draft
https://github.com/riscv-non-isa/riscv-toolchain-conventions/pull/36.

Currently, we replace specified profile in `-march` with standard
arch string.

We may need to pass it to backend so that we can emit an ELF attr
proposed by
https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/409.
---
 clang/test/Driver/riscv-profiles.c   | 112 +++
 llvm/include/llvm/Support/RISCVISAInfo.h |   4 +-
 llvm/lib/Support/RISCVISAInfo.cpp|  51 +++
 llvm/lib/Target/RISCV/RISCV.td   |   6 ++
 llvm/lib/Target/RISCV/RISCVProfiles.td   |  70 ++
 llvm/lib/Target/RISCV/RISCVSubtarget.h   |  14 +++
 llvm/test/CodeGen/RISCV/attributes.ll|  15 +++
 7 files changed, 271 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/Driver/riscv-profiles.c
 create mode 100644 llvm/lib/Target/RISCV/RISCVProfiles.td

diff --git a/clang/test/Driver/riscv-profiles.c 
b/clang/test/Driver/riscv-profiles.c
new file mode 100644
index 00..d41d68e078b976
--- /dev/null
+++ b/clang/test/Driver/riscv-profiles.c
@@ -0,0 +1,112 @@
+// RUN: %clang -### -c %s 2>&1 -march=rvi20u32 | FileCheck 
-check-prefix=RVI20U32 %s
+// RVI20U32: "-target-cpu" "generic-rv32"
+// RVI20U32: "-target-feature" "-a"
+// RVI20U32: "-target-feature" "-c"
+// RVI20U32: "-target-feature" "-d"
+// RVI20U32: "-target-feature" "-f"
+// RVI20U32: "-target-feature" "-m"
+// RVI20U32: "-target-feature" "+rvi20u32"
+// RVI20U32: "-target-abi" "ilp32"
+
+// RUN: %clang -### -c %s 2>&1 -march=rvi20u64 | FileCheck 
-check-prefix=RVI20U64 %s
+// RVI20U64: "-target-cpu" "generic-rv64"
+// RVI20U64: "-target-feature" "-a"
+// RVI20U64: "-target-feature" "-c"
+// RVI20U64: "-target-feature" "-d"
+// RVI20U64: "-target-feature" "-f"
+// RVI20U64: "-target-feature" "-m"
+// RVI20U64: "-target-feature" "+rvi20u64"
+// RVI20U64: "-target-abi" "lp64"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva20u64 | FileCheck 
-check-prefix=RVA20U64 %s
+// RVA20U64: "-target-cpu" "generic-rv64"
+// RVA20U64: "-target-feature" "+m"
+// RVA20U64: "-target-feature" "+a"
+// RVA20U64: "-target-feature" "+f"
+// RVA20U64: "-target-feature" "+d"
+// RVA20U64: "-target-feature" "+c"
+// RVA20U64: "-target-feature" "+zicsr"
+// RVA20U64: "-target-feature" "+rva20u64"
+// RVA20U64: "-target-abi" "lp64d"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva20s64 | FileCheck 
-check-prefix=RVA20S64 %s
+// RVA20S64: "-target-cpu" "generic-rv64"
+// RVA20S64: "-target-feature" "+m"
+// RVA20S64: "-target-feature" "+a"
+// RVA20S64: "-target-feature" "+f"
+// RVA20S64: "-target-feature" "+d"
+// RVA20S64: "-target-feature" "+c"
+// RVA20S64: "-target-feature" "+zicsr"
+// RVA20S64: "-target-feature" "+zifencei"
+// RVA20S64: "-target-feature" "+rva20s64"
+// RVA20S64: "-target-abi" "lp64d"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva22u64 | FileCheck 
-check-prefix=RVA22U64 %s
+// RVA22U64: "-target-cpu" "generic-rv64"
+// RVA22U64: "-target-feature" "+m"
+// RVA22U64: "-target-feature" "+a"
+// RVA22U64: "-target-feature" "+f"
+// RVA22U64: "-target-feature" "+d"
+// RVA22U64: "-target-feature" "+c"
+// RVA22U64: "-target-feature" "+zicbom"
+// RVA22U64: "-target-feature" "+zicbop"
+// RVA22U64: "-target-feature" "+zicboz"
+// RVA22U64: "-target-feature" "+zicsr"
+// RVA22U64: "-target-feature" "+zihintpause"
+// RVA22U64: "-target-feature" "+zfhmin" 
+// RVA22U64: "-target-feature" "+zba"
+// RVA22U64: "-target-feature" "+zbb"
+// RVA22U64: "-target-feature" "+zbs"
+// RVA22U64: "-target-feature" "+zkt"
+// RVA22U64: "-target-feature" "+rva22u64"
+// RVA22U64: "-target-abi" "lp64d"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva22s64 | FileCheck 
-check-prefix=RVA22S64 %s
+// RVA22S64: "-target-cpu" "generic-rv64"
+// RVA22S64: "-target-feature" "+m"
+// RVA22S64: "-target-feature" "+a"
+// RVA22S64: "-target-feature" "+f"
+// RVA22S64: "-target-feature" "+d"
+// RVA22S64: "-target-feature" "+c"
+// RVA22S64: "-target-feature" "+zicbom"
+// RVA22S64: "-target-feature" "+zicbop"
+// RVA22S64: "-target-feature" "+zicboz"
+// RVA22S64: "-target-feature" "+zicsr"
+// RVA22S64: "-target-feature" "+zifencei"
+// RVA22S64: "-target-feature" "+zihintpause"
+// RVA22S64: "-target-feature" "+zfhmin" 
+// RVA22S64: "-target-feature" "+zba"
+// RVA22S64: "-target-feature" "+zbb"
+// RVA22S64: "-target-feature" "+zbs"
+// RVA22S64: "-target-feature" "+zkt"
+// RVA22S64: "-target-feature" "+svinval"
+// RVA22S64: "-target-feature" "+svpbmt"
+// RVA22S64: "-target-feature" "+rva22s64"
+// RVA22S64: "-target-abi" "lp64d"
+
+// RUN: %clang -### -c %s 2>&1 -march=rva22u64_zfa | FileCheck 
-check-prefix=PROFILE-WITH-ADDITIONAL %s
+// PROFILE-WITH-ADDITIONAL: "-target-

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

2023-12-28 Thread Yueh-Shun Li via cfe-commits


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

ShamrockLee wrote:

> do you have any idea where is actually the right place to fix the code?

IIUC, it should be around

```c++
  V.getInt().toString(Str);
```

as I mentioned earlier in 
https://github.com/llvm/llvm-project/pull/75902#discussion_r1432050810

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


[clang] [clang] Add basic support for #embed (PR #76480)

2023-12-28 Thread Junior Rantila via cfe-commits

juniorrantila wrote:

Aah, my bad.

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


[clang] [clang] Add basic support for #embed (PR #76480)

2023-12-28 Thread Junior Rantila via cfe-commits

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


[clang-tools-extra] [flang] [llvm] [clang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2023-12-28 Thread Yi Wu via cfe-commits


@@ -0,0 +1,31 @@
+//===-- include/flang/Runtime/command.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef FORTRAN_RUNTIME_EXECUTE_H_
+#define FORTRAN_RUNTIME_EXECUTE_H_
+
+#include "flang/Runtime/entry-names.h"
+
+#include 

yi-wu-arm wrote:

no, removed.

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


[flang] [clang] [clang-tools-extra] [llvm] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2023-12-28 Thread Yi Wu via cfe-commits


@@ -0,0 +1,31 @@
+//===-- include/flang/Runtime/command.h -*- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef FORTRAN_RUNTIME_EXECUTE_H_
+#define FORTRAN_RUNTIME_EXECUTE_H_
+
+#include "flang/Runtime/entry-names.h"
+
+#include 

yi-wu-arm wrote:

not anymore, should be removed

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


[clang] [clang-format] Add .clang-format.ignore for ignoring files (PR #76327)

2023-12-28 Thread Björn Schäpers via cfe-commits


@@ -570,6 +571,74 @@ static int dumpConfig(bool IsSTDIN) {
   return 0;
 }
 
+// Check whether `FilePath` is ignored according to the nearest
+// .clang-format-ignore file based on the rules below:
+// - A blank line is skipped.
+// - Leading and trailing spaces of a line are trimmed.
+// - A line starting with a hash (`#`) is a comment.
+// - A non-comment line is a single pattern.
+// - The slash (`/`) is used as the directory separator.
+// - A pattern is relative to the directory of the .clang-format-ignore file 
(or
+//   the root directory if the pattern starts with a slash).
+// - A pattern is negated if it starts with a bang (`!`).
+static bool isIgnored(StringRef FilePath) {
+  using namespace llvm::sys::fs;
+  if (!is_regular_file(FilePath))
+return false;
+
+  using namespace llvm::sys::path;
+  SmallString<128> Path, AbsPath{FilePath};
+
+  make_absolute(AbsPath);
+  remove_dots(AbsPath, /*remove_dot_dot=*/true);
+
+  StringRef IgnoreDir{AbsPath};
+  do {
+IgnoreDir = parent_path(IgnoreDir);
+if (IgnoreDir.empty())
+  return false;
+
+Path = IgnoreDir;
+append(Path, ".clang-format-ignore");
+  } while (!is_regular_file(Path));
+
+  std::ifstream IgnoreFile{Path.c_str()};
+  if (!IgnoreFile.good())
+return false;
+
+  AbsPath = convert_to_slash(AbsPath);
+
+  bool HasMatch = false;
+  for (std::string Pattern; std::getline(IgnoreFile, Pattern);) {
+Pattern = StringRef(Pattern).trim();
+if (Pattern.empty() || Pattern[0] == '#')
+  continue;
+
+const bool IsNegated = Pattern[0] == '!';
+if (IsNegated)
+  Pattern.erase(0, 1);
+
+if (Pattern.empty())
+  continue;
+
+Pattern = StringRef(Pattern).ltrim();
+if (Pattern[0] != '/') {
+  Path = convert_to_slash(IgnoreDir);
+  append(Path, Style::posix, Pattern);
+  remove_dots(Path, /*remove_dot_dot=*/true, Style::posix);
+  Pattern = Path.str();
+}
+
+if (clang::format::matchFilePath(Pattern, AbsPath.str()) == !IsNegated) {
+  HasMatch = true;
+  break;
+}
+  }
+
+  IgnoreFile.close();

HazardyKnusperkeks wrote:

This is done be the destructor.

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


[clang] [clang-format] Add .clang-format.ignore for ignoring files (PR #76327)

2023-12-28 Thread Björn Schäpers via cfe-commits


@@ -570,6 +571,74 @@ static int dumpConfig(bool IsSTDIN) {
   return 0;
 }
 
+// Check whether `FilePath` is ignored according to the nearest
+// .clang-format-ignore file based on the rules below:
+// - A blank line is skipped.
+// - Leading and trailing spaces of a line are trimmed.
+// - A line starting with a hash (`#`) is a comment.
+// - A non-comment line is a single pattern.
+// - The slash (`/`) is used as the directory separator.
+// - A pattern is relative to the directory of the .clang-format-ignore file 
(or
+//   the root directory if the pattern starts with a slash).
+// - A pattern is negated if it starts with a bang (`!`).
+static bool isIgnored(StringRef FilePath) {
+  using namespace llvm::sys::fs;
+  if (!is_regular_file(FilePath))
+return false;
+
+  using namespace llvm::sys::path;
+  SmallString<128> Path, AbsPath{FilePath};
+
+  make_absolute(AbsPath);
+  remove_dots(AbsPath, /*remove_dot_dot=*/true);
+
+  StringRef IgnoreDir{AbsPath};
+  do {
+IgnoreDir = parent_path(IgnoreDir);
+if (IgnoreDir.empty())
+  return false;
+
+Path = IgnoreDir;
+append(Path, ".clang-format-ignore");
+  } while (!is_regular_file(Path));
+
+  std::ifstream IgnoreFile{Path.c_str()};
+  if (!IgnoreFile.good())
+return false;
+
+  AbsPath = convert_to_slash(AbsPath);
+
+  bool HasMatch = false;
+  for (std::string Pattern; std::getline(IgnoreFile, Pattern);) {
+Pattern = StringRef(Pattern).trim();

HazardyKnusperkeks wrote:

Only work on the `StringRef` and not converting it back to `std::string`?

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


[llvm] [clang-tools-extra] [flang] [clang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2023-12-28 Thread Yi Wu via cfe-commits


@@ -411,6 +412,24 @@ RT_API_ATTRS void ShallowCopy(const Descriptor &to, const 
Descriptor &from,
 bool toIsContiguous, bool fromIsContiguous);
 RT_API_ATTRS void ShallowCopy(const Descriptor &to, const Descriptor &from);
 
+RT_API_ATTRS const char *EnsureNullTerminated(
+const char *str, size_t length, Terminator &terminator);
+
+RT_API_ATTRS bool IsValidCharDescriptor(const Descriptor *value);
+
+RT_API_ATTRS bool IsValidIntDescriptor(const Descriptor *intVal);
+
+// Copy a null-terminated character array \p rawValue to descriptor \p value.
+// The copy starts at the given \p offset, if not present then start at 0.
+// If descriptor `errmsg` is provided, error messages will be stored to it.
+// Returns stats specified in standard.
+RT_API_ATTRS std::int32_t CopyCharsToDescriptor(const Descriptor &value,
+const char *rawValue, std::int64_t rawValueLength,

yi-wu-arm wrote:

done

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


[clang] [clang-format] Add .clang-format.ignore for ignoring files (PR #76327)

2023-12-28 Thread Björn Schäpers via cfe-commits


@@ -570,6 +571,74 @@ static int dumpConfig(bool IsSTDIN) {
   return 0;
 }
 
+// Check whether `FilePath` is ignored according to the nearest
+// .clang-format-ignore file based on the rules below:
+// - A blank line is skipped.
+// - Leading and trailing spaces of a line are trimmed.
+// - A line starting with a hash (`#`) is a comment.
+// - A non-comment line is a single pattern.
+// - The slash (`/`) is used as the directory separator.
+// - A pattern is relative to the directory of the .clang-format-ignore file 
(or
+//   the root directory if the pattern starts with a slash).
+// - A pattern is negated if it starts with a bang (`!`).
+static bool isIgnored(StringRef FilePath) {
+  using namespace llvm::sys::fs;
+  if (!is_regular_file(FilePath))
+return false;
+
+  using namespace llvm::sys::path;
+  SmallString<128> Path, AbsPath{FilePath};
+
+  make_absolute(AbsPath);
+  remove_dots(AbsPath, /*remove_dot_dot=*/true);
+
+  StringRef IgnoreDir{AbsPath};
+  do {
+IgnoreDir = parent_path(IgnoreDir);
+if (IgnoreDir.empty())
+  return false;
+
+Path = IgnoreDir;
+append(Path, ".clang-format-ignore");
+  } while (!is_regular_file(Path));
+
+  std::ifstream IgnoreFile{Path.c_str()};
+  if (!IgnoreFile.good())
+return false;
+
+  AbsPath = convert_to_slash(AbsPath);
+
+  bool HasMatch = false;
+  for (std::string Pattern; std::getline(IgnoreFile, Pattern);) {
+Pattern = StringRef(Pattern).trim();
+if (Pattern.empty() || Pattern[0] == '#')
+  continue;
+
+const bool IsNegated = Pattern[0] == '!';
+if (IsNegated)
+  Pattern.erase(0, 1);
+
+if (Pattern.empty())
+  continue;
+
+Pattern = StringRef(Pattern).ltrim();
+if (Pattern[0] != '/') {
+  Path = convert_to_slash(IgnoreDir);
+  append(Path, Style::posix, Pattern);
+  remove_dots(Path, /*remove_dot_dot=*/true, Style::posix);
+  Pattern = Path.str();
+}
+
+if (clang::format::matchFilePath(Pattern, AbsPath.str()) == !IsNegated) {
+  HasMatch = true;

HazardyKnusperkeks wrote:

You can directly `return true` and thus omit having `HasMatch` altogether.

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


[llvm] [flang] [clang] [clang-tools-extra] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2023-12-28 Thread Yi Wu via cfe-commits


@@ -173,5 +173,70 @@ RT_API_ATTRS void ShallowCopy(const Descriptor &to, const 
Descriptor &from) {
   ShallowCopy(to, from, to.IsContiguous(), from.IsContiguous());
 }
 
+RT_API_ATTRS const char *EnsureNullTerminated(
+const char *str, size_t length, Terminator &terminator) {
+  if (length <= std::strlen(str)) {

yi-wu-arm wrote:

done, thank you for taking the time to review my code, especially during the 
holiday season! 

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


[llvm] [clang-tools-extra] [flang] [clang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2023-12-28 Thread Yi Wu via cfe-commits


@@ -173,5 +173,70 @@ RT_API_ATTRS void ShallowCopy(const Descriptor &to, const 
Descriptor &from) {
   ShallowCopy(to, from, to.IsContiguous(), from.IsContiguous());
 }
 
+RT_API_ATTRS const char *EnsureNullTerminated(
+const char *str, size_t length, Terminator &terminator) {

yi-wu-arm wrote:

done

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


[clang] [clang-format] Add .clang-format.ignore for ignoring files (PR #76327)

2023-12-28 Thread Björn Schäpers via cfe-commits

HazardyKnusperkeks wrote:

In the description (and the commit messages?) you wrote `clang-format.ignore` 
instead of `clang-format-ignore`.

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


[llvm] [clang-tools-extra] [clang] [flang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2023-12-28 Thread Yi Wu via cfe-commits


@@ -0,0 +1,203 @@
+//===-- runtime/execute.cpp 
---===//
+//
+// 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 "flang/Runtime/execute.h"
+#include "environment.h"
+#include "stat.h"
+#include "terminator.h"
+#include "tools.h"
+#include "flang/Runtime/descriptor.h"
+#include 
+#include 
+#include 
+#ifdef _WIN32
+#define LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+#include 
+#else
+#include 
+#include 
+#endif
+
+namespace Fortran::runtime {
+
+// cmdstat specified in 16.9.73
+// −1 if the processor does not support command line execution,
+// a processor-dependent positive value if an error condition occurs
+// −2 if no error condition occurs but WAIT is present with the value false
+// and the processor does not support asynchronous execution. Otherwise it is
+// assigned the value 0
+enum CMD_STAT {
+  ASYNC_NO_SUPPORT_ERR = -2,
+  NO_SUPPORT_ERR = -1,
+  CMD_EXECUTED = 0,
+  FORK_ERR = 1,
+  EXECL_ERR = 2,
+  INVALID_CL_ERR = 3,
+  SIGNAL_ERR = 4
+};
+
+// Override CopyCharsToDescriptor in tools.h, pass string directly
+void CopyCharsToDescriptor(const Descriptor &value, const char *rawValue) {
+  CopyCharsToDescriptor(value, rawValue, std::strlen(rawValue));
+}
+
+void CheckAndCopyCharsToDescriptor(
+const Descriptor *value, const char *rawValue) {
+  if (value) {
+CopyCharsToDescriptor(*value, rawValue);
+  }
+}
+
+void CheckAndStoreIntToDescriptor(
+const Descriptor *intVal, std::int64_t value, Terminator &terminator) {
+  if (intVal) {
+StoreIntToDescriptor(intVal, value, terminator);
+  }
+}
+
+// If a condition occurs that would assign a nonzero value to CMDSTAT but
+// the CMDSTAT variable is not present, error termination is initiated.
+int TerminationCheck(int status, const Descriptor *cmdstat,
+const Descriptor *cmdmsg, Terminator &terminator) {
+  if (status == -1) {
+if (!cmdstat) {
+  terminator.Crash("Execution error with system status code: %d", status);
+} else {
+  CheckAndStoreIntToDescriptor(cmdstat, EXECL_ERR, terminator);
+  CopyCharsToDescriptor(*cmdmsg, "Execution error");
+}
+  }
+#ifdef _WIN32
+  // On WIN32 API std::system returns exit status directly
+  int exitStatusVal{status};
+  if (exitStatusVal == 1) {
+#else
+  int exitStatusVal{WEXITSTATUS(status)};
+  if (exitStatusVal == 127 || exitStatusVal == 126) {
+#endif
+if (!cmdstat) {
+  terminator.Crash(
+  "Invalid command quit with exit status code: %d", exitStatusVal);
+} else {
+  CheckAndStoreIntToDescriptor(cmdstat, INVALID_CL_ERR, terminator);
+  CopyCharsToDescriptor(*cmdmsg, "Invalid command line");
+}
+  }
+#if defined(WIFSIGNALED) && defined(WTERMSIG)
+  if (WIFSIGNALED(status)) {
+if (!cmdstat) {
+  terminator.Crash("killed by signal: %d", WTERMSIG(status));
+} else {
+  CheckAndStoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
+  CopyCharsToDescriptor(*cmdmsg, "killed by signal");
+}
+  }
+#endif
+#if defined(WIFSTOPPED) && defined(WSTOPSIG)
+  if (WIFSTOPPED(status)) {
+if (!cmdstat) {
+  terminator.Crash("stopped by signal: %d", WSTOPSIG(status));
+} else {
+  CheckAndStoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
+  CopyCharsToDescriptor(*cmdmsg, "stopped by signal");
+}
+  }
+#endif
+  return exitStatusVal;
+}
+
+void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
+const Descriptor *exitstat, const Descriptor *cmdstat,
+const Descriptor *cmdmsg, const char *sourceFile, int line) {
+  Terminator terminator{sourceFile, line};
+  const char *newCmd{EnsureNullTerminated(
+  command.OffsetElement(), command.ElementBytes(), terminator)};
+
+  if (exitstat) {
+RUNTIME_CHECK(terminator, IsValidIntDescriptor(exitstat));
+  }
+
+  if (cmdstat) {
+RUNTIME_CHECK(terminator, IsValidIntDescriptor(cmdstat));
+// Assigned 0 as specifed in standard, if error then overwrite
+StoreIntToDescriptor(cmdstat, CMD_EXECUTED, terminator);
+  }
+
+  if (cmdmsg) {
+RUNTIME_CHECK(terminator, IsValidCharDescriptor(cmdmsg));
+  }
+
+  if (wait) {
+// either wait is not specified or wait is true: synchronous mode
+int status{std::system(newCmd)};
+int exitStatusVal{TerminationCheck(status, cmdstat, cmdmsg, terminator)};
+// If sync, assigned processor-dependent exit status. Otherwise unchanged
+CheckAndStoreIntToDescriptor(exitstat, exitStatusVal, terminator);
+  } else {
+// Asynchronous mode
+#ifdef _WIN32
+STARTUPINFO si;
+PROCESS_INFORMATION pi;
+ZeroMemory(&si, sizeof(si));
+si.cb = sizeof(si);
+ZeroMemory(&pi, sizeof(pi));
+
+// append "cmd.exe /c " to the beginning of command
+const char *pre

[llvm] [clang-tools-extra] [clang] [flang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2023-12-28 Thread Yi Wu via cfe-commits


@@ -0,0 +1,203 @@
+//===-- runtime/execute.cpp 
---===//
+//
+// 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 "flang/Runtime/execute.h"
+#include "environment.h"
+#include "stat.h"
+#include "terminator.h"
+#include "tools.h"
+#include "flang/Runtime/descriptor.h"
+#include 
+#include 
+#include 
+#ifdef _WIN32
+#define LEAN_AND_MEAN
+#define NOMINMAX
+#include 
+#include 
+#else
+#include 
+#include 
+#endif
+
+namespace Fortran::runtime {
+
+// cmdstat specified in 16.9.73
+// −1 if the processor does not support command line execution,
+// a processor-dependent positive value if an error condition occurs
+// −2 if no error condition occurs but WAIT is present with the value false
+// and the processor does not support asynchronous execution. Otherwise it is
+// assigned the value 0
+enum CMD_STAT {
+  ASYNC_NO_SUPPORT_ERR = -2,
+  NO_SUPPORT_ERR = -1,
+  CMD_EXECUTED = 0,
+  FORK_ERR = 1,
+  EXECL_ERR = 2,
+  INVALID_CL_ERR = 3,
+  SIGNAL_ERR = 4
+};
+
+// Override CopyCharsToDescriptor in tools.h, pass string directly
+void CopyCharsToDescriptor(const Descriptor &value, const char *rawValue) {
+  CopyCharsToDescriptor(value, rawValue, std::strlen(rawValue));
+}
+
+void CheckAndCopyCharsToDescriptor(
+const Descriptor *value, const char *rawValue) {
+  if (value) {
+CopyCharsToDescriptor(*value, rawValue);
+  }
+}
+
+void CheckAndStoreIntToDescriptor(
+const Descriptor *intVal, std::int64_t value, Terminator &terminator) {
+  if (intVal) {
+StoreIntToDescriptor(intVal, value, terminator);
+  }
+}
+
+// If a condition occurs that would assign a nonzero value to CMDSTAT but
+// the CMDSTAT variable is not present, error termination is initiated.
+int TerminationCheck(int status, const Descriptor *cmdstat,
+const Descriptor *cmdmsg, Terminator &terminator) {
+  if (status == -1) {
+if (!cmdstat) {
+  terminator.Crash("Execution error with system status code: %d", status);
+} else {
+  CheckAndStoreIntToDescriptor(cmdstat, EXECL_ERR, terminator);
+  CopyCharsToDescriptor(*cmdmsg, "Execution error");
+}
+  }
+#ifdef _WIN32
+  // On WIN32 API std::system returns exit status directly
+  int exitStatusVal{status};
+  if (exitStatusVal == 1) {
+#else
+  int exitStatusVal{WEXITSTATUS(status)};
+  if (exitStatusVal == 127 || exitStatusVal == 126) {
+#endif
+if (!cmdstat) {
+  terminator.Crash(
+  "Invalid command quit with exit status code: %d", exitStatusVal);
+} else {
+  CheckAndStoreIntToDescriptor(cmdstat, INVALID_CL_ERR, terminator);
+  CopyCharsToDescriptor(*cmdmsg, "Invalid command line");
+}
+  }
+#if defined(WIFSIGNALED) && defined(WTERMSIG)
+  if (WIFSIGNALED(status)) {
+if (!cmdstat) {
+  terminator.Crash("killed by signal: %d", WTERMSIG(status));
+} else {
+  CheckAndStoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
+  CopyCharsToDescriptor(*cmdmsg, "killed by signal");
+}
+  }
+#endif
+#if defined(WIFSTOPPED) && defined(WSTOPSIG)
+  if (WIFSTOPPED(status)) {
+if (!cmdstat) {
+  terminator.Crash("stopped by signal: %d", WSTOPSIG(status));
+} else {
+  CheckAndStoreIntToDescriptor(cmdstat, SIGNAL_ERR, terminator);
+  CopyCharsToDescriptor(*cmdmsg, "stopped by signal");
+}
+  }
+#endif
+  return exitStatusVal;
+}
+
+void RTNAME(ExecuteCommandLine)(const Descriptor &command, bool wait,
+const Descriptor *exitstat, const Descriptor *cmdstat,
+const Descriptor *cmdmsg, const char *sourceFile, int line) {
+  Terminator terminator{sourceFile, line};
+  const char *newCmd{EnsureNullTerminated(
+  command.OffsetElement(), command.ElementBytes(), terminator)};
+
+  if (exitstat) {
+RUNTIME_CHECK(terminator, IsValidIntDescriptor(exitstat));
+  }
+
+  if (cmdstat) {
+RUNTIME_CHECK(terminator, IsValidIntDescriptor(cmdstat));
+// Assigned 0 as specifed in standard, if error then overwrite
+StoreIntToDescriptor(cmdstat, CMD_EXECUTED, terminator);
+  }
+
+  if (cmdmsg) {
+RUNTIME_CHECK(terminator, IsValidCharDescriptor(cmdmsg));
+  }
+
+  if (wait) {
+// either wait is not specified or wait is true: synchronous mode
+int status{std::system(newCmd)};
+int exitStatusVal{TerminationCheck(status, cmdstat, cmdmsg, terminator)};
+// If sync, assigned processor-dependent exit status. Otherwise unchanged
+CheckAndStoreIntToDescriptor(exitstat, exitStatusVal, terminator);
+  } else {
+// Asynchronous mode
+#ifdef _WIN32
+STARTUPINFO si;
+PROCESS_INFORMATION pi;
+ZeroMemory(&si, sizeof(si));
+si.cb = sizeof(si);
+ZeroMemory(&pi, sizeof(pi));
+
+// append "cmd.exe /c " to the beginning of command
+const char *pre

[llvm] [flang] [clang] [compiler-rt] [lldb] [clang-tools-extra] [libc] [libcxx] [libc++][variant] P2637R3: Member `visit` (PR #76447)

2023-12-28 Thread Hristo Hristov via cfe-commits

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


[lldb] [clang] [libcxx] [compiler-rt] [libc] [clang-tools-extra] [llvm] [flang] [libc++][variant] P2637R3: Member `visit` (for `variant`) (PR #76447)

2023-12-28 Thread Hristo Hristov via cfe-commits

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


[lldb] [clang] [libcxx] [compiler-rt] [libc] [clang-tools-extra] [llvm] [flang] [libc++][variant] P2637R3: Member `visit` (`std::variant`) (PR #76447)

2023-12-28 Thread Hristo Hristov via cfe-commits

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Gábor Spaits via cfe-commits

https://github.com/spaits created 
https://github.com/llvm/llvm-project/pull/76501

Add a short documentation for `StdVariantChecker`.

From f7f26c38d1d363bf1dd097dc73e004970dfb32df Mon Sep 17 00:00:00 2001
From: Gabor Spaits 
Date: Thu, 28 Dec 2023 14:17:55 +0100
Subject: [PATCH] [analyzer] Add documentation for std::variant checker

---
 clang/docs/analyzer/checkers.rst | 12 
 1 file changed, 12 insertions(+)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 81d40395067c9a..1e5ba013f85d67 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2097,6 +2097,18 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if the active value accessed in an ``std::variant`` instance.
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn
+ }
+
+.. _alpha-core-StdVariant:
+
 alpha.core.TestAfterDivZero (C)
 """
 Check for division by variable that is later compared against 0.

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Gábor Spaits (spaits)


Changes

Add a short documentation for `StdVariantChecker`.

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


1 Files Affected:

- (modified) clang/docs/analyzer/checkers.rst (+12) 


``diff
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 81d40395067c9a..1e5ba013f85d67 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2097,6 +2097,18 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if the active value accessed in an ``std::variant`` instance.
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn
+ }
+
+.. _alpha-core-StdVariant:
+
 alpha.core.TestAfterDivZero (C)
 """
 Check for division by variable that is later compared against 0.

``




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


[clang] [clang-format] Fix bad indentation with attribute and templated type (PR #76336)

2023-12-28 Thread Björn Schäpers via cfe-commits

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


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


[clang] [clang][modules] Print library module manifest path. (PR #76451)

2023-12-28 Thread Thorsten Schütt via cfe-commits


@@ -2164,6 +2164,12 @@ bool Driver::HandleImmediateArgs(const Compilation &C) {
 return false;
   }
 
+  if (C.getArgs().hasArg(options::OPT_print_library_module_manifest_path)) {
+llvm::outs() << "module: ="

tschuett wrote:

```shell
> clang --print-resource-dir

prints just a path without any prefix.

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


[clang-tools-extra] [clang] [llvm] [flang] [flang] Add EXECUTE_COMMAND_LINE runtime and lowering intrinsics implementation (PR #74077)

2023-12-28 Thread Yi Wu via cfe-commits

https://github.com/yi-wu-arm edited 
https://github.com/llvm/llvm-project/pull/74077
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Gábor Spaits via cfe-commits

https://github.com/spaits updated 
https://github.com/llvm/llvm-project/pull/76501

From e885006a873e4bd8eb4618c270bac72c11446f06 Mon Sep 17 00:00:00 2001
From: Gabor Spaits 
Date: Thu, 28 Dec 2023 14:17:55 +0100
Subject: [PATCH] [analyzer] Add documentation for std::variant checker

---
 clang/docs/analyzer/checkers.rst | 12 
 1 file changed, 12 insertions(+)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 81d40395067c9a..6e8052a0afacf8 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2097,6 +2097,18 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if the active value accessed in an ``std::variant`` instance.
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn
+ }
+
+.. _alpha-core-StdVariant:
+
 alpha.core.TestAfterDivZero (C)
 """
 Check for division by variable that is later compared against 0.

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits

https://github.com/DonatNagyE requested changes to this pull request.


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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits


@@ -2097,6 +2097,18 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if the active value accessed in an ``std::variant`` instance.

DonatNagyE wrote:

This sentence has no subject (you need to add e.g. "is"). Also consider writing 
something slightly longer and more specific, using "warn if" instead of "check 
if" and clarifying what does "accessed" mean.

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


[clang] [compiler-rt] [clang-tools-extra] [PGO] Exposing PGO's Counter Reset and File Dumping APIs (PR #76471)

2023-12-28 Thread Qiongsi Wu via cfe-commits

https://github.com/qiongsiwu updated 
https://github.com/llvm/llvm-project/pull/76471

>From 6c9381ec324595947237bd25642b03ab40b6a4df Mon Sep 17 00:00:00 2001
From: Qiongsi Wu 
Date: Wed, 27 Dec 2023 13:05:01 -0500
Subject: [PATCH 1/7] Initial commit

---
 .../ExpandModularHeadersPPCallbacks.cpp   |  2 +-
 clang/include/clang/Frontend/Utils.h  |  4 +-
 clang/lib/Frontend/CompilerInstance.cpp   |  2 +-
 clang/lib/Frontend/InitPreprocessor.cpp   | 12 ++--
 compiler-rt/include/CMakeLists.txt|  1 +
 .../include/profile/instr_prof_interface.h| 66 +++
 compiler-rt/lib/profile/InstrProfiling.h  | 32 +
 7 files changed, 83 insertions(+), 36 deletions(-)
 create mode 100644 compiler-rt/include/profile/instr_prof_interface.h

diff --git a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp 
b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
index e414ac8c770508..5ecd4fb19131e4 100644
--- a/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
+++ b/clang-tools-extra/clang-tidy/ExpandModularHeadersPPCallbacks.cpp
@@ -100,7 +100,7 @@ 
ExpandModularHeadersPPCallbacks::ExpandModularHeadersPPCallbacks(
   /*OwnsHeaderSearch=*/false);
   PP->Initialize(Compiler.getTarget(), Compiler.getAuxTarget());
   InitializePreprocessor(*PP, *PO, Compiler.getPCHContainerReader(),
- Compiler.getFrontendOpts());
+ Compiler.getFrontendOpts(), 
Compiler.getCodeGenOpts());
   ApplyHeaderSearchOptions(*HeaderInfo, *HSO, LangOpts,
Compiler.getTarget().getTriple());
 }
diff --git a/clang/include/clang/Frontend/Utils.h 
b/clang/include/clang/Frontend/Utils.h
index 143cf4359f00b5..604e42067a3f1e 100644
--- a/clang/include/clang/Frontend/Utils.h
+++ b/clang/include/clang/Frontend/Utils.h
@@ -43,12 +43,14 @@ class PCHContainerReader;
 class Preprocessor;
 class PreprocessorOptions;
 class PreprocessorOutputOptions;
+class CodeGenOptions;
 
 /// InitializePreprocessor - Initialize the preprocessor getting it and the
 /// environment ready to process a single file.
 void InitializePreprocessor(Preprocessor &PP, const PreprocessorOptions 
&PPOpts,
 const PCHContainerReader &PCHContainerRdr,
-const FrontendOptions &FEOpts);
+const FrontendOptions &FEOpts,
+const CodeGenOptions &CodeGenOpts);
 
 /// DoPrintPreprocessedInput - Implement -E mode.
 void DoPrintPreprocessedInput(Preprocessor &PP, raw_ostream *OS,
diff --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index 56bbef9697b650..ea44a26b6db7da 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -470,7 +470,7 @@ void 
CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
 
   // Predefine macros and configure the preprocessor.
   InitializePreprocessor(*PP, PPOpts, getPCHContainerReader(),
- getFrontendOpts());
+ getFrontendOpts(), getCodeGenOpts());
 
   // Initialize the header search object.  In CUDA compilations, we use the aux
   // triple (the host triple) to initialize our header search, since we need to
diff --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index d83128adb511ef..009a67eea1eb52 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -1366,10 +1366,11 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
 
 /// InitializePreprocessor - Initialize the preprocessor getting it and the
 /// environment ready to process a single file.
-void clang::InitializePreprocessor(
-Preprocessor &PP, const PreprocessorOptions &InitOpts,
-const PCHContainerReader &PCHContainerRdr,
-const FrontendOptions &FEOpts) {
+void clang::InitializePreprocessor(Preprocessor &PP,
+   const PreprocessorOptions &InitOpts,
+   const PCHContainerReader &PCHContainerRdr,
+   const FrontendOptions &FEOpts,
+   const CodeGenOptions &CodeGenOpts) {
   const LangOptions &LangOpts = PP.getLangOpts();
   std::string PredefineBuffer;
   PredefineBuffer.reserve(4080);
@@ -1416,6 +1417,9 @@ void clang::InitializePreprocessor(
   InitializeStandardPredefinedMacros(PP.getTargetInfo(), PP.getLangOpts(),
  FEOpts, Builder);
 
+  if (CodeGenOpts.hasProfileIRInstr())
+Builder.defineMacro("__LLVM_INSTR_PROFILE_GENERATE");
+
   // Add on the predefines from the driver.  Wrap in a #line directive to 
report
   // that they come from the command line.
   Builder.append("# 1 \"\" 1");
diff --git a/compiler-rt/include/CMakeLists.txt 
b/compiler-rt/include/CMakeLists.txt
index

[clang] [compiler-rt] [clang-tools-extra] [PGO] Exposing PGO's Counter Reset and File Dumping APIs (PR #76471)

2023-12-28 Thread Qiongsi Wu via cfe-commits

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


[clang] d488adb - [analyzer][docs] Update the release notes for llvm-18 (#76446)

2023-12-28 Thread via cfe-commits

Author: Balazs Benics
Date: 2023-12-28T15:48:59+01:00
New Revision: d488adb7c2928551d801efd8d4c1bcb2f07e2651

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

LOG: [analyzer][docs] Update the release notes for llvm-18 (#76446)

This PR prepares the release notes of the Clang Static Analyzer for the
llvm-18 release branch, due in about a week.
See the regular [release 
schedule](https://llvm.org/docs/HowToReleaseLLVM.html#annual-release-schedule).

This patch was written after examining the relevant Static Analyzer
commits since the last release.
Have a look at the commits, and provide feedback if I missed anything
interesting.
Note that the release notes is not meant to be an exhaustive list of the
changes, but rather a curated list of the relevant changes that might
interest our stakeholders, such as tool vendors based on top of CSA or
users with custom checkers.

See the relevant commits by using this command:
```
git log --oneline llvmorg-18-init..llvm/main   
clang/{lib/StaticAnalyzer,include/clang/StaticAnalyzer} | grep -v NFC | grep -v 
-i revert
```

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/docs/analyzer/checkers.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index ee211c16a48ac8..d3f352c6aabe79 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1052,18 +1052,113 @@ libclang
 Static Analyzer
 ---
 
+New features
+
+
+- Implemented the ``[[clang::suppress]]`` attribute for suppressing diagnostics
+  of static analysis tools, such as the Clang Static Analyzer.
+  `Documentation 
`__.
+
+- Added support for the ``cleanup`` attribute.
+  `Documentation 
`__.
+
+- Support "Deducing this" (P0847R7). (Worked out of the box)
+  (`af4751738db8 
`__)
+
 - Added a new checker ``core.BitwiseShift`` which reports situations where
   bitwise shift operators produce undefined behavior (because some operand is
   negative or too large).
+  `Documentation 
`__.
 
-- Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
-  to ``unix.Errno``.
+- Added a new experimental checker ``alpha.core.StdVariant`` to detect variant
+  accesses via wrong alternatives.
+  (`#66481 `_)
 
-- Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
-  to ``unix.StdCLibraryFunctions``.
+- Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect
+  destructions of arrays of polymorphic objects that are destructed as their
+  base class (`CERT EXP51-CPP 
`_).
+  `Documentation 
`__.
+  (`0e246bb67573 
`_)
+
+- Added a new checker configuration option ``InvalidatingGetEnv=[true,false]`` 
to
+  ``security.cert.env.InvalidPtr``. It's not set by default.
+  If set, ``getenv`` calls won't invalidate previously returned pointers.
+  `Documentation 
`__.
+  (`#67663 `_)
+
+Crash and bug fixes
+^^^
+
+- Fixed a crash caused by ``builtin_bit_cast``.
+  (`#69922 `_)
+
+- Fixed a ``core.StackAddressEscape`` crash on temporary object fields.
+  (`#66221 `_)
+
+- A few crashes have been found and fixed using randomized testing related
+  to the use of ``_BitInt()`` in tidy checks and in clang analysis.
+  (`#67212 `_,
+  `#66782 `_,
+  `#65889 `_,
+  `#65888 `_,
+  `#65887 `_)
+
+- Fixed note links of the HTML output.
+  (`#64054 `_)
+
+- Allow widening rage-based for loops.
+  (`#70190 `_)
+
+- Fixed uninitialized base class with initializer list when ctor is not
+  declared in the base class.
+  (`#70464 `_,
+  

[libc] [mlir] [llvm] [clang] [compiler-rt] [openmp] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread Balazs Benics via cfe-commits

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


[clang] [compiler-rt] [clang-tools-extra] [PGO] Exposing PGO's Counter Reset and File Dumping APIs (PR #76471)

2023-12-28 Thread Qiongsi Wu via cfe-commits


@@ -0,0 +1,26 @@
+// RUN: %clang_profgen %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=PROFGEN
+// RUN: %clang_profgen -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: %clang_profuse=%t.profdata %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=PROFUSE
+#include "profile/instr_profiling.h"
+
+__attribute__((noinline)) int bar() { return 4; }
+
+int foo() {
+  __llvm_profile_reset_counters();

qiongsiwu wrote:

Yes absolutely! See 
https://github.com/llvm/llvm-project/pull/76471/files#diff-73a2e60ab2cfe7ec232978d767316cd70af176df9a4d98b12d6d5ed92a63324fR1.
 

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


[clang] [clang-tools-extra] [compiler-rt] [PGO] Exposing PGO's Counter Reset and File Dumping APIs (PR #76471)

2023-12-28 Thread Qiongsi Wu via cfe-commits


@@ -1364,12 +1364,22 @@ static void InitializePredefinedMacros(const TargetInfo 
&TI,
   TI.getTargetDefines(LangOpts, Builder);
 }
 
+static void InitializePGOProfileMacros(const CodeGenOptions &CodeGenOpts,

qiongsiwu wrote:

This 
[comment](https://discourse.llvm.org/t/pgo-are-the-llvm-profile-functions-stable-c-apis-across-llvm-releases/75832/7?u=qwu_ibm)
 seems to indicate that such macros are useful, in addition to the reason that 
the compiler adding these macros can make the user program cleaner (user can 
now avoid wrapping these PGO calls or guarding them with macros). This PR does 
not change the current behaviour of `compiler-rt/lib/profile/InstrProfiling.h` 
so the user still has the freedom to use their own macros (or use the weak 
symbol mechanism).

Does this sound reasonable so we keep the macros? If not, I can split this into 
two PRs.  

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


[clang] [clang-tools-extra] [compiler-rt] [PGO] Exposing PGO's Counter Reset and File Dumping APIs (PR #76471)

2023-12-28 Thread Qiongsi Wu via cfe-commits


@@ -0,0 +1,26 @@
+// RUN: %clang_profgen %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=PROFGEN
+// RUN: %clang_profgen -o %t %s
+// RUN: env LLVM_PROFILE_FILE=%t.profraw %run %t
+// RUN: llvm-profdata merge -o %t.profdata %t.profraw
+// RUN: %clang_profuse=%t.profdata %s -S -emit-llvm -o - | FileCheck %s 
--check-prefix=PROFUSE
+#include "profile/instr_profiling.h"
+
+__attribute__((noinline)) int bar() { return 4; }
+
+int foo() {
+  __llvm_profile_reset_counters();

qiongsiwu wrote:

> (Maybe there exists one already but I'm not sure).

I checked but I did not find any existing one.

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


[clang] [clang-tools-extra] [compiler-rt] [PGO] Exposing PGO's Counter Reset and File Dumping APIs (PR #76471)

2023-12-28 Thread Qiongsi Wu via cfe-commits

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


[compiler-rt] [libc] [openmp] [clang] [mlir] [llvm] [analyzer][docs] Update the release notes for llvm-18 (PR #76446)

2023-12-28 Thread via cfe-commits

DonatNagyE wrote:

Late review: nice reorganization :)

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


[clang] [analyzer][solver] On SymSym RelOps, check EQClass members for contradictions (PR #71284)

2023-12-28 Thread Balazs Benics via cfe-commits

steakhal wrote:

Any objections for landing this PR? Or should we postpone this for llvm-19?

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


[libcxx] [flang] [clang] [clang-tools-extra] [compiler-rt] [llvm] [mlir] [polly] [lld] [CostModel][X86] Fix fpext conversion cost for 16 elements (PR #76278)

2023-12-28 Thread Simon Pilgrim via cfe-commits

RKSimon wrote:

I meant - llvm-mca currently says the throughput for skylake etc. is 3cy not 
5cy - so do you know why the intel scheduler models are underestimating the 
throughput?

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


[clang] d1856b2 - [analyzer][NFC] Prefer CallEvent over CallExpr in APIs

2023-12-28 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2023-12-28T15:55:33+01:00
New Revision: d1856b2f18c412f8ffbeee30e6e0316c197c143c

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

LOG: [analyzer][NFC] Prefer CallEvent over CallExpr in APIs

This change only uplifts existing APIs, without any semantic changes.
This is the continuation of 44820630dfa45bc47748a5abda7d4a9cb86da2c1.

Benefits of using CallEvents over CallExprs:
The callee decl is traced through function pointers if possible.
This will be important to fix #74269 in a follow-up patch.

Added: 


Modified: 
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp

Removed: 




diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 31f5b03dcdeba8..f5dbf9d82b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -121,7 +121,7 @@ class CStringChecker : public Checker< eval::Call,
const CallEvent *Call) const;
 
   using FnCheck = std::function;
+ const CallEvent &)>;
 
   CallDescriptionMap Callbacks = {
   {{CDF_MaybeBuiltin, {"memcpy"}, 3},
@@ -173,56 +173,53 @@ class CStringChecker : public Checker< eval::Call,
   StdCopyBackward{{"std", "copy_backward"}, 3};
 
   FnCheck identifyCall(const CallEvent &Call, CheckerContext &C) const;
-  void evalMemcpy(CheckerContext &C, const CallExpr *CE, CharKind CK) const;
-  void evalMempcpy(CheckerContext &C, const CallExpr *CE, CharKind CK) const;
-  void evalMemmove(CheckerContext &C, const CallExpr *CE, CharKind CK) const;
-  void evalBcopy(CheckerContext &C, const CallExpr *CE) const;
-  void evalCopyCommon(CheckerContext &C, const CallExpr *CE,
+  void evalMemcpy(CheckerContext &C, const CallEvent &Call, CharKind CK) const;
+  void evalMempcpy(CheckerContext &C, const CallEvent &Call, CharKind CK) 
const;
+  void evalMemmove(CheckerContext &C, const CallEvent &Call, CharKind CK) 
const;
+  void evalBcopy(CheckerContext &C, const CallEvent &Call) const;
+  void evalCopyCommon(CheckerContext &C, const CallEvent &Call,
   ProgramStateRef state, SizeArgExpr Size,
   DestinationArgExpr Dest, SourceArgExpr Source,
   bool Restricted, bool IsMempcpy, CharKind CK) const;
 
-  void evalMemcmp(CheckerContext &C, const CallExpr *CE, CharKind CK) const;
+  void evalMemcmp(CheckerContext &C, const CallEvent &Call, CharKind CK) const;
 
-  void evalstrLength(CheckerContext &C, const CallExpr *CE) const;
-  void evalstrnLength(CheckerContext &C, const CallExpr *CE) const;
-  void evalstrLengthCommon(CheckerContext &C,
-   const CallExpr *CE,
+  void evalstrLength(CheckerContext &C, const CallEvent &Call) const;
+  void evalstrnLength(CheckerContext &C, const CallEvent &Call) const;
+  void evalstrLengthCommon(CheckerContext &C, const CallEvent &Call,
bool IsStrnlen = false) const;
 
-  void evalStrcpy(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrncpy(CheckerContext &C, const CallExpr *CE) const;
-  void evalStpcpy(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrlcpy(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrcpyCommon(CheckerContext &C, const CallExpr *CE, bool ReturnEnd,
-bool IsBounded, ConcatFnKind appendK,
+  void evalStrcpy(CheckerContext &C, const CallEvent &Call) const;
+  void evalStrncpy(CheckerContext &C, const CallEvent &Call) const;
+  void evalStpcpy(CheckerContext &C, const CallEvent &Call) const;
+  void evalStrlcpy(CheckerContext &C, const CallEvent &Call) const;
+  void evalStrcpyCommon(CheckerContext &C, const CallEvent &Call,
+bool ReturnEnd, bool IsBounded, ConcatFnKind appendK,
 bool returnPtr = true) const;
 
-  void evalStrcat(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrncat(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrlcat(CheckerContext &C, const CallExpr *CE) const;
+  void evalStrcat(CheckerContext &C, const CallEvent &Call) const;
+  void evalStrncat(CheckerContext &C, const CallEvent &Call) const;
+  void evalStrlcat(CheckerContext &C, const CallEvent &Call) const;
 
-  void evalStrcmp(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrncmp(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrcasecmp(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrncasecmp(CheckerContext &C, const CallExpr *CE) const;
-  void evalStrcmpCommon(CheckerContext &C,
-const CallExpr *CE,
-bool IsBounded = false,
-bool IgnoreCase = f

[clang] a49cf6c - [analyzer] Fix "sprintf" parameter modeling in CStringChecker

2023-12-28 Thread Balazs Benics via cfe-commits

Author: Balazs Benics
Date: 2023-12-28T16:06:21+01:00
New Revision: a49cf6c14ad498244fee6026da59cfdcdad6b80c

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

LOG: [analyzer] Fix "sprintf" parameter modeling in CStringChecker

`CE->getCalleeDecl()` returns `VarDecl` if the callee is actually a
function pointer variable. Consequently, calling `getAsFunction()` will
return null.

To workaround the case, we should use the `CallEvent::parameters()`,
which will internally recover the function being called and do the right
thing.

Fixes #74269
Depends on "[analyzer][NFC] Prefer CallEvent over CallExpr in APIs"

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
clang/test/Analysis/string.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d3f352c6aabe79..e21ec78a1e8a77 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1115,6 +1115,9 @@ Crash and bug fixes
   `#59493 `_,
   `#54533 `_)
 
+- Fixed an ``alpha.unix.cstring`` crash on variadic functions.
+  (`#74269 `_)
+
 - Fix false positive in mutation check when using pointer to member function.
   (`#66204 `_)
 

diff  --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index f5dbf9d82b..b7b64c3da4f6c8 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -2487,8 +2487,7 @@ void CStringChecker::evalSprintfCommon(CheckerContext &C, 
const CallEvent &Call,
   const auto *CE = cast(Call.getOriginExpr());
   DestinationArgExpr Dest = {{Call.getArgExpr(0), 0}};
 
-  // FIXME: We should use `Call.parameters().size()` here.
-  const auto NumParams = CE->getCalleeDecl()->getAsFunction()->getNumParams();
+  const auto NumParams = Call.parameters().size();
   assert(CE->getNumArgs() >= NumParams);
 
   const auto AllArguments =

diff  --git a/clang/test/Analysis/string.cpp b/clang/test/Analysis/string.cpp
index f86416da6ee237..1be6c21466cc03 100644
--- a/clang/test/Analysis/string.cpp
+++ b/clang/test/Analysis/string.cpp
@@ -1,6 +1,4 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -verify %s
-
-// expected-no-diagnostics
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection 
-verify %s
 
 // Test functions that are called "memcpy" but aren't the memcpy
 // we're looking for. Unfortunately, this test cannot be put into
@@ -9,6 +7,11 @@
 typedef __typeof(sizeof(int)) size_t;
 void *memcpy(void *, const void *, size_t);
 
+int sprintf(char *str, const char *format, ...);
+int snprintf(char *str, size_t size, const char *format, ...);
+
+void clang_analyzer_warnIfReached();
+
 struct S {
   static S s1, s2;
 
@@ -26,3 +29,19 @@ void *memcpy(void *, const S &, size_t);
 void test_out_of_class_weird_memcpy() {
   memcpy(&S::s1, S::s2, 1); // no-crash
 }
+
+template
+void log(const char* fmt, const Args&... args) {
+  char buf[100] = {};
+  auto f = snprintf;
+  auto g = sprintf;
+  int n = 0;
+  n += f(buf, 99, fmt, args...); // no-crash: The CalleeDecl is a VarDecl, but 
it's okay.
+  n += g(buf, fmt, args...); // no-crash: Same.
+  (void)n;
+  clang_analyzer_warnIfReached(); // expected-warning {{REACHABLE}}
+}
+
+void test_gh_74269_no_crash() {
+  log("%d", 1);
+}



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


[clang] [analyzer] Fix "sprintf" parameter modeling in CStringChecker (PR #74345)

2023-12-28 Thread Balazs Benics via cfe-commits


@@ -1,13 +1,15 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix -verify %s
-
-// expected-no-diagnostics
+// RUN: %clang_analyze_cc1 -analyzer-checker=core,unix,debug.ExprInspection 
-verify %s
 
 // Test functions that are called "memcpy" but aren't the memcpy
 // we're looking for. Unfortunately, this test cannot be put into
 // a namespace. The out-of-class weird memcpy needs to be recognized
 // as a normal C function for the test to make sense.
 typedef __typeof(sizeof(int)) size_t;
 void *memcpy(void *, const void *, size_t);
+int sprintf(char *str, const char *format, ...);

steakhal wrote:

Added the newline.

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


[clang] [analyzer] Fix "sprintf" parameter modeling in CStringChecker (PR #74345)

2023-12-28 Thread Balazs Benics via cfe-commits

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


[clang] [analyzer] Fix "sprintf" parameter modeling in CStringChecker (PR #74345)

2023-12-28 Thread Balazs Benics via cfe-commits

steakhal wrote:

Manually merged as:
 - d1856b2f18c412f8ffbeee30e6e0316c197c143c
 - a49cf6c14ad498244fee6026da59cfdcdad6b80c

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits


@@ -2097,6 +2097,18 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if the active value accessed in an ``std::variant`` instance.
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;

whisperity wrote:

```suggestion
   std::variant v = 25;
```

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Gábor Spaits via cfe-commits

https://github.com/spaits updated 
https://github.com/llvm/llvm-project/pull/76501

From e885006a873e4bd8eb4618c270bac72c11446f06 Mon Sep 17 00:00:00 2001
From: Gabor Spaits 
Date: Thu, 28 Dec 2023 14:17:55 +0100
Subject: [PATCH 1/2] [analyzer] Add documentation for std::variant checker

---
 clang/docs/analyzer/checkers.rst | 12 
 1 file changed, 12 insertions(+)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 81d40395067c9a..6e8052a0afacf8 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2097,6 +2097,18 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if the active value accessed in an ``std::variant`` instance.
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn
+ }
+
+.. _alpha-core-StdVariant:
+
 alpha.core.TestAfterDivZero (C)
 """
 Check for division by variable that is later compared against 0.

From 67e647998a6a5b3e135c4fc760f545e73ad6b04c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Spaits?=
 <48805437+spa...@users.noreply.github.com>
Date: Thu, 28 Dec 2023 16:20:14 +0100
Subject: [PATCH 2/2] Update clang/docs/analyzer/checkers.rst

Co-authored-by: whisperity 
---
 clang/docs/analyzer/checkers.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 6e8052a0afacf8..8e6029406202bf 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2103,7 +2103,7 @@ Check if the active value accessed in an ``std::variant`` 
instance.
 .. code-block:: cpp
 
  void test() {
-   std::variant  v = 25;
+   std::variant v = 25;
char c = stg::get(v); // warn
  }
 

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


[clang] [analyzer][solver] On SymSym RelOps, check EQClass members for contradictions (PR #71284)

2023-12-28 Thread via cfe-commits

DonatNagyE wrote:

Hmm, I would prefer a cleaner, more "theoretical" improvement of the 
equivalence class handling instead of this "add yet another patch that covers 
many, but not all cases" approach.

I'm not opposed to landing this PR in llvm-18 (we have it, and it improves the 
user experience), but I wouldn't like to have it in llvm-19 and later.

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits

DonatNagyE wrote:

Note: the docs build check failed with
> /home/runner/work/llvm-project/llvm-project/clang-build/tools/clang/docs/analyzer/checkers.rst:2108:Definition
>  list ends without a blank line; unexpected unindent.

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Gábor Spaits via cfe-commits

https://github.com/spaits updated 
https://github.com/llvm/llvm-project/pull/76501

From c1884cc4d17c446491777baa43e3996aae22ad0d Mon Sep 17 00:00:00 2001
From: Gabor Spaits 
Date: Thu, 28 Dec 2023 14:17:55 +0100
Subject: [PATCH] [analyzer] Add documentation for std::variant checker

---
 clang/docs/analyzer/checkers.rst | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 81d40395067c9a..272e1965335ed3 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2097,6 +2097,21 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if a value of active type is retrieved from an ``std::variant`` instance 
with ``std::get``.
+In case of bad variant type access(the accessed type differs from the active 
type)
+a warning is emitted. Currently this checker does not take exception handling 
into account.
+
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn
+ }
+
+.. _alpha-core-StdVariant:
+
 alpha.core.TestAfterDivZero (C)
 """
 Check for division by variable that is later compared against 0.

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits

https://github.com/DonatNagyE commented:

There is a trivial typo, otherwise LGTM.

Thanks for the update!

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits


@@ -2097,6 +2097,21 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if a value of active type is retrieved from an ``std::variant`` instance 
with ``std::get``.
+In case of bad variant type access(the accessed type differs from the active 
type)

DonatNagyE wrote:

```suggestion
In case of bad variant type access (the accessed type differs from the active 
type)
```

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Gábor Spaits via cfe-commits

spaits wrote:

Added some more explanation. I will continue using "Check if" since the other 
descriptions that I saw stared like that (or "Check for").

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Gábor Spaits via cfe-commits

https://github.com/spaits updated 
https://github.com/llvm/llvm-project/pull/76501

From c1884cc4d17c446491777baa43e3996aae22ad0d Mon Sep 17 00:00:00 2001
From: Gabor Spaits 
Date: Thu, 28 Dec 2023 14:17:55 +0100
Subject: [PATCH 1/2] [analyzer] Add documentation for std::variant checker

---
 clang/docs/analyzer/checkers.rst | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 81d40395067c9a..272e1965335ed3 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2097,6 +2097,21 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if a value of active type is retrieved from an ``std::variant`` instance 
with ``std::get``.
+In case of bad variant type access(the accessed type differs from the active 
type)
+a warning is emitted. Currently this checker does not take exception handling 
into account.
+
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn
+ }
+
+.. _alpha-core-StdVariant:
+
 alpha.core.TestAfterDivZero (C)
 """
 Check for division by variable that is later compared against 0.

From 240c34c0f9e11b5059cc57b44fd776584d2e768a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=A1bor=20Spaits?=
 <48805437+spa...@users.noreply.github.com>
Date: Thu, 28 Dec 2023 16:41:07 +0100
Subject: [PATCH 2/2] Update clang/docs/analyzer/checkers.rst

Co-authored-by: DonatNagyE 
---
 clang/docs/analyzer/checkers.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 272e1965335ed3..7f5572c8c9c10c 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2100,7 +2100,7 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 alpha.core.StdVariant (C++)
 """
 Check if a value of active type is retrieved from an ``std::variant`` instance 
with ``std::get``.
-In case of bad variant type access(the accessed type differs from the active 
type)
+In case of bad variant type access (the accessed type differs from the active 
type)
 a warning is emitted. Currently this checker does not take exception handling 
into account.
 
 .. code-block:: cpp

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


[clang] [clang-tools-extra] [flang] [llvm] [flang] Pass to add frame pointer attribute (PR #74598)

2023-12-28 Thread Mats Petersson via cfe-commits

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


[clang] [riscv] Fix for __riscv_v_fixed_vlen in vector mask types (PR #76510)

2023-12-28 Thread via cfe-commits

https://github.com/ita-sc created 
https://github.com/llvm/llvm-project/pull/76510

It is already possible to have vector types with riscv_rvv_vector_bits 
attribute as structure members. But currently this is not the case for vector 
masks. Having vector masks in structures is useful for library implementations.

This patch removes restriction for using RISC-V vector mask types in structures.

>From 69bfbb84879b41d4e8e5fbbd51b9b95b0767c460 Mon Sep 17 00:00:00 2001
From: Ivan Tetyushkin 
Date: Thu, 28 Dec 2023 13:08:27 +0300
Subject: [PATCH] [riscv]  Fix for __riscv_v_fixed_vlen in vector mask types

---
 clang/include/clang/Basic/AttrDocs.td|  3 +-
 clang/lib/AST/ItaniumMangle.cpp  |  3 ++
 clang/lib/AST/Type.cpp   |  4 +++
 clang/lib/Sema/SemaType.cpp  |  3 ++
 clang/test/Sema/attr-riscv-rvv-vector-bits.c | 31 ++--
 5 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 98a7ecc7fd7df3..d50a57e7e0c7e8 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2415,7 +2415,8 @@ only be a power of 2 between 64 and 65536.
 For types where LMUL!=1, ``__riscv_v_fixed_vlen`` needs to be scaled by the 
LMUL
 of the type before passing to the attribute.
 
-``vbool*_t`` types are not supported at this time.
+For ``vbool*_t`` types, ``__riscv_v_fixed_vlen`` needs to be divided by the 
EEW/LMUL
+(e.g. for vbool64_t we need ``N==(__riscv_v_fixed_vlen/64)``).
 }];
 }
 
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index b1678479888eb7..b2e9ffd4231ead 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -4005,6 +4005,9 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(const 
VectorType *T) {
   llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
   TypeNameOS << "__rvv_";
   switch (cast(EltType)->getKind()) {
+  case BuiltinType::Bool:
+TypeNameOS << "int1";
+break;
   case BuiltinType::SChar:
 TypeNameOS << "int8";
 break;
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 160a725939ccd4..4a80fe83dfe8a2 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2479,6 +2479,10 @@ bool Type::isRVVVLSBuiltinType() const {
 IsFP, IsBF)
\
   case BuiltinType::Id:
\
 return NF == 1;
+
+#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls)  
\
+  case BuiltinType::Id:
\
+return true;
 #include "clang/Basic/RISCVVTypes.def"
 default:
   return false;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index a376f20fa4f4e0..740564a17aa6cb 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8543,8 +8543,11 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType 
&CurType,
   ASTContext::BuiltinVectorTypeInfo Info =
   S.Context.getBuiltinVectorTypeInfo(CurType->castAs());
   unsigned EltSize = S.Context.getTypeSize(Info.ElementType);
+  if (Info.ElementType->isBooleanType())
+EltSize = 1;
   unsigned MinElts = Info.EC.getKnownMinValue();
 
+
   // The attribute vector size must match -mrvv-vector-bits.
   unsigned ExpectedSize = VScale->first * MinElts * EltSize;
   if (VecSize != ExpectedSize) {
diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits.c 
b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
index fe507a102cee1e..6fc5954b01035b 100644
--- a/clang/test/Sema/attr-riscv-rvv-vector-bits.c
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
@@ -220,6 +220,15 @@ typedef uint64_t gnu_uint64m8_t 
__attribute__((vector_size(__riscv_v_fixed_vlen)
 typedef float gnu_float32m8_t 
__attribute__((vector_size(__riscv_v_fixed_vlen)));
 typedef double gnu_float64m8_t 
__attribute__((vector_size(__riscv_v_fixed_vlen)));
 
+
+typedef vbool1_t fixed_vbool1_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
+typedef vbool2_t fixed_vbool2_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
+typedef vbool4_t fixed_vbool4_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));
+typedef vbool8_t fixed_vbool8_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8)));
+typedef vbool16_t fixed_vbool16_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 16)));
+typedef vbool32_t fixed_vbool32_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 32)));
+typedef vbool64_t fixed_vbool64_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 64)));
+
 // Attribute must have a single argument
 typedef vint8m1_t no_argument __attribute__((riscv_rvv_vector_bits)); 
// expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}}
 typedef vint8m1_t two_argumen

[clang] [riscv] Fix for __riscv_v_fixed_vlen in vector mask types (PR #76510)

2023-12-28 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (ita-sc)


Changes

It is already possible to have vector types with riscv_rvv_vector_bits 
attribute as structure members. But currently this is not the case for vector 
masks. Having vector masks in structures is useful for library implementations.

This patch removes restriction for using RISC-V vector mask types in structures.

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


5 Files Affected:

- (modified) clang/include/clang/Basic/AttrDocs.td (+2-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (+3) 
- (modified) clang/lib/AST/Type.cpp (+4) 
- (modified) clang/lib/Sema/SemaType.cpp (+3) 
- (modified) clang/test/Sema/attr-riscv-rvv-vector-bits.c (+28-3) 


``diff
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 98a7ecc7fd7df3..d50a57e7e0c7e8 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2415,7 +2415,8 @@ only be a power of 2 between 64 and 65536.
 For types where LMUL!=1, ``__riscv_v_fixed_vlen`` needs to be scaled by the 
LMUL
 of the type before passing to the attribute.
 
-``vbool*_t`` types are not supported at this time.
+For ``vbool*_t`` types, ``__riscv_v_fixed_vlen`` needs to be divided by the 
EEW/LMUL
+(e.g. for vbool64_t we need ``N==(__riscv_v_fixed_vlen/64)``).
 }];
 }
 
diff --git a/clang/lib/AST/ItaniumMangle.cpp b/clang/lib/AST/ItaniumMangle.cpp
index b1678479888eb7..b2e9ffd4231ead 100644
--- a/clang/lib/AST/ItaniumMangle.cpp
+++ b/clang/lib/AST/ItaniumMangle.cpp
@@ -4005,6 +4005,9 @@ void CXXNameMangler::mangleRISCVFixedRVVVectorType(const 
VectorType *T) {
   llvm::raw_svector_ostream TypeNameOS(TypeNameStr);
   TypeNameOS << "__rvv_";
   switch (cast(EltType)->getKind()) {
+  case BuiltinType::Bool:
+TypeNameOS << "int1";
+break;
   case BuiltinType::SChar:
 TypeNameOS << "int8";
 break;
diff --git a/clang/lib/AST/Type.cpp b/clang/lib/AST/Type.cpp
index 160a725939ccd4..4a80fe83dfe8a2 100644
--- a/clang/lib/AST/Type.cpp
+++ b/clang/lib/AST/Type.cpp
@@ -2479,6 +2479,10 @@ bool Type::isRVVVLSBuiltinType() const {
 IsFP, IsBF)
\
   case BuiltinType::Id:
\
 return NF == 1;
+
+#define RVV_PREDICATE_TYPE(Name, Id, SingletonId, NumEls)  
\
+  case BuiltinType::Id:
\
+return true;
 #include "clang/Basic/RISCVVTypes.def"
 default:
   return false;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index a376f20fa4f4e0..740564a17aa6cb 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8543,8 +8543,11 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType 
&CurType,
   ASTContext::BuiltinVectorTypeInfo Info =
   S.Context.getBuiltinVectorTypeInfo(CurType->castAs());
   unsigned EltSize = S.Context.getTypeSize(Info.ElementType);
+  if (Info.ElementType->isBooleanType())
+EltSize = 1;
   unsigned MinElts = Info.EC.getKnownMinValue();
 
+
   // The attribute vector size must match -mrvv-vector-bits.
   unsigned ExpectedSize = VScale->first * MinElts * EltSize;
   if (VecSize != ExpectedSize) {
diff --git a/clang/test/Sema/attr-riscv-rvv-vector-bits.c 
b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
index fe507a102cee1e..6fc5954b01035b 100644
--- a/clang/test/Sema/attr-riscv-rvv-vector-bits.c
+++ b/clang/test/Sema/attr-riscv-rvv-vector-bits.c
@@ -220,6 +220,15 @@ typedef uint64_t gnu_uint64m8_t 
__attribute__((vector_size(__riscv_v_fixed_vlen)
 typedef float gnu_float32m8_t 
__attribute__((vector_size(__riscv_v_fixed_vlen)));
 typedef double gnu_float64m8_t 
__attribute__((vector_size(__riscv_v_fixed_vlen)));
 
+
+typedef vbool1_t fixed_vbool1_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen)));
+typedef vbool2_t fixed_vbool2_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 2)));
+typedef vbool4_t fixed_vbool4_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 4)));
+typedef vbool8_t fixed_vbool8_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 8)));
+typedef vbool16_t fixed_vbool16_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 16)));
+typedef vbool32_t fixed_vbool32_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 32)));
+typedef vbool64_t fixed_vbool64_t_t 
__attribute__((riscv_rvv_vector_bits(__riscv_v_fixed_vlen / 64)));
+
 // Attribute must have a single argument
 typedef vint8m1_t no_argument __attribute__((riscv_rvv_vector_bits)); 
// expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}}
 typedef vint8m1_t two_arguments __attribute__((riscv_rvv_vector_bits(2, 4))); 
// expected-error {{'riscv_rvv_vector_bits' attribute takes one argument}}
@@ -228,9 +237,6 @@ typedef vint8m1_t two_arguments 
__attribu

[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Balazs Benics via cfe-commits

https://github.com/steakhal commented:

Please also update the release notes with a link as documentation. Follow the 
existing patterns there.

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


[clang] [riscv] Fix for __riscv_v_fixed_vlen in vector mask types (PR #76510)

2023-12-28 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 ae0b2633c935950084860e5f6a1c2c3203726489 
69bfbb84879b41d4e8e5fbbd51b9b95b0767c460 -- clang/lib/AST/ItaniumMangle.cpp 
clang/lib/AST/Type.cpp clang/lib/Sema/SemaType.cpp 
clang/test/Sema/attr-riscv-rvv-vector-bits.c
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 740564a17a..39ac3701a5 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8547,7 +8547,6 @@ static void HandleRISCVRVVVectorBitsTypeAttr(QualType 
&CurType,
 EltSize = 1;
   unsigned MinElts = Info.EC.getKnownMinValue();
 
-
   // The attribute vector size must match -mrvv-vector-bits.
   unsigned ExpectedSize = VScale->first * MinElts * EltSize;
   if (VecSize != ExpectedSize) {

``




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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread via cfe-commits

DonatNagyE wrote:

> Added some more explanation. I will continue using "Check if" since the other 
> descriptions that I saw stared like that (or "Check for").

That's a good point for using "Check if".

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Balazs Benics via cfe-commits

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Balazs Benics via cfe-commits


@@ -2097,6 +2097,21 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if a value of active type is retrieved from an ``std::variant`` instance 
with ``std::get``.
+In case of bad variant type access (the accessed type differs from the active 
type)
+a warning is emitted. Currently this checker does not take exception handling 
into account.
+
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn
+ }
+
+.. _alpha-core-StdVariant:

steakhal wrote:

This xref label should be right before the `...` subsection introducer. It 
will behave as a link target in the TOC.
This is definitely not the right place here.
Note that the `_alpha-core-TestAfterDivZero:` label would currently refer to 
this section.

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Balazs Benics via cfe-commits

https://github.com/steakhal requested changes to this pull request.


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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Balazs Benics via cfe-commits


@@ -2097,6 +2097,18 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if the active value accessed in an ``std::variant`` instance.
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;

steakhal wrote:

I don't think this comment was resolved.

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Balazs Benics via cfe-commits


@@ -2097,6 +2097,21 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if a value of active type is retrieved from an ``std::variant`` instance 
with ``std::get``.
+In case of bad variant type access (the accessed type differs from the active 
type)
+a warning is emitted. Currently this checker does not take exception handling 
into account.
+
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn

steakhal wrote:

```suggestion
   char c = stg::get(v); // warn: "int" is the active alternative
```

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Balazs Benics via cfe-commits


@@ -2097,6 +2097,21 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if a value of active type is retrieved from an ``std::variant`` instance 
with ``std::get``.
+In case of bad variant type access (the accessed type differs from the active 
type)
+a warning is emitted. Currently this checker does not take exception handling 
into account.

steakhal wrote:

```suggestion
a warning is emitted. Currently, this checker does not take exception handling 
into account.
```
Grammarly suggest a missing comma here.

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


[clang] [analyzer][solver] On SymSym RelOps, check EQClass members for contradictions (PR #71284)

2023-12-28 Thread Balazs Benics via cfe-commits

steakhal wrote:

> I'm not opposed to landing this PR in llvm-18 (we have it, and it improves 
> the user experience), but I wouldn't like to have it in llvm-19 and later.

To clarify my intentions, I wanted to land this as it resolves user complaints 
(as fixing an open issue), at a likely reasonable runtime cost. I don't plan to 
work on the constraint manager for llvm-19 or later.
Given this, if we merge this, it will likely remain like that for a long time. 
If we don't merge this, we have the option for merging it for the next release 
cycle, but the questions and problems still remain, so why did we postpone this?

Personally, I'd say if there are no serious drawbacks for merging this, we 
should merge it.
We would still have plenty of time to revert if we wanted to.

Should we merge it?

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


[clang] [analyzer] Add documentation for std::variant checker (PR #76501)

2023-12-28 Thread Gábor Spaits via cfe-commits

https://github.com/spaits updated 
https://github.com/llvm/llvm-project/pull/76501

From 682bed6d800133a2d1f21bd49491d002ec8c6b54 Mon Sep 17 00:00:00 2001
From: Gabor Spaits 
Date: Thu, 28 Dec 2023 14:17:55 +0100
Subject: [PATCH] [analyzer] Add documentation for std::variant checker

---
 clang/docs/analyzer/checkers.rst | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 64a4752695f11f..06c08e14a8f136 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -2097,6 +2097,21 @@ This checker is a part of ``core.StackAddressEscape``, 
but is temporarily disabl
 
 .. _alpha-core-TestAfterDivZero:
 
+alpha.core.StdVariant (C++)
+"""
+Check if a value of active type is retrieved from an ``std::variant`` instance 
with ``std::get``.
+In case of bad variant type access(the accessed type differs from the active 
type)
+a warning is emitted. Currently this checker does not take exception handling 
into account.
+
+.. code-block:: cpp
+
+ void test() {
+   std::variant  v = 25;
+   char c = stg::get(v); // warn
+ }
+
+.. _alpha-core-StdVariant:
+
 alpha.core.TestAfterDivZero (C)
 """
 Check for division by variable that is later compared against 0.

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


  1   2   3   >