[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-01 Thread Saleem Abdulrasool via cfe-commits


@@ -322,6 +323,46 @@ static bool actionRequiresCodeGen(BackendAction Action) {
  Action != Backend_EmitLL;
 }
 
+static std::string flattenClangCommandLine(ArrayRef Args,
+  StringRef MainFilename) {
+  if (Args.empty())
+  {

compnerd wrote:

The braces are unnecessary here, but more importantly, they should be coddled.

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


[clang] [llvm] [RISCV][VCIX] Add vcix_state to GNU inline assembly register set (PR #106914)

2024-09-01 Thread Brandon Wu via cfe-commits

https://github.com/4vtomat created 
https://github.com/llvm/llvm-project/pull/106914

[RISCV][VCIX] Add vcix_state to GNU inline assembly register set

 Resolved https://github.com/llvm/llvm-project/issues/106700.
 This enables inline asm to have vcix_state to be a clobbered register
 thus disable reordering between VCIX intrinsics and inline asm.


>From 21f4687b58544bd08e8b6a4b76326fe956d87854 Mon Sep 17 00:00:00 2001
From: Brandon Wu 
Date: Sun, 1 Sep 2024 09:35:34 -0700
Subject: [PATCH 1/2] [RISCV][VCIX] Precommit test

---
 llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll | 22 
 1 file changed, 22 insertions(+)
 create mode 100644 llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll

diff --git a/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll 
b/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
new file mode 100644
index 00..4ceb189ab6a46f
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
+; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v,+xsfvcp \
+; RUN:   -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK
+; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v,+xsfvcp \
+; RUN:   -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK
+
+; VCIX instructions can not reorder between each other.
+define void @test_reorder( %vreg) {
+; CHECK-LABEL: test_reorder:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:#APP
+; CHECK-NEXT:sf.vc.vv 3, 0, v8, v8
+; CHECK-EMPTY:
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:vsetivli zero, 0, e64, m1, ta, ma
+; CHECK-NEXT:sf.vc.iv 0, 0, v8, 0
+; CHECK-NEXT:ret
+entry:
+  call void @llvm.riscv.sf.vc.iv.se.iXLen.nxv1i64.iXLen.iXLen(iXLen 0, iXLen 
0,  %vreg, iXLen 0, iXLen 0)
+  call iXLen asm sideeffect "sf.vc.vv 0x3, 0x0, $1, $1;", 
"=r,^vr,~{memory},~{vl},~{vcix_state}"( %vreg)
+  ret void
+}

>From 5f821a28b760efa20514a9080da1ae1127529138 Mon Sep 17 00:00:00 2001
From: Brandon Wu 
Date: Sun, 1 Sep 2024 09:39:44 -0700
Subject: [PATCH 2/2] [RISCV][VCIX] Add vcix_state to GNU inline assembly
 register set

Resolved https://github.com/llvm/llvm-project/issues/106700.
This enables inline asm to have vcix_state to be a clobbered register
thus disable reordering between VCIX intrinsics and inline asm.
---
 clang/lib/Basic/Targets/RISCV.cpp| 2 +-
 llvm/lib/Target/RISCV/RISCVRegisterInfo.td   | 6 +-
 llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll | 4 ++--
 3 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index b89109e7725d44..da6ecfb4e4022b 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -44,7 +44,7 @@ ArrayRef RISCVTargetInfo::getGCCRegNames() 
const {
   "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
 
   // CSRs
-  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm"
+  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm", "vcix_state"
 };
   // clang-format on
   return llvm::ArrayRef(GCCRegNames);
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index 4d5c0a7bef9416..03f05c0baea3b0 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -664,5 +664,9 @@ def FRM: RISCVReg<0, "frm">;
 // Shadow Stack register
 def SSP: RISCVReg<0, "ssp">;
 
-// Dummy VCIX state register
+// Dummy VCIX state register and its register class
 def VCIX_STATE : RISCVReg<0, "vcix_state">;
+def : RISCVRegisterClass<[XLenVT], 32, (add VCIX_STATE)> {
+  let RegInfos = XLenRI;
+  let isAllocatable = 0;
+}
diff --git a/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll 
b/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
index 4ceb189ab6a46f..0013461d873281 100644
--- a/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
+++ b/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
@@ -8,12 +8,12 @@
 define void @test_reorder( %vreg) {
 ; CHECK-LABEL: test_reorder:
 ; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetivli zero, 0, e64, m1, ta, ma
+; CHECK-NEXT:sf.vc.iv 0, 0, v8, 0
 ; CHECK-NEXT:#APP
 ; CHECK-NEXT:sf.vc.vv 3, 0, v8, v8
 ; CHECK-EMPTY:
 ; CHECK-NEXT:#NO_APP
-; CHECK-NEXT:vsetivli zero, 0, e64, m1, ta, ma
-; CHECK-NEXT:sf.vc.iv 0, 0, v8, 0
 ; CHECK-NEXT:ret
 entry:
   call void @llvm.riscv.sf.vc.iv.se.iXLen.nxv1i64.iXLen.iXLen(iXLen 0, iXLen 
0,  %vreg, iXLen 0, iXLen 0)

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


[clang] [llvm] [RISCV][VCIX] Add vcix_state to GNU inline assembly register set (PR #106914)

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


@@ -664,5 +664,9 @@ def FRM: RISCVReg<0, "frm">;
 // Shadow Stack register
 def SSP: RISCVReg<0, "ssp">;
 
-// Dummy VCIX state register
+// Dummy VCIX state register and its register class
 def VCIX_STATE : RISCVReg<0, "vcix_state">;
+def : RISCVRegisterClass<[XLenVT], 32, (add VCIX_STATE)> {

wangpc-pp wrote:

Why do we need a RegisterClass for it?

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


[clang] [clang-format] Add new option: WrapNamespaceBodyWithEmptyLines (PR #106901)

2024-09-01 Thread via cfe-commits

https://github.com/dmasloff created 
https://github.com/llvm/llvm-project/pull/106901

I would like to suggest a new clang-format option for llvm-project - 
WrapNamespaceBodyWithNewlines. I think it can be added to upstream since it is 
used by many popular public repositories, for example, 
[ytsaurus](https://github.com/ytsaurus/ytsaurus/). You can look through their 
style guide at this page: 
https://github.com/ytsaurus/ytsaurus/blob/main/yt/styleguide/cpp.md#namespaces

As you can see from the name of the option it wraps the body of namespace with 
additional newlines turning this code:
```
namespace N {
int function();
} 
 ```
into that:
```
namespace N {

int function();

} 
 ```
Looking forward to your advices and recommendations

>From 349408a878e7f72df6e225fdeb2be55bde4d2662 Mon Sep 17 00:00:00 2001
From: dmasloff 
Date: Sun, 1 Sep 2024 11:15:08 +0300
Subject: [PATCH] [clang-format] Add new option:
 WrapNamespaceBodyWithEmptyLines

---
 clang/docs/ClangFormatStyleOptions.rst  |  42 
 clang/include/clang/Format/Format.h |  40 +++-
 clang/lib/Format/Format.cpp |  15 ++
 clang/lib/Format/UnwrappedLineFormatter.cpp |  42 
 clang/unittests/Format/FormatTest.cpp   | 205 
 5 files changed, 343 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index a427d7cd40fcdd..06ac88fc337983 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6652,6 +6652,48 @@ the configuration (without a prefix: ``Auto``).
 
   For example: BOOST_PP_STRINGIZE
 
+.. _WrapNamespaceBodyWithEmptyLines:
+
+**WrapNamespaceBodyWithEmptyLines** (``WrapNamespaceBodyWithEmptyLinesStyle``) 
:versionbadge:`clang-format 19` :ref:`¶ `
+  Controls number of empty lines at the begging and at the end of
+  namespace definition.
+
+  Possible values:
+
+  * ``WNBWELS_Never`` (in configuration: ``Never``)
+Removes all empty lines at the beginning and at the end of
+namespace definition.
+
+.. code-block:: c++
+
+  namespace N1 {
+  namespace N2
+function();
+  }
+  }
+
+  * ``WNBWELS_Always`` (in configuration: ``Always``)
+Always adds an empty line at the beginning and at the end of
+namespace definition. MaxEmptyLinesToKeep is also applied, but
+empty lines between consecutive namespace declarations are
+always removed.
+
+.. code-block:: c++
+
+  namespace N1 {
+  namespace N2 {
+
+function();
+
+  }
+  }
+
+  * ``WNBWELS_Leave`` (in configuration: ``Leave``)
+Keeps existing newlines at the beginning and at the end of
+namespace definition using MaxEmptyLinesToKeep for formatting.
+
+
+
 .. END_FORMAT_STYLE_OPTIONS
 
 Adding additional style options
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index d8b62c7652a0f6..963c7cbe1f8809 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -5057,6 +5057,43 @@ struct FormatStyle {
   /// \version 11
   std::vector WhitespaceSensitiveMacros;
 
+  /// Different styles for modify number of empty lines in
+  /// the beginning and at the of end of namespaces.
+  enum WrapNamespaceBodyWithEmptyLinesStyle : int8_t {
+/// Removes all empty lines at the beginning and at the end of
+/// namespace definition.
+/// \code
+///   namespace N1 {
+///   namespace N2
+/// function();
+///   }
+///   }
+/// \endcode
+WNBWELS_Never,
+/// Always adds an empty line at the beginning and at the end of
+/// namespace definition. MaxEmptyLinesToKeep is also applied, but
+/// empty lines between consecutive namespace declarations are
+/// always removed.
+/// \code
+///   namespace N1 {
+///   namespace N2 {
+///
+/// function();
+///
+///   }
+///   }
+/// \endcode
+WNBWELS_Always,
+/// Keeps existing newlines at the beginning and at the end of
+/// namespace definition using MaxEmptyLinesToKeep for formatting.
+WNBWELS_Leave
+  };
+
+  /// Controls number of empty lines at the begging and at the end of
+  /// namespace definition.
+  /// \version 19
+  WrapNamespaceBodyWithEmptyLinesStyle WrapNamespaceBodyWithEmptyLines;
+
   bool operator==(const FormatStyle &R) const {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
@@ -5234,7 +5271,8 @@ struct FormatStyle {
TypenameMacros == R.TypenameMacros && UseTab == R.UseTab &&
VerilogBreakBetweenInstancePorts ==
R.VerilogBreakBetweenInstancePorts &&
-   WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
+   WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros &&
+   WrapNamespaceBodyWithEmptyLines == 
R.WrapNamespaceBodyWithEmptyLines;
   }
 
   std::optional GetLanguageStyl

[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

2024-09-01 Thread Younan Zhang via cfe-commits


@@ -1012,7 +1012,14 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // possible that e.g. constraints involving C> and C are
   // perceived identical.
   std::optional ContextScope;
-  if (auto *RD = dyn_cast(DeclInfo.getDeclContext())) {
+  const DeclContext *DC = [&] {
+if (!DeclInfo.getDecl())
+  return DeclInfo.getDeclContext();
+return DeclInfo.getDecl()->getFriendObjectKind()
+   ? DeclInfo.getLexicalDeclContext()
+   : DeclInfo.getDeclContext();

zyn0217 wrote:

Agreed, probably something like `Decl::getFriendDeclContext()`

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


[clang] 358165d - [Clang][Concepts] Correct the CurContext for friend declarations (#106890)

2024-09-01 Thread via cfe-commits

Author: Younan Zhang
Date: 2024-09-02T13:42:42+08:00
New Revision: 358165ded3c45115ce587d56ef792a9e7c0214ea

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

LOG: [Clang][Concepts] Correct the CurContext for friend declarations (#106890)

`FindInstantiatedDecl()` relies on the `CurContext` to find the
corresponding class template instantiation for a class template
declaration.

Previously, we pushed the semantic declaration context for constraint
comparison, which is incorrect for constraints on friend declarations.
In issue #78101, the semantic context of the friend is the TU, so we
missed the implicit template specialization `Template` when
looking for the instantiation of the primary template `Template` at the
time of checking the member instantiation; instead, we mistakenly picked
up the explicit specialization `Template`, hence the error.

As a bonus, this also fixes a crash when diagnosing constraints. The
DeclarationName is not necessarily an identifier, so it's incorrect to
call `getName()` on e.g. overloaded operators. Since the
DiagnosticBuilder has correctly handled Decl printing, we don't need to
find the printable name ourselves.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaConcept.cpp
clang/lib/Sema/SemaTemplateInstantiate.cpp
clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
clang/test/SemaTemplate/concepts-friends.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 98fb0174d4a37e..fc940db4813948 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -338,6 +338,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure when converting vectors to int/float with invalid 
expressions. (#GH105486)
 - Template parameter names are considered in the name lookup of out-of-line 
class template
   specialization right before its declaration context. (#GH64082)
+- Fixed a constraint comparison bug for friend declarations. (#GH78101)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 66f8890da75e5d..dcb49d8a67604a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5603,7 +5603,7 @@ def note_checking_constraints_for_function_here : Note<
 def note_constraint_substitution_here : Note<
   "while substituting template arguments into constraint expression here">;
 def note_constraint_normalization_here : Note<
-  "while calculating associated constraint of template '%0' here">;
+  "while calculating associated constraint of template %0 here">;
 def note_parameter_mapping_substitution_here : Note<
   "while substituting into concept arguments here; substitution failures not "
   "allowed in concept arguments">;

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 86d6f308a51cc2..6a1b32598bb4a6 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1012,7 +1012,14 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // possible that e.g. constraints involving C> and C are
   // perceived identical.
   std::optional ContextScope;
-  if (auto *RD = dyn_cast(DeclInfo.getDeclContext())) {
+  const DeclContext *DC = [&] {
+if (!DeclInfo.getDecl())
+  return DeclInfo.getDeclContext();
+return DeclInfo.getDecl()->getFriendObjectKind()
+   ? DeclInfo.getLexicalDeclContext()
+   : DeclInfo.getDeclContext();
+  }();
+  if (auto *RD = dyn_cast(DC)) {
 ThisScope.emplace(S, const_cast(RD), Qualifiers());
 ContextScope.emplace(S, const_cast(cast(RD)),
  /*NewThisContext=*/false);

diff  --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 776297479e141e..c42cc250bb904a 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1226,8 +1226,7 @@ void Sema::PrintInstantiationStack() {
 case CodeSynthesisContext::ConstraintNormalization:
   Diags.Report(Active->PointOfInstantiation,
diag::note_constraint_normalization_here)
-  << cast(Active->Entity)->getName()
-  << Active->InstantiationRange;
+  << cast(Active->Entity) << Active->InstantiationRange;
   break;
 case CodeSynthesisContext::ParameterMappingSubstitution:
   Diags.Report(Active->PointOfInstantiation,

diff  --git a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp 
b/clang/test/CXX/temp/temp.constr/

[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

2024-09-01 Thread Younan Zhang via cfe-commits

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


[clang] [Clang][CodeGen] Don't emit assumptions if current block is unreachable. (PR #106936)

2024-09-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-codegen

Author: Yingwei Zheng (dtcxzyw)


Changes

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

When emitting an infinite loop, clang codegen will delete the whole block and 
leave builder's current block as nullptr:
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/clang/lib/CodeGen/CGStmt.cpp#L597-L600

Then clang will create `zext (icmp slt %a, %b)` without parent block for `a 
< b`. It will crash here:
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/clang/lib/CodeGen/CGExprScalar.cpp#L416-L420

Even if we disabled this optimization, it still crashes in 
`Builder.CreateAssumption`:
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/llvm/lib/IR/IRBuilder.cpp#L551-L561

This patch disables assumptions emission if current block is null. As an 
alternative, we can fix the optimization in `EmitIntToBoolConversion` and use 
`CGM.getIntrinsic` as we do for `__builtin_assume`:
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/clang/lib/CodeGen/CGBuiltin.cpp#L3422-L3431


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


2 Files Affected:

- (modified) clang/lib/CodeGen/CGStmt.cpp (+1-1) 
- (modified) clang/test/SemaCXX/cxx23-assume.cpp (+9) 


``diff
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 7158a06e6bc3b3..b138c87a853495 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -752,7 +752,7 @@ void CodeGenFunction::EmitAttributedStmt(const 
AttributedStmt &S) {
 } break;
 case attr::CXXAssume: {
   const Expr *Assumption = cast(A)->getAssumption();
-  if (getLangOpts().CXXAssumptions &&
+  if (getLangOpts().CXXAssumptions && Builder.GetInsertBlock() &&
   !Assumption->HasSideEffects(getContext())) {
 llvm::Value *AssumptionVal = EvaluateExprAsBool(Assumption);
 Builder.CreateAssumption(AssumptionVal);
diff --git a/clang/test/SemaCXX/cxx23-assume.cpp 
b/clang/test/SemaCXX/cxx23-assume.cpp
index 9138501d726dd6..eeae59daea3f70 100644
--- a/clang/test/SemaCXX/cxx23-assume.cpp
+++ b/clang/test/SemaCXX/cxx23-assume.cpp
@@ -158,3 +158,12 @@ foo (int x, int y)
   return x + y;
 }
 }
+
+// Do not crash when assumptions are unreachable.
+namespace gh106898 {
+int foo () { 
+while(1);
+int a = 0, b = 1;
+__attribute__((assume (a < b)));
+}
+}

``




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


[clang] [llvm] [RISCV][VCIX] Add vcix_state to GNU inline assembly register set (PR #106914)

2024-09-01 Thread Kito Cheng via cfe-commits

kito-cheng wrote:

I would suggest it should prefix with a vendor prefix, either `sf.vcix_state` 
or `sifive.vcix_state`, also go `riscv-c-api-doc` or 
`riscv-toolchain-conventions` :)

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


[clang] [clang][AIX] Fix -print-runtime-dir on AIX (PR #104806)

2024-09-01 Thread Jake Egan via cfe-commits

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


[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

2024-09-01 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 created 
https://github.com/llvm/llvm-project/pull/106890

`FindInstantiatedDecl()` relies on the `CurContext` to find the corresponding 
class template instantiation for a class template declaration.

Previously, we pushed the semantic declaration context for constraint 
comparison, which is incorrect for constraints on friend declarations. In issue 
#78101, the semantic context of the friend is the TU, so we missed the implicit 
template specialization `Template` when looking for the instantiation 
of the primary template `Template` at the time of checking the member 
instantiation; instead, we mistakenly picked up the explicit specialization 
`Template`, hence the error.

As a bonus, this also fixes a crash when diagnosing constraints. The 
DeclarationName is not necessarily an identifier, so it's incorrect to call 
`getName()` on e.g. overloaded operators. Since the DiagnosticBuilder has 
correctly handled Decl printing, we don't need to find the printable name 
ourselves.

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

>From 679ece827467a25b14d0a718ac10f221327f5bef Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 1 Sep 2024 14:55:22 +0800
Subject: [PATCH] [Clang][Concepts] Correct the CurContext for friend
 declarations

---
 clang/docs/ReleaseNotes.rst   |  1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +-
 clang/lib/Sema/SemaConcept.cpp|  5 +++-
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  3 +--
 .../temp.constr/temp.constr.normal/p1.cpp |  2 +-
 clang/test/SemaTemplate/concepts-friends.cpp  | 23 +++
 6 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 98fb0174d4a37e..fc940db4813948 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -338,6 +338,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure when converting vectors to int/float with invalid 
expressions. (#GH105486)
 - Template parameter names are considered in the name lookup of out-of-line 
class template
   specialization right before its declaration context. (#GH64082)
+- Fixed a constraint comparison bug for friend declarations. (#GH78101)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 66f8890da75e5d..dcb49d8a67604a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5603,7 +5603,7 @@ def note_checking_constraints_for_function_here : Note<
 def note_constraint_substitution_here : Note<
   "while substituting template arguments into constraint expression here">;
 def note_constraint_normalization_here : Note<
-  "while calculating associated constraint of template '%0' here">;
+  "while calculating associated constraint of template %0 here">;
 def note_parameter_mapping_substitution_here : Note<
   "while substituting into concept arguments here; substitution failures not "
   "allowed in concept arguments">;
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 86d6f308a51cc2..afbfe278680240 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1012,7 +1012,10 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // possible that e.g. constraints involving C> and C are
   // perceived identical.
   std::optional ContextScope;
-  if (auto *RD = dyn_cast(DeclInfo.getDeclContext())) {
+  if (auto *RD =
+  dyn_cast(DeclInfo.getDecl()->getFriendObjectKind()
+  ? DeclInfo.getLexicalDeclContext()
+  : DeclInfo.getDeclContext())) {
 ThisScope.emplace(S, const_cast(RD), Qualifiers());
 ContextScope.emplace(S, const_cast(cast(RD)),
  /*NewThisContext=*/false);
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 776297479e141e..c42cc250bb904a 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1226,8 +1226,7 @@ void Sema::PrintInstantiationStack() {
 case CodeSynthesisContext::ConstraintNormalization:
   Diags.Report(Active->PointOfInstantiation,
diag::note_constraint_normalization_here)
-  << cast(Active->Entity)->getName()
-  << Active->InstantiationRange;
+  << cast(Active->Entity) << Active->InstantiationRange;
   break;
 case CodeSynthesisContext::ParameterMappingSubstitution:
   Diags.Report(Active->PointOfInstantiation,
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp 
b/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
index d80710937cdfa1..3992835c444027 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
+++ b/clang/

[clang] [Clang] Workaround dependent source location issues (PR #106925)

2024-09-01 Thread via cfe-commits

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


[clang] [clang-tools-extra] Add function check for windows platform (PR #106581)

2024-09-01 Thread via cfe-commits

fawdlstty wrote:

![test](https://github.com/user-attachments/assets/de4025d9-d787-4e4e-b9f5-a88e4308b452)


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


[clang] [llvm] [RISCV][VCIX] Add vcix_state to GNU inline assembly register set (PR #106914)

2024-09-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-risc-v

Author: Brandon Wu (4vtomat)


Changes

[RISCV][VCIX] Add vcix_state to GNU inline assembly register set

 Resolved https://github.com/llvm/llvm-project/issues/106700.
 This enables inline asm to have vcix_state to be a clobbered register
 thus disable reordering between VCIX intrinsics and inline asm.


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


3 Files Affected:

- (modified) clang/lib/Basic/Targets/RISCV.cpp (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+5-1) 
- (added) llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll (+22) 


``diff
diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index b89109e7725d44..da6ecfb4e4022b 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -44,7 +44,7 @@ ArrayRef RISCVTargetInfo::getGCCRegNames() 
const {
   "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
 
   // CSRs
-  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm"
+  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm", "vcix_state"
 };
   // clang-format on
   return llvm::ArrayRef(GCCRegNames);
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index 4d5c0a7bef9416..03f05c0baea3b0 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -664,5 +664,9 @@ def FRM: RISCVReg<0, "frm">;
 // Shadow Stack register
 def SSP: RISCVReg<0, "ssp">;
 
-// Dummy VCIX state register
+// Dummy VCIX state register and its register class
 def VCIX_STATE : RISCVReg<0, "vcix_state">;
+def : RISCVRegisterClass<[XLenVT], 32, (add VCIX_STATE)> {
+  let RegInfos = XLenRI;
+  let isAllocatable = 0;
+}
diff --git a/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll 
b/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
new file mode 100644
index 00..0013461d873281
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
+; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v,+xsfvcp \
+; RUN:   -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK
+; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v,+xsfvcp \
+; RUN:   -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK
+
+; VCIX instructions can not reorder between each other.
+define void @test_reorder( %vreg) {
+; CHECK-LABEL: test_reorder:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetivli zero, 0, e64, m1, ta, ma
+; CHECK-NEXT:sf.vc.iv 0, 0, v8, 0
+; CHECK-NEXT:#APP
+; CHECK-NEXT:sf.vc.vv 3, 0, v8, v8
+; CHECK-EMPTY:
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:ret
+entry:
+  call void @llvm.riscv.sf.vc.iv.se.iXLen.nxv1i64.iXLen.iXLen(iXLen 0, iXLen 
0,  %vreg, iXLen 0, iXLen 0)
+  call iXLen asm sideeffect "sf.vc.vv 0x3, 0x0, $1, $1;", 
"=r,^vr,~{memory},~{vl},~{vcix_state}"( %vreg)
+  ret void
+}

``




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


[clang] [clang-tools-extra] Add function check for windows platform (PR #106581)

2024-09-01 Thread via cfe-commits

https://github.com/fawdlstty updated 
https://github.com/llvm/llvm-project/pull/106581

>From f169f3c57a0a55c1a0dbb8f965bc17a87ceb98d7 Mon Sep 17 00:00:00 2001
From: fawdlstty 
Date: Fri, 30 Aug 2024 00:23:39 +0800
Subject: [PATCH 1/6] add check for windows platforms api

---
 .../bugprone/NotNullTerminatedResultCheck.cpp |  2 +-
 clang/docs/analyzer/checkers.rst  |  2 +-
 clang/include/clang/Basic/Builtins.td | 22 +++
 .../Checkers/CStringChecker.cpp   |  6 +
 4 files changed, 30 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
index 977241e91b9a93..e2cf96c88b90bd 100644
--- a/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/NotNullTerminatedResultCheck.cpp
@@ -106,7 +106,7 @@ static const CallExpr *getStrlenExpr(const 
MatchFinder::MatchResult &Result) {
 if (const Decl *D = StrlenExpr->getCalleeDecl())
   if (const FunctionDecl *FD = D->getAsFunction())
 if (const IdentifierInfo *II = FD->getIdentifier())
-  if (II->isStr("strlen") || II->isStr("wcslen"))
+  if (II->isStr("strlen") || II->isStr("lstrlen") || 
II->isStr("wcslen"))
 return StrlenExpr;
 
   return nullptr;
diff --git a/clang/docs/analyzer/checkers.rst b/clang/docs/analyzer/checkers.rst
index 89a1018e14c0e6..ca675ae37929fe 100644
--- a/clang/docs/analyzer/checkers.rst
+++ b/clang/docs/analyzer/checkers.rst
@@ -1582,7 +1582,7 @@ Check the size argument passed into C string functions 
for common erroneous patt
 unix.cstring.NullArg (C)
 
 Check for null pointers being passed as arguments to C string functions:
-``strlen, strnlen, strcpy, strncpy, strcat, strncat, strcmp, strncmp, 
strcasecmp, strncasecmp, wcslen, wcsnlen``.
+``strlen, lstrlen, strnlen, strcpy, lstrcpy, strncpy, strcat, lstrcat, 
strncat, strcmp, strncmp, strcasecmp, strncasecmp, wcslen, wcsnlen``.
 
 .. code-block:: c
 
diff --git a/clang/include/clang/Basic/Builtins.td 
b/clang/include/clang/Basic/Builtins.td
index 8668b25661dec8..cbc5fc52326ad2 100644
--- a/clang/include/clang/Basic/Builtins.td
+++ b/clang/include/clang/Basic/Builtins.td
@@ -4788,3 +4788,25 @@ def ArithmeticFence : LangBuiltin<"ALL_LANGUAGES"> {
   let Attributes = [CustomTypeChecking, Constexpr];
   let Prototype = "void(...)";
 }
+
+// Windows - WinBase.h
+def LStrLen : LibBuiltin<"WinBase.h"> {
+  let Spellings = ["lstrlen"];
+  let Attributes = [NoThrow, Constexpr];
+  let Prototype = "int(LPCTSTR)";
+  let AddBuiltinPrefixedAlias = 1;
+}
+
+def LStrCpy : LibBuiltin<"WinBase.h"> {
+  let Spellings = ["lstrcpy"];
+  let Attributes = [NoThrow];
+  let Prototype = "LPCTSTR(LPTSTR, LPCTSTR)";
+  let AddBuiltinPrefixedAlias = 1;
+}
+
+def LStrCat : LibBuiltin<"WinBase.h"> {
+  let Spellings = ["lstrcat"];
+  let Attributes = [NoThrow];
+  let Prototype = "LPTSTR(LPTSTR, LPCTSTR)";
+  let AddBuiltinPrefixedAlias = 1;
+}
diff --git a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
index 8dd08f14b2728b..2adf538486176d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -150,6 +150,8 @@ class CStringChecker : public Checker< eval::Call,
   // FIXME: C23 introduces 'memset_explicit', maybe also model that
   {{CDM::CLibraryMaybeHardened, {"strcpy"}, 2},
&CStringChecker::evalStrcpy},
+  {{CDM::CLibraryMaybeHardened, {"lstrcpy"}, 2},
+   &CStringChecker::evalStrcpy},
   {{CDM::CLibraryMaybeHardened, {"strncpy"}, 3},
&CStringChecker::evalStrncpy},
   {{CDM::CLibraryMaybeHardened, {"stpcpy"}, 2},
@@ -158,12 +160,16 @@ class CStringChecker : public Checker< eval::Call,
&CStringChecker::evalStrlcpy},
   {{CDM::CLibraryMaybeHardened, {"strcat"}, 2},
&CStringChecker::evalStrcat},
+  {{CDM::CLibraryMaybeHardened, {"lstrcat"}, 2},
+   &CStringChecker::evalStrcat},
   {{CDM::CLibraryMaybeHardened, {"strncat"}, 3},
&CStringChecker::evalStrncat},
   {{CDM::CLibraryMaybeHardened, {"strlcat"}, 3},
&CStringChecker::evalStrlcat},
   {{CDM::CLibraryMaybeHardened, {"strlen"}, 1},
&CStringChecker::evalstrLength},
+  {{CDM::CLibraryMaybeHardened, {"lstrlen"}, 1},
+   &CStringChecker::evalstrLength},
   {{CDM::CLibrary, {"wcslen"}, 1}, &CStringChecker::evalstrLength},
   {{CDM::CLibraryMaybeHardened, {"strnlen"}, 2},
&CStringChecker::evalstrnLength},

>From 52d40b558e14948c38c8c5f75245c5ba08bd3fea Mon Sep 17 00:00:00 2001
From: fawdlstty 
Date: Fri, 30 Aug 2024 00:33:22 +0800
Subject: [PATCH 2/6] add to insecureAPI

---
 clang/docs/analyzer/checkers.rst | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang/docs/analyzer/checkers.rst 

[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

2024-09-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Nikolas Klauser (philnik777)


Changes

This doesn't seem to have any use other than the possibility of merge conflicts 
and accidentally forgetting to update `NUM_PREDEF_DECL_IDS`.


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


1 Files Affected:

- (modified) clang/include/clang/AST/DeclID.h (+21-26) 


``diff
diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h
index e5e27389fac60d..81454a247229f5 100644
--- a/clang/include/clang/AST/DeclID.h
+++ b/clang/include/clang/AST/DeclID.h
@@ -20,8 +20,6 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/iterator.h"
 
-#include 
-
 namespace clang {
 
 /// Predefined declaration IDs.
@@ -32,65 +30,62 @@ namespace clang {
 /// it is created.
 enum PredefinedDeclIDs {
   /// The NULL declaration.
-  PREDEF_DECL_NULL_ID = 0,
+  PREDEF_DECL_NULL_ID,
 
   /// The translation unit.
-  PREDEF_DECL_TRANSLATION_UNIT_ID = 1,
+  PREDEF_DECL_TRANSLATION_UNIT_ID,
 
   /// The Objective-C 'id' type.
-  PREDEF_DECL_OBJC_ID_ID = 2,
+  PREDEF_DECL_OBJC_ID_ID,
 
   /// The Objective-C 'SEL' type.
-  PREDEF_DECL_OBJC_SEL_ID = 3,
+  PREDEF_DECL_OBJC_SEL_ID,
 
   /// The Objective-C 'Class' type.
-  PREDEF_DECL_OBJC_CLASS_ID = 4,
+  PREDEF_DECL_OBJC_CLASS_ID,
 
   /// The Objective-C 'Protocol' type.
-  PREDEF_DECL_OBJC_PROTOCOL_ID = 5,
+  PREDEF_DECL_OBJC_PROTOCOL_ID,
 
   /// The signed 128-bit integer type.
-  PREDEF_DECL_INT_128_ID = 6,
+  PREDEF_DECL_INT_128_ID,
 
   /// The unsigned 128-bit integer type.
-  PREDEF_DECL_UNSIGNED_INT_128_ID = 7,
+  PREDEF_DECL_UNSIGNED_INT_128_ID,
 
   /// The internal 'instancetype' typedef.
-  PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8,
+  PREDEF_DECL_OBJC_INSTANCETYPE_ID,
 
   /// The internal '__builtin_va_list' typedef.
-  PREDEF_DECL_BUILTIN_VA_LIST_ID = 9,
+  PREDEF_DECL_BUILTIN_VA_LIST_ID,
 
   /// The internal '__va_list_tag' struct, if any.
-  PREDEF_DECL_VA_LIST_TAG = 10,
+  PREDEF_DECL_VA_LIST_TAG,
 
   /// The internal '__builtin_ms_va_list' typedef.
-  PREDEF_DECL_BUILTIN_MS_VA_LIST_ID = 11,
+  PREDEF_DECL_BUILTIN_MS_VA_LIST_ID,
 
   /// The predeclared '_GUID' struct.
-  PREDEF_DECL_BUILTIN_MS_GUID_ID = 12,
+  PREDEF_DECL_BUILTIN_MS_GUID_ID,
 
   /// The extern "C" context.
-  PREDEF_DECL_EXTERN_C_CONTEXT_ID = 13,
+  PREDEF_DECL_EXTERN_C_CONTEXT_ID,
 
   /// The internal '__make_integer_seq' template.
-  PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 14,
+  PREDEF_DECL_MAKE_INTEGER_SEQ_ID,
 
   /// The internal '__NSConstantString' typedef.
-  PREDEF_DECL_CF_CONSTANT_STRING_ID = 15,
+  PREDEF_DECL_CF_CONSTANT_STRING_ID,
 
   /// The internal '__NSConstantString' tag type.
-  PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID = 16,
+  PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID,
 
   /// The internal '__type_pack_element' template.
-  PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17,
-};
+  PREDEF_DECL_TYPE_PACK_ELEMENT_ID,
 
-/// The number of declaration IDs that are predefined.
-///
-/// For more information about predefined declarations, see the
-/// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
-const unsigned int NUM_PREDEF_DECL_IDS = 18;
+  /// The number of declaration IDs that are predefined.
+  NUM_PREDEF_DECL_IDS
+};
 
 /// GlobalDeclID means DeclID in the current ASTContext and LocalDeclID means
 /// DeclID specific to a certain ModuleFile. Specially, in ASTWriter, the

``




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


[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

2024-09-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

`FindInstantiatedDecl()` relies on the `CurContext` to find the corresponding 
class template instantiation for a class template declaration.

Previously, we pushed the semantic declaration context for constraint 
comparison, which is incorrect for constraints on friend declarations. In issue 
#78101, the semantic context of the friend is the TU, so we missed the 
implicit template specialization `Template` when looking for the 
instantiation of the primary template `Template` at the time of checking the 
member instantiation; instead, we mistakenly picked up the explicit 
specialization `Template`, hence the error.

As a bonus, this also fixes a crash when diagnosing constraints. The 
DeclarationName is not necessarily an identifier, so it's incorrect to call 
`getName()` on e.g. overloaded operators. Since the DiagnosticBuilder has 
correctly handled Decl printing, we don't need to find the printable name 
ourselves.

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

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


6 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/include/clang/Basic/DiagnosticSemaKinds.td (+1-1) 
- (modified) clang/lib/Sema/SemaConcept.cpp (+4-1) 
- (modified) clang/lib/Sema/SemaTemplateInstantiate.cpp (+1-2) 
- (modified) clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp (+1-1) 
- (modified) clang/test/SemaTemplate/concepts-friends.cpp (+23) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 98fb0174d4a37e..fc940db4813948 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -338,6 +338,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure when converting vectors to int/float with invalid 
expressions. (#GH105486)
 - Template parameter names are considered in the name lookup of out-of-line 
class template
   specialization right before its declaration context. (#GH64082)
+- Fixed a constraint comparison bug for friend declarations. (#GH78101)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 66f8890da75e5d..dcb49d8a67604a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5603,7 +5603,7 @@ def note_checking_constraints_for_function_here : Note<
 def note_constraint_substitution_here : Note<
   "while substituting template arguments into constraint expression here">;
 def note_constraint_normalization_here : Note<
-  "while calculating associated constraint of template '%0' here">;
+  "while calculating associated constraint of template %0 here">;
 def note_parameter_mapping_substitution_here : Note<
   "while substituting into concept arguments here; substitution failures not "
   "allowed in concept arguments">;
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 86d6f308a51cc2..afbfe278680240 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1012,7 +1012,10 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // possible that e.g. constraints involving C> and C are
   // perceived identical.
   std::optional ContextScope;
-  if (auto *RD = dyn_cast(DeclInfo.getDeclContext())) {
+  if (auto *RD =
+  dyn_cast(DeclInfo.getDecl()->getFriendObjectKind()
+  ? DeclInfo.getLexicalDeclContext()
+  : DeclInfo.getDeclContext())) {
 ThisScope.emplace(S, const_cast(RD), Qualifiers());
 ContextScope.emplace(S, const_cast(cast(RD)),
  /*NewThisContext=*/false);
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 776297479e141e..c42cc250bb904a 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1226,8 +1226,7 @@ void Sema::PrintInstantiationStack() {
 case CodeSynthesisContext::ConstraintNormalization:
   Diags.Report(Active->PointOfInstantiation,
diag::note_constraint_normalization_here)
-  << cast(Active->Entity)->getName()
-  << Active->InstantiationRange;
+  << cast(Active->Entity) << Active->InstantiationRange;
   break;
 case CodeSynthesisContext::ParameterMappingSubstitution:
   Diags.Report(Active->PointOfInstantiation,
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp 
b/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
index d80710937cdfa1..3992835c444027 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
@@ -15,7 +15,7 @@ template requires Bar2 struct S2 { };
 // 

[clang] 4fef204 - [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (#106891)

2024-09-01 Thread via cfe-commits

Author: Nikolas Klauser
Date: 2024-09-01T13:39:11+02:00
New Revision: 4fef204ac42eb84e167d43ce076c9a167eae3be0

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

LOG: [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (#106891)

This doesn't seem to have any use other than the possibility of merge
conflicts and accidentally forgetting to update `NUM_PREDEF_DECL_IDS`.

Added: 


Modified: 
clang/include/clang/AST/DeclID.h

Removed: 




diff  --git a/clang/include/clang/AST/DeclID.h 
b/clang/include/clang/AST/DeclID.h
index e5e27389fac60d..81454a247229f5 100644
--- a/clang/include/clang/AST/DeclID.h
+++ b/clang/include/clang/AST/DeclID.h
@@ -20,8 +20,6 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/iterator.h"
 
-#include 
-
 namespace clang {
 
 /// Predefined declaration IDs.
@@ -32,65 +30,62 @@ namespace clang {
 /// it is created.
 enum PredefinedDeclIDs {
   /// The NULL declaration.
-  PREDEF_DECL_NULL_ID = 0,
+  PREDEF_DECL_NULL_ID,
 
   /// The translation unit.
-  PREDEF_DECL_TRANSLATION_UNIT_ID = 1,
+  PREDEF_DECL_TRANSLATION_UNIT_ID,
 
   /// The Objective-C 'id' type.
-  PREDEF_DECL_OBJC_ID_ID = 2,
+  PREDEF_DECL_OBJC_ID_ID,
 
   /// The Objective-C 'SEL' type.
-  PREDEF_DECL_OBJC_SEL_ID = 3,
+  PREDEF_DECL_OBJC_SEL_ID,
 
   /// The Objective-C 'Class' type.
-  PREDEF_DECL_OBJC_CLASS_ID = 4,
+  PREDEF_DECL_OBJC_CLASS_ID,
 
   /// The Objective-C 'Protocol' type.
-  PREDEF_DECL_OBJC_PROTOCOL_ID = 5,
+  PREDEF_DECL_OBJC_PROTOCOL_ID,
 
   /// The signed 128-bit integer type.
-  PREDEF_DECL_INT_128_ID = 6,
+  PREDEF_DECL_INT_128_ID,
 
   /// The unsigned 128-bit integer type.
-  PREDEF_DECL_UNSIGNED_INT_128_ID = 7,
+  PREDEF_DECL_UNSIGNED_INT_128_ID,
 
   /// The internal 'instancetype' typedef.
-  PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8,
+  PREDEF_DECL_OBJC_INSTANCETYPE_ID,
 
   /// The internal '__builtin_va_list' typedef.
-  PREDEF_DECL_BUILTIN_VA_LIST_ID = 9,
+  PREDEF_DECL_BUILTIN_VA_LIST_ID,
 
   /// The internal '__va_list_tag' struct, if any.
-  PREDEF_DECL_VA_LIST_TAG = 10,
+  PREDEF_DECL_VA_LIST_TAG,
 
   /// The internal '__builtin_ms_va_list' typedef.
-  PREDEF_DECL_BUILTIN_MS_VA_LIST_ID = 11,
+  PREDEF_DECL_BUILTIN_MS_VA_LIST_ID,
 
   /// The predeclared '_GUID' struct.
-  PREDEF_DECL_BUILTIN_MS_GUID_ID = 12,
+  PREDEF_DECL_BUILTIN_MS_GUID_ID,
 
   /// The extern "C" context.
-  PREDEF_DECL_EXTERN_C_CONTEXT_ID = 13,
+  PREDEF_DECL_EXTERN_C_CONTEXT_ID,
 
   /// The internal '__make_integer_seq' template.
-  PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 14,
+  PREDEF_DECL_MAKE_INTEGER_SEQ_ID,
 
   /// The internal '__NSConstantString' typedef.
-  PREDEF_DECL_CF_CONSTANT_STRING_ID = 15,
+  PREDEF_DECL_CF_CONSTANT_STRING_ID,
 
   /// The internal '__NSConstantString' tag type.
-  PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID = 16,
+  PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID,
 
   /// The internal '__type_pack_element' template.
-  PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17,
-};
+  PREDEF_DECL_TYPE_PACK_ELEMENT_ID,
 
-/// The number of declaration IDs that are predefined.
-///
-/// For more information about predefined declarations, see the
-/// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
-const unsigned int NUM_PREDEF_DECL_IDS = 18;
+  /// The number of declaration IDs that are predefined.
+  NUM_PREDEF_DECL_IDS
+};
 
 /// GlobalDeclID means DeclID in the current ASTContext and LocalDeclID means
 /// DeclID specific to a certain ModuleFile. Specially, in ASTWriter, the



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


[clang] [llvm] [RISCV][VCIX] Add vcix_state to GNU inline assembly register set (PR #106914)

2024-09-01 Thread Brandon Wu via cfe-commits


@@ -664,5 +664,9 @@ def FRM: RISCVReg<0, "frm">;
 // Shadow Stack register
 def SSP: RISCVReg<0, "ssp">;
 
-// Dummy VCIX state register
+// Dummy VCIX state register and its register class
 def VCIX_STATE : RISCVReg<0, "vcix_state">;
+def : RISCVRegisterClass<[XLenVT], 32, (add VCIX_STATE)> {

4vtomat wrote:

In `getRegForInlineAsmConstraint` if there would be no value in `AssignedRegs` 
when calling `getRegistersForValue` for the `vcix_state` constraint, thus it 
would be deprecated when constructing selectionDAG.

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


[clang] [llvm] [RISCV][VCIX] Add vcix_state to GNU inline assembly register set (PR #106914)

2024-09-01 Thread Brandon Wu via cfe-commits

4vtomat wrote:

> I would suggest it should prefix with a vendor prefix, either `sf.vcix_state` 
> or `sifive.vcix_state`, also go `riscv-c-api-doc` or 
> `riscv-toolchain-conventions` :)

Do you mean change the current `vcix_state` register to `sf.vcix_state`?

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


[clang] [clang] The ms-extension __noop should return zero in a constexpr context. (PR #106849)

2024-09-01 Thread Timm Baeder via cfe-commits


@@ -12720,8 +12720,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
   }
 
   case Builtin::BI__noop:
-  // __noop always evaluates successfully
-return true;
+// __noop always evaluates successfully
+return ZeroInitialization(E);

tbaederr wrote:

```suggestion
// __noop always evaluates successfully and returns 0.
return Success(0, E);
```

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


[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-01 Thread via cfe-commits

https://github.com/nebulark updated 
https://github.com/llvm/llvm-project/pull/106369

>From 60332916c1fba8ad20d3353e279a867807f46273 Mon Sep 17 00:00:00 2001
From: Florian Schmiderer 
Date: Wed, 28 Aug 2024 12:36:39 +0200
Subject: [PATCH 1/4] Flatten compiler args in Frontend, keep existing
 behaviour as fallback for other frontends

---
 clang/lib/CodeGen/BackendUtil.cpp | 38 +++
 llvm/include/llvm/MC/MCTargetOptions.h|  7 
 llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 15 ++--
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 564efa3181d188..3ddc6704383016 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -50,6 +50,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -322,6 +323,41 @@ static bool actionRequiresCodeGen(BackendAction Action) {
  Action != Backend_EmitLL;
 }
 
+static std::string flattenClangCommandLine(ArrayRef Args,
+  StringRef MainFilename) {
+  std::string FlatCmdLine;
+  raw_string_ostream OS(FlatCmdLine);
+  bool PrintedOneArg = false;
+  if (!StringRef(Args[0]).contains("-cc1")) {
+llvm::sys::printArg(OS, "-cc1", /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  for (unsigned i = 0; i < Args.size(); i++) {
+StringRef Arg = Args[i];
+if (Arg.empty()) {
+  continue;
+}
+if (Arg == "-main-file-name" || Arg == "-o") {
+  i++; // Skip this argument and next one.
+  continue;
+}
+if (Arg.starts_with("-object-file-name") || Arg == MainFilename) {
+  continue;
+}
+// Skip fmessage-length for reproduciability.
+if (Arg.starts_with("-fmessage-length")) {
+  continue;
+}
+if (PrintedOneArg) {
+  OS << " ";
+}
+llvm::sys::printArg(OS, Arg, /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  OS.flush();
+  return FlatCmdLine;
+}
+
 static bool initTargetOptions(DiagnosticsEngine &Diags,
   llvm::TargetOptions &Options,
   const CodeGenOptions &CodeGenOpts,
@@ -486,6 +522,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
   Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
   Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
+  Options.MCOptions.CommandlineArgsFlat = flattenClangCommandLine(
+  CodeGenOpts.CommandLineArgs, CodeGenOpts.MainFileName);
   Options.MCOptions.AsSecureLogFile = CodeGenOpts.AsSecureLogFile;
   Options.MCOptions.PPCUseFullRegisterNames =
   CodeGenOpts.PPCUseFullRegisterNames;
diff --git a/llvm/include/llvm/MC/MCTargetOptions.h 
b/llvm/include/llvm/MC/MCTargetOptions.h
index a5371b3387a13d..0937089d8a2c80 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -96,8 +96,15 @@ class MCTargetOptions {
   std::string AsSecureLogFile;
 
   const char *Argv0 = nullptr;
+
+  // Deprecated: Use FlatCommandlineArgs instead
+  // Arguments here are interpreted as coming from clang, formated and end up 
in LF_BUILDINFO as CommandLineArgs 
   ArrayRef CommandLineArgs;
 
+  // Arguments here end up in LF_BUILDINFO as CommandLineArgs without any 
additional formating
+  // If empty falls back to CommandLineArgs
+  std::string CommandlineArgsFlat;
+
   /// Additional paths to search for `.include` directives when using the
   /// integrated assembler.
   std::vector IASSearchPaths;
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 7700ffd6da8030..60387e4688996b 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -893,6 +893,8 @@ static TypeIndex getStringIdTypeIdx(GlobalTypeTableBuilder 
&TypeTable,
   return TypeTable.writeLeafType(SIR);
 }
 
+// This just exists for backwards compatability for the deprecated 
MCTargetOptions::CommandLineArgs
+// It assumed a clang compiler frontend
 static std::string flattenCommandLine(ArrayRef Args,
   StringRef MainFilename) {
   std::string FlatCmdLine;
@@ -950,9 +952,16 @@ void CodeViewDebug::emitBuildInfo() {
   if (Asm->TM.Options.MCOptions.Argv0 != nullptr) {
 BuildInfoArgs[BuildInfoRecord::BuildTool] =
 getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
-BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
-TypeTable, 
flattenCommandLine(Asm->TM.Options.MCOptions.CommandLineArgs,
-  MainSourceFile->getFilename()));
+
+if (!Asm->TM.Options.MCOptions.CommandlineArgsFlat.e

[clang] [clang] The ms-extension __noop should return zero in a constexpr context. (PR #106849)

2024-09-01 Thread via cfe-commits

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


[clang-tools-extra] [clang-tidy] Add option to cppcoreguidelines-pro-type-reinterpret-cas… (PR #106922)

2024-09-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Carlos Galvez (carlosgalvezp)


Changes

…t to allow casts to byte types

These casts are safe according to the Standard, so add an option to allow them 
and not emit a warning. This helps silencing some noise and focusing on the 
unsafe casts.

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


5 Files Affected:

- (modified) 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp 
(+47-3) 
- (modified) 
clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h 
(+5-2) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+4) 
- (modified) 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/pro-type-reinterpret-cast.rst
 (+19) 
- (modified) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/pro-type-reinterpret-cast.cpp
 (+34-2) 


``diff
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
index 14456caab612b7..6385dd5440901c 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
@@ -9,20 +9,64 @@
 #include "ProTypeReinterpretCastCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/STLExtras.h"
+#include 
+#include 
 
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::cppcoreguidelines {
 
+static bool isCastToBytes(ASTContext const &Ctx,
+  CXXReinterpretCastExpr const &Expr) {
+  // https://eel.is/c++draft/basic.lval#11.3
+  static constexpr std::array AllowedByteTypes = {
+  "char",
+  "unsigned char",
+  "std::byte",
+  };
+
+  // We only care about pointer casts
+  QualType DestType = Expr.getTypeAsWritten();
+  if (!DestType->isPointerType())
+return false;
+
+  // Get the unqualified canonical type, and check if it's allowed
+  // We need to wrap the Type into a QualType to call getAsString()
+  const Type *UnqualDestType =
+  DestType.getCanonicalType()->getPointeeType().getTypePtr();
+  std::string DestTypeString = QualType(UnqualDestType, /*Quals=*/0)
+   .getAsString(Ctx.getPrintingPolicy());
+  return llvm::any_of(AllowedByteTypes, [DestTypeString](StringRef Type) {
+return Type == DestTypeString;
+  });
+}
+
+ProTypeReinterpretCastCheck::ProTypeReinterpretCastCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AllowCastToBytes(Options.getLocalOrGlobal("AllowCastToBytes", false)) {}
+
+void ProTypeReinterpretCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowCastToBytes", AllowCastToBytes);
+}
+
 void ProTypeReinterpretCastCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
 }
 
 void ProTypeReinterpretCastCheck::check(
 const MatchFinder::MatchResult &Result) {
-  const auto *MatchedCast =
-  Result.Nodes.getNodeAs("cast");
-  diag(MatchedCast->getOperatorLoc(), "do not use reinterpret_cast");
+
+  if (const auto *MatchedCast =
+  Result.Nodes.getNodeAs("cast")) {
+ASTContext const &Ctx = *Result.Context;
+if (AllowCastToBytes && isCastToBytes(Ctx, *MatchedCast))
+  return;
+
+diag(MatchedCast->getOperatorLoc(), "do not use reinterpret_cast");
+  }
 }
 
 } // namespace clang::tidy::cppcoreguidelines
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
index da001bfb85d787..66b46ba7e9f5b9 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
@@ -19,13 +19,16 @@ namespace clang::tidy::cppcoreguidelines {
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/pro-type-reinterpret-cast.html
 class ProTypeReinterpretCastCheck : public ClangTidyCheck {
 public:
-  ProTypeReinterpretCastCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  ProTypeReinterpretCastCheck(StringRef Name, ClangTidyContext *Context);
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
 return LangOpts.CPlusPlus;
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:
+  const bool AllowCastToBytes;
 };
 
 } // namespace clang::tidy::cppcoreguidelines
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index b001a6ad446695..1b38a3572e02f3 100644
--- a/clang-tools-

[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

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

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


[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

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

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


[clang] [Clang] Workaround dependent source location issues (PR #106925)

2024-09-01 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

Does it fix #80210?

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


[clang] [clang] The ms-extension __noop should return zero in a constexpr context. (PR #106849)

2024-09-01 Thread via cfe-commits

c8ef wrote:

Hi, could you please take a look? @tbaederr 

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


[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

2024-09-01 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-aarch64-linux` 
running on `sanitizer-buildbot7` while building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/51/builds/3210


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[4406/5255] Building CXX object 
tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransGCCalls.cpp.o
[4407/5255] Building CXX object 
tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransZeroOutPropsInDealloc.cpp.o
[4408/5255] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ChainedIncludesSource.cpp.o
[4409/5255] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReaderStmt.cpp.o
[4410/5255] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/FixIt.cpp.o
[4411/5255] Building CXX object 
tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransProperties.cpp.o
[4412/5255] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/InitPreprocessor.cpp.o
[4413/5255] Building CXX object 
tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/Rename/SymbolOccurrences.cpp.o
[4414/5255] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ModuleDependencyCollector.cpp.o
[4415/5255] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
FAILED: 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/b/sanitizer-aarch64-linux/build/llvm_build0/bin/clang++ 
-DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/b/sanitizer-aarch64-linux/build/build_default/tools/clang/lib/Serialization
 -I/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/include 
-I/home/b/sanitizer-aarch64-linux/build/build_default/tools/clang/include 
-I/home/b/sanitizer-aarch64-linux/build/build_default/include 
-I/home/b/sanitizer-aarch64-linux/build/llvm-project/llvm/include -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -MF 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o.d
 -o 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -c 
/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp
/home/b/sanitizer-aarch64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:7800:11:
 error: enumeration value 'NUM_PREDEF_DECL_IDS' not handled in switch 
[-Werror,-Wswitch]
 7800 |   switch (ID) {
  |   ^~
1 error generated.
[4416/5255] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterDecl.cpp.o
[4417/5255] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterStmt.cpp.o
[4418/5255] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/TestModuleFileExtension.cpp.o
[4419/5255] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CommonOptionsParser.cpp.o
[4420/5255] Building CXX object 
tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransUnusedInitDelegate.cpp.o
[4421/5255] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Execution.cpp.o
[4422/5255] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/ExpandResponseFilesCompilationDatabase.cpp.o
[4423/5255] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/PrecompiledPreamble.cpp.o
[4424/5255] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/CompilationDatabase.cpp.o
[4425/5255] Building CXX object 
tools/clang/lib/Tooling/Inclusions/Stdlib/CMakeFiles/obj.clangToolingInclusionsStdlib.dir/StandardLibrary.cpp.o
[4426/5255] Building CXX object 
tools/clang

[clang] [clang-format] Add new option: WrapNamespaceBodyWithEmptyLines (PR #106901)

2024-09-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (dmasloff)


Changes

I would like to suggest a new clang-format option for llvm-project - 
WrapNamespaceBodyWithNewlines. I think it can be added to upstream since it is 
used by many popular public repositories, for example, 
[ytsaurus](https://github.com/ytsaurus/ytsaurus/). You can look through their 
style guide at this page: 
https://github.com/ytsaurus/ytsaurus/blob/main/yt/styleguide/cpp.md#namespaces

As you can see from the name of the option it wraps the body of namespace with 
additional newlines turning this code:
```
namespace N {
int function();
} 
 ```
into that:
```
namespace N {

int function();

} 
 ```
Looking forward to your advices and recommendations

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


5 Files Affected:

- (modified) clang/docs/ClangFormatStyleOptions.rst (+42) 
- (modified) clang/include/clang/Format/Format.h (+39-1) 
- (modified) clang/lib/Format/Format.cpp (+15) 
- (modified) clang/lib/Format/UnwrappedLineFormatter.cpp (+42) 
- (modified) clang/unittests/Format/FormatTest.cpp (+205) 


``diff
diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index a427d7cd40fcdd..06ac88fc337983 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6652,6 +6652,48 @@ the configuration (without a prefix: ``Auto``).
 
   For example: BOOST_PP_STRINGIZE
 
+.. _WrapNamespaceBodyWithEmptyLines:
+
+**WrapNamespaceBodyWithEmptyLines** (``WrapNamespaceBodyWithEmptyLinesStyle``) 
:versionbadge:`clang-format 19` :ref:`¶ `
+  Controls number of empty lines at the begging and at the end of
+  namespace definition.
+
+  Possible values:
+
+  * ``WNBWELS_Never`` (in configuration: ``Never``)
+Removes all empty lines at the beginning and at the end of
+namespace definition.
+
+.. code-block:: c++
+
+  namespace N1 {
+  namespace N2
+function();
+  }
+  }
+
+  * ``WNBWELS_Always`` (in configuration: ``Always``)
+Always adds an empty line at the beginning and at the end of
+namespace definition. MaxEmptyLinesToKeep is also applied, but
+empty lines between consecutive namespace declarations are
+always removed.
+
+.. code-block:: c++
+
+  namespace N1 {
+  namespace N2 {
+
+function();
+
+  }
+  }
+
+  * ``WNBWELS_Leave`` (in configuration: ``Leave``)
+Keeps existing newlines at the beginning and at the end of
+namespace definition using MaxEmptyLinesToKeep for formatting.
+
+
+
 .. END_FORMAT_STYLE_OPTIONS
 
 Adding additional style options
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index d8b62c7652a0f6..963c7cbe1f8809 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -5057,6 +5057,43 @@ struct FormatStyle {
   /// \version 11
   std::vector WhitespaceSensitiveMacros;
 
+  /// Different styles for modify number of empty lines in
+  /// the beginning and at the of end of namespaces.
+  enum WrapNamespaceBodyWithEmptyLinesStyle : int8_t {
+/// Removes all empty lines at the beginning and at the end of
+/// namespace definition.
+/// \code
+///   namespace N1 {
+///   namespace N2
+/// function();
+///   }
+///   }
+/// \endcode
+WNBWELS_Never,
+/// Always adds an empty line at the beginning and at the end of
+/// namespace definition. MaxEmptyLinesToKeep is also applied, but
+/// empty lines between consecutive namespace declarations are
+/// always removed.
+/// \code
+///   namespace N1 {
+///   namespace N2 {
+///
+/// function();
+///
+///   }
+///   }
+/// \endcode
+WNBWELS_Always,
+/// Keeps existing newlines at the beginning and at the end of
+/// namespace definition using MaxEmptyLinesToKeep for formatting.
+WNBWELS_Leave
+  };
+
+  /// Controls number of empty lines at the begging and at the end of
+  /// namespace definition.
+  /// \version 19
+  WrapNamespaceBodyWithEmptyLinesStyle WrapNamespaceBodyWithEmptyLines;
+
   bool operator==(const FormatStyle &R) const {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
@@ -5234,7 +5271,8 @@ struct FormatStyle {
TypenameMacros == R.TypenameMacros && UseTab == R.UseTab &&
VerilogBreakBetweenInstancePorts ==
R.VerilogBreakBetweenInstancePorts &&
-   WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
+   WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros &&
+   WrapNamespaceBodyWithEmptyLines == 
R.WrapNamespaceBodyWithEmptyLines;
   }
 
   std::optional GetLanguageStyle(LanguageKind Language) const;
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d2463b892fbb96..b0d2836e9c69c2 100644
--- a/clang/lib/Form

[clang] [clang-format] Correctly identify token-pasted record names (PR #106484)

2024-09-01 Thread Owen Pan via cfe-commits

owenca wrote:

/cherry-pick 
https://github.com/llvm/llvm-project/commit/7579787e05966f21684dd4b4a15b9deac13d09e1

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


[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

2024-09-01 Thread via cfe-commits


@@ -1012,7 +1012,14 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // possible that e.g. constraints involving C> and C are
   // perceived identical.
   std::optional ContextScope;
-  if (auto *RD = dyn_cast(DeclInfo.getDeclContext())) {
+  const DeclContext *DC = [&] {
+if (!DeclInfo.getDecl())
+  return DeclInfo.getDeclContext();
+return DeclInfo.getDecl()->getFriendObjectKind()
+   ? DeclInfo.getLexicalDeclContext()
+   : DeclInfo.getDeclContext();

cor3ntin wrote:

I wonder if we should have a function that handles that logic of getting a 
lexical context for friends - we do it in a few places

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


[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

2024-09-01 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`ppc64le-lld-multistage-test` running on `ppc64le-lld-multistage-test` while 
building `clang` at step 12 "build-stage2-unified-tree".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/168/builds/2806


Here is the relevant piece of the build log for the reference

```
Step 12 (build-stage2-unified-tree) failure: build (failure)
...
381.137 [924/412/4899] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaModule.cpp.o
381.233 [924/411/4900] Building CXX object 
lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/SMEPeepholeOpt.cpp.o
381.304 [924/410/4901] Building CXX object 
lib/Target/Mips/CMakeFiles/LLVMMipsCodeGen.dir/MipsTargetMachine.cpp.o
381.366 [923/410/4902] Building CXX object 
tools/clang/tools/clang-import-test/CMakeFiles/clang-import-test.dir/clang-import-test.cpp.o
381.424 [923/409/4903] Linking CXX static library lib/libLLVMMipsCodeGen.a
381.508 [923/408/4904] Building CXX object 
lib/Target/ARM/CMakeFiles/LLVMARMCodeGen.dir/ARMISelDAGToDAG.cpp.o
381.595 [923/407/4905] Building CXX object 
tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/NumberObjectConversionChecker.cpp.o
381.664 [923/406/4906] Building CXX object 
lib/Target/AArch64/CMakeFiles/LLVMAArch64CodeGen.dir/AArch64StorePairSuppress.cpp.o
381.671 [923/405/4907] Building CXX object 
tools/clang/tools/clang-refactor/CMakeFiles/clang-refactor.dir/ClangRefactor.cpp.o
381.688 [923/404/4908] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
FAILED: 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 
ccache 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/install/stage1/bin/clang++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/lib/Serialization
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Serialization
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/build/stage2/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -MF 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o.d
 -o 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Serialization/ASTReader.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-lld-multistage-test/ppc64le-lld-multistage-test/llvm-project/clang/lib/Serialization/ASTReader.cpp:7800:11:
 error: enumeration value 'NUM_PREDEF_DECL_IDS' not handled in switch 
[-Werror,-Wswitch]
 7800 |   switch (ID) {
  |   ^~
1 error generated.
381.697 [923/403/4909] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/LoopUnrolling.cpp.o
381.732 [923/402/4910] Building CXX object 
unittests/Target/AArch64/CMakeFiles/AArch64Tests.dir/Immediates.cpp.o
381.755 [923/401/4911] Building CXX object 
lib/Target/X86/CMakeFiles/LLVMX86CodeGen.dir/X86LoadValueInjectionLoadHardening.cpp.o
381.789 [923/400/4912] Building CXX object 
tools/clang/unittests/Frontend/CMakeFiles/FrontendTests.dir/UtilsTest.cpp.o
381.822 [923/399/4913] Building CXX object 
tools/clang/unittests/AST/CMakeFiles/ASTTests.dir/ExternalASTSourceTest.cpp.o
381.837 [923/398/4914] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CG

[clang] [llvm] [LTO] Reduce memory usage for import lists (PR #106772)

2024-09-01 Thread Kazu Hirata via cfe-commits

kazutakahirata wrote:

> It looks like this causes a compile-time regression. The clang thin link time 
> increases by 1% 
> (https://llvm-compile-time-tracker.com/compare_clang.php?from=9ccf82543d509bb5a0f5d0551fc4d6c1913b9a9b&to=5c0d61e318a77434487fcec8361d8110fb06e59d&stat=instructions%3Au).
>  There is no regression for thin link on CTMark, so the regression here 
> probably scales with the number of modules involved in the link, so is likely 
> even larger for larger applications.

Thank you for reporting this!  Let me look into this.

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


[clang] 5c0d61e - [LTO] Reduce memory usage for import lists (#106772)

2024-09-01 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-09-01T08:36:06-07:00
New Revision: 5c0d61e318a77434487fcec8361d8110fb06e59d

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

LOG: [LTO] Reduce memory usage for import lists (#106772)

This patch reduces the memory usage for import lists by employing
memory-efficient data structures.

With this patch, an import list for a given destination module is
basically DenseSet with each element indexing into the
deduplication table containing tuples of:

  {SourceModule, GUID, Definition/Declaration}

In one of our large applications, the peak memory usage goes down by
9.2% from 6.120GB to 5.555GB during the LTO indexing step.

This patch addresses several sources of space inefficiency associated
with std::unordered_map:

- std::unordered_map takes up 16 bytes because of
  padding even though ImportKind only carries one bit of information.

- std::unordered_map uses pointers to elements, both in the hash table
  proper and for collision chains.

- We allocate an instance of std::unordered_map for each
  {Destination Module, Source Module} pair for which we have at least
  one import.  Most import lists have less than 10 imports, so the
  metadata like the size of std::unordered_map and the pointer to the
  hash table costs a lot relative to the actual contents.

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp
llvm/include/llvm/Transforms/IPO/FunctionImport.h
llvm/lib/LTO/LTO.cpp
llvm/lib/Transforms/IPO/FunctionImport.cpp
llvm/tools/llvm-link/llvm-link.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 564efa3181d188..7fa69420298160 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1206,7 +1206,8 @@ static void runThinLTOBackend(
   // We can simply import the values mentioned in the combined index, since
   // we should only invoke this using the individual indexes written out
   // via a WriteIndexesThinBackend.
-  FunctionImporter::ImportMapTy ImportList;
+  FunctionImporter::ImportIDTable ImportIDs;
+  FunctionImporter::ImportMapTy ImportList(ImportIDs);
   if (!lto::initImportList(*M, *CombinedIndex, ImportList))
 return;
 

diff  --git a/llvm/include/llvm/Transforms/IPO/FunctionImport.h 
b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
index 99fe110191dec9..b5b328d96b2737 100644
--- a/llvm/include/llvm/Transforms/IPO/FunctionImport.h
+++ b/llvm/include/llvm/Transforms/IPO/FunctionImport.h
@@ -21,8 +21,6 @@
 #include 
 #include 
 #include 
-#include 
-#include 
 #include 
 
 namespace llvm {
@@ -33,14 +31,6 @@ class Module;
 /// based on the provided summary informations.
 class FunctionImporter {
 public:
-  /// The functions to import from a source module and their import type.
-  /// Note we choose unordered_map over (Small)DenseMap. The number of imports
-  /// from a source module could be small but DenseMap size grows to 64 quickly
-  /// and not memory efficient (see
-  /// https://llvm.org/docs/ProgrammersManual.html#llvm-adt-densemap-h)
-  using FunctionsToImportTy =
-  std::unordered_map;
-
   /// The 
diff erent reasons selectCallee will chose not to import a
   /// candidate.
   enum class ImportFailureReason {
@@ -156,6 +146,12 @@ class FunctionImporter {
   return std::make_tuple(FromModule, GUID, Kind);
 }
 
+// The same as lookup above.  Useful for map_iterator.
+std::tuple
+operator()(ImportIDTable::ImportIDTy ImportID) const {
+  return lookup(ImportID);
+}
+
   private:
 // Make a pair of import IDs [Def, Decl] from an index into TheTable.
 static std::pair makeIDPair(ImportIDTy Index) {
@@ -167,6 +163,9 @@ class FunctionImporter {
 MapVector, ImportIDTy> TheTable;
   };
 
+  // Forward-declare SortedImportList for ImportMapTy.
+  class SortedImportList;
+
   /// The map maintains the list of imports.  Conceptually, it is a collection
   /// of tuples of the form:
   ///
@@ -179,8 +178,6 @@ class FunctionImporter {
   /// path string table).
   class ImportMapTy {
   public:
-using ImportMapTyImpl = DenseMap;
-
 enum class AddDefinitionStatus {
   // No change was made to the list of imports or whether each import 
should
   // be imported as a declaration or definition.
@@ -192,6 +189,9 @@ class FunctionImporter {
   ChangedToDefinition,
 };
 
+ImportMapTy() = delete;
+ImportMapTy(ImportIDTable &IDs) : IDs(IDs) {}
+
 // Add the given GUID to ImportList as a definition.  If the same GUID has
 // been added as a declaration previously, that entry is overridden.
 AddDefinitionStatus addDefinition(StringRef FromModule,
@@ -215,13 +215,49 @@ class FunctionImporter {
 SmallVector getSourceModules() const;
 
 std::opt

[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

2024-09-01 Thread via cfe-commits

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


[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

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


@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager 
&SourceMgr,
   return false;
 }
 
+static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) {

a-tarasyuk wrote:

The reason I asked is that I recall clang has a predefined macro, 
`__has_cpp_attribute`, which relies on `hasAttribute`. This function uses a 
list of existing attributes generated from `Attr.td` for different _`Syntax`_. 
Should attributes currently defined in clang (for example, `indeterminate` 
isn’t defined yet) be disallowed _(maybe `hasAttribute` could be reused)_, or 
should all cpp attribute names from the standard be considered _(even if Clang 
doesn’t fully support it)_?

--- 

https://github.com/llvm/llvm-project/blob/357bd61744bb8cc2b9b07447294fa977e5758550/clang/lib/Lex/PPMacroExpansion.cpp#L1915-L1920

https://github.com/llvm/llvm-project/blob/357bd61744bb8cc2b9b07447294fa977e5758550/clang/lib/Basic/Attributes.cpp#L31

https://github.com/llvm/llvm-project/blob/357bd61744bb8cc2b9b07447294fa977e5758550/clang/lib/Basic/Attributes.cpp#L26

```
...
if (ScopeName == "") {
  return llvm::StringSwitch(Name)
.Case("noreturn", 200809)
.Case("assume", 202207)
.Case("carries_dependency", 200809)
.Case("deprecated", 201309)
.Case("fallthrough", 201603)
.Case("likely", 201803)
.Case("no_unique_address", true && ( Target.getCXXABI().isItaniumFamily() ) 
? 201803 : 0)
.Case("unlikely", 201803)
.Case("maybe_unused", 201603)
.Case("nodiscard", 201907)
.Default(0);
...
```

--- 

Should this one handle the standard versions too?
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/clang/lib/Parse/ParseDeclCXX.cpp#L4689-L4708

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


[clang] [clang-format] Add new option: WrapNamespaceBodyWithEmptyLines (PR #106901)

2024-09-01 Thread via cfe-commits

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


[clang] [Clang][Sema] Use the correct lookup context when building overloaded 'operator->' in the current instantiation (PR #104458)

2024-09-01 Thread via cfe-commits

h-vetinari wrote:

> I think there won't be a rc4 so it's actually probably too late

You have the wrong handle, on github it's @tru. 😉 Also, RC4 is being 
[considered](https://discourse.llvm.org/t/llvm-19-1-0-final-update-and-possible-rc4/81010).

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


[clang-tools-extra] [clang-tidy] Add option to cppcoreguidelines-pro-type-reinterpret-cas… (PR #106922)

2024-09-01 Thread Carlos Galvez via cfe-commits

https://github.com/carlosgalvezp created 
https://github.com/llvm/llvm-project/pull/106922

…t to allow casts to byte types

These casts are safe according to the Standard, so add an option to allow them 
and not emit a warning. This helps silencing some noise and focusing on the 
unsafe casts.

>From 87f3bca5a4f0cdb7f560da1d11d76ee9f3ce9d0a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Carlos=20G=C3=A1lvez?= 
Date: Sun, 1 Sep 2024 19:14:22 +
Subject: [PATCH] [clang-tidy] Add option to
 cppcoreguidelines-pro-type-reinterpret-cast to allow casts to byte types

These casts are safe according to the Standard, so add an option to
allow them and not emit a warning. This helps silencing some noise
and focusing on the unsafe casts.
---
 .../ProTypeReinterpretCastCheck.cpp   | 50 +--
 .../ProTypeReinterpretCastCheck.h |  7 ++-
 clang-tools-extra/docs/ReleaseNotes.rst   |  4 ++
 .../pro-type-reinterpret-cast.rst | 19 +++
 .../pro-type-reinterpret-cast.cpp | 36 -
 5 files changed, 109 insertions(+), 7 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
index 14456caab612b7..6385dd5440901c 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.cpp
@@ -9,20 +9,64 @@
 #include "ProTypeReinterpretCastCheck.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/STLExtras.h"
+#include 
+#include 
 
 using namespace clang::ast_matchers;
 
 namespace clang::tidy::cppcoreguidelines {
 
+static bool isCastToBytes(ASTContext const &Ctx,
+  CXXReinterpretCastExpr const &Expr) {
+  // https://eel.is/c++draft/basic.lval#11.3
+  static constexpr std::array AllowedByteTypes = {
+  "char",
+  "unsigned char",
+  "std::byte",
+  };
+
+  // We only care about pointer casts
+  QualType DestType = Expr.getTypeAsWritten();
+  if (!DestType->isPointerType())
+return false;
+
+  // Get the unqualified canonical type, and check if it's allowed
+  // We need to wrap the Type into a QualType to call getAsString()
+  const Type *UnqualDestType =
+  DestType.getCanonicalType()->getPointeeType().getTypePtr();
+  std::string DestTypeString = QualType(UnqualDestType, /*Quals=*/0)
+   .getAsString(Ctx.getPrintingPolicy());
+  return llvm::any_of(AllowedByteTypes, [DestTypeString](StringRef Type) {
+return Type == DestTypeString;
+  });
+}
+
+ProTypeReinterpretCastCheck::ProTypeReinterpretCastCheck(
+StringRef Name, ClangTidyContext *Context)
+: ClangTidyCheck(Name, Context),
+  AllowCastToBytes(Options.getLocalOrGlobal("AllowCastToBytes", false)) {}
+
+void ProTypeReinterpretCastCheck::storeOptions(
+ClangTidyOptions::OptionMap &Opts) {
+  Options.store(Opts, "AllowCastToBytes", AllowCastToBytes);
+}
+
 void ProTypeReinterpretCastCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(cxxReinterpretCastExpr().bind("cast"), this);
 }
 
 void ProTypeReinterpretCastCheck::check(
 const MatchFinder::MatchResult &Result) {
-  const auto *MatchedCast =
-  Result.Nodes.getNodeAs("cast");
-  diag(MatchedCast->getOperatorLoc(), "do not use reinterpret_cast");
+
+  if (const auto *MatchedCast =
+  Result.Nodes.getNodeAs("cast")) {
+ASTContext const &Ctx = *Result.Context;
+if (AllowCastToBytes && isCastToBytes(Ctx, *MatchedCast))
+  return;
+
+diag(MatchedCast->getOperatorLoc(), "do not use reinterpret_cast");
+  }
 }
 
 } // namespace clang::tidy::cppcoreguidelines
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
index da001bfb85d787..66b46ba7e9f5b9 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeReinterpretCastCheck.h
@@ -19,13 +19,16 @@ namespace clang::tidy::cppcoreguidelines {
 /// 
http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/pro-type-reinterpret-cast.html
 class ProTypeReinterpretCastCheck : public ClangTidyCheck {
 public:
-  ProTypeReinterpretCastCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  ProTypeReinterpretCastCheck(StringRef Name, ClangTidyContext *Context);
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
 return LangOpts.CPlusPlus;
   }
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:
+  const bool AllowCastToBytes;
 };
 
 } // 

[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

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

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

This doesn't seem to have any use other than the possibility of merge conflicts 
and accidentally forgetting to update `NUM_PREDEF_DECL_IDS`.


>From 29cd14dff005175d30598f19a370b6ebb48a8c0e Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Sun, 1 Sep 2024 09:52:15 +0200
Subject: [PATCH] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs

---
 clang/include/clang/AST/DeclID.h | 47 ++--
 1 file changed, 21 insertions(+), 26 deletions(-)

diff --git a/clang/include/clang/AST/DeclID.h b/clang/include/clang/AST/DeclID.h
index e5e27389fac60d..81454a247229f5 100644
--- a/clang/include/clang/AST/DeclID.h
+++ b/clang/include/clang/AST/DeclID.h
@@ -20,8 +20,6 @@
 #include "llvm/ADT/Hashing.h"
 #include "llvm/ADT/iterator.h"
 
-#include 
-
 namespace clang {
 
 /// Predefined declaration IDs.
@@ -32,65 +30,62 @@ namespace clang {
 /// it is created.
 enum PredefinedDeclIDs {
   /// The NULL declaration.
-  PREDEF_DECL_NULL_ID = 0,
+  PREDEF_DECL_NULL_ID,
 
   /// The translation unit.
-  PREDEF_DECL_TRANSLATION_UNIT_ID = 1,
+  PREDEF_DECL_TRANSLATION_UNIT_ID,
 
   /// The Objective-C 'id' type.
-  PREDEF_DECL_OBJC_ID_ID = 2,
+  PREDEF_DECL_OBJC_ID_ID,
 
   /// The Objective-C 'SEL' type.
-  PREDEF_DECL_OBJC_SEL_ID = 3,
+  PREDEF_DECL_OBJC_SEL_ID,
 
   /// The Objective-C 'Class' type.
-  PREDEF_DECL_OBJC_CLASS_ID = 4,
+  PREDEF_DECL_OBJC_CLASS_ID,
 
   /// The Objective-C 'Protocol' type.
-  PREDEF_DECL_OBJC_PROTOCOL_ID = 5,
+  PREDEF_DECL_OBJC_PROTOCOL_ID,
 
   /// The signed 128-bit integer type.
-  PREDEF_DECL_INT_128_ID = 6,
+  PREDEF_DECL_INT_128_ID,
 
   /// The unsigned 128-bit integer type.
-  PREDEF_DECL_UNSIGNED_INT_128_ID = 7,
+  PREDEF_DECL_UNSIGNED_INT_128_ID,
 
   /// The internal 'instancetype' typedef.
-  PREDEF_DECL_OBJC_INSTANCETYPE_ID = 8,
+  PREDEF_DECL_OBJC_INSTANCETYPE_ID,
 
   /// The internal '__builtin_va_list' typedef.
-  PREDEF_DECL_BUILTIN_VA_LIST_ID = 9,
+  PREDEF_DECL_BUILTIN_VA_LIST_ID,
 
   /// The internal '__va_list_tag' struct, if any.
-  PREDEF_DECL_VA_LIST_TAG = 10,
+  PREDEF_DECL_VA_LIST_TAG,
 
   /// The internal '__builtin_ms_va_list' typedef.
-  PREDEF_DECL_BUILTIN_MS_VA_LIST_ID = 11,
+  PREDEF_DECL_BUILTIN_MS_VA_LIST_ID,
 
   /// The predeclared '_GUID' struct.
-  PREDEF_DECL_BUILTIN_MS_GUID_ID = 12,
+  PREDEF_DECL_BUILTIN_MS_GUID_ID,
 
   /// The extern "C" context.
-  PREDEF_DECL_EXTERN_C_CONTEXT_ID = 13,
+  PREDEF_DECL_EXTERN_C_CONTEXT_ID,
 
   /// The internal '__make_integer_seq' template.
-  PREDEF_DECL_MAKE_INTEGER_SEQ_ID = 14,
+  PREDEF_DECL_MAKE_INTEGER_SEQ_ID,
 
   /// The internal '__NSConstantString' typedef.
-  PREDEF_DECL_CF_CONSTANT_STRING_ID = 15,
+  PREDEF_DECL_CF_CONSTANT_STRING_ID,
 
   /// The internal '__NSConstantString' tag type.
-  PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID = 16,
+  PREDEF_DECL_CF_CONSTANT_STRING_TAG_ID,
 
   /// The internal '__type_pack_element' template.
-  PREDEF_DECL_TYPE_PACK_ELEMENT_ID = 17,
-};
+  PREDEF_DECL_TYPE_PACK_ELEMENT_ID,
 
-/// The number of declaration IDs that are predefined.
-///
-/// For more information about predefined declarations, see the
-/// \c PredefinedDeclIDs type and the PREDEF_DECL_*_ID constants.
-const unsigned int NUM_PREDEF_DECL_IDS = 18;
+  /// The number of declaration IDs that are predefined.
+  NUM_PREDEF_DECL_IDS
+};
 
 /// GlobalDeclID means DeclID in the current ASTContext and LocalDeclID means
 /// DeclID specific to a certain ModuleFile. Specially, in ASTWriter, the

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


[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-01 Thread via cfe-commits

https://github.com/nebulark updated 
https://github.com/llvm/llvm-project/pull/106369

>From 60332916c1fba8ad20d3353e279a867807f46273 Mon Sep 17 00:00:00 2001
From: Florian Schmiderer 
Date: Wed, 28 Aug 2024 12:36:39 +0200
Subject: [PATCH 1/7] Flatten compiler args in Frontend, keep existing
 behaviour as fallback for other frontends

---
 clang/lib/CodeGen/BackendUtil.cpp | 38 +++
 llvm/include/llvm/MC/MCTargetOptions.h|  7 
 llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 15 ++--
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 564efa3181d188..3ddc6704383016 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -50,6 +50,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -322,6 +323,41 @@ static bool actionRequiresCodeGen(BackendAction Action) {
  Action != Backend_EmitLL;
 }
 
+static std::string flattenClangCommandLine(ArrayRef Args,
+  StringRef MainFilename) {
+  std::string FlatCmdLine;
+  raw_string_ostream OS(FlatCmdLine);
+  bool PrintedOneArg = false;
+  if (!StringRef(Args[0]).contains("-cc1")) {
+llvm::sys::printArg(OS, "-cc1", /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  for (unsigned i = 0; i < Args.size(); i++) {
+StringRef Arg = Args[i];
+if (Arg.empty()) {
+  continue;
+}
+if (Arg == "-main-file-name" || Arg == "-o") {
+  i++; // Skip this argument and next one.
+  continue;
+}
+if (Arg.starts_with("-object-file-name") || Arg == MainFilename) {
+  continue;
+}
+// Skip fmessage-length for reproduciability.
+if (Arg.starts_with("-fmessage-length")) {
+  continue;
+}
+if (PrintedOneArg) {
+  OS << " ";
+}
+llvm::sys::printArg(OS, Arg, /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  OS.flush();
+  return FlatCmdLine;
+}
+
 static bool initTargetOptions(DiagnosticsEngine &Diags,
   llvm::TargetOptions &Options,
   const CodeGenOptions &CodeGenOpts,
@@ -486,6 +522,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
   Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
   Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
+  Options.MCOptions.CommandlineArgsFlat = flattenClangCommandLine(
+  CodeGenOpts.CommandLineArgs, CodeGenOpts.MainFileName);
   Options.MCOptions.AsSecureLogFile = CodeGenOpts.AsSecureLogFile;
   Options.MCOptions.PPCUseFullRegisterNames =
   CodeGenOpts.PPCUseFullRegisterNames;
diff --git a/llvm/include/llvm/MC/MCTargetOptions.h 
b/llvm/include/llvm/MC/MCTargetOptions.h
index a5371b3387a13d..0937089d8a2c80 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -96,8 +96,15 @@ class MCTargetOptions {
   std::string AsSecureLogFile;
 
   const char *Argv0 = nullptr;
+
+  // Deprecated: Use FlatCommandlineArgs instead
+  // Arguments here are interpreted as coming from clang, formated and end up 
in LF_BUILDINFO as CommandLineArgs 
   ArrayRef CommandLineArgs;
 
+  // Arguments here end up in LF_BUILDINFO as CommandLineArgs without any 
additional formating
+  // If empty falls back to CommandLineArgs
+  std::string CommandlineArgsFlat;
+
   /// Additional paths to search for `.include` directives when using the
   /// integrated assembler.
   std::vector IASSearchPaths;
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 7700ffd6da8030..60387e4688996b 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -893,6 +893,8 @@ static TypeIndex getStringIdTypeIdx(GlobalTypeTableBuilder 
&TypeTable,
   return TypeTable.writeLeafType(SIR);
 }
 
+// This just exists for backwards compatability for the deprecated 
MCTargetOptions::CommandLineArgs
+// It assumed a clang compiler frontend
 static std::string flattenCommandLine(ArrayRef Args,
   StringRef MainFilename) {
   std::string FlatCmdLine;
@@ -950,9 +952,16 @@ void CodeViewDebug::emitBuildInfo() {
   if (Asm->TM.Options.MCOptions.Argv0 != nullptr) {
 BuildInfoArgs[BuildInfoRecord::BuildTool] =
 getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
-BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
-TypeTable, 
flattenCommandLine(Asm->TM.Options.MCOptions.CommandLineArgs,
-  MainSourceFile->getFilename()));
+
+if (!Asm->TM.Options.MCOptions.CommandlineArgsFlat.e

[clang] [clang-format] Correctly identify token-pasted record names (PR #106484)

2024-09-01 Thread via cfe-commits

llvmbot wrote:

/pull-request llvm/llvm-project#106900

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


[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

2024-09-01 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-x86_64-linux` 
running on `sanitizer-buildbot1` while building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/66/builds/3339


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[4416/5259] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGDebugInfo.cpp.o
[4417/5259] Building CXX object 
tools/clang/lib/Analysis/CMakeFiles/obj.clangAnalysis.dir/ReachableCode.cpp.o
[4418/5259] Building CXX object 
tools/clang/lib/FrontendTool/CMakeFiles/obj.clangFrontendTool.dir/ExecuteCompilerInvocation.cpp.o
[4419/5259] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/PrecompiledPreamble.cpp.o
[4420/5259] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/CommonBugCategories.cpp.o
[4421/5259] Building CXX object 
tools/clang/lib/Analysis/FlowSensitive/CMakeFiles/obj.clangAnalysisFlowSensitive.dir/ASTOps.cpp.o
[4422/5259] Building CXX object 
tools/clang/lib/Frontend/Rewrite/CMakeFiles/obj.clangRewriteFrontend.dir/FrontendActions.cpp.o
[4423/5259] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaTemplateDeduction.cpp.o
[4424/5259] Building CXX object 
tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/AtomicChange.cpp.o
[4425/5259] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
FAILED: 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/b/sanitizer-x86_64-linux/build/llvm_build0/bin/clang++ -DGTEST_HAS_RTTI=0 
-D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/b/sanitizer-x86_64-linux/build/build_default/tools/clang/lib/Serialization
 -I/home/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Serialization 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/clang/include 
-I/home/b/sanitizer-x86_64-linux/build/build_default/tools/clang/include 
-I/home/b/sanitizer-x86_64-linux/build/build_default/include 
-I/home/b/sanitizer-x86_64-linux/build/llvm-project/llvm/include -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -MF 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o.d
 -o 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -c 
/home/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp
/home/b/sanitizer-x86_64-linux/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:7800:11:
 error: enumeration value 'NUM_PREDEF_DECL_IDS' not handled in switch 
[-Werror,-Wswitch]
 7800 |   switch (ID) {
  |   ^~
1 error generated.
[4426/5259] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReaderStmt.cpp.o
[4427/5259] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterStmt.cpp.o
[4428/5259] Building CXX object 
tools/clang/lib/Tooling/Refactoring/CMakeFiles/obj.clangToolingRefactoring.dir/RefactoringActions.cpp.o
[4429/5259] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterDecl.cpp.o
[4430/5259] Building CXX object 
tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransAPIUses.cpp.o
[4431/5259] Building CXX object 
tools/clang/lib/Index/CMakeFiles/obj.clangIndex.dir/FileIndexRecord.cpp.o
[4432/5259] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/FrontendAction.cpp.o
[4433/5259] Building CXX object 
tools/clang/lib/Tooling/CMakeFiles/obj.clangTooling.dir/Tooling.cpp.o
[4434/5259] Building CXX object 
tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransARCAssign.cpp.o
[4435/5259] Building CXX object 
tools/clang/lib/Tooling/Transformer/CMakeFiles/obj.clangTransformer.dir/SourceCode.cpp.o
[4436/5259] Building CXX object 
tools/clang/lib/Index/CMakeFiles/obj.clan

[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-01 Thread Saleem Abdulrasool via cfe-commits


@@ -321,6 +322,41 @@ static bool actionRequiresCodeGen(BackendAction Action) {
  Action != Backend_EmitLL;
 }
 
+static std::string flattenClangCommandLine(ArrayRef Args,
+  StringRef MainFilename) {
+  std::string FlatCmdLine;
+  raw_string_ostream OS(FlatCmdLine);
+  bool PrintedOneArg = false;
+  if (!StringRef(Args[0]).contains("-cc1")) {
+llvm::sys::printArg(OS, "-cc1", /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  for (unsigned i = 0; i < Args.size(); i++) {

compnerd wrote:

Okay

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


[clang] [clang-format] Add new option: WrapNamespaceBodyWithNewlines (PR #106145)

2024-09-01 Thread via cfe-commits

https://github.com/dmasloff updated 
https://github.com/llvm/llvm-project/pull/106145

>From 219424f9cd3477d9290c8766eaa857234a1ae387 Mon Sep 17 00:00:00 2001
From: dmasloff 
Date: Mon, 26 Aug 2024 22:11:05 +0300
Subject: [PATCH] [clang-format] Add new option: WrapNamespaceBodyWithNewlines

---
 clang/docs/ClangFormatStyleOptions.rst  |  42 
 clang/include/clang/Format/Format.h |  40 +++-
 clang/lib/Format/Format.cpp |  15 ++
 clang/lib/Format/UnwrappedLineFormatter.cpp |  42 
 clang/unittests/Format/FormatTest.cpp   | 205 
 5 files changed, 343 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index a427d7cd40fcdd..06ac88fc337983 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6652,6 +6652,48 @@ the configuration (without a prefix: ``Auto``).
 
   For example: BOOST_PP_STRINGIZE
 
+.. _WrapNamespaceBodyWithEmptyLines:
+
+**WrapNamespaceBodyWithEmptyLines** (``WrapNamespaceBodyWithEmptyLinesStyle``) 
:versionbadge:`clang-format 19` :ref:`¶ `
+  Controls number of empty lines at the begging and at the end of
+  namespace definition.
+
+  Possible values:
+
+  * ``WNBWELS_Never`` (in configuration: ``Never``)
+Removes all empty lines at the beginning and at the end of
+namespace definition.
+
+.. code-block:: c++
+
+  namespace N1 {
+  namespace N2
+function();
+  }
+  }
+
+  * ``WNBWELS_Always`` (in configuration: ``Always``)
+Always adds an empty line at the beginning and at the end of
+namespace definition. MaxEmptyLinesToKeep is also applied, but
+empty lines between consecutive namespace declarations are
+always removed.
+
+.. code-block:: c++
+
+  namespace N1 {
+  namespace N2 {
+
+function();
+
+  }
+  }
+
+  * ``WNBWELS_Leave`` (in configuration: ``Leave``)
+Keeps existing newlines at the beginning and at the end of
+namespace definition using MaxEmptyLinesToKeep for formatting.
+
+
+
 .. END_FORMAT_STYLE_OPTIONS
 
 Adding additional style options
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index d8b62c7652a0f6..963c7cbe1f8809 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -5057,6 +5057,43 @@ struct FormatStyle {
   /// \version 11
   std::vector WhitespaceSensitiveMacros;
 
+  /// Different styles for modify number of empty lines in
+  /// the beginning and at the of end of namespaces.
+  enum WrapNamespaceBodyWithEmptyLinesStyle : int8_t {
+/// Removes all empty lines at the beginning and at the end of
+/// namespace definition.
+/// \code
+///   namespace N1 {
+///   namespace N2
+/// function();
+///   }
+///   }
+/// \endcode
+WNBWELS_Never,
+/// Always adds an empty line at the beginning and at the end of
+/// namespace definition. MaxEmptyLinesToKeep is also applied, but
+/// empty lines between consecutive namespace declarations are
+/// always removed.
+/// \code
+///   namespace N1 {
+///   namespace N2 {
+///
+/// function();
+///
+///   }
+///   }
+/// \endcode
+WNBWELS_Always,
+/// Keeps existing newlines at the beginning and at the end of
+/// namespace definition using MaxEmptyLinesToKeep for formatting.
+WNBWELS_Leave
+  };
+
+  /// Controls number of empty lines at the begging and at the end of
+  /// namespace definition.
+  /// \version 19
+  WrapNamespaceBodyWithEmptyLinesStyle WrapNamespaceBodyWithEmptyLines;
+
   bool operator==(const FormatStyle &R) const {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
@@ -5234,7 +5271,8 @@ struct FormatStyle {
TypenameMacros == R.TypenameMacros && UseTab == R.UseTab &&
VerilogBreakBetweenInstancePorts ==
R.VerilogBreakBetweenInstancePorts &&
-   WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
+   WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros &&
+   WrapNamespaceBodyWithEmptyLines == 
R.WrapNamespaceBodyWithEmptyLines;
   }
 
   std::optional GetLanguageStyle(LanguageKind Language) const;
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d2463b892fbb96..b0d2836e9c69c2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -829,6 +829,18 @@ template <> struct 
ScalarEnumerationTraits {
   }
 };
 
+template <>
+struct ScalarEnumerationTraits<
+FormatStyle::WrapNamespaceBodyWithEmptyLinesStyle> {
+  static void
+  enumeration(IO &IO,
+  FormatStyle::WrapNamespaceBodyWithEmptyLinesStyle &Value) {
+IO.enumCase(Value, "Never", FormatStyle::WNBWELS_Never);
+IO.enumCase(Value, "Always", FormatStyle::WNBWELS_Always);
+IO.enumCase(Value, "Le

[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

2024-09-01 Thread via cfe-commits

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

LGTM

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


[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

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


@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager 
&SourceMgr,
   return false;
 }
 
+static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) {

philnik777 wrote:

Yes, that's a supported extension.

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


[clang] [clang] NFCI: don't check deduced constraints when partial ordering (PR #106882)

2024-09-01 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] The ms-extension __noop should return zero in a constexpr context. (PR #106849)

2024-09-01 Thread via cfe-commits

https://github.com/c8ef updated https://github.com/llvm/llvm-project/pull/106849

>From 6ce4604725d36afaea17cf533d422a978c4389ff Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Fri, 30 Aug 2024 15:34:34 +
Subject: [PATCH 1/6] fix cast

---
 clang/lib/AST/ExprConstant.cpp |  2 +-
 clang/test/AST/atomic-expr.c   | 10 ++
 2 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/AST/atomic-expr.c

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index e8a4d1d3c74102..0571771e2a7e7d 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -14458,7 +14458,6 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) 
{
   case CK_IntegralComplexToFloatingComplex:
   case CK_BuiltinFnToFnPtr:
   case CK_ZeroToOCLOpaqueType:
-  case CK_NonAtomicToAtomic:
   case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:
   case CK_FloatingToFixedPoint:
@@ -14482,6 +14481,7 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) 
{
   case CK_UserDefinedConversion:
   case CK_LValueToRValue:
   case CK_AtomicToNonAtomic:
+  case CK_NonAtomicToAtomic:
   case CK_NoOp:
   case CK_LValueToRValueBitCast:
   case CK_HLSLArrayRValue:
diff --git a/clang/test/AST/atomic-expr.c b/clang/test/AST/atomic-expr.c
new file mode 100644
index 00..0826a6491e8a6a
--- /dev/null
+++ b/clang/test/AST/atomic-expr.c
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+// expected-no-diagnostics
+
+typedef _Atomic char atomic_char;
+
+atomic_char counter;
+
+char load_plus_one() {
+  return ({ counter; }) + 1;
+}
\ No newline at end of file

>From f0957df83597a2c43a8510a83619ef67c918c7d6 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Sat, 31 Aug 2024 21:19:46 +0800
Subject: [PATCH 2/6] __noop should return 0

---
 clang/lib/AST/ExprConstant.cpp  | 4 ++--
 clang/test/SemaCXX/builtins.cpp | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 0571771e2a7e7d..69d2707aed9171 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12720,8 +12720,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
   }
 
   case Builtin::BI__noop:
-  // __noop always evaluates successfully
-return true;
+// __noop always evaluates successfully
+return false;
 
   case Builtin::BI__builtin_is_constant_evaluated: {
 const auto *Callee = Info.CurrentCall->getCallee();
diff --git a/clang/test/SemaCXX/builtins.cpp b/clang/test/SemaCXX/builtins.cpp
index c6fbb8b514d671..78344c45092a79 100644
--- a/clang/test/SemaCXX/builtins.cpp
+++ b/clang/test/SemaCXX/builtins.cpp
@@ -178,4 +178,5 @@ static void __builtin_cpu_init(); // expected-error 
{{static declaration of '__b
 
 #ifdef _MSC_VER
 constexpr int x = []{ __noop; return 0; }(); // expected-no-diagnostics
+static_assert([] { return __noop; }() == 0);
 #endif

>From a53cbbb4f3aaf65d0ebb49602f76d7f648e80410 Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Sat, 31 Aug 2024 21:22:47 +0800
Subject: [PATCH 3/6] Revert "fix cast"

This reverts commit 6ce4604725d36afaea17cf533d422a978c4389ff.
---
 clang/lib/AST/ExprConstant.cpp |  2 +-
 clang/test/AST/atomic-expr.c   | 10 --
 2 files changed, 1 insertion(+), 11 deletions(-)
 delete mode 100644 clang/test/AST/atomic-expr.c

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 69d2707aed9171..57040043f74193 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -14458,6 +14458,7 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) 
{
   case CK_IntegralComplexToFloatingComplex:
   case CK_BuiltinFnToFnPtr:
   case CK_ZeroToOCLOpaqueType:
+  case CK_NonAtomicToAtomic:
   case CK_AddressSpaceConversion:
   case CK_IntToOCLSampler:
   case CK_FloatingToFixedPoint:
@@ -14481,7 +14482,6 @@ bool IntExprEvaluator::VisitCastExpr(const CastExpr *E) 
{
   case CK_UserDefinedConversion:
   case CK_LValueToRValue:
   case CK_AtomicToNonAtomic:
-  case CK_NonAtomicToAtomic:
   case CK_NoOp:
   case CK_LValueToRValueBitCast:
   case CK_HLSLArrayRValue:
diff --git a/clang/test/AST/atomic-expr.c b/clang/test/AST/atomic-expr.c
deleted file mode 100644
index 0826a6491e8a6a..00
--- a/clang/test/AST/atomic-expr.c
+++ /dev/null
@@ -1,10 +0,0 @@
-// RUN: %clang_cc1 -fsyntax-only %s -verify
-// expected-no-diagnostics
-
-typedef _Atomic char atomic_char;
-
-atomic_char counter;
-
-char load_plus_one() {
-  return ({ counter; }) + 1;
-}
\ No newline at end of file

>From a3727d3ab517a78b85792378b473f3d531e8532c Mon Sep 17 00:00:00 2001
From: c8ef 
Date: Sat, 31 Aug 2024 22:11:24 +0800
Subject: [PATCH 4/6] __noop should return 0

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

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 57040043f74193..55b51c2d25f7f6 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b

[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

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

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


[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

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

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


[clang] [clang-format] Add new option: WrapNamespaceBodyWithNewlines (PR #106145)

2024-09-01 Thread via cfe-commits

dmasloff wrote:

> Please run `git clang-format HEAD~` and `ninja clang-format-check-format` 
> before pushing.

Maybe it's only my problem, but i get this message running `git clang-format 
HEAD~`, hopefully I could fix it all manually using `ninja 
clang-format-check-format`:
```
/Users/daniilmaslov/llvm-project-copy/clang/include/clang/Format/.clang-format:1:1:
 error: Unknown value for BasedOnStyle: clang-format
BasedOnStyle: clang-format
^
Error reading 
/Users/daniilmaslov/llvm-project-copy/clang/include/clang/Format/.clang-format: 
Invalid argument
error: `clang-format -lines=5060:5096 -lines=5274:5275 
clang/include/clang/Format/Format.h` failed
```

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


[clang] [Clang] Workaround dependent source location issues (PR #106925)

2024-09-01 Thread via cfe-commits

https://github.com/cor3ntin created 
https://github.com/llvm/llvm-project/pull/106925

In #78436 we made some SourceLocExpr dependent to
deal with the fact that their value should reflect the name of specialized 
function - rather than the rtemplate in which they are first used.

However SourceLocExpr are unusual in two ways
 - They don't depend on template argumente
 - They morally depend on the context in which they are used (rather than 
called from).

It's fair to say that this is quite novels and confuses clang. In particular, 
in some cases, we used to create dependent SourceLocExpr and never subsequently 
transform them, leaving dependent objects in instantiated functions types. To 
work around that we avoid replacing SourceLocExpr when we think they could 
remain dependent.
It's certainly not perfect but it fixes a number of reported bugs, and seem to 
only affect scenarios in which the value of the SourceLocExpr does not matter 
(overload resolution).

Fixes #106428
Fixes #81155

>From 19a10bbf3484b358770276bf7884ee5b9bdf9623 Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Mon, 2 Sep 2024 00:22:40 +0200
Subject: [PATCH] [Clang] Workaround dependent source location issues

In #78436 we made some SourceLocExpr dependent to
deal with the fact that their value should reflect the name of
specialized function - rather than the rtemplate in which they
are first used.

However SourceLocExpr are unusual in two ways
 - They don't depend on template argumente
 - They morally depend on the context in which they are used
   (rather than called from).

It's fair to say that this is quite novels and confuses
clang. In particular, in some cases, we used to create
dependent SourceLocExpr and never subsequently transform them,
leaving dependent objects in instantiated functions types.
To work around that we avoid replacing SourceLocExpr when we think
they could remain dependent.
It's certainly not perfect but it fixes a number of reported bugs,
and seem to only affect scenarios in which the value of the
SourceLocExpr does not matter (overload resolution).

Fixes #106428
Fixes #81155
---
 clang/lib/Sema/SemaExpr.cpp| 21 +++--
 clang/test/SemaCXX/source_location.cpp | 60 ++
 2 files changed, 77 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 95f53dfefbcc52..d80d5fb516bc64 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5441,11 +5441,24 @@ struct EnsureImmediateInvocationInDefaultArgs
 
   // Rewrite to source location to refer to the context in which they are used.
   ExprResult TransformSourceLocExpr(SourceLocExpr *E) {
-if (E->getParentContext() == SemaRef.CurContext)
+DeclContext *DC = E->getParentContext();
+if (DC == SemaRef.CurContext)
   return E;
-return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
- E->getBeginLoc(), E->getEndLoc(),
- SemaRef.CurContext);
+
+// FIXME: During instantiation, because the rebuild of defaults arguments
+// is not always done in the context of the template instantiator,
+// we run the risk of producing a dependent source location
+// that would never be rebuilt.
+// This usually happen during overload resolution, or in contexts
+// where the value of the source location does not matter.
+// However, we should find a better way to deal with source location
+// of function template.
+if (!SemaRef.CurrentInstantiationScope ||
+!SemaRef.CurContext->isDependentContext() || DC->isDependentContext())
+  DC = SemaRef.CurContext;
+
+return getDerived().RebuildSourceLocExpr(
+E->getIdentKind(), E->getType(), E->getBeginLoc(), E->getEndLoc(), DC);
   }
 };
 
diff --git a/clang/test/SemaCXX/source_location.cpp 
b/clang/test/SemaCXX/source_location.cpp
index 6b3610d703e716..34177bfe287fc3 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -929,3 +929,63 @@ void test() {
 }
 
 }
+
+namespace GH106428 {
+
+struct add_fn {
+template 
+constexpr auto operator()(T lhs, T rhs,
+  const std::source_location loc = 
std::source_location::current())
+const -> T
+{
+return lhs + rhs;
+}
+};
+
+
+template 
+decltype(_Fp{}(0, 0))
+__invoke(_Fp&& __f);
+
+template
+struct type_identity { using type = T; };
+
+template
+struct invoke_result : type_identity {};
+
+using i = invoke_result::type;
+static_assert(__is_same(i, int));
+
+}
+
+#if __cplusplus >= 202002L
+
+namespace GH81155 {
+struct buff {
+  buff(buff &, const char * = __builtin_FUNCTION());
+};
+
+template 
+Ty declval();
+
+template 
+auto Call(buff arg) -> decltype(Fx{}(arg));
+
+template 
+struct F {};
+
+template 
+struct InvocableR : F(declval()))> {
+  static constexpr bool value = false;
+};
+
+template ::value>

[clang] 840d4d9 - [clang] NFCI: don't check deduced constraints when partial ordering (#106882)

2024-09-01 Thread via cfe-commits

Author: Matheus Izvekov
Date: 2024-09-01T05:11:09-03:00
New Revision: 840d4d9446ef0a49b7600b42a188148a1826e17c

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

LOG: [clang] NFCI: don't check deduced constraints when partial ordering 
(#106882)

Added: 


Modified: 
clang/lib/Sema/SemaTemplateDeduction.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplateDeduction.cpp 
b/clang/lib/Sema/SemaTemplateDeduction.cpp
index 11bc9f2d1e7484..01f18e5a325197 100644
--- a/clang/lib/Sema/SemaTemplateDeduction.cpp
+++ b/clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -3313,10 +3313,12 @@ FinishTemplateArgumentDeduction(
   if (Trap.hasErrorOccurred())
 return TemplateDeductionResult::SubstitutionFailure;
 
-  if (auto Result = CheckDeducedArgumentConstraints(S, Partial, SugaredBuilder,
-CanonicalBuilder, Info);
-  Result != TemplateDeductionResult::Success)
-return Result;
+  if (!IsPartialOrdering) {
+if (auto Result = CheckDeducedArgumentConstraints(
+S, Partial, SugaredBuilder, CanonicalBuilder, Info);
+Result != TemplateDeductionResult::Success)
+  return Result;
+  }
 
   return TemplateDeductionResult::Success;
 }
@@ -3364,13 +3366,16 @@ static TemplateDeductionResult 
FinishTemplateArgumentDeduction(
   if (Trap.hasErrorOccurred())
 return TemplateDeductionResult::SubstitutionFailure;
 
-  if (auto Result = CheckDeducedArgumentConstraints(S, Template, 
SugaredBuilder,
-CanonicalBuilder, Info);
-  Result != TemplateDeductionResult::Success)
-return Result;
+  if (!PartialOrdering) {
+if (auto Result = CheckDeducedArgumentConstraints(
+S, Template, SugaredBuilder, CanonicalBuilder, Info);
+Result != TemplateDeductionResult::Success)
+  return Result;
+  }
 
   return TemplateDeductionResult::Success;
 }
+
 /// Complete template argument deduction for DeduceTemplateArgumentsFromType.
 /// FIXME: this is mostly duplicated with the above two versions. Deduplicate
 /// the three implementations.
@@ -5595,19 +5600,8 @@ static TemplateDeductionResult 
FinishTemplateArgumentDeduction(
   TDR != TemplateDeductionResult::Success)
 return TDR;
 
-  // C++20 [temp.deduct]p5 - Only check constraints when all parameters have
-  // been deduced.
-  if (!IsIncomplete) {
-if (auto Result = CheckDeducedArgumentConstraints(S, FTD, SugaredBuilder,
-  CanonicalBuilder, Info);
-Result != TemplateDeductionResult::Success)
-  return Result;
-  }
-
-  if (Trap.hasErrorOccurred())
-return TemplateDeductionResult::SubstitutionFailure;
-
-  return TemplateDeductionResult::Success;
+  return Trap.hasErrorOccurred() ? TemplateDeductionResult::SubstitutionFailure
+ : TemplateDeductionResult::Success;
 }
 
 /// Determine whether the function template \p FT1 is at least as



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


[clang] 27e244f - [clang][AIX] Fix -print-runtime-dir on AIX (#104806)

2024-09-01 Thread via cfe-commits

Author: Jake Egan
Date: 2024-09-01T23:37:43-04:00
New Revision: 27e244f51435f8f0933969782a6faddfcbe809a6

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

LOG: [clang][AIX] Fix -print-runtime-dir on AIX (#104806)

Currently the option prints a path to a nonexistent directory with the
full triple, `lib/powerpc64-ibm-aix7.2.0.0`. It should only be
`lib/aix`.

Added: 
clang/test/Driver/aix-print-runtime-dir.c

Modified: 
clang/lib/Driver/ToolChain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 76901875c66959..64f23d43e87ee8 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -843,8 +843,8 @@ std::optional ToolChain::getRuntimePath() 
const {
   llvm::sys::path::append(P, "lib");
   if (auto Ret = getTargetSubDirPath(P))
 return Ret;
-  // Darwin does not use per-target runtime directory.
-  if (Triple.isOSDarwin())
+  // Darwin and AIX does not use per-target runtime directory.
+  if (Triple.isOSDarwin() || Triple.isOSAIX())
 return {};
   llvm::sys::path::append(P, Triple.str());
   return std::string(P);

diff  --git a/clang/test/Driver/aix-print-runtime-dir.c 
b/clang/test/Driver/aix-print-runtime-dir.c
new file mode 100644
index 00..0d68ad6fee005e
--- /dev/null
+++ b/clang/test/Driver/aix-print-runtime-dir.c
@@ -0,0 +1,11 @@
+// Test output of -print-runtime-dir on AIX
+
+// RUN: %clang -print-runtime-dir --target=powerpc-ibm-aix \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// RUN: %clang -print-runtime-dir --target=powerpc64-ibm-aix \
+// RUN:-resource-dir=%S/Inputs/resource_dir \
+// RUN:  | FileCheck --check-prefix=PRINT-RUNTIME-DIR %s
+
+// PRINT-RUNTIME-DIR: lib{{/|\\}}aix{{$}}



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


[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-01 Thread via cfe-commits

https://github.com/nebulark updated 
https://github.com/llvm/llvm-project/pull/106369

>From 60332916c1fba8ad20d3353e279a867807f46273 Mon Sep 17 00:00:00 2001
From: Florian Schmiderer 
Date: Wed, 28 Aug 2024 12:36:39 +0200
Subject: [PATCH 1/6] Flatten compiler args in Frontend, keep existing
 behaviour as fallback for other frontends

---
 clang/lib/CodeGen/BackendUtil.cpp | 38 +++
 llvm/include/llvm/MC/MCTargetOptions.h|  7 
 llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 15 ++--
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 564efa3181d188..3ddc6704383016 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -50,6 +50,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -322,6 +323,41 @@ static bool actionRequiresCodeGen(BackendAction Action) {
  Action != Backend_EmitLL;
 }
 
+static std::string flattenClangCommandLine(ArrayRef Args,
+  StringRef MainFilename) {
+  std::string FlatCmdLine;
+  raw_string_ostream OS(FlatCmdLine);
+  bool PrintedOneArg = false;
+  if (!StringRef(Args[0]).contains("-cc1")) {
+llvm::sys::printArg(OS, "-cc1", /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  for (unsigned i = 0; i < Args.size(); i++) {
+StringRef Arg = Args[i];
+if (Arg.empty()) {
+  continue;
+}
+if (Arg == "-main-file-name" || Arg == "-o") {
+  i++; // Skip this argument and next one.
+  continue;
+}
+if (Arg.starts_with("-object-file-name") || Arg == MainFilename) {
+  continue;
+}
+// Skip fmessage-length for reproduciability.
+if (Arg.starts_with("-fmessage-length")) {
+  continue;
+}
+if (PrintedOneArg) {
+  OS << " ";
+}
+llvm::sys::printArg(OS, Arg, /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  OS.flush();
+  return FlatCmdLine;
+}
+
 static bool initTargetOptions(DiagnosticsEngine &Diags,
   llvm::TargetOptions &Options,
   const CodeGenOptions &CodeGenOpts,
@@ -486,6 +522,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
   Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
   Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
+  Options.MCOptions.CommandlineArgsFlat = flattenClangCommandLine(
+  CodeGenOpts.CommandLineArgs, CodeGenOpts.MainFileName);
   Options.MCOptions.AsSecureLogFile = CodeGenOpts.AsSecureLogFile;
   Options.MCOptions.PPCUseFullRegisterNames =
   CodeGenOpts.PPCUseFullRegisterNames;
diff --git a/llvm/include/llvm/MC/MCTargetOptions.h 
b/llvm/include/llvm/MC/MCTargetOptions.h
index a5371b3387a13d..0937089d8a2c80 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -96,8 +96,15 @@ class MCTargetOptions {
   std::string AsSecureLogFile;
 
   const char *Argv0 = nullptr;
+
+  // Deprecated: Use FlatCommandlineArgs instead
+  // Arguments here are interpreted as coming from clang, formated and end up 
in LF_BUILDINFO as CommandLineArgs 
   ArrayRef CommandLineArgs;
 
+  // Arguments here end up in LF_BUILDINFO as CommandLineArgs without any 
additional formating
+  // If empty falls back to CommandLineArgs
+  std::string CommandlineArgsFlat;
+
   /// Additional paths to search for `.include` directives when using the
   /// integrated assembler.
   std::vector IASSearchPaths;
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 7700ffd6da8030..60387e4688996b 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -893,6 +893,8 @@ static TypeIndex getStringIdTypeIdx(GlobalTypeTableBuilder 
&TypeTable,
   return TypeTable.writeLeafType(SIR);
 }
 
+// This just exists for backwards compatability for the deprecated 
MCTargetOptions::CommandLineArgs
+// It assumed a clang compiler frontend
 static std::string flattenCommandLine(ArrayRef Args,
   StringRef MainFilename) {
   std::string FlatCmdLine;
@@ -950,9 +952,16 @@ void CodeViewDebug::emitBuildInfo() {
   if (Asm->TM.Options.MCOptions.Argv0 != nullptr) {
 BuildInfoArgs[BuildInfoRecord::BuildTool] =
 getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
-BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
-TypeTable, 
flattenCommandLine(Asm->TM.Options.MCOptions.CommandLineArgs,
-  MainSourceFile->getFilename()));
+
+if (!Asm->TM.Options.MCOptions.CommandlineArgsFlat.e

[clang] [lld] [llvm] [X86, lld] Add relocation R_X86_64_REX2_GOTPCRELX (PR #106681)

2024-09-01 Thread Shengchen Kan via cfe-commits

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


[clang] [clang] The ms-extension __noop should return zero in a constexpr context. (PR #106849)

2024-09-01 Thread via cfe-commits


@@ -12720,8 +12720,8 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
   }
 
   case Builtin::BI__noop:
-  // __noop always evaluates successfully
-return true;
+// __noop always evaluates successfully
+return ZeroInitialization(E);

c8ef wrote:

Done.

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


[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

2024-09-01 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`sanitizer-x86_64-linux-android` running on `sanitizer-buildbot-android` while 
building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/186/builds/1930


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[4299/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/PCHContainerOperations.cpp.o
[4300/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ObjectFilePCHContainerReader.cpp.o
[4301/5230] Building CXX object 
tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransZeroOutPropsInDealloc.cpp.o
[4302/5230] Building CXX object 
tools/clang/lib/ARCMigrate/CMakeFiles/obj.clangARCMigrate.dir/TransAutoreleasePool.cpp.o
[4303/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ModuleFile.cpp.o
[4304/5230] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ChainedDiagnosticConsumer.cpp.o
[4305/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ModuleManager.cpp.o
[4306/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GlobalModuleIndex.cpp.o
[4307/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/GeneratePCH.cpp.o
[4308/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
FAILED: 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build0/bin/clang++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/tools/clang/lib/Serialization
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Serialization
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/include
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/tools/clang/include
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm_build64/include
 
-I/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -MF 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o.d
 -o 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -c 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Serialization/ASTReader.cpp
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:7800:11:
 error: enumeration value 'NUM_PREDEF_DECL_IDS' not handled in switch 
[-Werror,-Wswitch]
 7800 |   switch (ID) {
  |   ^~
1 error generated.
[4309/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReaderStmt.cpp.o
[4310/5230] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ASTMerge.cpp.o
[4311/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterDecl.cpp.o
[4312/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterStmt.cpp.o
[4313/5230] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReaderDecl.cpp.o
[4314/5230] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ChainedIncludesSource.cpp.o
[4315/5230] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/CreateInvocationFromCommandLine.cpp.o
[4316/5230] Building CXX object 

[clang] [clang] The ms-extension __noop should return zero in a constexpr context. (PR #106849)

2024-09-01 Thread via cfe-commits

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

LGTM

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


[clang] 57ef16c - Fix -Wswitch warning after 4fef204ac42eb84e167d43ce076c9a167eae3be0

2024-09-01 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2024-09-01T15:40:44+02:00
New Revision: 57ef16c699c274b7f3eee12e5c2896e193f513c4

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

LOG: Fix -Wswitch warning after 4fef204ac42eb84e167d43ce076c9a167eae3be0

Added: 


Modified: 
clang/lib/Serialization/ASTReader.cpp

Removed: 




diff  --git a/clang/lib/Serialization/ASTReader.cpp 
b/clang/lib/Serialization/ASTReader.cpp
index bb4db089a765ce..e5a1e20a265616 100644
--- a/clang/lib/Serialization/ASTReader.cpp
+++ b/clang/lib/Serialization/ASTReader.cpp
@@ -7897,6 +7897,9 @@ Decl *ASTReader::getPredefinedDecl(PredefinedDeclIDs ID) {
   return Context.TypePackElementDecl;
 NewLoaded = Context.getTypePackElementDecl();
 break;
+  case NUM_PREDEF_DECL_IDS:
+llvm_unreachable("Invalid decl ID");
+break;
   }
 
   assert(NewLoaded && "Failed to load predefined decl?");



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


[clang] [Clang] Workaround dependent source location issues (PR #106925)

2024-09-01 Thread via cfe-commits

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


[clang] [Clang] Workaround dependent source location issues (PR #106925)

2024-09-01 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/106925

>From 6544062d2543c86a3701a035e6e18f12a87b3ffd Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Mon, 2 Sep 2024 00:22:40 +0200
Subject: [PATCH] [Clang] Workaround dependent source location issues

In #78436 we made some SourceLocExpr dependent to
deal with the fact that their value should reflect the name of
specialized function - rather than the rtemplate in which they
are first used.

However SourceLocExpr are unusual in two ways
 - They don't depend on template argumente
 - They morally depend on the context in which they are used
   (rather than called from).

It's fair to say that this is quite novels and confuses
clang. In particular, in some cases, we used to create
dependent SourceLocExpr and never subsequently transform them,
leaving dependent objects in instantiated functions types.
To work around that we avoid replacing SourceLocExpr when we think
they could remain dependent.
It's certainly not perfect but it fixes a number of reported bugs,
and seem to only affect scenarios in which the value of the
SourceLocExpr does not matter (overload resolution).

Fixes #106428
Fixes #81155
---
 clang/docs/ReleaseNotes.rst|  1 +
 clang/lib/Sema/SemaExpr.cpp| 21 +++--
 clang/test/SemaCXX/source_location.cpp | 60 ++
 3 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index fc940db4813948..159de2a694e9da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -339,6 +339,7 @@ Bug Fixes to C++ Support
 - Template parameter names are considered in the name lookup of out-of-line 
class template
   specialization right before its declaration context. (#GH64082)
 - Fixed a constraint comparison bug for friend declarations. (#GH78101)
+- Fix an issue with dependent source location expressions (#GH106428), 
(#GH81155), (#GH80210), (#GH85373)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 94bb938b53b441..f496cba7b9e51a 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5443,11 +5443,24 @@ struct EnsureImmediateInvocationInDefaultArgs
 
   // Rewrite to source location to refer to the context in which they are used.
   ExprResult TransformSourceLocExpr(SourceLocExpr *E) {
-if (E->getParentContext() == SemaRef.CurContext)
+DeclContext *DC = E->getParentContext();
+if (DC == SemaRef.CurContext)
   return E;
-return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
- E->getBeginLoc(), E->getEndLoc(),
- SemaRef.CurContext);
+
+// FIXME: During instantiation, because the rebuild of defaults arguments
+// is not always done in the context of the template instantiator,
+// we run the risk of producing a dependent source location
+// that would never be rebuilt.
+// This usually happen during overload resolution, or in contexts
+// where the value of the source location does not matter.
+// However, we should find a better way to deal with source location
+// of function template.
+if (!SemaRef.CurrentInstantiationScope ||
+!SemaRef.CurContext->isDependentContext() || DC->isDependentContext())
+  DC = SemaRef.CurContext;
+
+return getDerived().RebuildSourceLocExpr(
+E->getIdentKind(), E->getType(), E->getBeginLoc(), E->getEndLoc(), DC);
   }
 };
 
diff --git a/clang/test/SemaCXX/source_location.cpp 
b/clang/test/SemaCXX/source_location.cpp
index 6b3610d703e716..34177bfe287fc3 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -929,3 +929,63 @@ void test() {
 }
 
 }
+
+namespace GH106428 {
+
+struct add_fn {
+template 
+constexpr auto operator()(T lhs, T rhs,
+  const std::source_location loc = 
std::source_location::current())
+const -> T
+{
+return lhs + rhs;
+}
+};
+
+
+template 
+decltype(_Fp{}(0, 0))
+__invoke(_Fp&& __f);
+
+template
+struct type_identity { using type = T; };
+
+template
+struct invoke_result : type_identity {};
+
+using i = invoke_result::type;
+static_assert(__is_same(i, int));
+
+}
+
+#if __cplusplus >= 202002L
+
+namespace GH81155 {
+struct buff {
+  buff(buff &, const char * = __builtin_FUNCTION());
+};
+
+template 
+Ty declval();
+
+template 
+auto Call(buff arg) -> decltype(Fx{}(arg));
+
+template 
+struct F {};
+
+template 
+struct InvocableR : F(declval()))> {
+  static constexpr bool value = false;
+};
+
+template ::value>
+void Help(Fx) {}
+
+void Test() {
+  Help([](buff) {});
+}
+
+}
+
+#endif

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


[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

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

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


[clang] [Clang] Workaround dependent source location issues (PR #106925)

2024-09-01 Thread via cfe-commits

https://github.com/cor3ntin updated 
https://github.com/llvm/llvm-project/pull/106925

>From b561f0634c08a8cc845f8a58985c67b0e7ca35ad Mon Sep 17 00:00:00 2001
From: Corentin Jabot 
Date: Mon, 2 Sep 2024 00:22:40 +0200
Subject: [PATCH] [Clang] Workaround dependent source location issues

In #78436 we made some SourceLocExpr dependent to
deal with the fact that their value should reflect the name of
specialized function - rather than the rtemplate in which they
are first used.

However SourceLocExpr are unusual in two ways
 - They don't depend on template argumente
 - They morally depend on the context in which they are used
   (rather than called from).

It's fair to say that this is quite novels and confuses
clang. In particular, in some cases, we used to create
dependent SourceLocExpr and never subsequently transform them,
leaving dependent objects in instantiated functions types.
To work around that we avoid replacing SourceLocExpr when we think
they could remain dependent.
It's certainly not perfect but it fixes a number of reported bugs,
and seem to only affect scenarios in which the value of the
SourceLocExpr does not matter (overload resolution).

Fixes #106428
Fixes #81155
---
 clang/docs/ReleaseNotes.rst|  1 +
 clang/lib/Sema/SemaExpr.cpp| 21 +++--
 clang/test/SemaCXX/source_location.cpp | 60 ++
 3 files changed, 78 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 6df8bc64f1c7db..763acd99b8e334 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -326,6 +326,7 @@ Bug Fixes to C++ Support
 - Fix evaluation of the index of dependent pack indexing expressions/types 
specifiers (#GH105900)
 - Correctly handle subexpressions of an immediate invocation in the presence 
of implicit casts. (#GH105558)
 - Clang now correctly handles direct-list-initialization of a structured 
bindings from an array. (#GH31813)
+- Fix an issue with dependent source location expressions (#GH106428), 
(#GH81155)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 95f53dfefbcc52..d80d5fb516bc64 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5441,11 +5441,24 @@ struct EnsureImmediateInvocationInDefaultArgs
 
   // Rewrite to source location to refer to the context in which they are used.
   ExprResult TransformSourceLocExpr(SourceLocExpr *E) {
-if (E->getParentContext() == SemaRef.CurContext)
+DeclContext *DC = E->getParentContext();
+if (DC == SemaRef.CurContext)
   return E;
-return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
- E->getBeginLoc(), E->getEndLoc(),
- SemaRef.CurContext);
+
+// FIXME: During instantiation, because the rebuild of defaults arguments
+// is not always done in the context of the template instantiator,
+// we run the risk of producing a dependent source location
+// that would never be rebuilt.
+// This usually happen during overload resolution, or in contexts
+// where the value of the source location does not matter.
+// However, we should find a better way to deal with source location
+// of function template.
+if (!SemaRef.CurrentInstantiationScope ||
+!SemaRef.CurContext->isDependentContext() || DC->isDependentContext())
+  DC = SemaRef.CurContext;
+
+return getDerived().RebuildSourceLocExpr(
+E->getIdentKind(), E->getType(), E->getBeginLoc(), E->getEndLoc(), DC);
   }
 };
 
diff --git a/clang/test/SemaCXX/source_location.cpp 
b/clang/test/SemaCXX/source_location.cpp
index 6b3610d703e716..34177bfe287fc3 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -929,3 +929,63 @@ void test() {
 }
 
 }
+
+namespace GH106428 {
+
+struct add_fn {
+template 
+constexpr auto operator()(T lhs, T rhs,
+  const std::source_location loc = 
std::source_location::current())
+const -> T
+{
+return lhs + rhs;
+}
+};
+
+
+template 
+decltype(_Fp{}(0, 0))
+__invoke(_Fp&& __f);
+
+template
+struct type_identity { using type = T; };
+
+template
+struct invoke_result : type_identity {};
+
+using i = invoke_result::type;
+static_assert(__is_same(i, int));
+
+}
+
+#if __cplusplus >= 202002L
+
+namespace GH81155 {
+struct buff {
+  buff(buff &, const char * = __builtin_FUNCTION());
+};
+
+template 
+Ty declval();
+
+template 
+auto Call(buff arg) -> decltype(Fx{}(arg));
+
+template 
+struct F {};
+
+template 
+struct InvocableR : F(declval()))> {
+  static constexpr bool value = false;
+};
+
+template ::value>
+void Help(Fx) {}
+
+void Test() {
+  Help([](buff) {});
+}
+
+}
+
+#endif

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https

[clang] [clang-format] Add new option: WrapNamespaceBodyWithNewlines (PR #106145)

2024-09-01 Thread via cfe-commits

https://github.com/dmasloff updated 
https://github.com/llvm/llvm-project/pull/106145

>From 219424f9cd3477d9290c8766eaa857234a1ae387 Mon Sep 17 00:00:00 2001
From: dmasloff 
Date: Mon, 26 Aug 2024 22:11:05 +0300
Subject: [PATCH] [clang-format] Add new option: WrapNamespaceBodyWithNewlines

---
 clang/docs/ClangFormatStyleOptions.rst  |  42 
 clang/include/clang/Format/Format.h |  40 +++-
 clang/lib/Format/Format.cpp |  15 ++
 clang/lib/Format/UnwrappedLineFormatter.cpp |  42 
 clang/unittests/Format/FormatTest.cpp   | 205 
 5 files changed, 343 insertions(+), 1 deletion(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index a427d7cd40fcdd..06ac88fc337983 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6652,6 +6652,48 @@ the configuration (without a prefix: ``Auto``).
 
   For example: BOOST_PP_STRINGIZE
 
+.. _WrapNamespaceBodyWithEmptyLines:
+
+**WrapNamespaceBodyWithEmptyLines** (``WrapNamespaceBodyWithEmptyLinesStyle``) 
:versionbadge:`clang-format 19` :ref:`¶ `
+  Controls number of empty lines at the begging and at the end of
+  namespace definition.
+
+  Possible values:
+
+  * ``WNBWELS_Never`` (in configuration: ``Never``)
+Removes all empty lines at the beginning and at the end of
+namespace definition.
+
+.. code-block:: c++
+
+  namespace N1 {
+  namespace N2
+function();
+  }
+  }
+
+  * ``WNBWELS_Always`` (in configuration: ``Always``)
+Always adds an empty line at the beginning and at the end of
+namespace definition. MaxEmptyLinesToKeep is also applied, but
+empty lines between consecutive namespace declarations are
+always removed.
+
+.. code-block:: c++
+
+  namespace N1 {
+  namespace N2 {
+
+function();
+
+  }
+  }
+
+  * ``WNBWELS_Leave`` (in configuration: ``Leave``)
+Keeps existing newlines at the beginning and at the end of
+namespace definition using MaxEmptyLinesToKeep for formatting.
+
+
+
 .. END_FORMAT_STYLE_OPTIONS
 
 Adding additional style options
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index d8b62c7652a0f6..963c7cbe1f8809 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -5057,6 +5057,43 @@ struct FormatStyle {
   /// \version 11
   std::vector WhitespaceSensitiveMacros;
 
+  /// Different styles for modify number of empty lines in
+  /// the beginning and at the of end of namespaces.
+  enum WrapNamespaceBodyWithEmptyLinesStyle : int8_t {
+/// Removes all empty lines at the beginning and at the end of
+/// namespace definition.
+/// \code
+///   namespace N1 {
+///   namespace N2
+/// function();
+///   }
+///   }
+/// \endcode
+WNBWELS_Never,
+/// Always adds an empty line at the beginning and at the end of
+/// namespace definition. MaxEmptyLinesToKeep is also applied, but
+/// empty lines between consecutive namespace declarations are
+/// always removed.
+/// \code
+///   namespace N1 {
+///   namespace N2 {
+///
+/// function();
+///
+///   }
+///   }
+/// \endcode
+WNBWELS_Always,
+/// Keeps existing newlines at the beginning and at the end of
+/// namespace definition using MaxEmptyLinesToKeep for formatting.
+WNBWELS_Leave
+  };
+
+  /// Controls number of empty lines at the begging and at the end of
+  /// namespace definition.
+  /// \version 19
+  WrapNamespaceBodyWithEmptyLinesStyle WrapNamespaceBodyWithEmptyLines;
+
   bool operator==(const FormatStyle &R) const {
 return AccessModifierOffset == R.AccessModifierOffset &&
AlignAfterOpenBracket == R.AlignAfterOpenBracket &&
@@ -5234,7 +5271,8 @@ struct FormatStyle {
TypenameMacros == R.TypenameMacros && UseTab == R.UseTab &&
VerilogBreakBetweenInstancePorts ==
R.VerilogBreakBetweenInstancePorts &&
-   WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
+   WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros &&
+   WrapNamespaceBodyWithEmptyLines == 
R.WrapNamespaceBodyWithEmptyLines;
   }
 
   std::optional GetLanguageStyle(LanguageKind Language) const;
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index d2463b892fbb96..b0d2836e9c69c2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -829,6 +829,18 @@ template <> struct 
ScalarEnumerationTraits {
   }
 };
 
+template <>
+struct ScalarEnumerationTraits<
+FormatStyle::WrapNamespaceBodyWithEmptyLinesStyle> {
+  static void
+  enumeration(IO &IO,
+  FormatStyle::WrapNamespaceBodyWithEmptyLinesStyle &Value) {
+IO.enumCase(Value, "Never", FormatStyle::WNBWELS_Never);
+IO.enumCase(Value, "Always", FormatStyle::WNBWELS_Always);
+IO.enumCase(Value, "Le

[clang] [analyzer] Model overflow builtins (PR #102602)

2024-09-01 Thread Pavel Skripkin via cfe-commits


@@ -0,0 +1,157 @@
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-unknown -verify %s \
+// RUN:   -analyzer-checker=core,debug.ExprInspection
+
+#define __UINT_MAX__ (__INT_MAX__ * 2U + 1U)
+#define __INT_MIN__  (-__INT_MAX__ - 1)
+
+void clang_analyzer_dump_int(int);
+void clang_analyzer_dump_long(long);
+void clang_analyzer_eval(int);
+void clang_analyzer_warnIfReached(void);
+
+void test_add_nooverflow(void)
+{
+   int res;
+
+   if (__builtin_add_overflow(10, 20, &res)) {
+ clang_analyzer_warnIfReached();
+ return;
+   }
+
+   clang_analyzer_dump_int(res); //expected-warning{{30 S32b}}
+}
+
+void test_add_overflow(void)
+{
+   int res;
+
+   if (__builtin_add_overflow(__INT_MAX__, 1, &res)) {
+ clang_analyzer_dump_int(res); //expected-warning{{1st function call 
argument is an uninitialized value}}
+ return;
+   }
+
+   clang_analyzer_warnIfReached();
+}
+
+void test_add_underoverflow(void)
+{
+   int res;
+
+   if (__builtin_add_overflow(__INT_MIN__, -1, &res)) {
+ clang_analyzer_dump_int(res); //expected-warning{{1st function call 
argument is an uninitialized value}}
+ return;
+   }
+
+   clang_analyzer_warnIfReached();
+}
+
+void test_sub_underflow(void)
+{
+   int res;
+
+   if (__builtin_sub_overflow(__INT_MIN__, 10, &res)) {
+ return;
+   }
+
+   clang_analyzer_warnIfReached();
+}
+
+void test_sub_overflow(void)
+{
+   int res;
+
+   if (__builtin_sub_overflow(__INT_MAX__, -1, &res)) {
+ return;
+   }
+
+   clang_analyzer_warnIfReached();
+}
+
+void test_sub_nooverflow(void)
+{
+   int res;
+
+   if (__builtin_sub_overflow(__INT_MAX__, 1, &res)) {
+ clang_analyzer_warnIfReached();
+ return;
+   }
+
+   clang_analyzer_dump_int(res); //expected-warning{{2147483646 S32b}}
+}
+
+void test_mul_overrflow(void)
+{
+   int res;
+
+   if (__builtin_mul_overflow(__INT_MAX__, 2, &res)) {
+ return;
+   }
+
+   clang_analyzer_warnIfReached();
+}
+
+void test_mul_underrflow(void)
+{
+   int res;
+
+   if (__builtin_mul_overflow(__INT_MIN__, -2, &res)) {
+ return;
+   }
+
+   clang_analyzer_warnIfReached();
+}
+
+void test_mul_nooverflow(void)
+{
+   int res;
+
+   if (__builtin_mul_overflow(10, -2, &res)) {
+ clang_analyzer_warnIfReached();
+ return;
+   }
+
+   clang_analyzer_dump_int(res); //expected-warning{{-20 S32b}}
+}
+
+void test_nooverflow_diff_types(void)
+{
+   long res;
+
+   // This is not an overflow, since result type is long.
+   if (__builtin_add_overflow(__INT_MAX__, 1, &res)) {
+ clang_analyzer_warnIfReached();
+ return;
+   }
+
+   clang_analyzer_dump_long(res); //expected-warning{{2147483648 S64b}}
+}
+
+void test_uaddll_overflow_contraints(unsigned long a, unsigned long b)
+{
+   unsigned long long res;
+
+   if (a != 10)
+ return;
+   if (b != 10)

pskrgag wrote:

I've tried to add smth like this, but it fails even for more simple constraint 
like `if (a > 10 || b > 10) return`; for unsigned case. See 
https://github.com/llvm/llvm-project/pull/102602#discussion_r1712211946.

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


[clang] [Clang] Workaround dependent source location issues (PR #106925)

2024-09-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: cor3ntin (cor3ntin)


Changes

In #78436 we made some SourceLocExpr dependent to
deal with the fact that their value should reflect the name of specialized 
function - rather than the rtemplate in which they are first used.

However SourceLocExpr are unusual in two ways
 - They don't depend on template arguments
 - They morally depend on the context in which they are used (rather than 
called from).

It's fair to say that this is quite novels and confuses clang. In particular, 
in some cases, we used to create dependent SourceLocExpr and never subsequently 
transform them, leaving dependent objects in instantiated functions types. To 
work around that we avoid replacing SourceLocExpr when we think they could 
remain dependent.
It's certainly not perfect but it fixes a number of reported bugs, and seem to 
only affect scenarios in which the value of the SourceLocExpr does not matter 
(overload resolution).

Fixes #106428
Fixes #81155

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


2 Files Affected:

- (modified) clang/lib/Sema/SemaExpr.cpp (+17-4) 
- (modified) clang/test/SemaCXX/source_location.cpp (+60) 


``diff
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 95f53dfefbcc52..d80d5fb516bc64 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -5441,11 +5441,24 @@ struct EnsureImmediateInvocationInDefaultArgs
 
   // Rewrite to source location to refer to the context in which they are used.
   ExprResult TransformSourceLocExpr(SourceLocExpr *E) {
-if (E->getParentContext() == SemaRef.CurContext)
+DeclContext *DC = E->getParentContext();
+if (DC == SemaRef.CurContext)
   return E;
-return getDerived().RebuildSourceLocExpr(E->getIdentKind(), E->getType(),
- E->getBeginLoc(), E->getEndLoc(),
- SemaRef.CurContext);
+
+// FIXME: During instantiation, because the rebuild of defaults arguments
+// is not always done in the context of the template instantiator,
+// we run the risk of producing a dependent source location
+// that would never be rebuilt.
+// This usually happen during overload resolution, or in contexts
+// where the value of the source location does not matter.
+// However, we should find a better way to deal with source location
+// of function template.
+if (!SemaRef.CurrentInstantiationScope ||
+!SemaRef.CurContext->isDependentContext() || DC->isDependentContext())
+  DC = SemaRef.CurContext;
+
+return getDerived().RebuildSourceLocExpr(
+E->getIdentKind(), E->getType(), E->getBeginLoc(), E->getEndLoc(), DC);
   }
 };
 
diff --git a/clang/test/SemaCXX/source_location.cpp 
b/clang/test/SemaCXX/source_location.cpp
index 6b3610d703e716..34177bfe287fc3 100644
--- a/clang/test/SemaCXX/source_location.cpp
+++ b/clang/test/SemaCXX/source_location.cpp
@@ -929,3 +929,63 @@ void test() {
 }
 
 }
+
+namespace GH106428 {
+
+struct add_fn {
+template 
+constexpr auto operator()(T lhs, T rhs,
+  const std::source_location loc = 
std::source_location::current())
+const -> T
+{
+return lhs + rhs;
+}
+};
+
+
+template 
+decltype(_Fp{}(0, 0))
+__invoke(_Fp&& __f);
+
+template
+struct type_identity { using type = T; };
+
+template
+struct invoke_result : type_identity {};
+
+using i = invoke_result::type;
+static_assert(__is_same(i, int));
+
+}
+
+#if __cplusplus >= 202002L
+
+namespace GH81155 {
+struct buff {
+  buff(buff &, const char * = __builtin_FUNCTION());
+};
+
+template 
+Ty declval();
+
+template 
+auto Call(buff arg) -> decltype(Fx{}(arg));
+
+template 
+struct F {};
+
+template 
+struct InvocableR : F(declval()))> {
+  static constexpr bool value = false;
+};
+
+template ::value>
+void Help(Fx) {}
+
+void Test() {
+  Help([](buff) {});
+}
+
+}
+
+#endif

``




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


[clang] [Clang][CodeGen] Don't emit assumptions if current block is unreachable. (PR #106936)

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

https://github.com/dtcxzyw created 
https://github.com/llvm/llvm-project/pull/106936

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

When emitting an infinite loop, clang codegen will delete the whole block and 
leave builder's current block as nullptr:
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/clang/lib/CodeGen/CGStmt.cpp#L597-L600

Then clang will create `zext (icmp slt %a, %b)` without parent block for `a < 
b`. It will crash here:
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/clang/lib/CodeGen/CGExprScalar.cpp#L416-L420

Even if we disabled this optimization, it still crashes in 
`Builder.CreateAssumption`:
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/llvm/lib/IR/IRBuilder.cpp#L551-L561

This patch disables assumptions emission if current block is null. As an 
alternative, we can fix the optimization in `EmitIntToBoolConversion` and use 
`CGM.getIntrinsic` as we do for `__builtin_assume`:
https://github.com/llvm/llvm-project/blob/837ee5b46a5f7f898f0de7e46a19600b896a0a1f/clang/lib/CodeGen/CGBuiltin.cpp#L3422-L3431


>From 0361a0460507780a90d8b60f2adc0ecab60d511a Mon Sep 17 00:00:00 2001
From: Yingwei Zheng 
Date: Mon, 2 Sep 2024 10:51:58 +0800
Subject: [PATCH] [Clang][CodeGen] Don't emit assumptions if current block is
 unreachable.

---
 clang/lib/CodeGen/CGStmt.cpp| 2 +-
 clang/test/SemaCXX/cxx23-assume.cpp | 9 +
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 7158a06e6bc3b3..b138c87a853495 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -752,7 +752,7 @@ void CodeGenFunction::EmitAttributedStmt(const 
AttributedStmt &S) {
 } break;
 case attr::CXXAssume: {
   const Expr *Assumption = cast(A)->getAssumption();
-  if (getLangOpts().CXXAssumptions &&
+  if (getLangOpts().CXXAssumptions && Builder.GetInsertBlock() &&
   !Assumption->HasSideEffects(getContext())) {
 llvm::Value *AssumptionVal = EvaluateExprAsBool(Assumption);
 Builder.CreateAssumption(AssumptionVal);
diff --git a/clang/test/SemaCXX/cxx23-assume.cpp 
b/clang/test/SemaCXX/cxx23-assume.cpp
index 9138501d726dd6..eeae59daea3f70 100644
--- a/clang/test/SemaCXX/cxx23-assume.cpp
+++ b/clang/test/SemaCXX/cxx23-assume.cpp
@@ -158,3 +158,12 @@ foo (int x, int y)
   return x + y;
 }
 }
+
+// Do not crash when assumptions are unreachable.
+namespace gh106898 {
+int foo () { 
+while(1);
+int a = 0, b = 1;
+__attribute__((assume (a < b)));
+}
+}

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


[clang] [flang] [mlir] Avoid object libraries in the VS IDE (PR #93519)

2024-09-01 Thread via cfe-commits

Zentrik wrote:

Hi, this broke the build on windows using mingw and `LLVM_BUILD_LLVM_DYLIB`. 
See https://github.com/llvm/llvm-project/issues/106899 for more details. Any 
help fixing this would be appreciated, thanks.

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


[clang] 7b2fe84 - Don't run the lifetime analysis for pointer assignment if the warning is

2024-09-01 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2024-09-01T16:19:18+02:00
New Revision: 7b2fe84ff57b49f6275bc12d47f87a1887919d9e

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

LOG: Don't run the lifetime analysis for pointer assignment if the warning is
disabled.

Added: 


Modified: 
clang/lib/Sema/CheckExprLifetime.cpp

Removed: 




diff  --git a/clang/lib/Sema/CheckExprLifetime.cpp 
b/clang/lib/Sema/CheckExprLifetime.cpp
index c1362559536962..f28789dba34e10 100644
--- a/clang/lib/Sema/CheckExprLifetime.cpp
+++ b/clang/lib/Sema/CheckExprLifetime.cpp
@@ -1297,7 +1297,10 @@ void checkExprLifetime(Sema &SemaRef, const 
AssignedEntity &Entity,
Expr *Init) {
   bool EnableLifetimeWarnings = !SemaRef.getDiagnostics().isIgnored(
   diag::warn_dangling_lifetime_pointer, SourceLocation());
-  bool RunAnalysis = Entity.LHS->getType()->isPointerType() ||
+  bool EnableDanglingPointerAssignment = !SemaRef.getDiagnostics().isIgnored(
+  diag::warn_dangling_pointer_assignment, SourceLocation());
+  bool RunAnalysis = (EnableDanglingPointerAssignment &&
+  Entity.LHS->getType()->isPointerType()) ||
  (EnableLifetimeWarnings &&
   isRecordWithAttr(Entity.LHS->getType()));
 



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


[clang] [clang] NFCI: don't check deduced constraints when partial ordering (PR #106882)

2024-09-01 Thread via cfe-commits

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

LGTM

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


[clang] [llvm] [LTO] Reduce memory usage for import lists (PR #106772)

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

nikic wrote:

It looks like this causes a compile-time regression. The clang thin link time 
increases by 1% 
(https://llvm-compile-time-tracker.com/compare_clang.php?from=9ccf82543d509bb5a0f5d0551fc4d6c1913b9a9b&to=5c0d61e318a77434487fcec8361d8110fb06e59d&stat=instructions%3Au).
 There is no regression for thin link on CTMark, so the regression here 
probably scales with the number of modules involved in the link, so is likely 
even larger for larger applications.

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


[clang] [llvm] [RISCV][VCIX] Add vcix_state to GNU inline assembly register set (PR #106914)

2024-09-01 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Brandon Wu (4vtomat)


Changes

[RISCV][VCIX] Add vcix_state to GNU inline assembly register set

 Resolved https://github.com/llvm/llvm-project/issues/106700.
 This enables inline asm to have vcix_state to be a clobbered register
 thus disable reordering between VCIX intrinsics and inline asm.


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


3 Files Affected:

- (modified) clang/lib/Basic/Targets/RISCV.cpp (+1-1) 
- (modified) llvm/lib/Target/RISCV/RISCVRegisterInfo.td (+5-1) 
- (added) llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll (+22) 


``diff
diff --git a/clang/lib/Basic/Targets/RISCV.cpp 
b/clang/lib/Basic/Targets/RISCV.cpp
index b89109e7725d44..da6ecfb4e4022b 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -44,7 +44,7 @@ ArrayRef RISCVTargetInfo::getGCCRegNames() 
const {
   "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31",
 
   // CSRs
-  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm"
+  "fflags", "frm", "vtype", "vl", "vxsat", "vxrm", "vcix_state"
 };
   // clang-format on
   return llvm::ArrayRef(GCCRegNames);
diff --git a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td 
b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
index 4d5c0a7bef9416..03f05c0baea3b0 100644
--- a/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
+++ b/llvm/lib/Target/RISCV/RISCVRegisterInfo.td
@@ -664,5 +664,9 @@ def FRM: RISCVReg<0, "frm">;
 // Shadow Stack register
 def SSP: RISCVReg<0, "ssp">;
 
-// Dummy VCIX state register
+// Dummy VCIX state register and its register class
 def VCIX_STATE : RISCVReg<0, "vcix_state">;
+def : RISCVRegisterClass<[XLenVT], 32, (add VCIX_STATE)> {
+  let RegInfos = XLenRI;
+  let isAllocatable = 0;
+}
diff --git a/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll 
b/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
new file mode 100644
index 00..0013461d873281
--- /dev/null
+++ b/llvm/test/CodeGen/RISCV/inline-asm-xsfvcp.ll
@@ -0,0 +1,22 @@
+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 
UTC_ARGS: --version 5
+; RUN: sed 's/iXLen/i32/g' %s | llc -mtriple=riscv32 -mattr=+v,+xsfvcp \
+; RUN:   -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK
+; RUN: sed 's/iXLen/i64/g' %s | llc -mtriple=riscv64 -mattr=+v,+xsfvcp \
+; RUN:   -verify-machineinstrs | FileCheck %s --check-prefixes=CHECK
+
+; VCIX instructions can not reorder between each other.
+define void @test_reorder( %vreg) {
+; CHECK-LABEL: test_reorder:
+; CHECK:   # %bb.0: # %entry
+; CHECK-NEXT:vsetivli zero, 0, e64, m1, ta, ma
+; CHECK-NEXT:sf.vc.iv 0, 0, v8, 0
+; CHECK-NEXT:#APP
+; CHECK-NEXT:sf.vc.vv 3, 0, v8, v8
+; CHECK-EMPTY:
+; CHECK-NEXT:#NO_APP
+; CHECK-NEXT:ret
+entry:
+  call void @llvm.riscv.sf.vc.iv.se.iXLen.nxv1i64.iXLen.iXLen(iXLen 0, iXLen 
0,  %vreg, iXLen 0, iXLen 0)
+  call iXLen asm sideeffect "sf.vc.vv 0x3, 0x0, $1, $1;", 
"=r,^vr,~{memory},~{vl},~{vcix_state}"( %vreg)
+  ret void
+}

``




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


[clang] [llvm] [CodeView] Flatten cmd args in frontend for LF_BUILDINFO (PR #106369)

2024-09-01 Thread via cfe-commits

https://github.com/nebulark updated 
https://github.com/llvm/llvm-project/pull/106369

>From 60332916c1fba8ad20d3353e279a867807f46273 Mon Sep 17 00:00:00 2001
From: Florian Schmiderer 
Date: Wed, 28 Aug 2024 12:36:39 +0200
Subject: [PATCH 1/8] Flatten compiler args in Frontend, keep existing
 behaviour as fallback for other frontends

---
 clang/lib/CodeGen/BackendUtil.cpp | 38 +++
 llvm/include/llvm/MC/MCTargetOptions.h|  7 
 llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 15 ++--
 3 files changed, 57 insertions(+), 3 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 564efa3181d188..3ddc6704383016 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -50,6 +50,7 @@
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include "llvm/Support/PrettyStackTrace.h"
+#include "llvm/Support/Program.h"
 #include "llvm/Support/TimeProfiler.h"
 #include "llvm/Support/Timer.h"
 #include "llvm/Support/ToolOutputFile.h"
@@ -322,6 +323,41 @@ static bool actionRequiresCodeGen(BackendAction Action) {
  Action != Backend_EmitLL;
 }
 
+static std::string flattenClangCommandLine(ArrayRef Args,
+  StringRef MainFilename) {
+  std::string FlatCmdLine;
+  raw_string_ostream OS(FlatCmdLine);
+  bool PrintedOneArg = false;
+  if (!StringRef(Args[0]).contains("-cc1")) {
+llvm::sys::printArg(OS, "-cc1", /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  for (unsigned i = 0; i < Args.size(); i++) {
+StringRef Arg = Args[i];
+if (Arg.empty()) {
+  continue;
+}
+if (Arg == "-main-file-name" || Arg == "-o") {
+  i++; // Skip this argument and next one.
+  continue;
+}
+if (Arg.starts_with("-object-file-name") || Arg == MainFilename) {
+  continue;
+}
+// Skip fmessage-length for reproduciability.
+if (Arg.starts_with("-fmessage-length")) {
+  continue;
+}
+if (PrintedOneArg) {
+  OS << " ";
+}
+llvm::sys::printArg(OS, Arg, /*Quote=*/true);
+PrintedOneArg = true;
+  }
+  OS.flush();
+  return FlatCmdLine;
+}
+
 static bool initTargetOptions(DiagnosticsEngine &Diags,
   llvm::TargetOptions &Options,
   const CodeGenOptions &CodeGenOpts,
@@ -486,6 +522,8 @@ static bool initTargetOptions(DiagnosticsEngine &Diags,
   Entry.IgnoreSysRoot ? Entry.Path : HSOpts.Sysroot + Entry.Path);
   Options.MCOptions.Argv0 = CodeGenOpts.Argv0;
   Options.MCOptions.CommandLineArgs = CodeGenOpts.CommandLineArgs;
+  Options.MCOptions.CommandlineArgsFlat = flattenClangCommandLine(
+  CodeGenOpts.CommandLineArgs, CodeGenOpts.MainFileName);
   Options.MCOptions.AsSecureLogFile = CodeGenOpts.AsSecureLogFile;
   Options.MCOptions.PPCUseFullRegisterNames =
   CodeGenOpts.PPCUseFullRegisterNames;
diff --git a/llvm/include/llvm/MC/MCTargetOptions.h 
b/llvm/include/llvm/MC/MCTargetOptions.h
index a5371b3387a13d..0937089d8a2c80 100644
--- a/llvm/include/llvm/MC/MCTargetOptions.h
+++ b/llvm/include/llvm/MC/MCTargetOptions.h
@@ -96,8 +96,15 @@ class MCTargetOptions {
   std::string AsSecureLogFile;
 
   const char *Argv0 = nullptr;
+
+  // Deprecated: Use FlatCommandlineArgs instead
+  // Arguments here are interpreted as coming from clang, formated and end up 
in LF_BUILDINFO as CommandLineArgs 
   ArrayRef CommandLineArgs;
 
+  // Arguments here end up in LF_BUILDINFO as CommandLineArgs without any 
additional formating
+  // If empty falls back to CommandLineArgs
+  std::string CommandlineArgsFlat;
+
   /// Additional paths to search for `.include` directives when using the
   /// integrated assembler.
   std::vector IASSearchPaths;
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp 
b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index 7700ffd6da8030..60387e4688996b 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -893,6 +893,8 @@ static TypeIndex getStringIdTypeIdx(GlobalTypeTableBuilder 
&TypeTable,
   return TypeTable.writeLeafType(SIR);
 }
 
+// This just exists for backwards compatability for the deprecated 
MCTargetOptions::CommandLineArgs
+// It assumed a clang compiler frontend
 static std::string flattenCommandLine(ArrayRef Args,
   StringRef MainFilename) {
   std::string FlatCmdLine;
@@ -950,9 +952,16 @@ void CodeViewDebug::emitBuildInfo() {
   if (Asm->TM.Options.MCOptions.Argv0 != nullptr) {
 BuildInfoArgs[BuildInfoRecord::BuildTool] =
 getStringIdTypeIdx(TypeTable, Asm->TM.Options.MCOptions.Argv0);
-BuildInfoArgs[BuildInfoRecord::CommandLine] = getStringIdTypeIdx(
-TypeTable, 
flattenCommandLine(Asm->TM.Options.MCOptions.CommandLineArgs,
-  MainSourceFile->getFilename()));
+
+if (!Asm->TM.Options.MCOptions.CommandlineArgsFlat.e

[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

2024-09-01 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `sanitizer-ppc64le-linux` 
running on `ppc64le-sanitizer` while building `clang` at step 2 "annotate".

Full details are available at: 
https://lab.llvm.org/buildbot/#/builders/72/builds/2844


Here is the relevant piece of the build log for the reference

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
[3468/4029] Linking CXX executable bin/llvm-diff
[3469/4029] Building CXX object 
tools/clang/lib/StaticAnalyzer/Core/CMakeFiles/obj.clangStaticAnalyzerCore.dir/BugReporter.cpp.o
[3470/4029] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaInit.cpp.o
[3471/4029] Building CXX object 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/TypePrinter.cpp.o
[3472/4029] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/ChainedIncludesSource.cpp.o
[3473/4029] Building CXX object 
tools/clang/lib/StaticAnalyzer/Checkers/CMakeFiles/obj.clangStaticAnalyzerCheckers.dir/StreamChecker.cpp.o
[3474/4029] Building CXX object 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ASTDumper.cpp.o
[3475/4029] Building CXX object 
tools/clang/lib/Parse/CMakeFiles/obj.clangParse.dir/ParseDecl.cpp.o
[3476/4029] Building CXX object 
tools/clang/lib/Interpreter/CMakeFiles/obj.clangInterpreter.dir/Interpreter.cpp.o
[3477/4029] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
FAILED: 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm_build0/bin/clang++
 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE 
-D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/lib/Serialization
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Serialization
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/tools/clang/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/build_default/include
 
-I/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/llvm/include
 -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror 
-Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers 
-pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables 
-fno-rtti -UNDEBUG -MD -MT 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -MF 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o.d
 -o 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTReader.cpp.o
 -c 
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Serialization/ASTReader.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-sanitizer/sanitizer-ppc64le/build/llvm-project/clang/lib/Serialization/ASTReader.cpp:7800:11:
 error: enumeration value 'NUM_PREDEF_DECL_IDS' not handled in switch 
[-Werror,-Wswitch]
 7800 |   switch (ID) {
  |   ^~
1 error generated.
[3478/4029] Building CXX object 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/StmtPrinter.cpp.o
[3479/4029] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaExprObjC.cpp.o
[3480/4029] Building CXX object 
tools/clang/lib/Frontend/CMakeFiles/obj.clangFrontend.dir/FrontendAction.cpp.o
[3481/4029] Building CXX object 
tools/clang/lib/Serialization/CMakeFiles/obj.clangSerialization.dir/ASTWriterDecl.cpp.o
[3482/4029] Building CXX object 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/ByteCode/ByteCodeEmitter.cpp.o
[3483/4029] Building CXX object 
tools/clang/lib/AST/CMakeFiles/obj.clangAST.dir/Expr.cpp.o
[3484/4029] Building CXX object 
tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/ItaniumCXXABI.cpp.o
[3485/4029] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.dir/SemaARM.cpp.o
[3486/4029] Building CXX object 
tools/clang/lib/Sema/CMakeFiles/obj.clangSema.d

[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

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


@@ -177,6 +177,26 @@ static bool isLanguageDefinedBuiltin(const SourceManager 
&SourceMgr,
   return false;
 }
 
+static bool isReservedAttrName(Preprocessor &PP, IdentifierInfo *II) {

a-tarasyuk wrote:

The reason I asked is that I recall clang has a predefined macro, 
`__has_cpp_attribute`, which relies on `hasAttribute`. This function uses a 
list of existing attributes generated from `Attr.td` for different _`Syntax`_. 
Should attributes currently defined in clang (for example, `indeterminate` 
isn’t defined yet) be disallowed, or should all cpp attribute names from the 
standard be considered?

--- 

https://github.com/llvm/llvm-project/blob/357bd61744bb8cc2b9b07447294fa977e5758550/clang/lib/Lex/PPMacroExpansion.cpp#L1915-L1920

https://github.com/llvm/llvm-project/blob/357bd61744bb8cc2b9b07447294fa977e5758550/clang/lib/Basic/Attributes.cpp#L31

https://github.com/llvm/llvm-project/blob/357bd61744bb8cc2b9b07447294fa977e5758550/clang/lib/Basic/Attributes.cpp#L26

```
...
if (ScopeName == "") {
  return llvm::StringSwitch(Name)
.Case("noreturn", 200809)
.Case("assume", 202207)
.Case("carries_dependency", 200809)
.Case("deprecated", 201309)
.Case("fallthrough", 201603)
.Case("likely", 201803)
.Case("no_unique_address", true && ( Target.getCXXABI().isItaniumFamily() ) 
? 201803 : 0)
.Case("unlikely", 201803)
.Case("maybe_unused", 201603)
.Case("nodiscard", 201907)
.Default(0);
...
```

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


[clang] [Clang][Concepts] Correct the CurContext for friend declarations (PR #106890)

2024-09-01 Thread Younan Zhang via cfe-commits

https://github.com/zyn0217 updated 
https://github.com/llvm/llvm-project/pull/106890

>From 679ece827467a25b14d0a718ac10f221327f5bef Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 1 Sep 2024 14:55:22 +0800
Subject: [PATCH 1/2] [Clang][Concepts] Correct the CurContext for friend
 declarations

---
 clang/docs/ReleaseNotes.rst   |  1 +
 .../clang/Basic/DiagnosticSemaKinds.td|  2 +-
 clang/lib/Sema/SemaConcept.cpp|  5 +++-
 clang/lib/Sema/SemaTemplateInstantiate.cpp|  3 +--
 .../temp.constr/temp.constr.normal/p1.cpp |  2 +-
 clang/test/SemaTemplate/concepts-friends.cpp  | 23 +++
 6 files changed, 31 insertions(+), 5 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 98fb0174d4a37e..fc940db4813948 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -338,6 +338,7 @@ Bug Fixes to C++ Support
 - Fixed an assertion failure when converting vectors to int/float with invalid 
expressions. (#GH105486)
 - Template parameter names are considered in the name lookup of out-of-line 
class template
   specialization right before its declaration context. (#GH64082)
+- Fixed a constraint comparison bug for friend declarations. (#GH78101)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 66f8890da75e5d..dcb49d8a67604a 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -5603,7 +5603,7 @@ def note_checking_constraints_for_function_here : Note<
 def note_constraint_substitution_here : Note<
   "while substituting template arguments into constraint expression here">;
 def note_constraint_normalization_here : Note<
-  "while calculating associated constraint of template '%0' here">;
+  "while calculating associated constraint of template %0 here">;
 def note_parameter_mapping_substitution_here : Note<
   "while substituting into concept arguments here; substitution failures not "
   "allowed in concept arguments">;
diff --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 86d6f308a51cc2..afbfe278680240 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1012,7 +1012,10 @@ static const Expr 
*SubstituteConstraintExpressionWithoutSatisfaction(
   // possible that e.g. constraints involving C> and C are
   // perceived identical.
   std::optional ContextScope;
-  if (auto *RD = dyn_cast(DeclInfo.getDeclContext())) {
+  if (auto *RD =
+  dyn_cast(DeclInfo.getDecl()->getFriendObjectKind()
+  ? DeclInfo.getLexicalDeclContext()
+  : DeclInfo.getDeclContext())) {
 ThisScope.emplace(S, const_cast(RD), Qualifiers());
 ContextScope.emplace(S, const_cast(cast(RD)),
  /*NewThisContext=*/false);
diff --git a/clang/lib/Sema/SemaTemplateInstantiate.cpp 
b/clang/lib/Sema/SemaTemplateInstantiate.cpp
index 776297479e141e..c42cc250bb904a 100644
--- a/clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ b/clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -1226,8 +1226,7 @@ void Sema::PrintInstantiationStack() {
 case CodeSynthesisContext::ConstraintNormalization:
   Diags.Report(Active->PointOfInstantiation,
diag::note_constraint_normalization_here)
-  << cast(Active->Entity)->getName()
-  << Active->InstantiationRange;
+  << cast(Active->Entity) << Active->InstantiationRange;
   break;
 case CodeSynthesisContext::ParameterMappingSubstitution:
   Diags.Report(Active->PointOfInstantiation,
diff --git a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp 
b/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
index d80710937cdfa1..3992835c444027 100644
--- a/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
+++ b/clang/test/CXX/temp/temp.constr/temp.constr.normal/p1.cpp
@@ -15,7 +15,7 @@ template requires Bar2 struct S2 { };
 // expected-note@-1{{template is declared here}}
 template requires Bar2 && true struct S2 { };
 // expected-error@-1{{class template partial specialization is not more 
specialized than the primary template}}
-// expected-note@-2{{while calculating associated constraint of template 'S2' 
here}}
+// expected-note@-2{{while calculating associated constraint of template 
'S2' here}}
 
 namespace type_pack {
   template
diff --git a/clang/test/SemaTemplate/concepts-friends.cpp 
b/clang/test/SemaTemplate/concepts-friends.cpp
index 14b37d78d951dc..d05be423a8cfcd 100644
--- a/clang/test/SemaTemplate/concepts-friends.cpp
+++ b/clang/test/SemaTemplate/concepts-friends.cpp
@@ -525,3 +525,26 @@ struct S {
 };
 
 }
+
+namespace GH78101 {
+
+template 
+concept True = true;
+
+template  struct Template {
+  static constexpr int i = I;
+
+  friend constexpr auto operator+(True au

[clang] [lld] [llvm] [X86, lld] Add relocation R_X86_64_REX2_GOTPCRELX (PR #106681)

2024-09-01 Thread Shengchen Kan via cfe-commits

https://github.com/KanRobert updated 
https://github.com/llvm/llvm-project/pull/106681

>From 8d8aea0d9d6b85a3b279a1c60b50cf9b859d6919 Mon Sep 17 00:00:00 2001
From: Shengchen Kan 
Date: Tue, 25 Jun 2024 20:33:10 +0800
Subject: [PATCH 1/7] [X86,lld] Add relocation R_X86_64_REX2_GOTPCRELX

For

movname@GOTPCREL(%rip), %reg
test   %reg, name@GOTPCREL(%rip)
binop  name@GOTPCREL(%rip), %reg

where binop is one of adc, add, and, cmp, or, sbb, sub, xor instructions,
add

 R_X86_64_REX2_GOTPCRELX/R_X86_64_CODE_4_GOTPCRELX = 43

if the instruction starts at 4 bytes before the relocation offset.  It
similar to R_X86_64_GOTPCRELX.

Linker can treat R_X86_64_REX2_GOTPCRELX/R_X86_64_CODE_4_GOTPCRELX
as R_X86_64_GOTPCREL or convert the above instructions to

lea name(%rip), %reg
mov $name, %reg
test$name, %reg
binop   $name, %reg

if the first byte of the instruction at the relocation `offset - 4` is
`0xd5` (namely, encoded w/ REX2 prefix) when possible.

Binutils patch: 
https://github.com/bminor/binutils-gdb/commit/3d5a60de52556f6a53d71d7e607c6696450ae3e4
Binutils mailthread: 
https://sourceware.org/pipermail/binutils/2023-December/131462.html
ABI discussion: https://groups.google.com/g/x86-64-abi/c/KbzaNHRB6QU
Blog: https://kanrobert.github.io/rfc/All-about-APX-relocation
---
 clang/test/Driver/relax.s |  2 ++
 lld/ELF/Arch/X86_64.cpp   |  3 ++
 lld/test/ELF/x86-64-gotpc-no-relax-err.s  | 10 --
 lld/test/ELF/x86-64-gotpc-relax.s |  2 +-
 .../llvm/BinaryFormat/ELFRelocs/x86_64.def|  1 +
 llvm/lib/MC/MCTargetOptionsCommandFlags.cpp   |  4 +--
 .../Target/X86/MCTargetDesc/X86AsmBackend.cpp |  4 +++
 .../X86/MCTargetDesc/X86ELFObjectWriter.cpp   |  7 +++-
 .../Target/X86/MCTargetDesc/X86FixupKinds.h   |  4 +++
 .../X86/MCTargetDesc/X86MCCodeEmitter.cpp | 19 +--
 .../X86/MCTargetDesc/X86MachObjectWriter.cpp  |  6 +++-
 .../MCTargetDesc/X86WinCOFFObjectWriter.cpp   |  2 ++
 llvm/test/MC/ELF/relocation-alias.s   |  3 ++
 llvm/test/MC/X86/gotpcrelx.s  | 34 +++
 14 files changed, 83 insertions(+), 18 deletions(-)

diff --git a/clang/test/Driver/relax.s b/clang/test/Driver/relax.s
index 154d4db0a31385..b4a696a328eb56 100644
--- a/clang/test/Driver/relax.s
+++ b/clang/test/Driver/relax.s
@@ -8,5 +8,7 @@
 // RUN: llvm-readobj -r %t | FileCheck --check-prefix=REL %s
 
 // REL: R_X86_64_REX_GOTPCRELX foo
+// REL: R_X86_64_REX2_GOTPCRELX foo
 
 movq   foo@GOTPCREL(%rip), %rax
+movq   foo@GOTPCREL(%rip), %r16
diff --git a/lld/ELF/Arch/X86_64.cpp b/lld/ELF/Arch/X86_64.cpp
index 65a81fe12f8709..ba5ce68e509199 100644
--- a/lld/ELF/Arch/X86_64.cpp
+++ b/lld/ELF/Arch/X86_64.cpp
@@ -388,6 +388,7 @@ RelExpr X86_64::getRelExpr(RelType type, const Symbol &s,
   case R_X86_64_GOTPCREL:
   case R_X86_64_GOTPCRELX:
   case R_X86_64_REX_GOTPCRELX:
+  case R_X86_64_REX2_GOTPCRELX:
   case R_X86_64_GOTTPOFF:
 return R_GOT_PC;
   case R_X86_64_GOTOFF64:
@@ -725,6 +726,7 @@ int64_t X86_64::getImplicitAddend(const uint8_t *buf, 
RelType type) const {
   case R_X86_64_GOTPCREL:
   case R_X86_64_GOTPCRELX:
   case R_X86_64_REX_GOTPCRELX:
+  case R_X86_64_REX2_GOTPCRELX:
   case R_X86_64_PC32:
   case R_X86_64_GOTTPOFF:
   case R_X86_64_PLT32:
@@ -808,6 +810,7 @@ void X86_64::relocate(uint8_t *loc, const Relocation &rel, 
uint64_t val) const {
 break;
   case R_X86_64_GOTPCRELX:
   case R_X86_64_REX_GOTPCRELX:
+  case R_X86_64_REX2_GOTPCRELX:
 if (rel.expr != R_GOT_PC) {
   relaxGot(loc, rel, val);
 } else {
diff --git a/lld/test/ELF/x86-64-gotpc-no-relax-err.s 
b/lld/test/ELF/x86-64-gotpc-no-relax-err.s
index 618dca47755f41..4280c8fd1dc97e 100644
--- a/lld/test/ELF/x86-64-gotpc-no-relax-err.s
+++ b/lld/test/ELF/x86-64-gotpc-no-relax-err.s
@@ -7,15 +7,19 @@
 ## `>>> defined in` for linker synthesized __stop_* symbols (there is no
 ## associated file or linker script line number).
 
-# CHECK:  error: {{.*}}:(.text+0x2): relocation R_X86_64_GOTPCRELX out of 
range: 2147483658 is not in [-2147483648, 2147483647]; references '__stop_data'
+# CHECK:  error: {{.*}}:(.text+0x2): relocation R_X86_64_GOTPCRELX out of 
range: 2147483666 is not in [-2147483648, 2147483647]; references '__stop_data'
 # CHECK-NEXT: >>> defined in 
 # CHECK-EMPTY:
-# CHECK-NEXT: error: {{.*}}:(.text+0x9): relocation R_X86_64_REX_GOTPCRELX out 
of range: 2147483651 is not in [-2147483648, 2147483647]; references 
'__stop_data'
+# CHECK-NEXT: error: {{.*}}:(.text+0x9): relocation R_X86_64_REX_GOTPCRELX out 
of range: 2147483659 is not in [-2147483648, 2147483647]; references 
'__stop_data'
+# CHECK-NEXT: >>> defined in 
+# CHECK-EMPTY:
+# CHECK-NEXT: error: {{.*}}:(.text+0x11): relocation R_X86_64_REX2_GOTPCRELX 
out of range: 2147483651 is not in [-2147483648, 2147483647]; references 
'__stop_data'
 # CHECK-NEXT: >>> defined in 
 
 #--- a.s
  

[clang] [Clang][NFC] Don't manually enumerate the PredefinedDeclIDs (PR #106891)

2024-09-01 Thread via cfe-commits

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


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


[clang] [clang-format] Add new option: WrapNamespaceBodyWithEmptyLines (PR #106901)

2024-09-01 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] [llvm] [LTO] Reduce memory usage for import lists (PR #106772)

2024-09-01 Thread Kazu Hirata via cfe-commits

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


[clang] [Clang][Sema] Use the correct lookup context when building overloaded 'operator->' in the current instantiation (PR #104458)

2024-09-01 Thread via cfe-commits

cor3ntin wrote:

> > I think there won't be a rc4 so it's actually probably too late
> 
> You have the wrong handle, on github it's @tru. 😉 Also, RC4 is being 
> [considered](https://discourse.llvm.org/t/llvm-19-1-0-final-update-and-possible-rc4/81010).

Thanks! However we can't consider a backport until we have something to 
backport!

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


[clang] [Clang] restrict use of attribute names reserved by the C++ standard (PR #106036)

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

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