[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits

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

LGTM modulo comment to shorten + test to add
Thanks a lot for this PR!

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits


@@ -8340,8 +8340,54 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.
+//
+// C++0x [meta.rel]p4:
+//   Given the following function prototype:
+//
+// template 
+//   typename add_rvalue_reference::type create();
+//
+//   the predicate condition for a template specialization
+//   is_convertible shall be satisfied if and only if
+//   the return expression in the following code would be
+//   well-formed, including any implicit conversions to the return
+//   type of the function:
+//
+// To test() {
+//   return create();
+// }
+//
+//   Access checking is performed as if in a context unrelated to To 
and
+//   From. Only the validity of the immediate context of the expression
+//   of the return-statement (including conversions to the return type)
+//   is considered.
+//
+// We skip to check whether we are evaluating one of {__is_convertible,
+// __is_nothrow_convertible, __is_convertible_to} type traits
+// expression, because we model the initialization as a
+// copy-initialization of a temporary of the appropriate type, which 
for
+// this expression is identical to the return statement (since NRVO
+// doesn't apply), and not really build a `return create()` in
+// type traits expression evaluation. Therefor, P2748R5 has no impact
+// for evaluation of {__is_convertible, __is_nothrow_convertible,
+// __is_convertible_to}.
+//
+// Clang can correctly handle cases like the following:
+//
+// static_assert(__is_convertible(int, const int &));
+// static_assert(__is_nothrow_convertible(int, const int &));
+// static_assert(__is_convertible_to(int, const int &));

cor3ntin wrote:

I don't think this comment is useful in this context at this point in time.
If we ever need to do further surgery here, we can add the comment back

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits


@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s
+
+auto&& f1() {
+  return 42; // expected-error{{returning reference to local temporary object}}
+}
+const double& f2() {
+  static int x = 42;
+  return x; // expected-error{{returning reference to local temporary object}}
+}
+auto&& id(auto&& r) {
+  return static_cast(r);
+}
+auto&& f3() {
+  return id(42);// OK, but probably a bug
+}
+
+static_assert(__is_convertible(int, const int &));
+static_assert(__is_nothrow_convertible(int, const int &));

cor3ntin wrote:

To cover the paper, can you add a test for unevaluated cases (it should warn)

```cpp
void unevaluated() {
  using a = decltype ([] () -> int & {
int i = 0;
return i; // warning expected
} ());
}```

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


[clang] [llvm] [CMake][Release] Enable CMAKE_POSITION_INDEPENDENT_CODE (PR #90139)

2024-04-26 Thread Tobias Hieta via cfe-commits

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


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


[clang] [CMake][Release] Use the TGZ cpack generator for binaries (PR #90138)

2024-04-26 Thread Tobias Hieta via cfe-commits

tru wrote:

If this is for permanent storage I suggest we use TXZ instead, since it has 
better compression. You should also set CPACK_ARCHIVE_THREADS to something 
higher than the default (1). Since xz really benefits from this.

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


[clang] 2308d46 - [clang][Interp][NFC] Rename locals and add assertions to virtual casts

2024-04-26 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-26T09:21:52+02:00
New Revision: 2308d4697e0b3b0cfd905e2b025ea905ee763fbe

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

LOG: [clang][Interp][NFC] Rename locals and add assertions to virtual casts

Added: 


Modified: 
clang/lib/AST/Interp/Interp.h
clang/lib/AST/Interp/Opcodes.td

Removed: 




diff  --git a/clang/lib/AST/Interp/Interp.h b/clang/lib/AST/Interp/Interp.h
index 9283f697c00709..0e9f287cd2218f 100644
--- a/clang/lib/AST/Interp/Interp.h
+++ b/clang/lib/AST/Interp/Interp.h
@@ -1355,12 +1355,14 @@ inline bool VirtBaseHelper(InterpState &S, CodePtr 
OpPC, const RecordDecl *Decl,
   while (Base.isBaseClass())
 Base = Base.getBase();
 
-  auto *Field = Base.getRecord()->getVirtualBase(Decl);
-  S.Stk.push(Base.atField(Field->Offset));
+  const Record::Base *VirtBase = Base.getRecord()->getVirtualBase(Decl);
+  S.Stk.push(Base.atField(VirtBase->Offset));
   return true;
 }
 
-inline bool GetPtrVirtBase(InterpState &S, CodePtr OpPC, const RecordDecl *D) {
+inline bool GetPtrVirtBasePop(InterpState &S, CodePtr OpPC,
+  const RecordDecl *D) {
+  assert(D);
   const Pointer &Ptr = S.Stk.pop();
   if (!CheckNull(S, OpPC, Ptr, CSK_Base))
 return false;
@@ -1369,6 +1371,7 @@ inline bool GetPtrVirtBase(InterpState &S, CodePtr OpPC, 
const RecordDecl *D) {
 
 inline bool GetPtrThisVirtBase(InterpState &S, CodePtr OpPC,
const RecordDecl *D) {
+  assert(D);
   if (S.checkingPotentialConstantExpression())
 return false;
   const Pointer &This = S.Current->getThis();

diff  --git a/clang/lib/AST/Interp/Opcodes.td b/clang/lib/AST/Interp/Opcodes.td
index 742785b28eb4d7..2a97b978b52325 100644
--- a/clang/lib/AST/Interp/Opcodes.td
+++ b/clang/lib/AST/Interp/Opcodes.td
@@ -336,7 +336,7 @@ def GetPtrDerivedPop : Opcode {
 }
 
 // [Pointer] -> [Pointer]
-def GetPtrVirtBase : Opcode {
+def GetPtrVirtBasePop : Opcode {
   // RecordDecl of base class.
   let Args = [ArgRecordDecl];
 }



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


[clang] 8979644 - [clang][Interp][NFC] Add InlineDescriptor::dump()

2024-04-26 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-26T09:22:58+02:00
New Revision: 8979644bbd82b85ef40c17165b37769980455b75

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

LOG: [clang][Interp][NFC] Add InlineDescriptor::dump()

Added: 


Modified: 
clang/lib/AST/Interp/Descriptor.h
clang/lib/AST/Interp/Disasm.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Descriptor.h 
b/clang/lib/AST/Interp/Descriptor.h
index c386fc8ac7b09d..cd20495c259c7d 100644
--- a/clang/lib/AST/Interp/Descriptor.h
+++ b/clang/lib/AST/Interp/Descriptor.h
@@ -82,6 +82,9 @@ struct InlineDescriptor {
   InlineDescriptor(const Descriptor *D)
   : Offset(sizeof(InlineDescriptor)), IsConst(false), IsInitialized(false),
 IsBase(false), IsActive(false), IsFieldMutable(false), Desc(D) {}
+
+  void dump() const { dump(llvm::errs()); }
+  void dump(llvm::raw_ostream &OS) const;
 };
 
 /// Describes a memory block created by an allocation site.

diff  --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp
index d127f33223e802..e847a237660d07 100644
--- a/clang/lib/AST/Interp/Disasm.cpp
+++ b/clang/lib/AST/Interp/Disasm.cpp
@@ -208,6 +208,25 @@ LLVM_DUMP_METHOD void Descriptor::dump(llvm::raw_ostream 
&OS) const {
 OS << " dummy";
 }
 
+LLVM_DUMP_METHOD void InlineDescriptor::dump(llvm::raw_ostream &OS) const {
+  {
+ColorScope SC(OS, true, {llvm::raw_ostream::BLUE, true});
+OS << "InlineDescriptor " << (const void *)this << "\n";
+  }
+  OS << "Offset: " << Offset << "\n";
+  OS << "IsConst: " << IsConst << "\n";
+  OS << "IsInitialized: " << IsInitialized << "\n";
+  OS << "IsBase: " << IsBase << "\n";
+  OS << "IsActive: " << IsActive << "\n";
+  OS << "IsFieldMutable: " << IsFieldMutable << "\n";
+  OS << "Desc: ";
+  if (Desc)
+Desc->dump(OS);
+  else
+OS << "nullptr";
+  OS << "\n";
+}
+
 LLVM_DUMP_METHOD void InterpFrame::dump(llvm::raw_ostream &OS,
 unsigned Indent) const {
   unsigned Spaces = Indent * 2;



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


[clang] c70f058 - [clang][dataflow] Fix crash when `ConstantExpr` is used in conditional operator. (#90112)

2024-04-26 Thread via cfe-commits

Author: martinboehme
Date: 2024-04-26T09:30:07+02:00
New Revision: c70f05831663915f1c66d3767803ff74c08e79ee

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

LOG: [clang][dataflow] Fix crash when `ConstantExpr` is used in conditional 
operator. (#90112)

`ConstantExpr` does not appear as a `CFGStmt` in the CFG, so
`StmtToEnvMap::getEnvironment()` was not finding an entry for it in the
map,
causing a crash when we tried to access the iterator resulting from the
map
lookup.

The fix is to make `ignoreCFGOmittedNodes()` ignore `ConstantExpr`, but
in
addition, I'm hardening `StmtToEnvMap::getEnvironment()` to make sure
release
builds don't crash in similar situations in the future.

Added: 


Modified: 
clang/lib/Analysis/FlowSensitive/ASTOps.cpp
clang/lib/Analysis/FlowSensitive/Transfer.cpp
clang/unittests/Analysis/FlowSensitive/TransferTest.cpp

Removed: 




diff  --git a/clang/lib/Analysis/FlowSensitive/ASTOps.cpp 
b/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
index 619bf772bba5ee..bd1676583ecccd 100644
--- a/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
+++ b/clang/lib/Analysis/FlowSensitive/ASTOps.cpp
@@ -33,12 +33,20 @@ namespace clang::dataflow {
 
 const Expr &ignoreCFGOmittedNodes(const Expr &E) {
   const Expr *Current = &E;
-  if (auto *EWC = dyn_cast(Current)) {
-Current = EWC->getSubExpr();
+  const Expr *Last = nullptr;
+  while (Current != Last) {
+Last = Current;
+if (auto *EWC = dyn_cast(Current)) {
+  Current = EWC->getSubExpr();
+  assert(Current != nullptr);
+}
+if (auto *CE = dyn_cast(Current)) {
+  Current = CE->getSubExpr();
+  assert(Current != nullptr);
+}
+Current = Current->IgnoreParens();
 assert(Current != nullptr);
   }
-  Current = Current->IgnoreParens();
-  assert(Current != nullptr);
   return *Current;
 }
 

diff  --git a/clang/lib/Analysis/FlowSensitive/Transfer.cpp 
b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
index 43fdfa5abcbb51..fd224aeb79b151 100644
--- a/clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -41,7 +41,11 @@ namespace dataflow {
 
 const Environment *StmtToEnvMap::getEnvironment(const Stmt &S) const {
   auto BlockIt = ACFG.getStmtToBlock().find(&ignoreCFGOmittedNodes(S));
-  assert(BlockIt != ACFG.getStmtToBlock().end());
+  if (BlockIt == ACFG.getStmtToBlock().end()) {
+assert(false);
+// Return null to avoid dereferencing the end iterator in non-assert 
builds.
+return nullptr;
+  }
   if (!ACFG.isBlockReachable(*BlockIt->getSecond()))
 return nullptr;
   if (BlockIt->getSecond()->getBlockID() == CurBlockID)

diff  --git a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp 
b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
index d204700919d315..301bec32c0cf1d 100644
--- a/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5357,6 +5357,38 @@ TEST(TransferTest, ConditionalOperatorLocation) {
   });
 }
 
+TEST(TransferTest, ConditionalOperatorOnConstantExpr) {
+  // This is a regression test: We used to crash when a `ConstantExpr` was used
+  // in the branches of a conditional operator.
+  std::string Code = R"cc(
+consteval bool identity(bool B) { return B; }
+void target(bool Cond) {
+  bool JoinTrueTrue = Cond ? identity(true) : identity(true);
+  bool JoinTrueFalse = Cond ? identity(true) : identity(false);
+  // [[p]]
+}
+  )cc";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+Environment Env = getEnvironmentAtAnnotation(Results, "p").fork();
+
+auto &JoinTrueTrue =
+getValueForDecl(ASTCtx, Env, "JoinTrueTrue");
+// FIXME: This test documents the current behavior, namely that we
+// don't actually use the constant result of the `ConstantExpr` and
+// instead treat it like a normal function call.
+EXPECT_EQ(JoinTrueTrue.formula().kind(), Formula::Kind::AtomRef);
+// EXPECT_TRUE(JoinTrueTrue.formula().literal());
+
+auto &JoinTrueFalse =
+getValueForDecl(ASTCtx, Env, "JoinTrueFalse");
+EXPECT_EQ(JoinTrueFalse.formula().kind(), Formula::Kind::AtomRef);
+  },
+  LangStandard::lang_cxx20);
+}
+
 TEST(TransferTest, IfStmtBranchExtendsFlowCondition) {
   std::string Code = R"(
 void target(bool Foo) {



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


[clang] [clang][dataflow] Fix crash when `ConstantExpr` is used in conditional operator. (PR #90112)

2024-04-26 Thread via cfe-commits

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


[clang] [llvm] [RISCV] Add subtarget features for profiles (PR #84877)

2024-04-26 Thread Pengcheng Wang via cfe-commits

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


[clang] [llvm] [RISCV] Add subtarget features for profiles (PR #84877)

2024-04-26 Thread Pengcheng Wang via cfe-commits

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

>From ec68548a470d6d9032a900a725e95b92691657b2 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Tue, 12 Mar 2024 14:28:09 +0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/test/Driver/riscv-cpus.c| 319 ++
 clang/test/Misc/target-invalid-cpu-note.c |   8 +-
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 224 ++-
 3 files changed, 539 insertions(+), 12 deletions(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index ff2bd6f7c8ba34..a285f0f9c41f54 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -302,3 +302,322 @@
 
 // RUN: not %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 
-march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
 // MISMATCH-ARCH: cpu 'generic-rv32' does not support rv64
+
+// Check profile CPUs
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rvi20u32 | 
FileCheck -check-prefix=MCPU-GENERIC-RVI20U32 %s
+// MCPU-GENERIC-RVI20U32: "-target-cpu" "generic-rvi20u32"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-a"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-c"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-d"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-f"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-m"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-abi" "ilp32"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rvi20u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVI20U64 %s
+// MCPU-GENERIC-RVI20U64: "-target-cpu" "generic-rvi20u64"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-a"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-c"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-d"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-f"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-m"
+// MCPU-GENERIC-RVI20U64-SAME: "-target-abi" "lp64"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva20u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA20U64 %s
+// MCPU-GENERIC-RVA20U64: "-target-cpu" "generic-rva20u64"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+m"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+a"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+f"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+d"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+c"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccamoa"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccif"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicclsm"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccrse"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicntr"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicsr"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+za128rs"
+// MCPU-GENERIC-RVA20U64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva20s64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA20S64 %s
+// MCPU-GENERIC-RVA20S64: "-target-cpu" "generic-rva20s64"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+m"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+a"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+f"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+d"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+c"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccamoa"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccif"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicclsm"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccrse"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicntr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicsr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zifencei"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+za128rs"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ssccptr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+sstvala"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+sstvecd"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+svade"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+svbare"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva22u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA22U64 %s
+// MCPU-GENERIC-RVA22U64: "-target-cpu" "generic-rva22u64"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+m"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+a"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+f"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+d"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+c"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zic64b"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicbom"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicbop"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicb

[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #90143)

2024-04-26 Thread Jack Styles via cfe-commits

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

LGTM!

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


[clang] [llvm] [RISCV] Add subtarget features for profiles (PR #84877)

2024-04-26 Thread Kito Cheng via cfe-commits


@@ -138,6 +155,8 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
   /// initializeProperties().
   RISCVProcFamilyEnum getProcFamily() const { return RISCVProcFamily; }
 
+  RISCVProfileEnum getRISCVProfile() const { return RISCVProfile; }
+

kito-cheng wrote:

I guess it little bit same situation like those macro extensions, so what if 
user manually specify all extension present in certain profile? does it will 
detect right when invoke `getRISCVProfile`?

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


[clang] [llvm] [RISCV] Add subtarget features for profiles (PR #84877)

2024-04-26 Thread Pengcheng Wang via cfe-commits

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

>From ec68548a470d6d9032a900a725e95b92691657b2 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Tue, 12 Mar 2024 14:28:09 +0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/test/Driver/riscv-cpus.c| 319 ++
 clang/test/Misc/target-invalid-cpu-note.c |   8 +-
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 224 ++-
 3 files changed, 539 insertions(+), 12 deletions(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index ff2bd6f7c8ba34..a285f0f9c41f54 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -302,3 +302,322 @@
 
 // RUN: not %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 
-march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
 // MISMATCH-ARCH: cpu 'generic-rv32' does not support rv64
+
+// Check profile CPUs
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rvi20u32 | 
FileCheck -check-prefix=MCPU-GENERIC-RVI20U32 %s
+// MCPU-GENERIC-RVI20U32: "-target-cpu" "generic-rvi20u32"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-a"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-c"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-d"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-f"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-m"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-abi" "ilp32"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rvi20u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVI20U64 %s
+// MCPU-GENERIC-RVI20U64: "-target-cpu" "generic-rvi20u64"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-a"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-c"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-d"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-f"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-m"
+// MCPU-GENERIC-RVI20U64-SAME: "-target-abi" "lp64"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva20u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA20U64 %s
+// MCPU-GENERIC-RVA20U64: "-target-cpu" "generic-rva20u64"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+m"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+a"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+f"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+d"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+c"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccamoa"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccif"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicclsm"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccrse"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicntr"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicsr"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+za128rs"
+// MCPU-GENERIC-RVA20U64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva20s64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA20S64 %s
+// MCPU-GENERIC-RVA20S64: "-target-cpu" "generic-rva20s64"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+m"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+a"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+f"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+d"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+c"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccamoa"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccif"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicclsm"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccrse"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicntr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicsr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zifencei"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+za128rs"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ssccptr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+sstvala"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+sstvecd"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+svade"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+svbare"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva22u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA22U64 %s
+// MCPU-GENERIC-RVA22U64: "-target-cpu" "generic-rva22u64"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+m"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+a"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+f"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+d"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+c"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zic64b"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicbom"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicbop"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicb

[clang] [clang] Implement constexpr evaluation for `__builtin_{add,sub}c` (PR #66005)

2024-04-26 Thread Daniel Bertalan via cfe-commits

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


[clang] [clang] Implement constexpr evaluation for `__builtin_{add,sub}c` (PR #66005)

2024-04-26 Thread Daniel Bertalan via cfe-commits

BertalanD wrote:

Obsoleted by #81656 

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


[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #90143)

2024-04-26 Thread David Green via cfe-commits


@@ -447,6 +447,16 @@ def TuneNeoverseN2 : SubtargetFeature<"neoversen2", 
"ARMProcFamily", "NeoverseN2
   FeatureEnableSelectOptimize,
   FeaturePredictableSelectIsExpensive]>;
 
+def TuneNeoverseN3 : SubtargetFeature<"neoversen3", "ARMProcFamily", 
"NeoverseN3",
+  "Neoverse N3 ARM processors", [
+  FeatureFuseAES,
+  FeaturePostRAScheduler,
+  FeatureCmpBccFusion,

davemgreen wrote:

Hi - Should FeatureCmpBccFusion be enabled over what is in N2? The core might 
well be able to fuse them, but I don't think that is new and from what I 
remember the performance was sometimes worse with it enabled. (I think llvm's 
implementation of FeatureCmpBccFusion might be a bit more aggressive than is 
helpful).

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


[clang] [llvm] [RISCV] Add subtarget features for profiles (PR #84877)

2024-04-26 Thread Pengcheng Wang via cfe-commits


@@ -138,6 +155,8 @@ class RISCVSubtarget : public RISCVGenSubtargetInfo {
   /// initializeProperties().
   RISCVProcFamilyEnum getProcFamily() const { return RISCVProcFamily; }
 
+  RISCVProfileEnum getRISCVProfile() const { return RISCVProfile; }
+

wangpc-pp wrote:

Curently no, but we can support them in `RISCVISAInfo::updateCombination()`.
And I don't know if we need `getRISCVProfile` function, maybe we should remove 
it because there is no user.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits

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


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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-verify=expected,new
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-fno-relaxed-template-template-args -verify=expected,old

Endilll wrote:

We don't test non-conforming modes of operation in DR test suite.
This should be tested elsewhere, e.g. in SemaTemplate tests.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-verify=expected,new

Endilll wrote:

Why only C++23 is tested? DR tests should test all language modes.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Matheus Izvekov via cfe-commits


@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-verify=expected,new
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-fno-relaxed-template-template-args -verify=expected,old

mizvekov wrote:

Okay, I think I misunderstood then what `CXX/drs` was about, I should probably 
move it elsewhere.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Matheus Izvekov via cfe-commits


@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-verify=expected,new

mizvekov wrote:

While it's true this is a DR, I just don't think for this particular case it's 
worth the cost of testing every single mode, as there are no particularly 
interesting interactions there.
Moot point as I will be moving it away anyway.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov updated 
https://github.com/llvm/llvm-project/pull/89807

>From 43f813d0a1a87b6cad9b859237489778f4f2945f Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Tue, 9 Apr 2024 01:14:28 -0300
Subject: [PATCH] [clang] Enable C++17 relaxed template template argument
 matching by default

In order to implement this as a DR and avoid breaking reasonable code
that worked before P0522, this patch implements a provisional resolution
for CWG2398: When deducing template template parameters against each other,
and the argument side names a template specialization, instead of just
deducing A, we instead deduce a synthesized template template parameter based
on A, but with it's parameters using the template specialization's arguments
as defaults.

The driver flag is deprecated with a warning.

With this patch, we finally mark C++17 support in clang as complete.

Closes #55894
---
 clang/docs/ReleaseNotes.rst   |  18 +++
 .../clang/Basic/DiagnosticDriverKinds.td  |   2 +-
 clang/include/clang/Basic/LangOptions.def |   2 +-
 clang/include/clang/Driver/Options.td |   8 +-
 clang/lib/Driver/SanitizerArgs.cpp|   9 +-
 clang/lib/Driver/ToolChains/Clang.cpp |  16 ++-
 clang/lib/Sema/SemaTemplate.cpp   |   3 -
 clang/lib/Sema/SemaTemplateDeduction.cpp  | 107 +++-
 .../temp/temp.arg/temp.arg.template/p3-2a.cpp |   2 +-
 clang/test/CodeGenCXX/mangle-concept.cpp  |   4 +-
 .../frelaxed-template-template-args.cpp   |   5 +
 clang/test/Lexer/cxx-features.cpp |   6 +-
 clang/test/SemaTemplate/cwg2398.cpp   | 115 ++
 clang/test/SemaTemplate/default-arguments.cpp |   7 +-
 .../instantiate-template-template-parm.cpp|  17 ++-
 clang/test/SemaTemplate/nested-template.cpp   |   8 +-
 clang/test/SemaTemplate/temp_arg_template.cpp |   6 +-
 .../SemaTemplate/temp_arg_template_cxx1z.cpp  |   2 +-
 clang/www/cxx_status.html |  18 ++-
 19 files changed, 292 insertions(+), 63 deletions(-)
 create mode 100644 clang/test/Driver/frelaxed-template-template-args.cpp
 create mode 100644 clang/test/SemaTemplate/cwg2398.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f5e5d3a2e6ea36..f525bdd73010cb 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -48,6 +48,11 @@ C++ Specific Potentially Breaking Changes
 - Clang now diagnoses function/variable templates that shadow their own 
template parameters, e.g. ``template void T();``.
   This error can be disabled via `-Wno-strict-primary-template-shadow` for 
compatibility with previous versions of clang.
 
+- The behavior controlled by the `-frelaxed-template-template-args` flag is now
+  on by default, and the flag is deprecated. Until the flag is finally removed,
+  it's negative spelling can be used to obtain compatibility with previous
+  versions of clang.
+
 ABI Changes in This Version
 ---
 - Fixed Microsoft name mangling of implicitly defined variables used for thread
@@ -88,6 +93,16 @@ sections with improvements to Clang's support for those 
languages.
 
 C++ Language Changes
 
+- C++17 support is now completed, with the enablement of the
+  relaxed temlate template argument matching rules introduced in P0522,
+  which was retroactively applied as a defect report.
+  While the implementation already existed since Clang 4, it was turned off by
+  default, and was controlled with the `-frelaxed-template-template-args` flag.
+  In this release, we implement provisional wording for a core defect on
+  P0522 (CWG2398), which avoids the most serious compatibility issues caused
+  by it, allowing us to enable it by default in this release.
+  The flag is now deprecated, and will be removed in the next release, but can
+  still be used to turn it off and regain compatibility with previous versions.
 - Implemented ``_BitInt`` literal suffixes ``__wb`` or ``__WB`` as a Clang 
extension with ``unsigned`` modifiers also allowed. (#GH85223).
 
 C++20 Feature Support
@@ -152,6 +167,9 @@ Resolutions to C++ Defect Reports
 - Clang now diagnoses declarative nested-name-specifiers with 
pack-index-specifiers.
   (`CWG2858: Declarative nested-name-specifiers and pack-index-specifiers 
`_).
 
+- P0522 implementation is enabled by default in all language versions, and
+  provisional wording for CWG2398 is implemented.
+
 C Language Changes
 --
 
diff --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index ed3fd9b1c4a55b..9781fcaa4ff5e9 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -435,7 +435,7 @@ def warn_drv_diagnostics_misexpect_requires_pgo : Warning<
 def warn_drv_clang_unsupported : Warning<
   "the clang compiler does not support '%0'">

[clang] c2db883 - [clang][Interp][NFC] Print virtual bases in Record::dump()

2024-04-26 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-26T10:21:27+02:00
New Revision: c2db883ff4340b2f70154eca04e3adbc8e0d082c

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

LOG: [clang][Interp][NFC] Print virtual bases in Record::dump()

Added: 


Modified: 
clang/lib/AST/Interp/Disasm.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/Disasm.cpp b/clang/lib/AST/Interp/Disasm.cpp
index e847a237660d07..01cc88ea9a8459 100644
--- a/clang/lib/AST/Interp/Disasm.cpp
+++ b/clang/lib/AST/Interp/Disasm.cpp
@@ -270,8 +270,6 @@ LLVM_DUMP_METHOD void Record::dump(llvm::raw_ostream &OS, 
unsigned Indentation,
 ++I;
   }
 
-  // FIXME: Virtual bases.
-
   I = 0;
   for (const Record::Field &F : fields()) {
 OS.indent(Indent) << "- Field " << I << ": ";
@@ -282,6 +280,14 @@ LLVM_DUMP_METHOD void Record::dump(llvm::raw_ostream &OS, 
unsigned Indentation,
 OS << ". Offset " << (Offset + F.Offset) << "\n";
 ++I;
   }
+
+  I = 0;
+  for (const Record::Base &B : virtual_bases()) {
+OS.indent(Indent) << "- Virtual Base " << I << ". Offset "
+  << (Offset + B.Offset) << "\n";
+B.R->dump(OS, Indentation + 1, Offset + B.Offset);
+++I;
+  }
 }
 
 LLVM_DUMP_METHOD void Block::dump(llvm::raw_ostream &OS) const {



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


[clang] bc8a4ea - [clang][Interp][NFC] Move collectBaseOffset() to Context

2024-04-26 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-26T10:21:27+02:00
New Revision: bc8a4ea11070d06374b403cd09b771a99cc6ba1a

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

LOG: [clang][Interp][NFC] Move collectBaseOffset() to Context

We will need this outside of ByteCodeExprGen later.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/Context.cpp
clang/lib/AST/Interp/Context.h

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index 8cd0c198d9a844..bbd2771d37124c 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -110,8 +110,8 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr 
*CE) {
 if (!this->visit(SubExpr))
   return false;
 
-unsigned DerivedOffset = collectBaseOffset(getRecordTy(CE->getType()),
-   
getRecordTy(SubExpr->getType()));
+unsigned DerivedOffset =
+collectBaseOffset(CE->getType(), SubExpr->getType());
 
 return this->emitGetPtrBasePop(DerivedOffset, CE);
   }
@@ -120,8 +120,8 @@ bool ByteCodeExprGen::VisitCastExpr(const CastExpr 
*CE) {
 if (!this->visit(SubExpr))
   return false;
 
-unsigned DerivedOffset = collectBaseOffset(getRecordTy(SubExpr->getType()),
-   getRecordTy(CE->getType()));
+unsigned DerivedOffset =
+collectBaseOffset(SubExpr->getType(), CE->getType());
 
 return this->emitGetPtrDerivedPop(DerivedOffset, CE);
   }
@@ -3529,35 +3529,17 @@ void ByteCodeExprGen::emitCleanup() {
 
 template 
 unsigned
-ByteCodeExprGen::collectBaseOffset(const RecordType *BaseType,
-const RecordType *DerivedType) {
-  assert(BaseType);
-  assert(DerivedType);
-  const auto *FinalDecl = cast(BaseType->getDecl());
-  const RecordDecl *CurDecl = DerivedType->getDecl();
-  const Record *CurRecord = getRecord(CurDecl);
-  assert(CurDecl && FinalDecl);
-
-  unsigned OffsetSum = 0;
-  for (;;) {
-assert(CurRecord->getNumBases() > 0);
-// One level up
-for (const Record::Base &B : CurRecord->bases()) {
-  const auto *BaseDecl = cast(B.Decl);
-
-  if (BaseDecl == FinalDecl || BaseDecl->isDerivedFrom(FinalDecl)) {
-OffsetSum += B.Offset;
-CurRecord = B.R;
-CurDecl = BaseDecl;
-break;
-  }
-}
-if (CurDecl == FinalDecl)
-  break;
-  }
+ByteCodeExprGen::collectBaseOffset(const QualType BaseType,
+const QualType DerivedType) {
+  const auto extractRecordDecl = [](QualType Ty) -> const CXXRecordDecl * {
+if (const auto *PT = dyn_cast(Ty))
+  return PT->getPointeeType()->getAsCXXRecordDecl();
+return Ty->getAsCXXRecordDecl();
+  };
+  const CXXRecordDecl *BaseDecl = extractRecordDecl(BaseType);
+  const CXXRecordDecl *DerivedDecl = extractRecordDecl(DerivedType);
 
-  assert(OffsetSum > 0);
-  return OffsetSum;
+  return Ctx.collectBaseOffset(BaseDecl, DerivedDecl);
 }
 
 /// Emit casts from a PrimType to another PrimType.

diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 7e9dc8631fc0d3..4a57f76ae5b372 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -283,8 +283,8 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
 
   bool emitRecordDestruction(const Record *R);
   bool emitDestruction(const Descriptor *Desc);
-  unsigned collectBaseOffset(const RecordType *BaseType,
- const RecordType *DerivedType);
+  unsigned collectBaseOffset(const QualType BaseType,
+ const QualType DerivedType);
 
 protected:
   /// Variable to storage mapping.

diff  --git a/clang/lib/AST/Interp/Context.cpp 
b/clang/lib/AST/Interp/Context.cpp
index 274178837bf047..d51a57e5e92eae 100644
--- a/clang/lib/AST/Interp/Context.cpp
+++ b/clang/lib/AST/Interp/Context.cpp
@@ -262,3 +262,36 @@ const Function *Context::getOrCreateFunction(const 
FunctionDecl *FD) {
 
   return Func;
 }
+
+unsigned Context::collectBaseOffset(const RecordDecl *BaseDecl,
+const RecordDecl *DerivedDecl) const {
+  assert(BaseDecl);
+  assert(DerivedDecl);
+  const auto *FinalDecl = cast(BaseDecl);
+  const RecordDecl *CurDecl = DerivedDecl;
+  const Record *CurRecord = P->getOrCreateRecord(CurDecl);
+  assert(CurDecl && FinalDecl);
+
+  unsigned OffsetSum = 0;
+  for (;;) {
+assert(CurRecord->getNumBases() > 0);
+// One level up
+for (const Record::Base &B : CurRecord->bases()) {
+  const auto *BaseDecl = cast(B.Decl);
+
+  if (

[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Matheus Izvekov via cfe-commits

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-verify=expected,new
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-fno-relaxed-template-template-args -verify=expected,old

Endilll wrote:

Given that you're fixing CWG2398, you should be adding a test here to update 
https://clang.llvm.org/cxx_dr_status.html. This corner of our test suite lives 
by its own rules to some extent, so you should stay consistent with 700 tests 
we already have.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Matheus Izvekov via cfe-commits


@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-verify=expected,new
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-fno-relaxed-template-template-args -verify=expected,old

mizvekov wrote:

Thanks.

Since the core issue is not resolved by WG21, I don't want to claim to be 
resolving it here with this patch.

And while we don't remove the non-conforming flag, we should still test it, and 
it's just much more economical and error proof that we reuse the same tests.


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


[clang] [llvm] [AMDGPU] Add OpenCL-specific fence address space masks (PR #78572)

2024-04-26 Thread Pierre van Houtryve via cfe-commits


@@ -18319,6 +18320,26 @@ Value *CodeGenFunction::EmitHLSLBuiltinExpr(unsigned 
BuiltinID,
   return nullptr;
 }
 
+void CodeGenFunction::AddAMDGCNAddressSpaceMMRA(llvm::Instruction *Inst,
+llvm::Value *ASMask) {
+  constexpr const char *Tag = "opencl-fence-mem";
+
+  uint64_t Mask = cast(ASMask)->getZExtValue();
+  if (Mask == 0)
+return;
+
+  // 3 bits can be set: local, global, image in that order.
+  LLVMContext &Ctx = Inst->getContext();
+  SmallVector MMRAs;
+  if (Mask & (1 << 0))

Pierre-vh wrote:

@arsenm Do you mean just having a space-separate list of address spaces such as 
`"image local"`?
If that's acceptable then it definitely works for me too

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


[clang] [llvm] [AMDGPU] Add OpenCL-specific fence address space masks (PR #78572)

2024-04-26 Thread Pierre van Houtryve via cfe-commits


@@ -69,6 +69,7 @@ BUILTIN(__builtin_amdgcn_iglp_opt, "vIi", "n")
 BUILTIN(__builtin_amdgcn_s_dcache_inv, "v", "n")
 BUILTIN(__builtin_amdgcn_buffer_wbinvl1, "v", "n")
 BUILTIN(__builtin_amdgcn_fence, "vUicC*", "n")
+BUILTIN(__builtin_amdgcn_masked_fence, "vUiUicC*", "n")

Pierre-vh wrote:

Added docs with tests. I also documented the other fence intrinsic 

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-verify=expected,new
+// RUN: %clang_cc1 %s -fsyntax-only -std=c++23 
-fno-relaxed-template-template-args -verify=expected,old

Endilll wrote:

> Since the core issue is not resolved by WG21, I don't want to claim to be 
> resolving it here with this patch.

It'd be far from the first time we're testing an issue that is still open 
(https://github.com/llvm/llvm-project/blob/bd53c7cce418fe7f3e171859d4718df15d03dc2b/clang/test/CXX/drs/dr24xx.cpp#L62),
 but the fact that 2398 filing lacks any possible resolution that we can be 
testing against, it complicates the matter.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits

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


[clang] [alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes. (PR #90180)

2024-04-26 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa created https://github.com/llvm/llvm-project/pull/90180

None

>From e00d9f1a928f3bec0780a43b64ea9cab5252126e Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Fri, 26 Apr 2024 01:50:35 -0700
Subject: [PATCH] [alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF
 String classes.

---
 .../WebKit/UncountedCallArgsChecker.cpp   |  11 +-
 .../WebKit/call-args-wtf-containers.cpp   | 118 ++
 .../Analysis/Checkers/WebKit/mock-types.h |   2 +-
 3 files changed, 128 insertions(+), 3 deletions(-)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index 8b41a949fd6734..bdd020585a9af1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -220,10 +220,17 @@ class UncountedCallArgsChecker
 return NamespaceName == "WTF" &&
(MethodName == "find" || MethodName == "findIf" ||
 MethodName == "reverseFind" || MethodName == "reverseFindIf" ||
+MethodName == "findIgnoringASCIICase" ||
 MethodName == "get" || MethodName == "inlineGet" ||
-MethodName == "contains" || MethodName == "containsIf") &&
+MethodName == "contains" || MethodName == "containsIf" ||
+MethodName == "containsIgnoringASCIICase" ||
+MethodName == "startsWith" || MethodName == "endsWith" ||
+MethodName == "startsWithIgnoringASCIICase" ||
+MethodName == "endsWithIgnoringASCIICase" ||
+MethodName == "substring") &&
(ClsName.ends_with("Vector") || ClsName.ends_with("Set") ||
-ClsName.ends_with("Map"));
+ClsName.ends_with("Map") || ClsName == "StringImpl" ||
+ClsName.ends_with("String"));
   }
 
   void reportBug(const Expr *CallArg, const ParmVarDecl *Param) const {
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp 
b/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
index 0a63a789856127..17e25d9a627039 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
@@ -4,6 +4,92 @@
 
 namespace WTF {
 
+  constexpr unsigned long notFound = static_cast(-1);
+
+  class String;
+  class StringImpl;
+
+  class StringView {
+  public:
+StringView(const String&);
+  private:
+RefPtr m_impl;
+  };
+
+  class StringImpl {
+  public:
+void ref() const { ++m_refCount; }
+void deref() const {
+  if (!--m_refCount)
+delete this;
+}
+
+static constexpr unsigned s_flagIs8Bit = 1u << 0;
+bool is8Bit() const { return m_hashAndFlags & s_flagIs8Bit; }
+const char* characters8() const { return m_char8; }
+const short* characters16() const { return m_char16; }
+unsigned length() const { return m_length; }
+Ref substring(unsigned position, unsigned length) const;
+
+unsigned long find(char) const;
+unsigned long find(StringView) const;
+unsigned long contains(StringView) const;
+unsigned long findIgnoringASCIICase(StringView) const;
+
+bool startsWith(StringView) const;
+bool startsWithIgnoringASCIICase(StringView) const;
+bool endsWith(StringView) const;
+bool endsWithIgnoringASCIICase(StringView) const;
+
+  private:
+mutable unsigned m_refCount { 0 };
+unsigned m_length { 0 };
+union {
+  const char* m_char8;
+  const short* m_char16;
+};
+unsigned m_hashAndFlags { 0 };
+  };
+
+  class String {
+  public:
+String() = default;
+String(StringImpl& impl) : m_impl(&impl) { }
+String(StringImpl* impl) : m_impl(impl) { }
+String(Ref&& impl) : m_impl(impl.get()) { }
+StringImpl* impl() { return m_impl.get(); }
+unsigned length() const { return m_impl ? m_impl->length() : 0; }
+const char* characters8() const { return m_impl ? m_impl->characters8() : 
nullptr; }
+const short* characters16() const { return m_impl ? m_impl->characters16() 
: nullptr; }
+
+bool is8Bit() const { return !m_impl || m_impl->is8Bit(); }
+
+unsigned long find(char character) const { return m_impl ? 
m_impl->find(character) : notFound; }
+unsigned long find(StringView str) const { return m_impl ? 
m_impl->find(str) : notFound; }
+unsigned long findIgnoringASCIICase(StringView) const;
+
+bool contains(char character) const { return find(character) != notFound; }
+bool contains(StringView) const;
+bool containsIgnoringASCIICase(StringView) const;
+
+bool startsWith(StringView) const;
+bool startsWithIgnoringASCIICase(StringView) const;
+bool endsWith(StringView) const;
+bool endsWithIgnoringASCIICase(StringView) const;
+
+String substring(unsigned position, unsigned length) const
+{
+  if (!m_impl)
+return { };
+  if (!positi

[clang] [alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes. (PR #90180)

2024-04-26 Thread via cfe-commits

llvmbot wrote:




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

Author: Ryosuke Niwa (rniwa)


Changes



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


3 Files Affected:

- (modified) 
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp (+9-2) 
- (modified) clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp 
(+118) 
- (modified) clang/test/Analysis/Checkers/WebKit/mock-types.h (+1-1) 


``diff
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index 8b41a949fd6734..bdd020585a9af1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -220,10 +220,17 @@ class UncountedCallArgsChecker
 return NamespaceName == "WTF" &&
(MethodName == "find" || MethodName == "findIf" ||
 MethodName == "reverseFind" || MethodName == "reverseFindIf" ||
+MethodName == "findIgnoringASCIICase" ||
 MethodName == "get" || MethodName == "inlineGet" ||
-MethodName == "contains" || MethodName == "containsIf") &&
+MethodName == "contains" || MethodName == "containsIf" ||
+MethodName == "containsIgnoringASCIICase" ||
+MethodName == "startsWith" || MethodName == "endsWith" ||
+MethodName == "startsWithIgnoringASCIICase" ||
+MethodName == "endsWithIgnoringASCIICase" ||
+MethodName == "substring") &&
(ClsName.ends_with("Vector") || ClsName.ends_with("Set") ||
-ClsName.ends_with("Map"));
+ClsName.ends_with("Map") || ClsName == "StringImpl" ||
+ClsName.ends_with("String"));
   }
 
   void reportBug(const Expr *CallArg, const ParmVarDecl *Param) const {
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp 
b/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
index 0a63a789856127..17e25d9a627039 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
@@ -4,6 +4,92 @@
 
 namespace WTF {
 
+  constexpr unsigned long notFound = static_cast(-1);
+
+  class String;
+  class StringImpl;
+
+  class StringView {
+  public:
+StringView(const String&);
+  private:
+RefPtr m_impl;
+  };
+
+  class StringImpl {
+  public:
+void ref() const { ++m_refCount; }
+void deref() const {
+  if (!--m_refCount)
+delete this;
+}
+
+static constexpr unsigned s_flagIs8Bit = 1u << 0;
+bool is8Bit() const { return m_hashAndFlags & s_flagIs8Bit; }
+const char* characters8() const { return m_char8; }
+const short* characters16() const { return m_char16; }
+unsigned length() const { return m_length; }
+Ref substring(unsigned position, unsigned length) const;
+
+unsigned long find(char) const;
+unsigned long find(StringView) const;
+unsigned long contains(StringView) const;
+unsigned long findIgnoringASCIICase(StringView) const;
+
+bool startsWith(StringView) const;
+bool startsWithIgnoringASCIICase(StringView) const;
+bool endsWith(StringView) const;
+bool endsWithIgnoringASCIICase(StringView) const;
+
+  private:
+mutable unsigned m_refCount { 0 };
+unsigned m_length { 0 };
+union {
+  const char* m_char8;
+  const short* m_char16;
+};
+unsigned m_hashAndFlags { 0 };
+  };
+
+  class String {
+  public:
+String() = default;
+String(StringImpl& impl) : m_impl(&impl) { }
+String(StringImpl* impl) : m_impl(impl) { }
+String(Ref&& impl) : m_impl(impl.get()) { }
+StringImpl* impl() { return m_impl.get(); }
+unsigned length() const { return m_impl ? m_impl->length() : 0; }
+const char* characters8() const { return m_impl ? m_impl->characters8() : 
nullptr; }
+const short* characters16() const { return m_impl ? m_impl->characters16() 
: nullptr; }
+
+bool is8Bit() const { return !m_impl || m_impl->is8Bit(); }
+
+unsigned long find(char character) const { return m_impl ? 
m_impl->find(character) : notFound; }
+unsigned long find(StringView str) const { return m_impl ? 
m_impl->find(str) : notFound; }
+unsigned long findIgnoringASCIICase(StringView) const;
+
+bool contains(char character) const { return find(character) != notFound; }
+bool contains(StringView) const;
+bool containsIgnoringASCIICase(StringView) const;
+
+bool startsWith(StringView) const;
+bool startsWithIgnoringASCIICase(StringView) const;
+bool endsWith(StringView) const;
+bool endsWithIgnoringASCIICase(StringView) const;
+
+String substring(unsigned position, unsigned length) const
+{
+  if (!m_impl)
+return { };
+  if (!position && length >= m_impl->length())
+return *this;
+  return m_impl->substring(posit

[clang] [alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes. (PR #90180)

2024-04-26 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 10661ba2403f73cd2c4b76ebd177fdcf9261cbf2 
e00d9f1a928f3bec0780a43b64ea9cab5252126e -- 
clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp 
clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp 
clang/test/Analysis/Checkers/WebKit/mock-types.h
``





View the diff from clang-format here.


``diff
diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index bdd020585a..14b3ba4c0c 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -220,9 +220,9 @@ public:
 return NamespaceName == "WTF" &&
(MethodName == "find" || MethodName == "findIf" ||
 MethodName == "reverseFind" || MethodName == "reverseFindIf" ||
-MethodName == "findIgnoringASCIICase" ||
-MethodName == "get" || MethodName == "inlineGet" ||
-MethodName == "contains" || MethodName == "containsIf" ||
+MethodName == "findIgnoringASCIICase" || MethodName == "get" ||
+MethodName == "inlineGet" || MethodName == "contains" ||
+MethodName == "containsIf" ||
 MethodName == "containsIgnoringASCIICase" ||
 MethodName == "startsWith" || MethodName == "endsWith" ||
 MethodName == "startsWithIgnoringASCIICase" ||

``




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


[clang-tools-extra] cf5a8b4 - [clang] Enable sized deallocation by default in C++14 onwards (#83774)

2024-04-26 Thread via cfe-commits

Author: Pengcheng Wang
Date: 2024-04-26T16:59:12+08:00
New Revision: cf5a8b489464d09dfdd7a48ce7c8b41d3c9bf819

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

LOG: [clang] Enable sized deallocation by default in C++14 onwards (#83774)


Since C++14 has been released for about nine years and most standard
libraries have implemented sized deallocation functions, it's time to
make this feature default again.

This is another try of https://reviews.llvm.org/D112921.

Fixes #60061

Added: 


Modified: 
clang-tools-extra/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
clang/docs/ReleaseNotes.rst
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/lib/Driver/ToolChains/ZOS.cpp
clang/test/AST/ast-dump-expr-json.cpp
clang/test/AST/ast-dump-expr.cpp
clang/test/AST/ast-dump-stmt-json.cpp
clang/test/Analysis/cxxnewexpr-callback.cpp

clang/test/CXX/basic/basic.stc/basic.stc.dynamic/basic.stc.dynamic.deallocation/p2.cpp
clang/test/CXX/drs/cwg292.cpp
clang/test/CXX/expr/expr.unary/expr.new/p14.cpp
clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
clang/test/CodeGenCXX/delete-two-arg.cpp
clang/test/CodeGenCXX/delete.cpp
clang/test/CodeGenCXX/dllimport.cpp
clang/test/CodeGenCXX/new.cpp
clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp
clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp
clang/test/CodeGenCoroutines/coro-alloc.cpp
clang/test/CodeGenCoroutines/coro-cleanup.cpp
clang/test/CodeGenCoroutines/coro-dealloc.cpp
clang/test/CodeGenCoroutines/coro-gro.cpp
clang/test/CodeGenCoroutines/pr56919.cpp
clang/test/Lexer/cxx-features.cpp
clang/test/PCH/cxx1z-aligned-alloc.cpp
clang/test/SemaCXX/MicrosoftExtensions.cpp
clang/test/SemaCXX/builtin-operator-new-delete.cpp
clang/test/SemaCXX/cxx1y-sized-deallocation.cpp
clang/test/SemaCXX/unavailable_aligned_allocation.cpp
clang/tools/clang-repl/CMakeLists.txt
clang/unittests/Interpreter/CMakeLists.txt
clang/unittests/StaticAnalyzer/CallEventTest.cpp
clang/www/cxx_status.html
libcxx/test/libcxx/language.support/support.dynamic/libcpp_deallocate.sh.cpp

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.array/sized_delete_array14.pass.cpp

libcxx/test/std/language.support/support.dynamic/new.delete/new.delete.single/sized_delete14.pass.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 799a549ff0816e..88aae2729904f4 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -839,7 +839,9 @@ TEST_F(TargetDeclTest, OverloadExpr) {
   [[delete]] x;
 }
   )cpp";
-  EXPECT_DECLS("CXXDeleteExpr", "void operator delete(void *) noexcept");
+  // Sized deallocation is enabled by default in C++14 onwards.
+  EXPECT_DECLS("CXXDeleteExpr",
+   "void operator delete(void *, unsigned long) noexcept");
 }
 
 TEST_F(TargetDeclTest, DependentExprs) {

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
index 78f021144b2e19..f86fe8a4c5b14f 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/misc/new-delete-overloads.cpp
@@ -12,16 +12,6 @@ struct S {
 // CHECK-MESSAGES: :[[@LINE+1]]:7: warning: declaration of 'operator new' has 
no matching declaration of 'operator delete' at the same scope
 void *operator new(size_t size) noexcept(false);
 
-struct T {
-  // Sized deallocations are not enabled by default, and so this new/delete 
pair
-  // does not match. However, we expect only one warning, for the new, because
-  // the operator delete is a placement delete and we do not warn on 
mismatching
-  // placement operations.
-  // CHECK-MESSAGES: :[[@LINE+1]]:9: warning: declaration of 'operator new' 
has no matching declaration of 'operator delete' at the same scope
-  void *operator new(size_t size) noexcept;
-  void operator delete(void *ptr, size_t) noexcept; // ok only if sized 
deallocation is enabled
-};
-
 struct U {
   void *operator new(size_t size) noexcept;
   void operator delete(void *ptr) noexcept;

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index f5e5d3a2e6ea36..1576f681707de0 100644
--- a/clang/docs

[clang] [clang-tools-extra] [libcxx] [clang] Enable sized deallocation by default in C++14 onwards (PR #83774)

2024-04-26 Thread Pengcheng Wang via cfe-commits

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


[clang-tools-extra] [clangd] Expand response files before CDB interpolation (PR #75753)

2024-04-26 Thread via cfe-commits

twmht wrote:

@HighCommander4 

can you have a look for this? 
https://discourse.cmake.org/t/cmake-target-include-directories-doesnt-export-to-compile-commands-json-when-using-cuda/10072/2

I am using clangd language server for neovim, but it seems that it still can't 
expand rsp files automatically.

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread via cfe-commits


@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A,
+  TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+auto *T = cast(A);
+// FIXME: DefaultArgument can't represent a pack.
+if (T->isParameterPack())

cor3ntin wrote:

My question was more whether we want to deduce packs at all.

I think the new behavior make sense, in that it is consistent with 
https://eel.is/c++draft/temp.deduct#partial-11 (
I suspect because both candidates are valid, this tie breaker gets triggered)

We might change that in the future, but now packs can't be defaulted, so I 
struggle to come up to think of a case where considering the pack would change 
the order of partial ordering (and not trailing packs can't be deduced)

here are more tests which I think are consistent https://godbolt.org/z/5Ke3TGfK6


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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread via cfe-commits


@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A,
+  TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+auto *T = cast(A);
+// FIXME: DefaultArgument can't represent a pack.
+if (T->isParameterPack())
+  return A;
+auto *R = TemplateTypeParmDecl::Create(
+S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(),
+T->getDepth(), T->getIndex(), T->getIdentifier(),
+T->wasDeclaredWithTypename(), /*ParameterPack=*/false,
+T->hasTypeConstraint());
+R->setDefaultArgument(
+S.Context.getTrivialTypeSourceInfo(Default.getAsType()));
+if (R->hasTypeConstraint()) {
+  auto *C = R->getTypeConstraint();
+  R->setTypeConstraint(C->getConceptReference(),
+   C->getImmediatelyDeclaredConstraint());

cor3ntin wrote:

Can you point me to where these tests are?

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread via cfe-commits

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


[clang] [alpha.webkit.UncountedCallArgsChecker] Ignore methods of WTF String classes. (PR #90180)

2024-04-26 Thread Ryosuke Niwa via cfe-commits

https://github.com/rniwa updated https://github.com/llvm/llvm-project/pull/90180

>From e00d9f1a928f3bec0780a43b64ea9cab5252126e Mon Sep 17 00:00:00 2001
From: Ryosuke Niwa 
Date: Fri, 26 Apr 2024 01:50:35 -0700
Subject: [PATCH 1/2] [alpha.webkit.UncountedCallArgsChecker] Ignore methods of
 WTF String classes.

---
 .../WebKit/UncountedCallArgsChecker.cpp   |  11 +-
 .../WebKit/call-args-wtf-containers.cpp   | 118 ++
 .../Analysis/Checkers/WebKit/mock-types.h |   2 +-
 3 files changed, 128 insertions(+), 3 deletions(-)

diff --git 
a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
index 8b41a949fd6734..bdd020585a9af1 100644
--- a/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/WebKit/UncountedCallArgsChecker.cpp
@@ -220,10 +220,17 @@ class UncountedCallArgsChecker
 return NamespaceName == "WTF" &&
(MethodName == "find" || MethodName == "findIf" ||
 MethodName == "reverseFind" || MethodName == "reverseFindIf" ||
+MethodName == "findIgnoringASCIICase" ||
 MethodName == "get" || MethodName == "inlineGet" ||
-MethodName == "contains" || MethodName == "containsIf") &&
+MethodName == "contains" || MethodName == "containsIf" ||
+MethodName == "containsIgnoringASCIICase" ||
+MethodName == "startsWith" || MethodName == "endsWith" ||
+MethodName == "startsWithIgnoringASCIICase" ||
+MethodName == "endsWithIgnoringASCIICase" ||
+MethodName == "substring") &&
(ClsName.ends_with("Vector") || ClsName.ends_with("Set") ||
-ClsName.ends_with("Map"));
+ClsName.ends_with("Map") || ClsName == "StringImpl" ||
+ClsName.ends_with("String"));
   }
 
   void reportBug(const Expr *CallArg, const ParmVarDecl *Param) const {
diff --git a/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp 
b/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
index 0a63a789856127..17e25d9a627039 100644
--- a/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
+++ b/clang/test/Analysis/Checkers/WebKit/call-args-wtf-containers.cpp
@@ -4,6 +4,92 @@
 
 namespace WTF {
 
+  constexpr unsigned long notFound = static_cast(-1);
+
+  class String;
+  class StringImpl;
+
+  class StringView {
+  public:
+StringView(const String&);
+  private:
+RefPtr m_impl;
+  };
+
+  class StringImpl {
+  public:
+void ref() const { ++m_refCount; }
+void deref() const {
+  if (!--m_refCount)
+delete this;
+}
+
+static constexpr unsigned s_flagIs8Bit = 1u << 0;
+bool is8Bit() const { return m_hashAndFlags & s_flagIs8Bit; }
+const char* characters8() const { return m_char8; }
+const short* characters16() const { return m_char16; }
+unsigned length() const { return m_length; }
+Ref substring(unsigned position, unsigned length) const;
+
+unsigned long find(char) const;
+unsigned long find(StringView) const;
+unsigned long contains(StringView) const;
+unsigned long findIgnoringASCIICase(StringView) const;
+
+bool startsWith(StringView) const;
+bool startsWithIgnoringASCIICase(StringView) const;
+bool endsWith(StringView) const;
+bool endsWithIgnoringASCIICase(StringView) const;
+
+  private:
+mutable unsigned m_refCount { 0 };
+unsigned m_length { 0 };
+union {
+  const char* m_char8;
+  const short* m_char16;
+};
+unsigned m_hashAndFlags { 0 };
+  };
+
+  class String {
+  public:
+String() = default;
+String(StringImpl& impl) : m_impl(&impl) { }
+String(StringImpl* impl) : m_impl(impl) { }
+String(Ref&& impl) : m_impl(impl.get()) { }
+StringImpl* impl() { return m_impl.get(); }
+unsigned length() const { return m_impl ? m_impl->length() : 0; }
+const char* characters8() const { return m_impl ? m_impl->characters8() : 
nullptr; }
+const short* characters16() const { return m_impl ? m_impl->characters16() 
: nullptr; }
+
+bool is8Bit() const { return !m_impl || m_impl->is8Bit(); }
+
+unsigned long find(char character) const { return m_impl ? 
m_impl->find(character) : notFound; }
+unsigned long find(StringView str) const { return m_impl ? 
m_impl->find(str) : notFound; }
+unsigned long findIgnoringASCIICase(StringView) const;
+
+bool contains(char character) const { return find(character) != notFound; }
+bool contains(StringView) const;
+bool containsIgnoringASCIICase(StringView) const;
+
+bool startsWith(StringView) const;
+bool startsWithIgnoringASCIICase(StringView) const;
+bool endsWith(StringView) const;
+bool endsWithIgnoringASCIICase(StringView) const;
+
+String substring(unsigned position, unsigned length) const
+{
+  if (!m_impl)
+return { };
+  if (!position

[clang] 15f0272 - [clang][Interp] Improve support for virtual bases

2024-04-26 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-04-26T11:10:45+02:00
New Revision: 15f02723d49be9a828fbf072966a225babd60457

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

LOG: [clang][Interp] Improve support for virtual bases

Fix initializing virtual bases. We only consider their base size,
not their virtual size because they get flattened into the Record
hierarchy when we create them. Fix that and also virtual
derived-to-base casts.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/lib/AST/Interp/ByteCodeStmtGen.cpp
clang/lib/AST/Interp/Descriptor.cpp
clang/lib/AST/Interp/Interp.h
clang/test/AST/Interp/cxx23.cpp
clang/test/AST/Interp/records.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index bbd2771d37124c..588ffa55c11e61 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -110,10 +110,29 @@ bool ByteCodeExprGen::VisitCastExpr(const 
CastExpr *CE) {
 if (!this->visit(SubExpr))
   return false;
 
-unsigned DerivedOffset =
-collectBaseOffset(CE->getType(), SubExpr->getType());
+const auto extractRecordDecl = [](QualType Ty) -> const CXXRecordDecl * {
+  if (const auto *PT = dyn_cast(Ty))
+return PT->getPointeeType()->getAsCXXRecordDecl();
+  return Ty->getAsCXXRecordDecl();
+};
 
-return this->emitGetPtrBasePop(DerivedOffset, CE);
+// FIXME: We can express a series of non-virtual casts as a single
+// GetPtrBasePop op.
+QualType CurType = SubExpr->getType();
+for (const CXXBaseSpecifier *B : CE->path()) {
+  if (B->isVirtual()) {
+if (!this->emitGetPtrVirtBasePop(extractRecordDecl(B->getType()), CE))
+  return false;
+CurType = B->getType();
+  } else {
+unsigned DerivedOffset = collectBaseOffset(B->getType(), CurType);
+if (!this->emitGetPtrBasePop(DerivedOffset, CE))
+  return false;
+CurType = B->getType();
+  }
+}
+
+return true;
   }
 
   case CK_BaseToDerived: {

diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp 
b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index 36dab6252ece67..9b8e64f1138559 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -189,14 +189,24 @@ bool ByteCodeStmtGen::visitFunc(const 
FunctionDecl *F) {
 if (!emitFieldInitializer(F, F->Offset, InitExpr))
   return false;
   } else if (const Type *Base = Init->getBaseClass()) {
-// Base class initializer.
-// Get This Base and call initializer on it.
 const auto *BaseDecl = Base->getAsCXXRecordDecl();
 assert(BaseDecl);
-const Record::Base *B = R->getBase(BaseDecl);
-assert(B);
-if (!this->emitGetPtrThisBase(B->Offset, InitExpr))
-  return false;
+
+if (Init->isBaseVirtual()) {
+  const Record::Base *B = R->getVirtualBase(BaseDecl);
+  assert(B);
+  if (!this->emitGetPtrThisVirtBase(BaseDecl, InitExpr))
+return false;
+
+} else {
+  // Base class initializer.
+  // Get This Base and call initializer on it.
+  const Record::Base *B = R->getBase(BaseDecl);
+  assert(B);
+  if (!this->emitGetPtrThisBase(B->Offset, InitExpr))
+return false;
+}
+
 if (!this->visitInitializer(InitExpr))
   return false;
 if (!this->emitFinishInitPop(InitExpr))

diff  --git a/clang/lib/AST/Interp/Descriptor.cpp 
b/clang/lib/AST/Interp/Descriptor.cpp
index a4ccc0236d292c..954c58c8cb3716 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -136,28 +136,66 @@ static void moveArrayDesc(Block *B, const std::byte *Src, 
std::byte *Dst,
   }
 }
 
+static void initField(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
+  bool IsActive, const Descriptor *D,
+  unsigned FieldOffset) {
+  bool IsUnion = false; // FIXME
+  auto *Desc = reinterpret_cast(Ptr + FieldOffset) - 1;
+  Desc->Offset = FieldOffset;
+  Desc->Desc = D;
+  Desc->IsInitialized = D->IsArray;
+  Desc->IsBase = false;
+  Desc->IsActive = IsActive && !IsUnion;
+  Desc->IsConst = IsConst || D->IsConst;
+  Desc->IsFieldMutable = IsMutable || D->IsMutable;
+
+  if (auto Fn = D->CtorFn)
+Fn(B, Ptr + FieldOffset, Desc->IsConst, Desc->IsFieldMutable,
+   Desc->IsActive, D);
+}
+
+static void initBase(Block *B, std::byte *Ptr, bool IsConst, bool IsMutable,
+ bool IsActive, const Descriptor *D, unsigned FieldOffset,
+ bool IsVirtualBase) {
+  assert(D);
+  assert(D->ElemRecord);
+
+  bool IsUnion

[clang] [clang] CTAD: implement the missing IsDeducible constraint for alias templates (PR #89358)

2024-04-26 Thread Haojian Wu via cfe-commits

hokein wrote:

It appears that the consensus is to avoid exposing the internal 
`__is_deducible` type trait to end-users, as there are no compelling use cases 
and it's not expected to be used in libc++. This also aligns with the approach 
taken by GCC.

Regarding implementation, the current tablegen-based mechanism doesn't offer an 
optimal solution for defining internal-only builtins. Several options:

1) Making manual changes in the `TypeTrait` structure code, as proposed by 
@AaronBallman. While feasible, this approach may be somewhat hacky and would 
require modifications in multiple places (please see the current 
implementation, which involves four locations).
2) Following the standard defining-builtin approach but emitting a diagnostic 
warning when Clang parses `__is_deducible`. This option seems to strike the 
right balance, as it provides a compromise between adherence to clang's 
standard implementation and user guidance. Additionally, it would allow for 
dedicated lit tests for this type trait.
3) Following the standard approach but omitting the type trait name in the 
`TYPE_TRAIT_2` macro, as suggested by @cor3ntin. However, this approach will 
affect components that need to print the type-trait name (e.g., AST dump, 
diagnostics).

Opinions and thoughts would be appreciated, @AaronBallman, @cor3ntin, 
@erichkeane 


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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread via cfe-commits

cor3ntin wrote:

@mizvekov We have a bunch of related issues, could you look at them
https://github.com/llvm/llvm-project/issues?q=is%3Aissue+is%3Aopen+%22-frelaxed-template-template-args%22
 ?

(and add tests + "Fixes #` to the commit message, as well as mentioning all 
the fixed issues in the release notes)

Thanks!

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Matheus Izvekov via cfe-commits


@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A,
+  TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+auto *T = cast(A);
+// FIXME: DefaultArgument can't represent a pack.
+if (T->isParameterPack())
+  return A;
+auto *R = TemplateTypeParmDecl::Create(
+S.Context, A->getDeclContext(), SourceLocation(), SourceLocation(),
+T->getDepth(), T->getIndex(), T->getIdentifier(),
+T->wasDeclaredWithTypename(), /*ParameterPack=*/false,
+T->hasTypeConstraint());
+R->setDefaultArgument(
+S.Context.getTrivialTypeSourceInfo(Default.getAsType()));
+if (R->hasTypeConstraint()) {
+  auto *C = R->getTypeConstraint();
+  R->setTypeConstraint(C->getConceptReference(),
+   C->getImmediatelyDeclaredConstraint());

mizvekov wrote:

It's the same tests I linked in the other thread: 
https://github.com/llvm/llvm-project/blob/15f02723d49be9a828fbf072966a225babd60457/clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp#L48

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread via cfe-commits

cor3ntin wrote:

In particular #49185, #63281 and #62529 seem worth looking into

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


[clang] [Coverage] Add a new flag to split region after every call. (PR #90031)

2024-04-26 Thread via cfe-commits

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


[clang] [Coverage] Add a new flag to split region after every call. (PR #90031)

2024-04-26 Thread via cfe-commits

c01db33f wrote:

Something has broken; this worked in the test that I tried previously, but it's 
not working correctly on the example I tried to day, so I need to investigate 
what's going on more closely. Closing this PR for now, I'll open a new one if I 
can get it working correctly.

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


[clang] [llvm] [RISCV] Add subtarget features for profiles (PR #84877)

2024-04-26 Thread Pengcheng Wang via cfe-commits

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

>From ec68548a470d6d9032a900a725e95b92691657b2 Mon Sep 17 00:00:00 2001
From: Wang Pengcheng 
Date: Tue, 12 Mar 2024 14:28:09 +0800
Subject: [PATCH 1/3] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20in?=
 =?UTF-8?q?itial=20version?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Created using spr 1.3.4
---
 clang/test/Driver/riscv-cpus.c| 319 ++
 clang/test/Misc/target-invalid-cpu-note.c |   8 +-
 llvm/lib/Target/RISCV/RISCVProcessors.td  | 224 ++-
 3 files changed, 539 insertions(+), 12 deletions(-)

diff --git a/clang/test/Driver/riscv-cpus.c b/clang/test/Driver/riscv-cpus.c
index ff2bd6f7c8ba34..a285f0f9c41f54 100644
--- a/clang/test/Driver/riscv-cpus.c
+++ b/clang/test/Driver/riscv-cpus.c
@@ -302,3 +302,322 @@
 
 // RUN: not %clang --target=riscv32 -### -c %s 2>&1 -mcpu=generic-rv32 
-march=rv64i | FileCheck -check-prefix=MISMATCH-ARCH %s
 // MISMATCH-ARCH: cpu 'generic-rv32' does not support rv64
+
+// Check profile CPUs
+
+// RUN: %clang -target riscv32 -### -c %s 2>&1 -mcpu=generic-rvi20u32 | 
FileCheck -check-prefix=MCPU-GENERIC-RVI20U32 %s
+// MCPU-GENERIC-RVI20U32: "-target-cpu" "generic-rvi20u32"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-a"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-c"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-d"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-f"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-feature" "-m"
+// MCPU-GENERIC-RVI20U32-SAME: "-target-abi" "ilp32"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rvi20u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVI20U64 %s
+// MCPU-GENERIC-RVI20U64: "-target-cpu" "generic-rvi20u64"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-a"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-c"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-d"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-f"
+// MCPU-GENERIC-RVI20U64: "-target-feature" "-m"
+// MCPU-GENERIC-RVI20U64-SAME: "-target-abi" "lp64"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva20u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA20U64 %s
+// MCPU-GENERIC-RVA20U64: "-target-cpu" "generic-rva20u64"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+m"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+a"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+f"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+d"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+c"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccamoa"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccif"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicclsm"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+ziccrse"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicntr"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+zicsr"
+// MCPU-GENERIC-RVA20U64: "-target-feature" "+za128rs"
+// MCPU-GENERIC-RVA20U64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva20s64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA20S64 %s
+// MCPU-GENERIC-RVA20S64: "-target-cpu" "generic-rva20s64"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+m"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+a"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+f"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+d"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+c"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccamoa"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccif"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicclsm"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ziccrse"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicntr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zicsr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+zifencei"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+za128rs"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+ssccptr"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+sstvala"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+sstvecd"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+svade"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-feature" "+svbare"
+// MCPU-GENERIC-RVA20S64-SAME: "-target-abi" "lp64d"
+
+// RUN: %clang -target riscv64 -### -c %s 2>&1 -mcpu=generic-rva22u64 | 
FileCheck -check-prefix=MCPU-GENERIC-RVA22U64 %s
+// MCPU-GENERIC-RVA22U64: "-target-cpu" "generic-rva22u64"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+m"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+a"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+f"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+d"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+c"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zic64b"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicbom"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicbop"
+// MCPU-GENERIC-RVA22U64-SAME: "-target-feature" "+zicb

[clang] [clang] CTAD: implement the missing IsDeducible constraint for alias templates (PR #89358)

2024-04-26 Thread via cfe-commits

cor3ntin wrote:

@hokein Independently of the direction taken I'd like to see a better 
diagnostic than "atomic constraint using an undocumented/cryptic trait that is 
not in the code is not satisfied". So when we try to print atomic constraints, 
we should do something more user friendly for is_deducible. 
(`note_atomic_constraint_evaluated_to_false` in 
`diagnoseWellFormedUnsatisfiedConstraintExpr` AFAICT).
It might be a bit ad-hoc, but I think it's worth doing

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


[clang] [clang] Enable C++17 relaxed template template argument matching by default (PR #89807)

2024-04-26 Thread Matheus Izvekov via cfe-commits


@@ -507,10 +507,62 @@ static TemplateDeductionResult 
DeduceNonTypeTemplateArgument(
   S, TemplateParams, NTTP, DeducedTemplateArgument(New), T, Info, Deduced);
 }
 
+static NamedDecl *DeduceTemplateArguments(Sema &S, NamedDecl *A,
+  TemplateArgument Default) {
+  switch (A->getKind()) {
+  case Decl::TemplateTypeParm: {
+auto *T = cast(A);
+// FIXME: DefaultArgument can't represent a pack.
+if (T->isParameterPack())

mizvekov wrote:

I see.

The code I posted was an attempt to construct such an example, where a pack 
doesn't need to be defaulted as-written for the proposed changes in the rules 
to have an effect. Except that example hits the wall at something else first, 
and I haven't fully investigated that. I haven't excluded the possibility that 
such an example could be constructed yet.

So when I proposed that provisional wording, I didn't exclude packs from the 
equation. I don't see a reason to, as without excluding them, the rules stay 
simpler and more general and should still work.

If we want to exclude them for implementation efficiency reasons, we could, as 
presumably it could still work as-if.

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


[clang] [ASTMatchers] forCallable should not erase binding on success (PR #89657)

2024-04-26 Thread Marco Borgeaud via cfe-commits

https://github.com/marco-antognini-sonarsource updated 
https://github.com/llvm/llvm-project/pull/89657

>From ebc417fe98f1cb0e030ec77c17c0150c3fcca7f9 Mon Sep 17 00:00:00 2001
From: Marco Borgeaud
 <89914223+marco-antognini-sonarsou...@users.noreply.github.com>
Date: Fri, 19 Apr 2024 17:33:22 +0200
Subject: [PATCH] forCallable should not erase binding on success

Do not erase Builder when the first check fails because it could succeed
on the second stack frame.

The problem was that `InnerMatcher.matches` erases the bindings when it
returns false. The appropriate solution is to pass a copy of the
bindings, similar to what `matchesFirstInRange` does.
---
 clang/include/clang/ASTMatchers/ASTMatchers.h |  16 ++-
 .../ASTMatchers/ASTMatchersTraversalTest.cpp  | 130 ++
 2 files changed, 142 insertions(+), 4 deletions(-)

diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index dc1f49525a004a..54671fe4043378 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -8341,20 +8341,28 @@ AST_MATCHER_P(Stmt, forCallable, 
internal::Matcher, InnerMatcher) {
 const auto &CurNode = Stack.back();
 Stack.pop_back();
 if (const auto *FuncDeclNode = CurNode.get()) {
-  if (InnerMatcher.matches(*FuncDeclNode, Finder, Builder)) {
+  BoundNodesTreeBuilder B = *Builder;
+  if (InnerMatcher.matches(*FuncDeclNode, Finder, &B)) {
+*Builder = std::move(B);
 return true;
   }
 } else if (const auto *LambdaExprNode = CurNode.get()) {
+  BoundNodesTreeBuilder B = *Builder;
   if (InnerMatcher.matches(*LambdaExprNode->getCallOperator(), Finder,
-   Builder)) {
+   &B)) {
+*Builder = std::move(B);
 return true;
   }
 } else if (const auto *ObjCMethodDeclNode = CurNode.get()) 
{
-  if (InnerMatcher.matches(*ObjCMethodDeclNode, Finder, Builder)) {
+  BoundNodesTreeBuilder B = *Builder;
+  if (InnerMatcher.matches(*ObjCMethodDeclNode, Finder, &B)) {
+*Builder = std::move(B);
 return true;
   }
 } else if (const auto *BlockDeclNode = CurNode.get()) {
-  if (InnerMatcher.matches(*BlockDeclNode, Finder, Builder)) {
+  BoundNodesTreeBuilder B = *Builder;
+  if (InnerMatcher.matches(*BlockDeclNode, Finder, &B)) {
+*Builder = std::move(B);
 return true;
   }
 } else {
diff --git a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
index 6911d7600a7188..2ecbdf659358fe 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
+++ b/clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
@@ -5916,6 +5916,37 @@ TEST(StatementMatcher, ForCallable) {
   EXPECT_TRUE(notMatches(CppString2,
  returnStmt(forCallable(functionDecl(hasName("F"));
 
+  StringRef CodeWithDeepCallExpr = R"cpp(
+void Other();
+void Function() {
+  {
+(
+  Other()
+);
+  }
+}
+)cpp";
+  auto ForCallableFirst =
+  callExpr(forCallable(functionDecl(hasName("Function"))),
+   callee(functionDecl(hasName("Other")).bind("callee")))
+  .bind("call");
+  auto ForCallableSecond =
+  callExpr(callee(functionDecl(hasName("Other")).bind("callee")),
+   forCallable(functionDecl(hasName("Function"
+  .bind("call");
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  CodeWithDeepCallExpr, ForCallableFirst,
+  std::make_unique>("call")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  CodeWithDeepCallExpr, ForCallableFirst,
+  std::make_unique>("callee")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  CodeWithDeepCallExpr, ForCallableSecond,
+  std::make_unique>("call")));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  CodeWithDeepCallExpr, ForCallableSecond,
+  std::make_unique>("callee")));
+
   // These tests are specific to forCallable().
   StringRef ObjCString1 = "@interface I"
   "-(void) foo;"
@@ -5957,6 +5988,105 @@ TEST(StatementMatcher, ForCallable) {
   binaryOperator(forCallable(blockDecl();
 }
 
+namespace {
+class ForCallablePreservesBindingWithMultipleParentsTestCallback
+: public BoundNodesCallback {
+public:
+  bool run(const BoundNodes *BoundNodes) override {
+FunctionDecl const *FunDecl =
+BoundNodes->getNodeAs("funDecl");
+// Validate test assumptions. This would be expressed as ASSERT_* in
+// a TEST().
+if (!FunDecl) {
+  EXPECT_TRUE(false && "Incorrect test setup");
+  return false;
+}
+auto const *FunDef = FunDecl->getDefinition();
+if (!FunDef || !FunDef->getBody() ||
+FunDef->getNameAsString() != "Function") {
+  EXPECT_TRUE(false && "Incorrect test setup");
+  return false;
+}
+
+ExpectCorrectResult(
+"Baseline",
+callExpr(callee(

[clang] 24c6409 - [clang] Fix -Wunused-variable in ByteCodeStmtGen.cpp (NFC)

2024-04-26 Thread Jie Fu via cfe-commits

Author: Jie Fu
Date: 2024-04-26T17:53:31+08:00
New Revision: 24c6409d56e43a7af3f6be6dd3e7267e243fb162

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

LOG: [clang] Fix -Wunused-variable in ByteCodeStmtGen.cpp (NFC)

llvm-project/clang/lib/AST/Interp/ByteCodeStmtGen.cpp:196:31:
error: unused variable 'B' [-Werror,-Wunused-variable]
  const Record::Base *B = R->getVirtualBase(BaseDecl);
  ^
1 error generated.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeStmtGen.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp 
b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
index 9b8e64f1138559..ec2fe39a8aeae9 100644
--- a/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeStmtGen.cpp
@@ -193,8 +193,7 @@ bool ByteCodeStmtGen::visitFunc(const FunctionDecl 
*F) {
 assert(BaseDecl);
 
 if (Init->isBaseVirtual()) {
-  const Record::Base *B = R->getVirtualBase(BaseDecl);
-  assert(B);
+  assert(R->getVirtualBase(BaseDecl));
   if (!this->emitGetPtrThisVirtBase(BaseDecl, InitExpr))
 return false;
 



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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits


@@ -8340,8 +8340,17 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.

yronglin wrote:

> I don't know if Clang implements all the cases in [class.temporary]

AFAIK, I think Clang covered all the cases in [class.temporary](except 
https://github.com/llvm/llvm-project/pull/87933 and 
https://github.com/llvm/llvm-project/pull/86960 they still WIP).

> And IMO std::is_nothrow_convertible(_v) should be implementable without 
> intrinsic (and the implementation strategy would be [quite 
> simple](https://en.cppreference.com/w/cpp/types/is_convertible#Possible_implementation)).
>  The __is_nothrow_convertible instrinsic should only be meaningful for 
> acceleration of compilation.

Wow! it's sensible to me now, somehow, I've a local patch to build a 
hypothetical function declared `void conv-dest(To) noexcept;`.., I 
don't know why I would do such a thing, lol. 

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits


@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s
+
+auto&& f1() {
+  return 42; // expected-error{{returning reference to local temporary object}}
+}
+const double& f2() {
+  static int x = 42;
+  return x; // expected-error{{returning reference to local temporary object}}
+}
+auto&& id(auto&& r) {
+  return static_cast(r);
+}
+auto&& f3() {
+  return id(42);// OK, but probably a bug
+}
+
+static_assert(__is_convertible(int, const int &));
+static_assert(__is_nothrow_convertible(int, const int &));

yronglin wrote:

Agree!

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits


@@ -8340,8 +8340,17 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.
+if (getLangOpts().CPlusPlus26)
+  Diag(DiagLoc, diag::err_ret_local_temp_addr_ref)
+  << Entity.getType()->isReferenceType() << DiagRange;

yronglin wrote:

I removed the hard error for this case.

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits

https://github.com/yronglin updated 
https://github.com/llvm/llvm-project/pull/89942

>From 8c5f1d0f92d77bffec88759c19133a0bac130f32 Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Wed, 24 Apr 2024 23:36:10 +0800
Subject: [PATCH 1/7] [Clang] Implement P2748R5 "Disallow Binding a Returned
 Glvalue to a Temporary"

Signed-off-by: yronglin 
---
 clang/docs/ReleaseNotes.rst|  4 +++-
 .../include/clang/Basic/DiagnosticSemaKinds.td |  2 ++
 clang/lib/Sema/SemaInit.cpp| 13 +++--
 clang/test/CXX/drs/cwg650.cpp  |  2 +-
 clang/test/CXX/stmt.stmt/stmt.return/p6.cpp| 18 ++
 5 files changed, 35 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/CXX/stmt.stmt/stmt.return/p6.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 64526ed6d06f55..5e07000198d63a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -129,7 +129,9 @@ C++2c Feature Support
 
 - Implemented `P2662R3 Pack Indexing `_.
 
-- Implemented `P2573R2: = delete("should have a reason"); 
`_
+- Implemented `P2573R2: = delete("should have a reason"); 
`_.
+
+- Implemented `P2748R5 Disallow Binding a Returned Glvalue to a Temporary 
`_.
 
 
 Resolutions to C++ Defect Reports
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6732a1a98452ad..7342215db9cc3d 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -9950,6 +9950,8 @@ def warn_ret_stack_addr_ref : Warning<
 def warn_ret_local_temp_addr_ref : Warning<
   "returning %select{address of|reference to}0 local temporary object">,
   InGroup;
+def err_ret_local_temp_addr_ref : Error<
+  "returning %select{address of|reference to}0 local temporary object">;
 def warn_ret_addr_label : Warning<
   "returning address of label, which is local">,
   InGroup;
diff --git a/clang/lib/Sema/SemaInit.cpp b/clang/lib/Sema/SemaInit.cpp
index 793e16df178914..003c4c34810e1f 100644
--- a/clang/lib/Sema/SemaInit.cpp
+++ b/clang/lib/Sema/SemaInit.cpp
@@ -8340,8 +8340,17 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.
+if (getLangOpts().CPlusPlus26)
+  Diag(DiagLoc, diag::err_ret_local_temp_addr_ref)
+  << Entity.getType()->isReferenceType() << DiagRange;
+else
+  Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
+  << Entity.getType()->isReferenceType() << DiagRange;
   }
   break;
 }
diff --git a/clang/test/CXX/drs/cwg650.cpp b/clang/test/CXX/drs/cwg650.cpp
index dcb844095b0598..01a841b04b42d3 100644
--- a/clang/test/CXX/drs/cwg650.cpp
+++ b/clang/test/CXX/drs/cwg650.cpp
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
 // RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
 // RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
-// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -o - 
-fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s 
--check-prefixes CHECK
+// Since C++26, P2748R5 "Disallow Binding a Returned Glvalue to a Temporary". 
Therefore we do not test this issue after C++26.
 
 #if __cplusplus == 199711L
 #define NOTHROW throw()
diff --git a/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp 
b/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp
new file mode 100644
index 00..682d3a8a075d4e
--- /dev/null
+++ b/clang/test/CXX/stmt.stmt/stmt.return/p6.cpp
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s
+
+auto&& f1() {
+  return 42; // expected-error{{returning reference to local temporary object}}
+}
+const double& f2() {
+  static int x = 42;
+  return x; // expected-error{{returning reference to local temporary object}}
+}
+auto&& id(auto&& r) {
+  return static_cast(r);
+}
+a

[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits


@@ -8340,8 +8340,54 @@ void Sema::checkInitializerLifetime(const 
InitializedEntity &Entity,
 << Entity.getType()->isReferenceType() << CLE->getInitializer() << 
2
 << DiagRange;
   } else {
-Diag(DiagLoc, diag::warn_ret_local_temp_addr_ref)
- << Entity.getType()->isReferenceType() << DiagRange;
+// P2748R5: Disallow Binding a Returned Glvalue to a Temporary.
+// [stmt.return]/p6: In a function whose return type is a reference,
+// other than an invented function for std::is_convertible 
([meta.rel]),
+// a return statement that binds the returned reference to a temporary
+// expression ([class.temporary]) is ill-formed.
+//
+// C++0x [meta.rel]p4:
+//   Given the following function prototype:
+//
+// template 
+//   typename add_rvalue_reference::type create();
+//
+//   the predicate condition for a template specialization
+//   is_convertible shall be satisfied if and only if
+//   the return expression in the following code would be
+//   well-formed, including any implicit conversions to the return
+//   type of the function:
+//
+// To test() {
+//   return create();
+// }
+//
+//   Access checking is performed as if in a context unrelated to To 
and
+//   From. Only the validity of the immediate context of the expression
+//   of the return-statement (including conversions to the return type)
+//   is considered.
+//
+// We skip to check whether we are evaluating one of {__is_convertible,
+// __is_nothrow_convertible, __is_convertible_to} type traits
+// expression, because we model the initialization as a
+// copy-initialization of a temporary of the appropriate type, which 
for
+// this expression is identical to the return statement (since NRVO
+// doesn't apply), and not really build a `return create()` in
+// type traits expression evaluation. Therefor, P2748R5 has no impact
+// for evaluation of {__is_convertible, __is_nothrow_convertible,
+// __is_convertible_to}.
+//
+// Clang can correctly handle cases like the following:
+//
+// static_assert(__is_convertible(int, const int &));
+// static_assert(__is_nothrow_convertible(int, const int &));
+// static_assert(__is_convertible_to(int, const int &));

yronglin wrote:

Removed. I originally wanted to explain here why I didn't check whether 
__is_convertible is currently being processed.

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits


@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -std=c++26 -fsyntax-only -verify %s
+
+auto&& f1() {
+  return 42; // expected-error{{returning reference to local temporary object}}
+}
+const double& f2() {
+  static int x = 42;
+  return x; // expected-error{{returning reference to local temporary object}}
+}
+auto&& id(auto&& r) {
+  return static_cast(r);
+}
+auto&& f3() {
+  return id(42);// OK, but probably a bug
+}
+
+static_assert(__is_convertible(int, const int &));
+static_assert(__is_nothrow_convertible(int, const int &));

yronglin wrote:

Added, with a bit change.

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits

yronglin wrote:

> LGTM modulo comment to shorten + test to add Thanks a lot for this PR!

Thanks for your review and help!

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits

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


[clang] [clang] Add test for CWG2149 "Brace elision and array length deduction" (PR #90079)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits


@@ -12702,7 +12702,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2149.html";>2149
 drafting
 Brace elision and array length deduction
-Not resolved
+Not 
Resolved*

Endilll wrote:

As I mentioned in 
https://github.com/llvm/llvm-project/pull/90079#issuecomment-2077691304, CWG 
index page that we fetch from is not updated yet. I checked with CWG chair 
regarding most up-to-date source of CWG issue status, and I'll prepare an 
update to `make_cxx_dr_status` script to reduce amount of confusions like this 
one.

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


[clang] [clang] Add test for CWG2149 "Brace elision and array length deduction" (PR #90079)

2024-04-26 Thread Vlad Serebrennikov via cfe-commits


@@ -0,0 +1,77 @@
+// RUN: %clang_cc1 -std=c++98 -triple x86_64-unknown-unknown %s 
-verify=expected,cxx98 -fexceptions -fcxx-exceptions -pedantic-errors -ast-dump 
| FileCheck %s --check-prefixes CXX98
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++14 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++17 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++20 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++23 -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+// RUN: %clang_cc1 -std=c++2c -triple x86_64-unknown-unknown %s 
-verify=expected,since-cxx11 -fexceptions -fcxx-exceptions -pedantic-errors
+
+#if __cplusplus == 199711L
+#define static_assert(...) __extension__ _Static_assert(__VA_ARGS__)
+// cxx98-error@-1 {{variadic macros are a C99 feature}}
+#endif
+
+namespace cwg2149 { // cwg2149: 3.1 drafting 2024-04

Endilll wrote:

The root cause of your confusion is the same as in the other comment you left. 
Responded there.

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


[clang] [Clang] Implement C++26 P2748R5 "Disallow Binding a Returned Glvalue to a Temporary" (PR #89942)

2024-04-26 Thread via cfe-commits

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


[clang] 0fa1f1f - [LLVM][SVE] Seperate the int and floating-point variants of addqv. (#89762)

2024-04-26 Thread via cfe-commits

Author: Paul Walker
Date: 2024-04-26T11:25:55+01:00
New Revision: 0fa1f1f2d117564d86a0df8383e84341ba85c531

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

LOG: [LLVM][SVE] Seperate the int and floating-point variants of addqv. (#89762)

We only use common intrinsics for operations that treat their element
type as a container of bits.

Added: 


Modified: 
clang/include/clang/Basic/arm_sve.td
clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fp_reduce.c
llvm/include/llvm/IR/IntrinsicsAArch64.td
llvm/lib/IR/AutoUpgrade.cpp
llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td

Removed: 




diff  --git a/clang/include/clang/Basic/arm_sve.td 
b/clang/include/clang/Basic/arm_sve.td
index 6cc249837d3f3d..15340ebb62b365 100644
--- a/clang/include/clang/Basic/arm_sve.td
+++ b/clang/include/clang/Basic/arm_sve.td
@@ -1961,19 +1961,20 @@ def SVPSEL_D : SInst<"svpsel_lane_b64", "PPPm", "Pl", 
MergeNone, "", [IsStreamin
 
 // Standalone sve2.1 builtins
 let TargetGuard = "sve2p1" in {
-def SVORQV   : SInst<"svorqv[_{d}]", "{Pd", "csilUcUsUiUl", MergeNone, 
"aarch64_sve_orqv", [IsReductionQV]>;
-def SVEORQV  : SInst<"sveorqv[_{d}]", "{Pd", "csilUcUsUiUl", MergeNone, 
"aarch64_sve_eorqv", [IsReductionQV]>;
-def SVADDQV  : SInst<"svaddqv[_{d}]", "{Pd", "hfdcsilUcUsUiUl", MergeNone, 
"aarch64_sve_addqv", [IsReductionQV]>;
-def SVANDQV  : SInst<"svandqv[_{d}]", "{Pd", "csilUcUsUiUl", MergeNone, 
"aarch64_sve_andqv", [IsReductionQV]>;
-def SVSMAXQV : SInst<"svmaxqv[_{d}]", "{Pd", "csil", MergeNone, 
"aarch64_sve_smaxqv", [IsReductionQV]>;
-def SVUMAXQV : SInst<"svmaxqv[_{d}]", "{Pd", "UcUsUiUl", MergeNone, 
"aarch64_sve_umaxqv", [IsReductionQV]>;
-def SVSMINQV : SInst<"svminqv[_{d}]", "{Pd", "csil", MergeNone, 
"aarch64_sve_sminqv", [IsReductionQV]>;
-def SVUMINQV : SInst<"svminqv[_{d}]", "{Pd", "UcUsUiUl", MergeNone, 
"aarch64_sve_uminqv", [IsReductionQV]>;
-
-def SVFMAXNMQV: SInst<"svmaxnmqv[_{d}]", "{Pd", "hfd", MergeNone, 
"aarch64_sve_fmaxnmqv", [IsReductionQV]>;
-def SVFMINNMQV: SInst<"svminnmqv[_{d}]", "{Pd", "hfd", MergeNone, 
"aarch64_sve_fminnmqv", [IsReductionQV]>;
-def SVFMAXQV: SInst<"svmaxqv[_{d}]", "{Pd", "hfd", MergeNone, 
"aarch64_sve_fmaxqv", [IsReductionQV]>;
-def SVFMINQV: SInst<"svminqv[_{d}]", "{Pd", "hfd", MergeNone, 
"aarch64_sve_fminqv", [IsReductionQV]>;
+def SVORQV   : SInst<"svorqv[_{d}]",  "{Pd", "csilUcUsUiUl", MergeNone, 
"aarch64_sve_orqv",   [IsReductionQV]>;
+def SVEORQV  : SInst<"sveorqv[_{d}]", "{Pd", "csilUcUsUiUl", MergeNone, 
"aarch64_sve_eorqv",  [IsReductionQV]>;
+def SVADDQV  : SInst<"svaddqv[_{d}]", "{Pd", "csilUcUsUiUl", MergeNone, 
"aarch64_sve_addqv",  [IsReductionQV]>;
+def SVANDQV  : SInst<"svandqv[_{d}]", "{Pd", "csilUcUsUiUl", MergeNone, 
"aarch64_sve_andqv",  [IsReductionQV]>;
+def SVSMAXQV : SInst<"svmaxqv[_{d}]", "{Pd", "csil", MergeNone, 
"aarch64_sve_smaxqv", [IsReductionQV]>;
+def SVUMAXQV : SInst<"svmaxqv[_{d}]", "{Pd", "UcUsUiUl", MergeNone, 
"aarch64_sve_umaxqv", [IsReductionQV]>;
+def SVSMINQV : SInst<"svminqv[_{d}]", "{Pd", "csil", MergeNone, 
"aarch64_sve_sminqv", [IsReductionQV]>;
+def SVUMINQV : SInst<"svminqv[_{d}]", "{Pd", "UcUsUiUl", MergeNone, 
"aarch64_sve_uminqv", [IsReductionQV]>;
+
+def SVFADDQV   : SInst<"svaddqv[_{d}]",   "{Pd", "hfd", MergeNone, 
"aarch64_sve_faddqv",   [IsReductionQV]>;
+def SVFMAXNMQV : SInst<"svmaxnmqv[_{d}]", "{Pd", "hfd", MergeNone, 
"aarch64_sve_fmaxnmqv", [IsReductionQV]>;
+def SVFMINNMQV : SInst<"svminnmqv[_{d}]", "{Pd", "hfd", MergeNone, 
"aarch64_sve_fminnmqv", [IsReductionQV]>;
+def SVFMAXQV   : SInst<"svmaxqv[_{d}]",   "{Pd", "hfd", MergeNone, 
"aarch64_sve_fmaxqv",   [IsReductionQV]>;
+def SVFMINQV   : SInst<"svminqv[_{d}]",   "{Pd", "hfd", MergeNone, 
"aarch64_sve_fminqv",   [IsReductionQV]>;
 }
 
 let TargetGuard = "sve2p1|sme2" in {

diff  --git 
a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fp_reduce.c 
b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fp_reduce.c
index e58cf4e49a37f9..9d5ffdafe8663e 100644
--- a/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fp_reduce.c
+++ b/clang/test/CodeGen/aarch64-sve2p1-intrinsics/acle_sve2p1_fp_reduce.c
@@ -20,13 +20,13 @@
 // CHECK-LABEL: @test_svaddqv_f16(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = tail call  
@llvm.aarch64.sve.convert.from.svbool.nxv8i1( [[PG:%.*]])
-// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> 
@llvm.aarch64.sve.addqv.v8f16.nxv8f16( [[TMP0]],  [[OP:%.*]])
+// CHECK-NEXT:[[TMP1:%.*]] = tail call <8 x half> 
@llvm.aarch64.sve.faddqv.v8f16.nxv8f16( [[TMP0]],  [[OP:%.*]])
 // CHECK-NEXT:ret <8 x half> [[TMP1]]
 //
 // CPP-CHECK-LABEL: @_Z16test_svaddqv_f16u10__SVBool_tu13__SVFloat16_t(
 // CPP-CHECK-NEXT:  entry:
 // CPP-CHEC

[clang] [llvm] [LLVM][SVE] Seperate the int and floating-point variants of addqv. (PR #89762)

2024-04-26 Thread Paul Walker via cfe-commits

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


[clang-tools-extra] [clang-tidy] Ensure nullable variable is not accessed without validity test (PR #90173)

2024-04-26 Thread Julian Schmidt via cfe-commits

https://github.com/5chmidti approved this pull request.


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


[clang] [clang] Add test for CWG2149 "Brace elision and array length deduction" (PR #90079)

2024-04-26 Thread via cfe-commits

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

I'm happy to approve that as is, I expect additional tests to materialize for 
the rest of the paper.
I'm not concerned about the status page, a new core issue list should 
materialize any day now

Thanks

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


[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-26 Thread Tom Eccles via cfe-commits

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


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


[clang] [clang] Add test for CWG2149 "Brace elision and array length deduction" (PR #90079)

2024-04-26 Thread via cfe-commits


@@ -12702,7 +12702,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2149.html";>2149
 drafting
 Brace elision and array length deduction
-Not resolved
+Not 
Resolved*

Sirraide wrote:

> CWG index page that we fetch from

Ah, I see; I didn’t know that that’s how it works. Makes sense.

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


[clang] [flang] [lld] [flang] Generate main only when a Fortran program statement is present (PR #89938)

2024-04-26 Thread Paul Osmialowski via cfe-commits

https://github.com/pawosm-arm approved this pull request.

The -fno-fortran-main flag should disappear before it finds any widespread use.


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


[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #90143)

2024-04-26 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray updated 
https://github.com/llvm/llvm-project/pull/90143

>From 020b30260b501902d728fbc9a92b4bc6fa81af18 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Tue, 2 Apr 2024 22:08:50 +0100
Subject: [PATCH 1/2] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and
 Neoverse-V3AE

Neoverse-N3, Neoverse-V3 and Neoverse-V3AE are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Neoverse-N3:
   https://developer.arm.com/documentation/107997/latest/

Technical Reference Manual for Neoverse-V3:
   https://developer.arm.com/documentation/107734/latest/

Technical Reference Manual for Neoverse-V3AE:
   https://developer.arm.com/documentation/101595/latest/
---
 clang/docs/ReleaseNotes.rst   |  3 +
 clang/test/Driver/aarch64-mcpu.c  |  6 ++
 clang/test/Misc/target-invalid-cpu-note.c |  4 +-
 llvm/docs/ReleaseNotes.rst|  3 +-
 .../llvm/TargetParser/AArch64TargetParser.h   | 21 +++
 llvm/lib/Target/AArch64/AArch64Processors.td  | 46 +++
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 +
 llvm/lib/TargetParser/Host.cpp|  3 +
 .../TargetParser/TargetParserTest.cpp | 58 ++-
 9 files changed, 142 insertions(+), 4 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1576f681707de0..92563262cc6737 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -633,6 +633,9 @@ Arm and AArch64 Support
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
+* Arm Neoverse-N3 (neoverse-n3).
+* Arm Neoverse-V3 (neoverse-v3).
+* Arm Neoverse-V3AE (neoverse-v3ae).
 
 Android Support
 ^^^
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index 77ba43122b2453..ad4a5f9ac6fb80 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -64,10 +64,16 @@
 // NEOVERSE-V1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v2  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V2 %s
 // NEOVERSE-V2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V3 %s
+// NEOVERSE-V3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-V3AE %s
+// NEOVERSE-V3AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3ae"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n1 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N1 %s
 // NEOVERSE-N1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N2 %s
 // NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-n3 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N3 %s
+// NEOVERSE-N3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n3"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-512tvb -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-512TVB %s
 // NEOVERSE-512TVB: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-512tvb"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a520 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A520 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 9c91c4157cd6a0..21d80b7134508f 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, 
cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, 
neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, 
apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, 
apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, 
exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, 
thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, 
carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-

[clang] 468fecf - Fix mismatches between function parameter definitions and declarations (#89512)

2024-04-26 Thread via cfe-commits

Author: Troy Butler
Date: 2024-04-26T13:00:31+02:00
New Revision: 468fecfc39a7ad4a88ac9f8b8acb5ea76cbb1fc7

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

LOG: Fix mismatches between function parameter definitions and declarations 
(#89512)

Addresses issue #88716.

Some function parameter names in the affected header files did not match
the parameter names in the definitions, or were listed in a different
order.

-

Signed-off-by: Troy-Butler 

Added: 


Modified: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
llvm/lib/Transforms/Vectorize/VPlan.h
mlir/lib/Dialect/SparseTensor/Transforms/Utils/SparseTensorIterator.h

Removed: 




diff  --git a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h 
b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
index fac0c04ae2caab..ef23b160a3c032 100644
--- a/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
+++ b/clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
@@ -225,15 +225,11 @@ class StoreManager {
   ///   invalidated. This should include any regions explicitly invalidated
   ///   even if they do not currently have bindings. Pass \c NULL if this
   ///   information will not be used.
-  virtual StoreRef invalidateRegions(Store store,
-  ArrayRef Values,
-  const Expr *E, unsigned Count,
-  const LocationContext *LCtx,
-  const CallEvent *Call,
-  InvalidatedSymbols &IS,
-  RegionAndSymbolInvalidationTraits &ITraits,
-  InvalidatedRegions *InvalidatedTopLevel,
-  InvalidatedRegions *Invalidated) = 0;
+  virtual StoreRef invalidateRegions(
+  Store store, ArrayRef Values, const Expr *Ex, unsigned Count,
+  const LocationContext *LCtx, const CallEvent *Call,
+  InvalidatedSymbols &IS, RegionAndSymbolInvalidationTraits &ITraits,
+  InvalidatedRegions *TopLevelRegions, InvalidatedRegions *Invalidated) = 
0;
 
   /// enterStackFrame - Let the StoreManager to do something when execution
   /// engine is about to execute into a callee.

diff  --git a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp 
b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
index 8ec1ed7529c1cb..ed9a89b14efcca 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineAndOrXor.cpp
@@ -3141,20 +3141,20 @@ Value *InstCombinerImpl::getSelectCondition(Value *A, 
Value *B,
   return nullptr;
 }
 
-/// We have an expression of the form (A & C) | (B & D). Try to simplify this
-/// to "A' ? C : D", where A' is a boolean or vector of booleans.
+/// We have an expression of the form (A & B) | (C & D). Try to simplify this
+/// to "A' ? B : D", where A' is a boolean or vector of booleans.
 /// When InvertFalseVal is set to true, we try to match the pattern
-/// where we have peeked through a 'not' op and A and B are the same:
-/// (A & C) | ~(A | D) --> (A & C) | (~A & ~D) --> A' ? C : ~D
-Value *InstCombinerImpl::matchSelectFromAndOr(Value *A, Value *C, Value *B,
+/// where we have peeked through a 'not' op and A and C are the same:
+/// (A & B) | ~(A | D) --> (A & B) | (~A & ~D) --> A' ? B : ~D
+Value *InstCombinerImpl::matchSelectFromAndOr(Value *A, Value *B, Value *C,
   Value *D, bool InvertFalseVal) {
   // The potential condition of the select may be bitcasted. In that case, look
   // through its bitcast and the corresponding bitcast of the 'not' condition.
   Type *OrigType = A->getType();
   A = peekThroughBitcast(A, true);
-  B = peekThroughBitcast(B, true);
-  if (Value *Cond = getSelectCondition(A, B, InvertFalseVal)) {
-// ((bc Cond) & C) | ((bc ~Cond) & D) --> bc (select Cond, (bc C), (bc D))
+  C = peekThroughBitcast(C, true);
+  if (Value *Cond = getSelectCondition(A, C, InvertFalseVal)) {
+// ((bc Cond) & B) | ((bc ~Cond) & D) --> bc (select Cond, (bc B), (bc D))
 // If this is a vector, we may need to cast to match the condition's 
length.
 // The bitcasts will either all exist or all not exist. The builder will
 // not create unnecessary casts if the types already match.
@@ -3168,11 +3168,11 @@ Value *InstCombinerImpl::matchSelectFromAndOr(Value *A, 
Value *C, Value *B,
   Type *EltTy = Builder.getIntNTy(SelEltSize / Elts);
   SelTy = VectorType::get(EltTy, VecTy->getElementCount());
 }
-Value *BitcastC = Builder.CreateBitCast(C, SelTy);
+Value *BitcastB = Builder.CreateBitCast(B, SelTy);
 if

[clang] [llvm] [mlir] Fix mismatches between function parameter definitions and declarations (PR #89512)

2024-04-26 Thread via cfe-commits

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


[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #90143)

2024-04-26 Thread Jonathan Thackray via cfe-commits


@@ -447,6 +447,16 @@ def TuneNeoverseN2 : SubtargetFeature<"neoversen2", 
"ARMProcFamily", "NeoverseN2
   FeatureEnableSelectOptimize,
   FeaturePredictableSelectIsExpensive]>;
 
+def TuneNeoverseN3 : SubtargetFeature<"neoversen3", "ARMProcFamily", 
"NeoverseN3",
+  "Neoverse N3 ARM processors", [
+  FeatureFuseAES,
+  FeaturePostRAScheduler,
+  FeatureCmpBccFusion,

jthackray wrote:

Thanks for the suggestion, Dave. I've removed the `FeatureCmpBccFusion` feature 
flag in a new commit, as we don't want performance to suffer.

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


[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #90143)

2024-04-26 Thread David Green via cfe-commits

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

Thanks. I didn't check the enabled features but the tunings look good to me.

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


[clang] [analyzer] Removing untrusted buffer size taint warning (PR #68607)

2024-04-26 Thread Daniel Krupp via cfe-commits

https://github.com/dkrupp updated 
https://github.com/llvm/llvm-project/pull/68607

>From 143db26ffe8620c2b45eb15d331466c883bbfce0 Mon Sep 17 00:00:00 2001
From: Daniel Krupp 
Date: Mon, 9 Oct 2023 16:52:13 +0200
Subject: [PATCH 1/4] [analyzer] Removing untrusted buffer size taint warning

alpha.security.taint.TaintPropagation checker
emitted a false warning to the following code

char buf[100];
size_t size = tainted();
if (size > 100)
  return;
memset(buf, 0, size); // warn: untrusted data used as buffer size

The checker does not take into consideration that the
size tainted variable is bounded.

The false warning was emmitted also for the malloc/calloc calls.

These warning (the sink) should be implemented in the
MallocChecker and CStringChecker checkers instead, where more sophisticated
handling can be done taking into consideration buffer size and integer 
constraints.
---
 .../Checkers/GenericTaintChecker.cpp  | 49 +
 .../test/Analysis/taint-diagnostic-visitor.c  | 68 +--
 clang/test/Analysis/taint-generic.c   | 26 ---
 3 files changed, 67 insertions(+), 76 deletions(-)

diff --git a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
index 4ceaf933d0bfc8..b949cac504eddf 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GenericTaintChecker.cpp
@@ -59,13 +59,6 @@ constexpr llvm::StringLiteral MsgSanitizeSystemArgs =
 "Untrusted data is passed to a system call "
 "(CERT/STR02-C. Sanitize data passed to complex subsystems)";
 
-/// Check if tainted data is used as a buffer size in strn.. functions,
-/// and allocators.
-constexpr llvm::StringLiteral MsgTaintedBufferSize =
-"Untrusted data is used to specify the buffer size "
-"(CERT/STR31-C. Guarantee that storage for strings has sufficient space "
-"for character data and the null terminator)";
-
 /// Check if tainted data is used as a custom sink's parameter.
 constexpr llvm::StringLiteral MsgCustomSink =
 "Untrusted data is passed to a user-defined sink";
@@ -733,13 +726,23 @@ void GenericTaintChecker::initTaintRules(CheckerContext 
&C) const {
   {{CDF_MaybeBuiltin, {{"stpcpy"}}},
TR::Prop({{1}}, {{0, ReturnValueIndex}})},
   {{CDF_MaybeBuiltin, {{"strcat"}}},
-   TR::Prop({{1}}, {{0, ReturnValueIndex}})},
+   TR::Prop({{0,1}}, {{0, ReturnValueIndex}})},
   {{CDF_MaybeBuiltin, {{"wcsncat"}}},
TR::Prop({{1}}, {{0, ReturnValueIndex}})},
   {{CDF_MaybeBuiltin, {{"strdup"}}}, TR::Prop({{0}}, 
{{ReturnValueIndex}})},
   {{CDF_MaybeBuiltin, {{"strdupa"}}},
TR::Prop({{0}}, {{ReturnValueIndex}})},
   {{CDF_MaybeBuiltin, {{"wcsdup"}}}, TR::Prop({{0}}, 
{{ReturnValueIndex}})},
+  {{CDF_MaybeBuiltin, BI.getName(Builtin::BImemcpy)},
+   TR::Prop({{1, 2}}, {{0, ReturnValueIndex}})},
+  {{CDF_MaybeBuiltin, {BI.getName(Builtin::BImemmove)}},
+   TR::Prop({{1, 2}}, {{0, ReturnValueIndex}})},
+  {{CDF_MaybeBuiltin, {BI.getName(Builtin::BIstrncpy)}},
+   TR::Prop({{1, 2}}, {{0, ReturnValueIndex}})},
+  {{CDF_MaybeBuiltin, {BI.getName(Builtin::BIstrndup)}},
+   TR::Prop({{0, 1}}, {{ReturnValueIndex}})},
+  {{CDF_MaybeBuiltin, {"bcopy"}},
+   TR::Prop({{0, 2}}, {{1}})},
 
   // Sinks
   {{{"system"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
@@ -753,32 +756,16 @@ void GenericTaintChecker::initTaintRules(CheckerContext 
&C) const {
   {{{"execvp"}}, TR::Sink({{0, 1}}, MsgSanitizeSystemArgs)},
   {{{"execvpe"}}, TR::Sink({{0, 1, 2}}, MsgSanitizeSystemArgs)},
   {{{"dlopen"}}, TR::Sink({{0}}, MsgSanitizeSystemArgs)},
-  {{CDF_MaybeBuiltin, {{"malloc"}}}, TR::Sink({{0}}, 
MsgTaintedBufferSize)},
-  {{CDF_MaybeBuiltin, {{"calloc"}}}, TR::Sink({{0}}, 
MsgTaintedBufferSize)},
-  {{CDF_MaybeBuiltin, {{"alloca"}}}, TR::Sink({{0}}, 
MsgTaintedBufferSize)},
-  {{CDF_MaybeBuiltin, {{"memccpy"}}},
-   TR::Sink({{3}}, MsgTaintedBufferSize)},
-  {{CDF_MaybeBuiltin, {{"realloc"}}},
-   TR::Sink({{1}}, MsgTaintedBufferSize)},
+   // malloc, calloc, alloca, realloc, memccpy
+   // are intentionally left out as taint sinks
+   // because unconditional reporting for these functions
+   // generate many false positives.
+   // These taint sinks should be implemented in other checkers
+   // with more sophisticated sanitation heuristics.
   "setproctitle"}}}, TR::Sink({{0}, 1}, MsgUncontrolledFormatString)},
   "setproctitle_fast"}}},
TR::Sink({{0}, 1}, MsgUncontrolledFormatString)},
-
-  // SinkProps
-  {{CDF_MaybeBuiltin, BI.getName(Builtin::BImemcpy)},
-   TR::SinkProp({{2}}, {{1, 2}}, {{0, ReturnValueIndex}},
-MsgTaintedBufferSize)},
-  {{CDF_MaybeBuiltin, {BI.getName(Builtin::BImemmove)}},
-   TR::SinkProp({{2}}, {{1, 2}}, {{0, ReturnValueIndex}},
-

[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

2024-04-26 Thread via cfe-commits

https://github.com/JinjinLi868 updated 
https://github.com/llvm/llvm-project/pull/89051

>From 0afac9d8a6acedff53089f55eacb92a2880f58aa Mon Sep 17 00:00:00 2001
From: Jinjin Li 
Date: Wed, 17 Apr 2024 16:44:50 +0800
Subject: [PATCH] [clang] Fix half && bfloat16 convert node expr codegen

Data type conversion between fp16 and bf16 will generate fptrunc
and fpextend nodes, but they are actually bitcast nodes.
---
 clang/lib/CodeGen/CGExprScalar.cpp| 15 +++-
 .../test/CodeGen/X86/bfloat16-convert-half.c  | 25 +++
 .../test/CodeGenHIP/bfloat16-half-convert.hip | 71 +++
 3 files changed, 109 insertions(+), 2 deletions(-)
 create mode 100644 clang/test/CodeGen/X86/bfloat16-convert-half.c
 create mode 100644 clang/test/CodeGenHIP/bfloat16-half-convert.hip

diff --git a/clang/lib/CodeGen/CGExprScalar.cpp 
b/clang/lib/CodeGen/CGExprScalar.cpp
index 1f18e0d5ba409a..8e35c801bc9599 100644
--- a/clang/lib/CodeGen/CGExprScalar.cpp
+++ b/clang/lib/CodeGen/CGExprScalar.cpp
@@ -1431,7 +1431,10 @@ Value *ScalarExprEmitter::EmitScalarCast(Value *Src, 
QualType SrcType,
 return Builder.CreateFPToUI(Src, DstTy, "conv");
   }
 
-  if (DstElementTy->getTypeID() < SrcElementTy->getTypeID())
+  if ((DstElementTy->is16bitFPTy() && SrcElementTy->is16bitFPTy())) {
+Value *FloatVal = Builder.CreateFPExt(Src, Builder.getFloatTy(), "fpext");
+return Builder.CreateFPTrunc(FloatVal, DstTy, "fptrunc");
+  } else if (DstElementTy->getTypeID() < SrcElementTy->getTypeID())
 return Builder.CreateFPTrunc(Src, DstTy, "conv");
   return Builder.CreateFPExt(Src, DstTy, "conv");
 }
@@ -1906,7 +1909,15 @@ Value 
*ScalarExprEmitter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
   } else {
 assert(SrcEltTy->isFloatingPointTy() && DstEltTy->isFloatingPointTy() &&
"Unknown real conversion");
-if (DstEltTy->getTypeID() < SrcEltTy->getTypeID())
+if ((DstEltTy->is16bitFPTy() && SrcEltTy->is16bitFPTy())) {
+  auto *ScrVecTy = cast(SrcTy);
+  Value *FloatVal = Builder.CreateFPExt(
+  Src,
+  llvm::VectorType::get(Builder.getFloatTy(),
+ScrVecTy->getElementCount()),
+  "fpext");
+  Res = Builder.CreateFPTrunc(FloatVal, DstTy, "fptrunc");
+} else if (DstEltTy->getTypeID() < SrcEltTy->getTypeID())
   Res = Builder.CreateFPTrunc(Src, DstTy, "conv");
 else
   Res = Builder.CreateFPExt(Src, DstTy, "conv");
diff --git a/clang/test/CodeGen/X86/bfloat16-convert-half.c 
b/clang/test/CodeGen/X86/bfloat16-convert-half.c
new file mode 100644
index 00..55451dc6f092cd
--- /dev/null
+++ b/clang/test/CodeGen/X86/bfloat16-convert-half.c
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -disable-O0-optnone 
-emit-llvm \
+// RUN:   %s -o - | opt -S -passes=mem2reg | FileCheck %s
+
+// CHECK-LABEL: define dso_local half @test_convert_from_bf16_to_fp16(
+// CHECK-SAME: bfloat noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FPEXT:%.*]] = fpext bfloat [[A]] to float
+// CHECK-NEXT:[[FPTRUNC:%.*]] = fptrunc float [[FPEXT]] to half
+// CHECK-NEXT:ret half [[FPTRUNC]]
+//
+_Float16 test_convert_from_bf16_to_fp16(__bf16 a) {
+return (_Float16)a;
+}
+
+// CHECK-LABEL: define dso_local bfloat @test_convert_from_fp16_to_bf16(
+// CHECK-SAME: half noundef [[A:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FPEXT:%.*]] = fpext half [[A]] to float
+// CHECK-NEXT:[[FPTRUNC:%.*]] = fptrunc float [[FPEXT]] to bfloat
+// CHECK-NEXT:ret bfloat [[FPTRUNC]]
+//
+__bf16 test_convert_from_fp16_to_bf16(_Float16 a) {
+return (__bf16)a;
+}
+
diff --git a/clang/test/CodeGenHIP/bfloat16-half-convert.hip 
b/clang/test/CodeGenHIP/bfloat16-half-convert.hip
new file mode 100644
index 00..0ffebb44c969b4
--- /dev/null
+++ b/clang/test/CodeGenHIP/bfloat16-half-convert.hip
@@ -0,0 +1,71 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -x hip -disable-O0-optnone 
-emit-llvm -fcuda-is-device \
+// RUN:   %s -o - | opt -S -passes=mem2reg | FileCheck %s
+
+#define __device__ __attribute__((device))
+
+typedef _Float16 half2 __attribute__((ext_vector_type(2)));
+typedef _Float16 half4 __attribute__((ext_vector_type(4)));
+
+typedef __bf16 bfloat2 __attribute__((ext_vector_type(2)));
+typedef __bf16 bfloat4 __attribute__((ext_vector_type(4)));
+
+// CHECK-LABEL: define dso_local noundef <2 x bfloat> 
@_Z40test_convertvector_from_half2_to_bfloat2Dv2_DF16_
+// CHECK-SAME: (<2 x half> noundef [[IN:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[IN_ADDR:%.*]] = alloca <2 x half>, align 4, addrspace(5)
+// CHECK-NEXT:[[IN_ADDR_ASCAST:%.*]] = addrspacecast ptr addrspace(5) 
[[IN_ADDR]] to ptr
+// CHECK-NEXT:store <2 x half> [[IN]], ptr [[IN_ADDR_ASCAST]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load <2 x half>, ptr [[IN_ADDR_ASCAST]], 
align 4
+// CHECK-NEXT:[[FPEXT:%.*]] = 

[clang] [NFC] Factor out common parts of ArraySections into its own class (PR #89639)

2024-04-26 Thread via cfe-commits


@@ -74,12 +74,12 @@ void use() {
   for (int i = 0; i < 10; ++i) {
 // FIXME: Once we have a new array-section type to represent OpenACC as
 // well, change this error message.

NagyDonat wrote:

This FIXME was resolved by this commit, consider removing it in a trivial 
follow-up change.

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


[clang] [Sema] Avoid an undesired pack expansion while transforming PackIndexingType (PR #90195)

2024-04-26 Thread Younan Zhang via cfe-commits

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

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

>From f708694fc2686684589dca7b8f3738a117fc047e Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Fri, 26 Apr 2024 19:06:57 +0800
Subject: [PATCH] [Sema] Avoid an undesired pack expansion while transforming
 PackIndexingType

---
 clang/lib/Sema/TreeTransform.h |  3 +++
 clang/test/SemaCXX/cxx2c-pack-indexing.cpp | 19 +++
 2 files changed, 22 insertions(+)

diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 9404be5a46f3f7..abc4a16c004a9f 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6649,6 +6649,9 @@ 
TreeTransform::TransformPackIndexingType(TypeLocBuilder &TLB,
 }
   }
 
+  // We may be doing this in the context of expanding the Pattern. Forget that
+  // because it has been handled above.
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
   QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
 
   QualType Out = getDerived().RebuildPackIndexingType(
diff --git a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp 
b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
index 606715e6aacffd..2fd0dbfed294a5 100644
--- a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
+++ b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
@@ -160,3 +160,22 @@ namespace GH88929 {
 using E = P...[0]; // expected-error {{unknown type name 'P'}} \
// expected-error {{expected ';' after alias 
declaration}}
 }
+
+namespace GH88925 {
+template  struct S {};
+
+template  struct sequence {};
+
+template  auto f(sequence) {
+  return S(); // #use
+}
+
+void g() {
+  static_assert(__is_same(decltype(f(sequence<0, 0>())), S));
+  static_assert(__is_same(decltype(f(sequence<0, 0>())), S));
+  static_assert(__is_same(decltype(f(sequence<0, 1>())), S));
+  f(sequence<3>());
+  // expected-error@#use {{invalid index 3 for pack 'Args' of size 2}}}
+  // expected-note-re@-2 {{function template specialization '{{.*}}' requested 
here}}
+}
+}

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


[clang] [Sema] Avoid an undesired pack expansion while transforming PackIndexingType (PR #90195)

2024-04-26 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

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

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


2 Files Affected:

- (modified) clang/lib/Sema/TreeTransform.h (+3) 
- (modified) clang/test/SemaCXX/cxx2c-pack-indexing.cpp (+19) 


``diff
diff --git a/clang/lib/Sema/TreeTransform.h b/clang/lib/Sema/TreeTransform.h
index 9404be5a46f3f7..abc4a16c004a9f 100644
--- a/clang/lib/Sema/TreeTransform.h
+++ b/clang/lib/Sema/TreeTransform.h
@@ -6649,6 +6649,9 @@ 
TreeTransform::TransformPackIndexingType(TypeLocBuilder &TLB,
 }
   }
 
+  // We may be doing this in the context of expanding the Pattern. Forget that
+  // because it has been handled above.
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
   QualType Result = getDerived().TransformType(TLB, TL.getPatternLoc());
 
   QualType Out = getDerived().RebuildPackIndexingType(
diff --git a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp 
b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
index 606715e6aacffd..2fd0dbfed294a5 100644
--- a/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
+++ b/clang/test/SemaCXX/cxx2c-pack-indexing.cpp
@@ -160,3 +160,22 @@ namespace GH88929 {
 using E = P...[0]; // expected-error {{unknown type name 'P'}} \
// expected-error {{expected ';' after alias 
declaration}}
 }
+
+namespace GH88925 {
+template  struct S {};
+
+template  struct sequence {};
+
+template  auto f(sequence) {
+  return S(); // #use
+}
+
+void g() {
+  static_assert(__is_same(decltype(f(sequence<0, 0>())), S));
+  static_assert(__is_same(decltype(f(sequence<0, 0>())), S));
+  static_assert(__is_same(decltype(f(sequence<0, 1>())), S));
+  f(sequence<3>());
+  // expected-error@#use {{invalid index 3 for pack 'Args' of size 2}}}
+  // expected-note-re@-2 {{function template specialization '{{.*}}' requested 
here}}
+}
+}

``




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


[clang-tools-extra] [clang-tidy] Ensure nullable variable is not accessed without validity test (PR #90173)

2024-04-26 Thread Piotr Zegar via cfe-commits

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


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


[clang] [Sema] Avoid an undesired pack expansion while transforming PackIndexingType (PR #90195)

2024-04-26 Thread via cfe-commits


@@ -6649,6 +6649,9 @@ 
TreeTransform::TransformPackIndexingType(TypeLocBuilder &TLB,
 }
   }
 
+  // We may be doing this in the context of expanding the Pattern. Forget that
+  // because it has been handled above.
+  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);

cor3ntin wrote:

```suggestion
  // A pack indexing type can appear in a larger pack expansion, 
  // e.g `Pack...[pack_of_indexes]...`
  // so we need to temporarily disable substitution of pack elements
  Sema::ArgumentPackSubstitutionIndexRAII SubstIndex(getSema(), -1);
```

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


[clang] [Sema] Avoid an undesired pack expansion while transforming PackIndexingType (PR #90195)

2024-04-26 Thread via cfe-commits

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


[clang] [Sema] Avoid an undesired pack expansion while transforming PackIndexingType (PR #90195)

2024-04-26 Thread via cfe-commits


@@ -160,3 +160,22 @@ namespace GH88929 {
 using E = P...[0]; // expected-error {{unknown type name 'P'}} \
// expected-error {{expected ';' after alias 
declaration}}
 }
+
+namespace GH88925 {
+template  struct S {};
+
+template  struct sequence {};
+
+template  auto f(sequence) {
+  return S(); // #use
+}
+

cor3ntin wrote:

I suspect there is the same problem for expressions

```cpp
template  struct S2 {};
template  auto f(sequence) {
  return S2(); // #use
}
```


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


[clang] [Sema] Avoid an undesired pack expansion while transforming PackIndexingType (PR #90195)

2024-04-26 Thread via cfe-commits

https://github.com/cor3ntin commented:

Thanks for working on that!
I suspect there is the same problem for pack indexing expressions, could you 
try to add a test?

Thanks!

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


[clang] [clang-scan-deps] Fix contention when updating `TrackingStatistic`s in hot code paths in `FileManager`. (PR #88427)

2024-04-26 Thread Alexandre Ganea via cfe-commits

aganea wrote:

Thanks for pointing that out @MaskRay !

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


[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

2024-04-26 Thread via cfe-commits

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


[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

2024-04-26 Thread via cfe-commits

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

Can you add a changelog entry mentioning the fixed issue ?
Otherwise LGTM

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


[clang] [clang codegen] Fix MS ABI detection of user-provided constructors. (PR #90151)

2024-04-26 Thread via cfe-commits


@@ -201,3 +201,17 @@ S11 f11() {
   S11 x;
   return func11(x);
 }
+

cor3ntin wrote:

```suggestion

//GH86384
```

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


[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

2024-04-26 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -disable-O0-optnone 
-emit-llvm \
+// RUN:   %s -o - | opt -S -passes=mem2reg | FileCheck %s
+
+// CHECK-LABEL: define dso_local half @test_convert_from_bf16_to_fp16(
+// CHECK-SAME: bfloat noundef [[A:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FPEXT:%.*]] = fpext bfloat [[A]] to float
+// CHECK-NEXT:[[FPTRUNC:%.*]] = fptrunc float [[FPEXT]] to half
+// CHECK-NEXT:ret half [[FPTRUNC]]
+//
+_Float16 test_convert_from_bf16_to_fp16(__bf16 a) {
+return (_Float16)a;
+}
+
+// CHECK-LABEL: define dso_local bfloat @test_convert_from_fp16_to_bf16(
+// CHECK-SAME: half noundef [[A:%.*]]) #[[ATTR0]] {
+// CHECK-NEXT:  entry:
+// CHECK-NEXT:[[FPEXT:%.*]] = fpext half [[A]] to float
+// CHECK-NEXT:[[FPTRUNC:%.*]] = fptrunc float [[FPEXT]] to bfloat
+// CHECK-NEXT:ret bfloat [[FPTRUNC]]
+//
+__bf16 test_convert_from_fp16_to_bf16(_Float16 a) {
+return (__bf16)a;
+}
+

arsenm wrote:

The regular C case should still test the vector conversions. Also the rebase is 
confusing me 

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


[clang] [clang] fix half && bfloat16 convert node expr codegen (PR #89051)

2024-04-26 Thread Matt Arsenault via cfe-commits


@@ -1906,7 +1909,15 @@ Value 
*ScalarExprEmitter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
   } else {
 assert(SrcEltTy->isFloatingPointTy() && DstEltTy->isFloatingPointTy() &&
"Unknown real conversion");
-if (DstEltTy->getTypeID() < SrcEltTy->getTypeID())
+if ((DstEltTy->is16bitFPTy() && SrcEltTy->is16bitFPTy())) {

arsenm wrote:

This should be a separate change if it's correct 

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


[clang] a670cda - [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (#90143)

2024-04-26 Thread via cfe-commits

Author: Jonathan Thackray
Date: 2024-04-26T13:04:35+01:00
New Revision: a670cdadca54910a8e65d5521f2119337fb0bd03

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

LOG: [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE 
(#90143)

Neoverse-N3, Neoverse-V3 and Neoverse-V3AE are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Neoverse-N3:
   https://developer.arm.com/documentation/107997/latest/

Technical Reference Manual for Neoverse-V3:
   https://developer.arm.com/documentation/107734/latest/

Technical Reference Manual for Neoverse-V3AE:
   https://developer.arm.com/documentation/101595/latest/

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/test/Driver/aarch64-mcpu.c
clang/test/Misc/target-invalid-cpu-note.c
llvm/docs/ReleaseNotes.rst
llvm/include/llvm/TargetParser/AArch64TargetParser.h
llvm/lib/Target/AArch64/AArch64Processors.td
llvm/lib/Target/AArch64/AArch64Subtarget.cpp
llvm/lib/TargetParser/Host.cpp
llvm/unittests/TargetParser/TargetParserTest.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1576f681707de0..92563262cc6737 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -633,6 +633,9 @@ Arm and AArch64 Support
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
+* Arm Neoverse-N3 (neoverse-n3).
+* Arm Neoverse-V3 (neoverse-v3).
+* Arm Neoverse-V3AE (neoverse-v3ae).
 
 Android Support
 ^^^

diff  --git a/clang/test/Driver/aarch64-mcpu.c 
b/clang/test/Driver/aarch64-mcpu.c
index 77ba43122b2453..ad4a5f9ac6fb80 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -64,10 +64,16 @@
 // NEOVERSE-V1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v2  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V2 %s
 // NEOVERSE-V2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V3 %s
+// NEOVERSE-V3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-v3ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-V3AE %s
+// NEOVERSE-V3AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-v3ae"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n1 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N1 %s
 // NEOVERSE-N1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N2 %s
 // NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n2"
+// RUN: %clang --target=aarch64 -mcpu=neoverse-n3 -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-N3 %s
+// NEOVERSE-N3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-n3"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-512tvb -### -c %s 2>&1 | 
FileCheck -check-prefix=NEOVERSE-512TVB %s
 // NEOVERSE-512TVB: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-512tvb"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a520 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A520 %s

diff  --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 9c91c4157cd6a0..21d80b7134508f 100644
--- a/clang/test/Misc/target-invalid-cpu-note.c
+++ b/clang/test/Misc/target-invalid-cpu-note.c
@@ -5,11 +5,11 @@
 
 // RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 
2>&1 | FileCheck %s --check-prefix AARCH64
 // AARCH64: error: unknown target CPU 'not-a-cpu'
-// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, 
cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, 
cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, 
cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, 
cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, 
cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, 
neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, 
apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, 
apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, 
exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, 
thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, 
carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}
+// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a3

[clang] [llvm] [AArch64] Add support for Neoverse-N3, Neoverse-V3 and Neoverse-V3AE (PR #90143)

2024-04-26 Thread Jonathan Thackray via cfe-commits

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


[clang] [clang-tools-extra] Reapply "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent

2024-04-26 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/90152

>From 6ea7f9d476910681ad01e2fe4525fb4d2c556c6f Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Thu, 25 Apr 2024 14:50:53 -0400
Subject: [PATCH 1/2] Reapply "[Clang][Sema] Diagnose class member access
 expressions naming non-existent members of the current instantiation prior to
 instantiation in the absence of dependent base classes (#84050)"

Consider the following:
```cpp
template
struct A
{
auto f()
{
return this->x;
}
};
```
Although `A` has no dependent base classes and the lookup context for
`x` is the current instantiation, we currently do not diagnose the
absence of a member `x` until `A::f` is instantiated. This patch
moves the point of diagnosis for such expressions to occur at the point
of definition (i.e. prior to instantiation).
---
 .../clangd/unittests/FindTargetTests.cpp  |   8 +-
 .../unittests/SemanticHighlightingTests.cpp   |   2 +-
 .../cppcoreguidelines/owning-memory.cpp   |   2 +
 .../modernize/use-equals-default-copy.cpp |  12 +
 clang/docs/ReleaseNotes.rst   |  12 +
 clang/include/clang/Sema/Lookup.h |   4 +-
 clang/include/clang/Sema/Sema.h   |  14 +-
 clang/lib/AST/Expr.cpp|   2 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +-
 clang/lib/Sema/HLSLExternalSemaSource.cpp |   7 +-
 clang/lib/Sema/SemaAttr.cpp   |   2 +-
 clang/lib/Sema/SemaDecl.cpp   |   7 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   6 +-
 clang/lib/Sema/SemaExpr.cpp   |  20 +-
 clang/lib/Sema/SemaExprCXX.cpp|   2 +-
 clang/lib/Sema/SemaExprMember.cpp | 183 +++
 clang/lib/Sema/SemaLookup.cpp | 114 -
 clang/lib/Sema/SemaOpenMP.cpp |  17 +-
 clang/lib/Sema/SemaTemplate.cpp   |  32 +-
 clang/lib/Sema/TreeTransform.h|  20 +
 .../AST/HLSL/this-reference-template.hlsl |   2 +-
 clang/test/CXX/drs/dr2xx.cpp  |  10 +-
 clang/test/CXX/drs/dr3xx.cpp  |  16 +-
 .../temp.res/temp.dep/temp.dep.type/p4.cpp| 456 ++
 .../test/CXX/temp/temp.res/temp.local/p3.cpp  |   3 +-
 clang/test/CodeGenCXX/mangle.cpp  |   8 -
 .../Index/annotate-nested-name-specifier.cpp  |   4 +-
 clang/test/SemaCXX/member-expr.cpp|   4 +-
 .../SemaTemplate/instantiate-function-1.cpp   |  14 +-
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |   5 +-
 30 files changed, 765 insertions(+), 225 deletions(-)
 create mode 100644 clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 799a549ff0816e..94437857cecca6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -854,7 +854,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Similar to above but base expression involves a function call.
   Code = R"cpp(
@@ -872,7 +872,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Similar to above but uses a function pointer.
   Code = R"cpp(
@@ -891,7 +891,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Base expression involves a member access into this.
   Code = R"cpp(
@@ -962,7 +962,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   void Foo() { this->[[find]](); }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
+  EXPECT_DECLS("MemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 4156921d83edf8..30b9b1902aa9c7 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -621,7 +621,7 @@ sizeof...($TemplateParameter[[Elements]]);
   struct $Class_def[[Foo]] {
 int $Field_decl[[Waldo]];
 void $Method_def[[bar]]() {
-  $Class[[Foo]]().$Field_dependentName[[Waldo]];
+  $Class[[Foo]]().$Field[[Waldo]];
 }
 template $Bracket[[<]]typename $TemplateParameter_def[[U]]$Bracket[[>]]
 void $Method_def[[bar1]]() {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
 
b/clang-tools-extra/test/clang

[clang] [clang-tools-extra] Reapply "[Clang][Sema] Diagnose class member access expressions naming non-existent members of the current instantiation prior to instantiation in the absence of dependent

2024-04-26 Thread Krystian Stasiowski via cfe-commits

https://github.com/sdkrystian updated 
https://github.com/llvm/llvm-project/pull/90152

>From 6ea7f9d476910681ad01e2fe4525fb4d2c556c6f Mon Sep 17 00:00:00 2001
From: Krystian Stasiowski 
Date: Thu, 25 Apr 2024 14:50:53 -0400
Subject: [PATCH 1/2] Reapply "[Clang][Sema] Diagnose class member access
 expressions naming non-existent members of the current instantiation prior to
 instantiation in the absence of dependent base classes (#84050)"

Consider the following:
```cpp
template
struct A
{
auto f()
{
return this->x;
}
};
```
Although `A` has no dependent base classes and the lookup context for
`x` is the current instantiation, we currently do not diagnose the
absence of a member `x` until `A::f` is instantiated. This patch
moves the point of diagnosis for such expressions to occur at the point
of definition (i.e. prior to instantiation).
---
 .../clangd/unittests/FindTargetTests.cpp  |   8 +-
 .../unittests/SemanticHighlightingTests.cpp   |   2 +-
 .../cppcoreguidelines/owning-memory.cpp   |   2 +
 .../modernize/use-equals-default-copy.cpp |  12 +
 clang/docs/ReleaseNotes.rst   |  12 +
 clang/include/clang/Sema/Lookup.h |   4 +-
 clang/include/clang/Sema/Sema.h   |  14 +-
 clang/lib/AST/Expr.cpp|   2 +-
 clang/lib/Parse/ParseDecl.cpp |   2 +-
 clang/lib/Sema/HLSLExternalSemaSource.cpp |   7 +-
 clang/lib/Sema/SemaAttr.cpp   |   2 +-
 clang/lib/Sema/SemaDecl.cpp   |   7 +-
 clang/lib/Sema/SemaDeclCXX.cpp|   6 +-
 clang/lib/Sema/SemaExpr.cpp   |  20 +-
 clang/lib/Sema/SemaExprCXX.cpp|   2 +-
 clang/lib/Sema/SemaExprMember.cpp | 183 +++
 clang/lib/Sema/SemaLookup.cpp | 114 -
 clang/lib/Sema/SemaOpenMP.cpp |  17 +-
 clang/lib/Sema/SemaTemplate.cpp   |  32 +-
 clang/lib/Sema/TreeTransform.h|  20 +
 .../AST/HLSL/this-reference-template.hlsl |   2 +-
 clang/test/CXX/drs/dr2xx.cpp  |  10 +-
 clang/test/CXX/drs/dr3xx.cpp  |  16 +-
 .../temp.res/temp.dep/temp.dep.type/p4.cpp| 456 ++
 .../test/CXX/temp/temp.res/temp.local/p3.cpp  |   3 +-
 clang/test/CodeGenCXX/mangle.cpp  |   8 -
 .../Index/annotate-nested-name-specifier.cpp  |   4 +-
 clang/test/SemaCXX/member-expr.cpp|   4 +-
 .../SemaTemplate/instantiate-function-1.cpp   |  14 +-
 .../ASTMatchers/ASTMatchersNarrowingTest.cpp  |   5 +-
 30 files changed, 765 insertions(+), 225 deletions(-)
 create mode 100644 clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp

diff --git a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp 
b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
index 799a549ff0816e..94437857cecca6 100644
--- a/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ b/clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -854,7 +854,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Similar to above but base expression involves a function call.
   Code = R"cpp(
@@ -872,7 +872,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Similar to above but uses a function pointer.
   Code = R"cpp(
@@ -891,7 +891,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void foo()");
+  EXPECT_DECLS("MemberExpr", "void foo()");
 
   // Base expression involves a member access into this.
   Code = R"cpp(
@@ -962,7 +962,7 @@ TEST_F(TargetDeclTest, DependentExprs) {
   void Foo() { this->[[find]](); }
 };
   )cpp";
-  EXPECT_DECLS("CXXDependentScopeMemberExpr", "void find()");
+  EXPECT_DECLS("MemberExpr", "void find()");
 }
 
 TEST_F(TargetDeclTest, DependentTypes) {
diff --git a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp 
b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
index 4156921d83edf8..30b9b1902aa9c7 100644
--- a/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ b/clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -621,7 +621,7 @@ sizeof...($TemplateParameter[[Elements]]);
   struct $Class_def[[Foo]] {
 int $Field_decl[[Waldo]];
 void $Method_def[[bar]]() {
-  $Class[[Foo]]().$Field_dependentName[[Waldo]];
+  $Class[[Foo]]().$Field[[Waldo]];
 }
 template $Bracket[[<]]typename $TemplateParameter_def[[U]]$Bracket[[>]]
 void $Method_def[[bar1]]() {
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/owning-memory.cpp
 
b/clang-tools-extra/test/clang

  1   2   3   4   5   >