[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)

2024-06-12 Thread via cfe-commits

https://github.com/Andarwinux updated 
https://github.com/llvm/llvm-project/pull/94731

>From eacbf19d71bab727675286fd45b27ea125d64298 Mon Sep 17 00:00:00 2001
From: Andarwinux <144242044+andarwi...@users.noreply.github.com>
Date: Fri, 7 Jun 2024 07:07:40 +
Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver

fixes #91216
---
 clang/include/clang/Driver/Options.td | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d44faa55c456f..1cce7a5146dd8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8569,6 +8569,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">,
 Alias<_SLASH_winsdkdir>;
 def : Separate<["-"], "Xmicrosoft-windows-sdk-version">,
 Alias<_SLASH_winsdkversion>;
+def : Separate<["-"], "Xmicrosoft-windows-sys-root">,
+Alias<_SLASH_winsysroot>;
 
 // Ignored:
 

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Matheus Izvekov via cfe-commits

https://github.com/mizvekov created 
https://github.com/llvm/llvm-project/pull/95202

This reverts the functional elements of commit 
3e78fa860235431323aaf08c8fa922d75a7cfffa and redoes it, by fixing the true root 
cause of #61317.

A TemplateName can be non-canonical; profiling it based on the canonical name 
would result in inconsistent preservation of as-written information in the AST.

The true problem in #61317 is that we would not consider the methods with 
requirements expression which contain DTSTs as the same in relation to merging 
of declarations when importing modules.

The expressions would never match because they contained DTSTs pointing to 
different redeclarations of the same class template, but since canonicalization 
for them was broken, their canonical types would not match either.

---

No changelog entry because #61317 was already claimed as fixed in previous 
release.

>From 71a827e8ff6dcc47f1fd434a19070e6f841ee27a Mon Sep 17 00:00:00 2001
From: Matheus Izvekov 
Date: Wed, 12 Jun 2024 00:42:48 -0300
Subject: [PATCH] [clang] fix broken canonicalization of
 DeducedTemplateSpecializationType

This reverts the functional elements of commit 
3e78fa860235431323aaf08c8fa922d75a7cfffa
and redoes it, by fixing the true root cause of #61317.

A TemplateName can be non-canonical; profiling it based on the canonical
name would result in inconsistent preservation of as-written information
in the AST.

The true problem in #61317 is that we would not consider the methods
with requirements expression which contain DTSTs as the same
in relation to merging of declarations when importing modules.

The expressions would never match because they contained DTSTs pointing
to different redeclarations of the same class template, but since
canonicalization for them was broken, their canonical types would not
match either.

---

No changelog entry because #61317 was already claimed as fixed in
previous release.
---
 clang/include/clang/AST/ASTContext.h   |  4 
 clang/include/clang/AST/TemplateName.h |  4 +++-
 clang/include/clang/AST/Type.h |  9 +++--
 clang/lib/AST/ASTContext.cpp   | 25 +++--
 clang/lib/AST/TemplateName.cpp |  9 -
 5 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index a1d1d1c51cd41..5985887000d44 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1770,6 +1770,10 @@ class ASTContext : public RefCountedBase {
   QualType getDeducedTemplateSpecializationType(TemplateName Template,
 QualType DeducedType,
 bool IsDependent) const;
+  QualType getDeducedTemplateSpecializationTypeInternal(TemplateName Template,
+QualType DeducedType,
+bool IsDependent,
+QualType Canon) const;
 
   /// Return the unique reference to the type for the specified TagDecl
   /// (struct/union/class/enum) decl.
diff --git a/clang/include/clang/AST/TemplateName.h 
b/clang/include/clang/AST/TemplateName.h
index 988a55acd2252..24a7fde76195d 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -346,7 +346,9 @@ class TemplateName {
   /// error.
   void dump() const;
 
-  void Profile(llvm::FoldingSetNodeID &ID);
+  void Profile(llvm::FoldingSetNodeID &ID) {
+ID.AddPointer(Storage.getOpaqueValue());
+  }
 
   /// Retrieve the template name as a void pointer.
   void *getAsVoidPointer() const { return Storage.getOpaqueValue(); }
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 9eb3f6c09e3d3..f557697da74c6 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6050,14 +6050,13 @@ class DeducedTemplateSpecializationType : public 
DeducedType,
 
   DeducedTemplateSpecializationType(TemplateName Template,
 QualType DeducedAsType,
-bool IsDeducedAsDependent)
+bool IsDeducedAsDependent, QualType Canon)
   : DeducedType(DeducedTemplateSpecialization, DeducedAsType,
 toTypeDependence(Template.getDependence()) |
 (IsDeducedAsDependent
  ? TypeDependence::DependentInstantiation
  : TypeDependence::None),
-DeducedAsType.isNull() ? QualType(this, 0)
-   : DeducedAsType.getCanonicalType()),
+Canon),
 Template(Template) {}
 
 public:
@@ -6071,9 +6070,7 @@ class DeducedTemplateSpecializationType : public 
DeducedType,
   static void Profile(llvm::FoldingSetNodeID &ID, TemplateName

[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Matheus Izvekov (mizvekov)


Changes

This reverts the functional elements of commit 
3e78fa860235431323aaf08c8fa922d75a7cfffa and redoes it, by fixing the true root 
cause of #61317.

A TemplateName can be non-canonical; profiling it based on the canonical name 
would result in inconsistent preservation of as-written information in the AST.

The true problem in #61317 is that we would not consider the methods 
with requirements expression which contain DTSTs as the same in relation to 
merging of declarations when importing modules.

The expressions would never match because they contained DTSTs pointing to 
different redeclarations of the same class template, but since canonicalization 
for them was broken, their canonical types would not match either.

---

No changelog entry because #61317 was already claimed as fixed in 
previous release.

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


5 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (+4) 
- (modified) clang/include/clang/AST/TemplateName.h (+3-1) 
- (modified) clang/include/clang/AST/Type.h (+3-6) 
- (modified) clang/lib/AST/ASTContext.cpp (+19-6) 
- (modified) clang/lib/AST/TemplateName.cpp (-9) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index a1d1d1c51cd41..5985887000d44 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -1770,6 +1770,10 @@ class ASTContext : public RefCountedBase {
   QualType getDeducedTemplateSpecializationType(TemplateName Template,
 QualType DeducedType,
 bool IsDependent) const;
+  QualType getDeducedTemplateSpecializationTypeInternal(TemplateName Template,
+QualType DeducedType,
+bool IsDependent,
+QualType Canon) const;
 
   /// Return the unique reference to the type for the specified TagDecl
   /// (struct/union/class/enum) decl.
diff --git a/clang/include/clang/AST/TemplateName.h 
b/clang/include/clang/AST/TemplateName.h
index 988a55acd2252..24a7fde76195d 100644
--- a/clang/include/clang/AST/TemplateName.h
+++ b/clang/include/clang/AST/TemplateName.h
@@ -346,7 +346,9 @@ class TemplateName {
   /// error.
   void dump() const;
 
-  void Profile(llvm::FoldingSetNodeID &ID);
+  void Profile(llvm::FoldingSetNodeID &ID) {
+ID.AddPointer(Storage.getOpaqueValue());
+  }
 
   /// Retrieve the template name as a void pointer.
   void *getAsVoidPointer() const { return Storage.getOpaqueValue(); }
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 9eb3f6c09e3d3..f557697da74c6 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6050,14 +6050,13 @@ class DeducedTemplateSpecializationType : public 
DeducedType,
 
   DeducedTemplateSpecializationType(TemplateName Template,
 QualType DeducedAsType,
-bool IsDeducedAsDependent)
+bool IsDeducedAsDependent, QualType Canon)
   : DeducedType(DeducedTemplateSpecialization, DeducedAsType,
 toTypeDependence(Template.getDependence()) |
 (IsDeducedAsDependent
  ? TypeDependence::DependentInstantiation
  : TypeDependence::None),
-DeducedAsType.isNull() ? QualType(this, 0)
-   : DeducedAsType.getCanonicalType()),
+Canon),
 Template(Template) {}
 
 public:
@@ -6071,9 +6070,7 @@ class DeducedTemplateSpecializationType : public 
DeducedType,
   static void Profile(llvm::FoldingSetNodeID &ID, TemplateName Template,
   QualType Deduced, bool IsDependent) {
 Template.Profile(ID);
-QualType CanonicalType =
-Deduced.isNull() ? Deduced : Deduced.getCanonicalType();
-ID.AddPointer(CanonicalType.getAsOpaquePtr());
+Deduced.Profile(ID);
 ID.AddBoolean(IsDependent || Template.isDependent());
   }
 
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index bf74e56a14799..34aa399fda2f8 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -5925,11 +5925,9 @@ QualType ASTContext::getUnconstrainedType(QualType T) 
const {
   return T;
 }
 
-/// Return the uniqued reference to the deduced template specialization type
-/// which has been deduced to the given type, or to the canonical undeduced
-/// such type, or the canonical deduced-but-dependent such type.
-QualType ASTContext::getDeducedTemplateSpecializationType(
-TemplateName Template, QualType DeducedType, bool IsDependent) const {
+QualTy

[clang-tools-extra] [IncludeCleaner] display overview (PR #93932)

2024-06-12 Thread via cfe-commits

https://github.com/TheHillBright updated 
https://github.com/llvm/llvm-project/pull/93932

>From 4c97edfc73754bdcafeeecf09e8c60c6086393f5 Mon Sep 17 00:00:00 2001
From: TheHillBright <150074496+thehillbri...@users.noreply.github.com>
Date: Fri, 31 May 2024 15:00:37 +0800
Subject: [PATCH] IncludeCleaner: display overview

---
 clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp 
b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
index 3bc449b0152bb..788ad87b1d4e8 100644
--- a/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
+++ b/clang-tools-extra/include-cleaner/tool/IncludeCleaner.cpp
@@ -279,7 +279,7 @@ int main(int argc, const char **argv) {
 
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   auto OptionsParser =
-  clang::tooling::CommonOptionsParser::create(argc, argv, IncludeCleaner);
+  clang::tooling::CommonOptionsParser::create(argc, argv, IncludeCleaner, 
cl::OneOrMore, Overview);
   if (!OptionsParser) {
 llvm::errs() << toString(OptionsParser.takeError());
 return 1;

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


[clang-tools-extra] [IncludeCleaner] display overview (PR #93932)

2024-06-12 Thread via cfe-commits

TheHillBright wrote:

Ping @sam-mccall after 2 weeks of inactivity.

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


[libclc] [CMake][libclc] Improve dependencies to avoid build errors (PR #95018)

2024-06-12 Thread Fraser Cormack via cfe-commits

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

LGTM, thank you!

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


[libclc] [CMake][libclc] Improve dependencies to avoid build errors (PR #95018)

2024-06-12 Thread Fraser Cormack via cfe-commits

frasercrmck wrote:

> Yes, the article you link to is highly relevant. Without this PR we're 
> hitting the problem described in example #4.
> 
> We can promote the issue to a build failure by choosing a custom command 
> which can't run concurrently with itself:
> 
> ```cmake
> cmake_minimum_required(VERSION 3.2)
> 
> add_custom_command(
> OUTPUT gen
> # Try to grab a lock and fail immediately if we can't:
> COMMAND flock -x -n gen.lock sleep 1
> COMMAND cmake -E echo Hello > gen
> )
> 
> add_custom_target(
> my-all-1 ALL DEPENDS gen
> )
> 
> add_custom_target(
> my-all-2 ALL DEPENDS gen
> )
> ```
> 
> With the above `make` will succeed, but `make -j2` will fail. The issue is 
> not exposed with Ninja. This is the same behavior I see in libclc today, 
> except more jobs are needed. Adding an intermediate target and depending on 
> both the new target and the file does seem to fix all of our problems.
> 
> I've added the file dependencies back in 
> [b707fc7](https://github.com/llvm/llvm-project/commit/b707fc7dea2e5e57bc3e4f01e27b9ca7bbf0e398),
>  and I think it fixes the build issue while preserving the incremental build 
> behavior you described. Could you please give it a try?

Brilliant, thanks. I have played around and see that incremental builds appear 
to work as intended. I've tried deleting and `touch`ing various files and full 
rebuilds and partial rebuilds do what I'd expect.

Thanks also for pointing out I've already read about this exact issue (example 
#4) and missed it! It's a real shame there isn't a better framework for testing 
CMake and build generators themselves.

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 commented:

Oh, thanks. This looks generally good. And it looks like true that I abused the 
Profile components.

Since this commit aimed to fix a regression, it will be better to have a 
regression test. WDYT?

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Chuanqi Xu via cfe-commits


@@ -1770,6 +1770,10 @@ class ASTContext : public RefCountedBase {
   QualType getDeducedTemplateSpecializationType(TemplateName Template,
 QualType DeducedType,
 bool IsDependent) const;
+  QualType getDeducedTemplateSpecializationTypeInternal(TemplateName Template,

ChuanqiXu9 wrote:

Given it is called `*Internal`, it might be better to give it a private access.

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Chuanqi Xu via cfe-commits

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


[clang] 3b3b839 - [ConstantFold] Drop gep of gep fold entirely (#95126)

2024-06-12 Thread via cfe-commits

Author: Nikita Popov
Date: 2024-06-12T09:50:14+02:00
New Revision: 3b3b839c66dc49674fd6646650525a2173030690

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

LOG: [ConstantFold] Drop gep of gep fold entirely (#95126)

This is a followup to https://github.com/llvm/llvm-project/pull/93823
and drops the DataLayout-unaware GEP of GEP fold entirely. All cases are
now left to the DataLayout-aware constant folder, which will fold
everything to a single i8 GEP.

We didn't have any test coverage for this fold in LLVM, but some Clang
tests change.

Added: 


Modified: 
clang/test/CodeGenCUDA/managed-var.cu
clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
clang/test/OpenMP/threadprivate_codegen.cpp
llvm/include/llvm/IR/ConstantFold.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp

Removed: 




diff  --git a/clang/test/CodeGenCUDA/managed-var.cu 
b/clang/test/CodeGenCUDA/managed-var.cu
index 5206acc62fe00..07e1a1e692c75 100644
--- a/clang/test/CodeGenCUDA/managed-var.cu
+++ b/clang/test/CodeGenCUDA/managed-var.cu
@@ -127,9 +127,10 @@ __device__ __host__ float load2() {
 
 // HOST-LABEL: define {{.*}}@_Z5load3v()
 // HOST:  %ld.managed = load ptr, ptr @v2, align 16
-// HOST:  %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, 
i64 0, i64 1, i32 1
-// HOST:  %1 = load float, ptr %0, align 4
-// HOST:  ret float %1
+// HOST:  %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, 
i64 0, i64 1
+// HOST:  %1 = getelementptr inbounds %struct.vec, ptr %0, i32 0, i32 1
+// HOST:  %2 = load float, ptr %1, align 4
+// HOST:  ret float %2
 float load3() {
   return v2[1].y;
 }
@@ -139,10 +140,11 @@ float load3() {
 // HOST:  %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, 
i64 0, i64 1
 // HOST:  %1 = ptrtoint ptr %0 to i64
 // HOST:  %ld.managed1 = load ptr, ptr @v2, align 16
-// HOST:  %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, 
i64 0, i64 1, i32 1
-// HOST:  %3 = ptrtoint ptr %2 to i64
-// HOST:  %4 = sub i64 %3, %1
-// HOST:  %sub.ptr.div = sdiv exact i64 %4, 4
+// HOST:  %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, 
i64 0, i64 1
+// HOST:  %3 = getelementptr inbounds %struct.vec, ptr %2, i32 0, i32 1
+// HOST:  %4 = ptrtoint ptr %3 to i64
+// HOST:  %5 = sub i64 %4, %1
+// HOST:  %sub.ptr.div = sdiv exact i64 %5, 4
 // HOST:  %conv = sitofp i64 %sub.ptr.div to float
 // HOST:  ret float %conv
 float addr_taken2() {

diff  --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp 
b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
index 4033adc8f0390..14557829268ef 100644
--- a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
+++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
@@ -21,6 +21,6 @@ struct S {
 // CHECK: store i32 0, ptr @arr
 // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str)
 // CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1)
-// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 1, i32 1), ptr noundef @.str.1)
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1), i32 0, i32 
1), ptr noundef @.str.1)
 // CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2)
-// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 2, i32 1), ptr noundef @.str.2)
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2), i32 0, i32 
1), ptr noundef @.str.2)

diff  --git 
a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp 
b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
index 6fbe4c7fd17a7..caa92f47a93c2 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
@@ -79,12 +79,12 @@ std::initializer_list> nested = {
 // CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr 
@_ZGR6nested1_, i64 1)
 // CHECK-DYNAMIC-BL: store ptr @_ZGR6nested1_,
 // CHECK-DYNAMIC-BL:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 1), align 8
-// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 1, i32 1), align 8
+// CHECK-DYNAMIC-BL: store i64 2, ptr getele

[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)

2024-06-12 Thread Nikita Popov via cfe-commits

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


[clang] 8ad82b4 - [clang][Interp] Fix re-visiting OpenCL variables of in constant AS

2024-06-12 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2024-06-12T09:53:33+02:00
New Revision: 8ad82b419b88102746735505effe5bc09f26ae54

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

LOG: [clang][Interp] Fix re-visiting OpenCL variables of in constant AS

We need to use isConstant() here, isConstQualified() is not enough.

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.cpp
clang/test/AST/Interp/opencl.cl

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.cpp 
b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
index e766558ab3083..602d105715d2b 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -3964,7 +3964,7 @@ bool ByteCodeExprGen::visitDeclRef(const 
ValueDecl *D, const Expr *E) {
 if (const auto *VD = dyn_cast(D)) {
   // Visit local const variables like normal.
   if ((VD->isLocalVarDecl() || VD->isStaticDataMember()) &&
-  VD->getType().isConstQualified()) {
+  VD->getType().isConstant(Ctx.getASTContext())) {
 if (!this->visitVarDecl(VD))
   return false;
 // Retry.
@@ -3973,8 +3973,8 @@ bool ByteCodeExprGen::visitDeclRef(const 
ValueDecl *D, const Expr *E) {
 }
   } else {
 if (const auto *VD = dyn_cast(D);
-VD && VD->getAnyInitializer() && VD->getType().isConstQualified() &&
-!VD->isWeak()) {
+VD && VD->getAnyInitializer() &&
+VD->getType().isConstant(Ctx.getASTContext()) && !VD->isWeak()) {
   if (!this->visitVarDecl(VD))
 return false;
   // Retry.

diff  --git a/clang/test/AST/Interp/opencl.cl b/clang/test/AST/Interp/opencl.cl
index fd7756fff7c11..32cc000cefd30 100644
--- a/clang/test/AST/Interp/opencl.cl
+++ b/clang/test/AST/Interp/opencl.cl
@@ -36,3 +36,10 @@ void negativeShift32(int a,int b) {
 
 int2 A = {1,2};
 int4 B = {(int2)(1,2), (int2)(3,4)};
+
+
+constant int sz0 = 5;
+kernel void testvla()
+{
+  int vla0[sz0];
+}



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


[clang] 82e1931 - [clang-format] Fix a bug in annotating lambda l_square (#95084)

2024-06-12 Thread via cfe-commits

Author: Owen Pan
Date: 2024-06-12T00:56:48-07:00
New Revision: 82e19318e660afc8277d9a2b1136d2d7836d67f8

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

LOG: [clang-format] Fix a bug in annotating lambda l_square (#95084)

Fixes #95072.

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/TokenAnnotatorTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index eb96b54ec4c96..08387d2e08ee0 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -2257,6 +2257,8 @@ bool UnwrappedLineParser::tryToParseLambda() {
   break;
 case tok::kw_auto:
 case tok::kw_class:
+case tok::kw_struct:
+case tok::kw_union:
 case tok::kw_template:
 case tok::kw_typename:
 case tok::amp:

diff  --git a/clang/unittests/Format/TokenAnnotatorTest.cpp 
b/clang/unittests/Format/TokenAnnotatorTest.cpp
index 8cc5c239d30a1..3e9638d9f3c56 100644
--- a/clang/unittests/Format/TokenAnnotatorTest.cpp
+++ b/clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1655,6 +1655,12 @@ TEST_F(TokenAnnotatorTest, UnderstandsLambdas) {
   EXPECT_TOKEN(Tokens[2], tok::arrow, TT_TrailingReturnArrow);
   EXPECT_TOKEN(Tokens[4], tok::l_brace, TT_LambdaLBrace);
 
+  Tokens = annotate("[] -> struct S { return {}; }");
+  ASSERT_EQ(Tokens.size(), 12u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::l_square, TT_LambdaLSquare);
+  EXPECT_TOKEN(Tokens[2], tok::arrow, TT_TrailingReturnArrow);
+  EXPECT_TOKEN(Tokens[5], tok::l_brace, TT_LambdaLBrace);
+
   Tokens = annotate("foo([&](u32 bar) __attribute__((attr)) -> void {});");
   ASSERT_EQ(Tokens.size(), 22u) << Tokens;
   EXPECT_TOKEN(Tokens[2], tok::l_square, TT_LambdaLSquare);



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


[clang] [clang-format] Fix a bug in annotating lambda l_square (PR #95084)

2024-06-12 Thread Owen Pan via cfe-commits

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:

It still fixes the original bug report though.

Otherwise adding a test which directly tests all observable effects of the 
profiling fix would be a bit arbitrary, as we don't have any unit tests for the 
gazillion ways this could go wrong for the other AST nodes.

This usually gets caught incidentally in diagnostics for unrelated tests. In 
this case that incidental test was in libc++.

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName 
&Name) const {
 canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(),
 subst->getFinal(), subst->getIndex());
   }
+  case TemplateName::DeducedTemplate: {
+assert(IgnoreDeduced == false);
+DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName();
+DefaultArguments DefArgs = DTS->getDefaultArguments();
+TemplateName Underlying = DTS->getUnderlying();
+
+bool NonCanonical = false;
+TemplateName CanonUnderlying =
+getCanonicalTemplateName(Underlying, /*IgnoreDeduced=*/true);
+NonCanonical |= CanonUnderlying != Underlying;
+auto CanonArgs =
+getCanonicalTemplateArguments(*this, DefArgs.Args, NonCanonical);
+{

cor3ntin wrote:

I don't think this scope is useful (unless you would want to put the whole 
thing in a separate function which might be cleaner)

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName 
&Name) const {
 canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(),
 subst->getFinal(), subst->getIndex());
   }
+  case TemplateName::DeducedTemplate: {
+assert(IgnoreDeduced == false);
+DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName();
+DefaultArguments DefArgs = DTS->getDefaultArguments();
+TemplateName Underlying = DTS->getUnderlying();
+
+bool NonCanonical = false;
+TemplateName CanonUnderlying =
+getCanonicalTemplateName(Underlying, /*IgnoreDeduced=*/true);
+NonCanonical |= CanonUnderlying != Underlying;
+auto CanonArgs =
+getCanonicalTemplateArguments(*this, DefArgs.Args, NonCanonical);
+{
+  unsigned NumArgs = CanonArgs.size() - 1;
+  auto handleParamDefArg = [&](const TemplateArgument &ParamDefArg,
+   unsigned I) {
+auto CanonParamDefArg = getCanonicalTemplateArgument(ParamDefArg);
+TemplateArgument &CanonDefArg = CanonArgs[I];
+if (CanonDefArg.structurallyEquals(CanonParamDefArg))
+  return;
+if (I == NumArgs)
+  CanonArgs.pop_back();
+NonCanonical = true;
+  };
+  auto handleParam = [&](auto *TP, int I) -> bool {
+if (!TP->hasDefaultArgument())
+  return true;
+handleParamDefArg(TP->getDefaultArgument().getArgument(), I);
+return false;
+  };
+
+  ArrayRef Params = CanonUnderlying.getAsTemplateDecl()
+ ->getTemplateParameters()
+ ->asArray();
+  assert(CanonArgs.size() <= Params.size());
+  for (int I = NumArgs; I >= 0; --I) {

cor3ntin wrote:

Should that not be `NumArgs -1` ?

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName 
&Name) const {
 canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(),
 subst->getFinal(), subst->getIndex());
   }
+  case TemplateName::DeducedTemplate: {
+assert(IgnoreDeduced == false);
+DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName();
+DefaultArguments DefArgs = DTS->getDefaultArguments();
+TemplateName Underlying = DTS->getUnderlying();
+
+bool NonCanonical = false;

cor3ntin wrote:

```suggestion
```

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits

https://github.com/cor3ntin commented:

Thanks for this!
I still need time to fully understand the work this but i left a few comment in 
the meantime.
Overall it seems like a good approach

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -9219,7 +9222,8 @@ class Sema final : public SemaBase {
   /// \returns true if an error occurred, false otherwise.
   bool CheckTemplateArgumentList(
   TemplateDecl *Template, SourceLocation TemplateLoc,
-  TemplateArgumentListInfo &TemplateArgs, bool PartialTemplateArgs,
+  TemplateArgumentListInfo &TemplateArgs,

cor3ntin wrote:

I wonder if instead we want to add an additional method.
In a lot of places through the rest of the patch, `DefaultArgs` is defaulted

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName 
&Name) const {
 canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(),
 subst->getFinal(), subst->getIndex());
   }
+  case TemplateName::DeducedTemplate: {
+assert(IgnoreDeduced == false);
+DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName();
+DefaultArguments DefArgs = DTS->getDefaultArguments();
+TemplateName Underlying = DTS->getUnderlying();
+
+bool NonCanonical = false;
+TemplateName CanonUnderlying =
+getCanonicalTemplateName(Underlying, /*IgnoreDeduced=*/true);
+NonCanonical |= CanonUnderlying != Underlying;

cor3ntin wrote:

```suggestion
bool NonCanonical = CanonUnderlying != Underlying;
```

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName 
&Name) const {
 canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(),
 subst->getFinal(), subst->getIndex());
   }
+  case TemplateName::DeducedTemplate: {
+assert(IgnoreDeduced == false);
+DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName();
+DefaultArguments DefArgs = DTS->getDefaultArguments();
+TemplateName Underlying = DTS->getUnderlying();

cor3ntin wrote:

These could be reference. they are small-ish, but no need to copy

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -139,28 +165,61 @@ TemplateName::NameKind TemplateName::getKind() const {
 return AssumedTemplate;
   if (uncommon->getAsSubstTemplateTemplateParm())
 return SubstTemplateTemplateParm;
+  if (uncommon->getAsDeducedTemplateName())
+return DeducedTemplate;
+
+  assert(uncommon->getAsSubstTemplateTemplateParmPack() != nullptr);
   return SubstTemplateTemplateParmPack;
 }
 
 TemplateDecl *TemplateName::getAsTemplateDecl() const {
-  if (Decl *TemplateOrUsing = Storage.dyn_cast()) {
-if (UsingShadowDecl *USD = dyn_cast(TemplateOrUsing))
-  return cast(USD->getTargetDecl());
+  TemplateName Name = *this;
+  while (std::optional UnderlyingOrNone =
+ Name.desugar(/*IgnoreDeduced=*/false))
+Name = *UnderlyingOrNone;
 
-assert(isa(TemplateOrUsing));
+  if (Decl *TemplateOrUsing = Name.Storage.dyn_cast())
 return cast(TemplateOrUsing);
+  return nullptr;
+}
+
+std::pair
+TemplateName::getTemplateDeclAndDefaultArgs() const {
+  DefaultArguments DefArgs;
+  for (TemplateName Name = *this; /**/; /**/) {
+if (!DefArgs && Name.getKind() == TemplateName::DeducedTemplate) {
+  DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName();
+  Name = DTS->getUnderlying();
+  DefArgs = DTS->getDefaultArguments();
+  continue;
+}
+if (std::optional UnderlyingOrNone =
+Name.desugar(/*IgnoreDeduced=*/DefArgs)) {
+  Name = *UnderlyingOrNone;
+  continue;
+}
+TemplateDecl *TD = Name.getAsTemplateDecl();
+if (TD && DefArgs != 0)
+  assert(DefArgs.StartPos + DefArgs.Args.size() <=
+ TD->getTemplateParameters()->size());
+return {TD, DefArgs};
   }
+}

cor3ntin wrote:

This is too clever.

I'd do

```cpp
static std::pair
getTemplateDeclAndDefaultArgs(const TemplateName N&,  DefaultArguments Args) {
if(...) {
return getTemplateDeclAndDefaultArgs(DTS->getUnderlying(), 
DTS->getDefaultArguments()) ;
}
   // ...
}

std::pair
TemplateName::getTemplateDeclAndDefaultArgs() const {
return getTemplateDeclAndDefaultArgs(*this, {});
}

```





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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -172,6 +180,13 @@ class SubstTemplateTemplateParmPackStorage : public 
UncommonTemplateNameStorage,
   unsigned Index, bool Final);
 };
 
+struct DefaultArguments {
+  unsigned StartPos;

cor3ntin wrote:

Can we add a comment here?

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -9434,6 +9505,32 @@ ASTContext::getSubstTemplateTemplateParmPack(const 
TemplateArgument &ArgPack,
   return TemplateName(Subst);
 }
 
+/// Retrieve the template name that represents a template name
+/// deduced from a specialization.
+TemplateName
+ASTContext::getDeducedTemplateName(TemplateName Underlying,
+   DefaultArguments DefaultArgs) const {
+  if (!DefaultArgs)
+return Underlying;
+
+  auto &Self = const_cast(*this);

cor3ntin wrote:

Why do you need the const_cast?

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


[clang] [clang-tools-extra] [clang] Implement CWG2398 provisional TTP matching to class templates (PR #94981)

2024-06-12 Thread via cfe-commits


@@ -6371,6 +6376,70 @@ ASTContext::getCanonicalTemplateName(const TemplateName 
&Name) const {
 canonArgPack, subst->getAssociatedDecl()->getCanonicalDecl(),
 subst->getFinal(), subst->getIndex());
   }
+  case TemplateName::DeducedTemplate: {
+assert(IgnoreDeduced == false);
+DeducedTemplateStorage *DTS = Name.getAsDeducedTemplateName();
+DefaultArguments DefArgs = DTS->getDefaultArguments();
+TemplateName Underlying = DTS->getUnderlying();
+
+bool NonCanonical = false;
+TemplateName CanonUnderlying =
+getCanonicalTemplateName(Underlying, /*IgnoreDeduced=*/true);
+NonCanonical |= CanonUnderlying != Underlying;
+auto CanonArgs =
+getCanonicalTemplateArguments(*this, DefArgs.Args, NonCanonical);
+{
+  unsigned NumArgs = CanonArgs.size() - 1;
+  auto handleParamDefArg = [&](const TemplateArgument &ParamDefArg,
+   unsigned I) {
+auto CanonParamDefArg = getCanonicalTemplateArgument(ParamDefArg);
+TemplateArgument &CanonDefArg = CanonArgs[I];
+if (CanonDefArg.structurallyEquals(CanonParamDefArg))
+  return;
+if (I == NumArgs)
+  CanonArgs.pop_back();
+NonCanonical = true;

cor3ntin wrote:

I think this lambdas needs a comment, I'm not sure I understand what's 
happening here

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

> It still fixes the original bug report though.

Yeah, this is why it is good.

> 
> Otherwise adding a test which directly tests all observable effects of the 
> profiling fix would be a bit arbitrary, as we don't have any unit tests for 
> the gazillion ways this could go wrong for the other AST nodes.

I don't understand this. If we can have a reduced test for this, why is it not 
great? 

> 
> This usually gets caught incidentally in diagnostics for unrelated tests. In 
> this case that incidental test was in libc++.

Or, are you saying it is too hard to get reduced?


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


[clang] [libcxxabi] [llvm] Add support for WASI builds (PR #91051)

2024-06-12 Thread Luca Versari via cfe-commits

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


[clang] [libcxxabi] [llvm] Add support for WASI builds (PR #91051)

2024-06-12 Thread Luca Versari via cfe-commits

veluca93 wrote:

Will close this PR for now waiting for the other one to go through - if that 
does not happen, feel free to reopen it!

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Matheus Izvekov via cfe-commits

mizvekov wrote:


> Or, are you saying it is too hard to get reduced?
> 
> 

I don't have a reduced test case. It's not impossible to reduce. Though we 
usually do a poor job of preserving TemplateNames in other places, which makes 
this harder to test. I have patches on my pipeline dealing with this though.

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


[clang] [clang] Emit bad shift warnings (PR #70307)

2024-06-12 Thread Budimir Aranđelović via cfe-commits

https://github.com/budimirarandjelovicsyrmia updated 
https://github.com/llvm/llvm-project/pull/70307

From 550bdebeb5ee3e305495407063a7d33c640a333c Mon Sep 17 00:00:00 2001
From: budimirarandjelovicsyrmia 
Date: Thu, 26 Oct 2023 10:39:52 +0200
Subject: [PATCH] [clang] Emit bad shift warnings

---
 clang/lib/AST/ExprConstant.cpp |  7 +++
 clang/lib/Sema/SemaExpr.cpp| 17 +
 clang/test/AST/Interp/shifts.cpp   |  4 +---
 clang/test/C/drs/dr0xx.c   |  2 +-
 clang/test/Sema/shift-count-negative.c | 10 ++
 clang/test/Sema/shift-count-overflow.c |  7 +++
 clang/test/Sema/shift-negative-value.c | 10 ++
 clang/test/Sema/vla-2.c|  6 --
 clang/test/SemaCXX/shift.cpp   |  1 -
 9 files changed, 53 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/Sema/shift-count-negative.c
 create mode 100644 clang/test/Sema/shift-count-overflow.c
 create mode 100644 clang/test/Sema/shift-negative-value.c

diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 78cfecbec9fd3..8b26ba30c2bbd 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -2816,6 +2816,9 @@ static bool handleIntIntBinOp(EvalInfo &Info, const Expr 
*E, const APSInt &LHS,
   else if (LHS.countLeadingZeros() < SA)
 Info.CCEDiag(E, diag::note_constexpr_lshift_discards);
 }
+if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
+Info.getLangOpts().CPlusPlus)
+  return false;
 Result = LHS << SA;
 return true;
   }
@@ -2839,6 +2842,10 @@ static bool handleIntIntBinOp(EvalInfo &Info, const Expr 
*E, const APSInt &LHS,
 if (SA != RHS)
   Info.CCEDiag(E, diag::note_constexpr_large_shift)
 << RHS << E->getType() << LHS.getBitWidth();
+
+if (Info.EvalStatus.Diag && !Info.EvalStatus.Diag->empty() &&
+Info.getLangOpts().CPlusPlus)
+  return false;
 Result = LHS >> SA;
 return true;
   }
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 94f52004cf6c2..70afced7a32e7 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -11446,7 +11446,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult 
&LHS, ExprResult &RHS,
   if (Right.isNegative()) {
 S.DiagRuntimeBehavior(Loc, RHS.get(),
   S.PDiag(diag::warn_shift_negative)
-<< RHS.get()->getSourceRange());
+  << RHS.get()->getSourceRange());
 return;
   }
 
@@ -11462,7 +11462,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult 
&LHS, ExprResult &RHS,
   if (Right.uge(LeftBits)) {
 S.DiagRuntimeBehavior(Loc, RHS.get(),
   S.PDiag(diag::warn_shift_gt_typewidth)
-<< RHS.get()->getSourceRange());
+  << RHS.get()->getSourceRange());
 return;
   }
 
@@ -11495,7 +11495,7 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult 
&LHS, ExprResult &RHS,
   if (Left.isNegative()) {
 S.DiagRuntimeBehavior(Loc, LHS.get(),
   S.PDiag(diag::warn_shift_lhs_negative)
-<< LHS.get()->getSourceRange());
+  << LHS.get()->getSourceRange());
 return;
   }
 
@@ -17322,11 +17322,20 @@ Sema::VerifyIntegerConstantExpression(Expr *E, 
llvm::APSInt *Result,
   // Circumvent ICE checking in C++11 to avoid evaluating the expression twice
   // in the non-ICE case.
   if (!getLangOpts().CPlusPlus11 && E->isIntegerConstantExpr(Context)) {
+SmallVector Notes;
 if (Result)
-  *Result = E->EvaluateKnownConstIntCheckOverflow(Context);
+  *Result = E->EvaluateKnownConstIntCheckOverflow(Context, &Notes);
 if (!isa(E))
   E = Result ? ConstantExpr::Create(Context, E, APValue(*Result))
  : ConstantExpr::Create(Context, E);
+
+if (Notes.size() && !Diagnoser.Suppress) {
+  Diagnoser.diagnoseNotICE(*this, DiagLoc) << E->getSourceRange();
+  for (const PartialDiagnosticAt &Note : Notes)
+Diag(Note.first, Note.second);
+  return ExprError();
+}
+
 return E;
   }
 
diff --git a/clang/test/AST/Interp/shifts.cpp b/clang/test/AST/Interp/shifts.cpp
index b1df7b85cc9f2..b2b2cb60f4a61 100644
--- a/clang/test/AST/Interp/shifts.cpp
+++ b/clang/test/AST/Interp/shifts.cpp
@@ -33,9 +33,7 @@ namespace shifts {
// FIXME: 'implicit conversion' warning missing in 
the new interpreter. \
// cxx17-warning {{shift count >= width of type}} \
// ref-warning {{shift count >= width of type}} \
-   // ref-warning {{implicit conversion}} \
-   // ref-cxx17-warning {{shift count >= width of 
type}} \
-   // ref-cxx17-warning {{implicit conversion}}
+   // ref-cxx17-warning {{shif

[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits

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


[clang] [clang] Emit bad shift warnings (PR #70307)

2024-06-12 Thread Budimir Aranđelović via cfe-commits


@@ -11444,9 +11444,12 @@ static void DiagnoseBadShiftValues(Sema& S, ExprResult 
&LHS, ExprResult &RHS,
   llvm::APSInt Right = RHSResult.Val.getInt();
 
   if (Right.isNegative()) {
-S.DiagRuntimeBehavior(Loc, RHS.get(),
-  S.PDiag(diag::warn_shift_negative)
-<< RHS.get()->getSourceRange());
+if (S.ExprEvalContexts.back().isConstantEvaluated())
+  S.Diag(Loc, diag::warn_shift_negative) << RHS.get()->getSourceRange();
+else
+  S.DiagRuntimeBehavior(Loc, RHS.get(),
+S.PDiag(diag::warn_shift_negative)
+  << RHS.get()->getSourceRange());

budimirarandjelovicsyrmia wrote:

Diagnose is caught in handleIntIntBinOp() and is emitted for C++ in 
VerifyIntegerConstantExpression(). There are two reasons why diagnostic could 
be emitted in case of C++:
1) evaluating expression as rvalue fails or evaluation result has side 
effects or it is not an integer; evaluating expression as rvalue fails if 
function handleIntIntBinOp() returns false
2) folding is allowed (CanFold == AllowFoldKind::AllowFold); this value 
depends on place where constant expression is defined; eg. in case on enum 
folding is allowed and in case of static assertion it is not allowed
Also, diagnostic would not be emitted if Diagnoser is suppresed.

However, in C case there are no diagnostic for integer constant expression.

So I enabled diagnosing in C case (if Diagnoser is not suppressed). In function 
EvaluateKnownConstIntCheckOverflow() it is expected that evaluating rvalue is 
successful, so I keep handleIntIntBinOp() returning true.
For C++ diagnostic, I modified handleIntIntBinOp() to return false.

As folding is allowed for enum and not for static assertion, I added in tests 
to check both enum and static assertion diagnosing.

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Chuanqi Xu via cfe-commits

ChuanqiXu9 wrote:

I feel better to have a regression test for this if possible. I am just 
worrying someone someday meet the problem unconsciously.

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


[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)

2024-06-12 Thread via cfe-commits

https://github.com/Andarwinux updated 
https://github.com/llvm/llvm-project/pull/94731

>From 509b60d82c582279c2a56597a10b9f11f21e5eb2 Mon Sep 17 00:00:00 2001
From: Andarwinux <144242044+andarwi...@users.noreply.github.com>
Date: Fri, 7 Jun 2024 07:07:40 +
Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver

fixes #91216
---
 clang/include/clang/Driver/Options.td | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f7904dd94b94..a512e5385d532 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8575,6 +8575,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">,
 Alias<_SLASH_winsdkdir>;
 def : Separate<["-"], "Xmicrosoft-windows-sdk-version">,
 Alias<_SLASH_winsdkversion>;
+def : Separate<["-"], "Xmicrosoft-windows-sys-root">,
+Alias<_SLASH_winsysroot>;
 
 // Ignored:
 

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


[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)

2024-06-12 Thread Jan Patrick Lehr via cfe-commits

jplehr wrote:

I believe this broke our flang+openmp+offload bot: 
https://lab.llvm.org/staging/#/builders/140/builds/10168
Happy to help looking into it.

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits

https://github.com/DavidSpickett commented:

I can't fully approve this, I leave that to other members of 
@llvm/pr-subscribers-arm .

2 overall comments:
* Calling a function marked interrupt from a function marked interrupt is still 
UB isn't it? Should there be another warning to cover that scenario as well?
* I see that gcc has a warning in `-Wattributes` for this, you should raise a 
bug there equivalent to the one llvm has, perhaps there even is one already.

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits


@@ -336,9 +336,10 @@ def warn_anyx86_excessive_regsave : Warning<
   " with attribute 'no_caller_saved_registers'"
   " or be compiled with '-mgeneral-regs-only'">,
   InGroup>;
-def warn_arm_interrupt_calling_convention : Warning<
-   "call to function without interrupt attribute could clobber interruptee's 
VFP registers">,
-   InGroup;
+def warn_arm_interrupt_vfp_clobber : Warning<
+   "calling a VFP-enabled function from an interrupt could clobber the "

DavidSpickett wrote:

Unless "VFP-enabled" is some Arm defined, specific spelling, I would write it 
as "VFP enabled" without the "-".

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits


@@ -384,6 +384,10 @@ Modified Compiler Flags
   evaluating to ``true`` and an empty body such as ``while(1);``)
   are considered infinite, even when the ``-ffinite-loop`` flag is set.
 
+- Removed "arm interrupt calling convention" warning that was included in

DavidSpickett wrote:

I would rephrase this a bit:
```
The "arm interrupt calling convention" warning previously included in 
``-Wextra`` has been removed and made into a unique warning enabled using 
``-Warm-interrrupt-vfp-clobber``.
```

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits


@@ -544,6 +548,14 @@ Improvements to Clang's diagnostics
 - Clang no longer emits a "declared here" note for a builtin function that has 
no declaration in source.
   Fixes #GH93369.
 
+- On ARM, Clang no longer suggests adding ``__attribute__((interrupt))`` to

DavidSpickett wrote:

I would phrase this "For the ARM target", since Clang could be running on any 
host architecture.

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


[clang] [clang][ARM] Fix warning for VFP function calls from interrupts. (PR #91870)

2024-06-12 Thread David Spickett via cfe-commits

DavidSpickett wrote:

> I'd like to also address https://github.com/llvm/llvm-project/issues/47815, 
> but I wasn't able to find the right path to answer "is this M-profile" from 
> TargetInfo.

Any ARM folks know if there are existing M profile only warnings to learn from?

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


[clang] [clang][NFC] Add a test for CWG2685 (PR #95206)

2024-06-12 Thread Younan Zhang via cfe-commits

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

I believe it has been implemented since D139837 "Implements CTAD for aggregates 
P1816R0 and P2082R1", so this just claims we have already supported it.

Plus an update on the dr status page.

>From f6503d93891233bb03fc73b5dabbe4fdec9ff34d Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Wed, 12 Jun 2024 16:31:02 +0800
Subject: [PATCH] [clang][NFC] Add a test for CWG2685

I believe it has been implemented since D139837 "Implements CTAD for aggregates 
P1816R0 and P2082R1", so this just claims we have already supported it.

Plus an update on the dr status page.
---
 clang/test/CXX/drs/cwg26xx.cpp |  9 +
 clang/www/cxx_dr_status.html   | 62 --
 2 files changed, 61 insertions(+), 10 deletions(-)

diff --git a/clang/test/CXX/drs/cwg26xx.cpp b/clang/test/CXX/drs/cwg26xx.cpp
index d3c5b5bb7b6b9..60258055e30b5 100644
--- a/clang/test/CXX/drs/cwg26xx.cpp
+++ b/clang/test/CXX/drs/cwg26xx.cpp
@@ -225,6 +225,15 @@ void m() {
 }
 
 #if __cplusplus >= 202302L
+
+namespace cwg2685 { // cwg2685: 17
+template 
+struct A {
+  T ar[4];
+};
+A a = { "foo" };
+}
+
 namespace cwg2687 { // cwg2687: 18
 struct S{
 void f(int);
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 4c5f922e52954..a27f5a3937fae 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -12670,7 +12670,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2144.html";>2144
-drafting
+tentatively ready
 Function/variable declaration ambiguity
 Not resolved
   
@@ -15918,7 +15918,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2685.html";>2685
 C++23
 Aggregate CTAD, string, and brace elision
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2686.html";>2686
@@ -17081,7 +17081,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2879.html";>2879
-open
+drafting
 Undesired outcomes with const_cast
 Not resolved
   
@@ -17099,13 +17099,13 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2882.html";>2882
-open
+tentatively ready
 Unclear treatment of conversion to void
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2883.html";>2883
-open
+tentatively ready
 Definition of "odr-usable" ignores lambda scopes
 Not resolved
   
@@ -17117,25 +17117,25 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2885.html";>2885
-review
+tentatively ready
 Non-eligible trivial default constructors
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2886.html";>2886
-open
+tentatively ready
 Temporaries and trivial potentially-throwing special member 
functions
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2887.html";>2887
-open
+tentatively ready
 Missing compatibility entries for xvalues
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2888.html";>2888
-open
+review
 Missing cases for reference and array types for argument-dependent 
lookup
 Not resolved
   
@@ -17153,9 +17153,51 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2891.html";>2891
-review
+tentatively ready
 Normative status of implementation limits
 Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2892.html";>2892
+tentatively ready
+Unclear usual arithmetic conversions
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2893.html";>2893
+open
+Instantiations in discarded if constexpr substatements
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2894.html";>2894
+open
+Functional casts create prvalues of reference type
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2895.html";>2895
+open
+Initialization should ignore the destination type's 
cv-qualification
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2896.html";>2896
+open
+Template argument deduction involving exception specifications
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2897.html";>2897
+open
+Copying potentially-overlapping union subobjects
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2898.html";>2898
+open
+Clarify implicit conversion sequence from cv T to 
T
+Not resolved
   
 
 

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


[clang] [clang][NFC] Add a test for CWG2685 (PR #95206)

2024-06-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Younan Zhang (zyn0217)


Changes

I believe it has been implemented since D139837 "Implements CTAD for aggregates 
P1816R0 and P2082R1", so this just claims we have already supported it.

Plus an update on the dr status page.

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


2 Files Affected:

- (modified) clang/test/CXX/drs/cwg26xx.cpp (+9) 
- (modified) clang/www/cxx_dr_status.html (+52-10) 


``diff
diff --git a/clang/test/CXX/drs/cwg26xx.cpp b/clang/test/CXX/drs/cwg26xx.cpp
index d3c5b5bb7b6b9..60258055e30b5 100644
--- a/clang/test/CXX/drs/cwg26xx.cpp
+++ b/clang/test/CXX/drs/cwg26xx.cpp
@@ -225,6 +225,15 @@ void m() {
 }
 
 #if __cplusplus >= 202302L
+
+namespace cwg2685 { // cwg2685: 17
+template 
+struct A {
+  T ar[4];
+};
+A a = { "foo" };
+}
+
 namespace cwg2687 { // cwg2687: 18
 struct S{
 void f(int);
diff --git a/clang/www/cxx_dr_status.html b/clang/www/cxx_dr_status.html
index 4c5f922e52954..a27f5a3937fae 100755
--- a/clang/www/cxx_dr_status.html
+++ b/clang/www/cxx_dr_status.html
@@ -12670,7 +12670,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2144.html";>2144
-drafting
+tentatively ready
 Function/variable declaration ambiguity
 Not resolved
   
@@ -15918,7 +15918,7 @@ C++ defect report implementation 
status
 https://cplusplus.github.io/CWG/issues/2685.html";>2685
 C++23
 Aggregate CTAD, string, and brace elision
-Unknown
+Clang 17
   
   
 https://cplusplus.github.io/CWG/issues/2686.html";>2686
@@ -17081,7 +17081,7 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2879.html";>2879
-open
+drafting
 Undesired outcomes with const_cast
 Not resolved
   
@@ -17099,13 +17099,13 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2882.html";>2882
-open
+tentatively ready
 Unclear treatment of conversion to void
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2883.html";>2883
-open
+tentatively ready
 Definition of "odr-usable" ignores lambda scopes
 Not resolved
   
@@ -17117,25 +17117,25 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2885.html";>2885
-review
+tentatively ready
 Non-eligible trivial default constructors
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2886.html";>2886
-open
+tentatively ready
 Temporaries and trivial potentially-throwing special member 
functions
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2887.html";>2887
-open
+tentatively ready
 Missing compatibility entries for xvalues
 Not resolved
   
   
 https://cplusplus.github.io/CWG/issues/2888.html";>2888
-open
+review
 Missing cases for reference and array types for argument-dependent 
lookup
 Not resolved
   
@@ -17153,9 +17153,51 @@ C++ defect report implementation 
status
   
   
 https://cplusplus.github.io/CWG/issues/2891.html";>2891
-review
+tentatively ready
 Normative status of implementation limits
 Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2892.html";>2892
+tentatively ready
+Unclear usual arithmetic conversions
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2893.html";>2893
+open
+Instantiations in discarded if constexpr substatements
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2894.html";>2894
+open
+Functional casts create prvalues of reference type
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2895.html";>2895
+open
+Initialization should ignore the destination type's 
cv-qualification
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2896.html";>2896
+open
+Template argument deduction involving exception specifications
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2897.html";>2897
+open
+Copying potentially-overlapping union subobjects
+Not resolved
+  
+  
+https://cplusplus.github.io/CWG/issues/2898.html";>2898
+open
+Clarify implicit conversion sequence from cv T to 
T
+Not resolved
   
 
 

``




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


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-12 Thread via cfe-commits

zmodem wrote:

Do you have access to press the "Squash and merge" button, or should I do it?

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


[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)

2024-06-12 Thread Mariya Podchishchaeva via cfe-commits


@@ -2161,6 +2161,21 @@ static RValue EmitLoadOfMatrixLValue(LValue LV, 
SourceLocation Loc,
   return RValue::get(CGF.EmitLoadOfScalar(LV, Loc));
 }
 
+RValue CodeGenFunction::EmitLoadOfAnyValue(LValue LV, AggValueSlot Slot,
+   SourceLocation Loc) {
+  QualType Ty = LV.getType();
+  switch (getEvaluationKind(Ty)) {
+  case TEK_Scalar:
+return EmitLoadOfLValue(LV, Loc);
+  case TEK_Complex:
+return RValue::getComplex(EmitLoadOfComplex(LV, Loc));
+  case TEK_Aggregate:
+EmitAggFinalDestCopy(Ty, Slot, LV, EVK_RValue);

Fznamznon wrote:

Ok, passed EVK_NonRValue instead.

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


[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)

2024-06-12 Thread Mariya Podchishchaeva via cfe-commits


@@ -102,12 +98,7 @@ char *test_ptr(char *fmt, ...) {
 // N32:   [[TMP2:%.+]] = load i64, ptr [[AP_CUR]], align 8
 // N32:   [[TMP3:%.+]] = trunc i64 [[TMP2]] to i32
 // N32:   [[PTR:%.+]] = inttoptr i32 [[TMP3]] to ptr
-// N32:   store ptr [[PTR]], ptr [[AP_CAST]], align 4
-// N32:   [[ARG:%.+]] = load ptr, ptr [[AP_CAST]], align [[$PTRALIGN]]
-//
-// O32:   [[ARG:%.+]] = load ptr, ptr [[AP_CUR]], align [[$PTRALIGN]]
-// N64:   [[ARG:%.+]] = load ptr, ptr [[AP_CUR]], align [[$PTRALIGN]]
-// ALL:   store ptr [[ARG]], ptr [[V]], align [[$PTRALIGN]]
+// N32:   store ptr [[PTR]], ptr [[V]], align 4

Fznamznon wrote:

I suppose now it does.

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


[clang] [clang][CodeGen] Return RValue from `EmitVAArg` (PR #94635)

2024-06-12 Thread Mariya Podchishchaeva via cfe-commits


@@ -789,27 +791,37 @@ Address AArch64ABIInfo::EmitAAPCSVAArg(Address 
VAListAddr, QualType Ty,
  OnStackBlock, "vaargs.addr");
 
   if (IsIndirect)
-return Address(CGF.Builder.CreateLoad(ResAddr, "vaarg.addr"), ElementTy,
-   TyAlign);
-
-  return ResAddr;
+return CGF.EmitLoadOfAnyValue(
+CGF.MakeAddrLValue(
+Address(CGF.Builder.CreateLoad(ResAddr, "vaarg.addr"), ElementTy,
+TyAlign),
+Ty),
+Slot);
+
+  return CGF.EmitLoadOfAnyValue(CGF.MakeAddrLValue(ResAddr, Ty), Slot);
 }
 
-Address AArch64ABIInfo::EmitDarwinVAArg(Address VAListAddr, QualType Ty,
-CodeGenFunction &CGF) const {
+RValue AArch64ABIInfo::EmitDarwinVAArg(Address VAListAddr, QualType Ty,
+   CodeGenFunction &CGF,
+   AggValueSlot Slot) const {
   // The backend's lowering doesn't support va_arg for aggregates or
   // illegal vector types.  Lower VAArg here for these cases and use
   // the LLVM va_arg instruction for everything else.
   if (!isAggregateTypeForABI(Ty) && !isIllegalVectorType(Ty))
-return EmitVAArgInstr(CGF, VAListAddr, Ty, ABIArgInfo::getDirect());
+return CGF.EmitLoadOfAnyValue(
+CGF.MakeAddrLValue(
+EmitVAArgInstr(CGF, VAListAddr, Ty, ABIArgInfo::getDirect()), Ty),
+Slot);
 
   uint64_t PointerSize = getTarget().getPointerWidth(LangAS::Default) / 8;
   CharUnits SlotSize = CharUnits::fromQuantity(PointerSize);
 
   // Empty records are ignored for parameter passing purposes.
-  if (isEmptyRecord(getContext(), Ty, true))
-return Address(CGF.Builder.CreateLoad(VAListAddr, "ap.cur"),
-   CGF.ConvertTypeForMem(Ty), SlotSize);
+  if (isEmptyRecord(getContext(), Ty, true)) {
+Address ResAddr = Address(CGF.Builder.CreateLoad(VAListAddr, "ap.cur"),

Fznamznon wrote:

Done.

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


[clang] Add flag to opt out of wasm-opt (PR #95208)

2024-06-12 Thread Quentin Michaud via cfe-commits

https://github.com/mh4ck-Thales created 
https://github.com/llvm/llvm-project/pull/95208

 This PR fixes #55781 by adding the `--no-wasm-opt` and `--wasm-opt` flags in 
clang to disable/enable the `wasm-opt` optimizations. The default is to enable 
`wasm-opt` as before in order to not break existing workflows.

I think that adding a warning when no flag or the `--wasm-opt` flag is given 
but `wasm-opt` wasn't found in the path may be relevant here. It allows people 
using `wasm-opt` to be aware of if it have been used on their produced binary 
or not. The only downside I see to this is that people already using the 
toolchain with the `-O` and `-Werror` flags but without `wasm-opt` in the path 
will see their toolchain break (with an easy fix: either adding `--no-wasm-opt` 
or add `wasm-opt` to the path). I haven't implemented this here because I 
haven't figured out how to add such a warning, and I don't know if this warning 
should be added here or in another PR.

CC @sunfishcode that proposed in the associated issue to review this patch.

>From 8c7052d5da074eb1d754aeddc4257d33e4e299aa Mon Sep 17 00:00:00 2001
From: Quentin Michaud 
Date: Tue, 11 Jun 2024 16:25:51 +0200
Subject: [PATCH] Add flag to opt out of wasm-opt (#55781)

---
 clang/include/clang/Basic/LangOptions.h |  4 ++
 clang/include/clang/Driver/Options.td   |  8 +++
 clang/lib/Driver/ToolChains/WebAssembly.cpp | 72 +++--
 3 files changed, 49 insertions(+), 35 deletions(-)

diff --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 75e88afbd9705..91f1c2f2e6239 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -575,6 +575,10 @@ class LangOptions : public LangOptionsBase {
   // implementation on real-world examples.
   std::string OpenACCMacroOverride;
 
+  // Indicates if the wasm-opt binary must be ignored in the case of a
+  // WebAssembly target.
+  bool NoWasmOpt = false;
+
   LangOptions();
 
   /// Set language defaults for the given input language and
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d44faa55c456f..22a400c9707b1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8740,3 +8740,11 @@ def spirv : DXCFlag<"spirv">,
 def fspv_target_env_EQ : Joined<["-"], "fspv-target-env=">, Group,
   HelpText<"Specify the target environment">,
   Values<"vulkan1.2, vulkan1.3">;
+def no_wasm_opt : Flag<["--"], "no-wasm-opt">,
+  Group,
+  HelpText<"Disable the wasm-opt optimizer">,
+  MarshallingInfoFlag>;
+def wasm_opt : Flag<["--"], "wasm-opt">,
+  Group,
+  HelpText<"Enable the wasm-opt optimizer (default)">,
+  MarshallingInfoNegativeFlag>;
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 5b763df9b3329..60bd97e0ee987 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -158,44 +158,46 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  // When optimizing, if wasm-opt is available, run it.
-  std::string WasmOptPath;
-  if (Args.getLastArg(options::OPT_O_Group)) {
-WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
-if (WasmOptPath == "wasm-opt") {
-  WasmOptPath = {};
+  if (Args.hasFlag(options::OPT_wasm_opt, options::OPT_no_wasm_opt, true)) {
+// When optimizing, if wasm-opt is available, run it.
+std::string WasmOptPath;
+if (Args.getLastArg(options::OPT_O_Group)) {
+  WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
+  if (WasmOptPath == "wasm-opt") {
+WasmOptPath = {};
+  }
 }
-  }
-
-  if (!WasmOptPath.empty()) {
-CmdArgs.push_back("--keep-section=target_features");
-  }
 
-  C.addCommand(std::make_unique(JA, *this,
- ResponseFileSupport::AtFileCurCP(),
- Linker, CmdArgs, Inputs, Output));
-
-  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
 if (!WasmOptPath.empty()) {
-  StringRef OOpt = "s";
-  if (A->getOption().matches(options::OPT_O4) ||
-  A->getOption().matches(options::OPT_Ofast))
-OOpt = "4";
-  else if (A->getOption().matches(options::OPT_O0))
-OOpt = "0";
-  else if (A->getOption().matches(options::OPT_O))
-OOpt = A->getValue();
-
-  if (OOpt != "0") {
-const char *WasmOpt = Args.MakeArgString(WasmOptPath);
-ArgStringList OptArgs;
-OptArgs.push_back(Output.getFilename());
-OptArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
-OptArgs.push_back("-o");
-OptArgs.push_back(Output.getFilename());
-C.addCommand(std::make_unique(
-JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, OptArgs,
-Inputs, Output));
+   

[clang] Add flag to opt out of wasm-opt (PR #95208)

2024-06-12 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang] Add flag to opt out of wasm-opt (PR #95208)

2024-06-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Quentin Michaud (mh4ck-Thales)


Changes

 This PR fixes #55781 by adding the `--no-wasm-opt` and `--wasm-opt` 
flags in clang to disable/enable the `wasm-opt` optimizations. The default is 
to enable `wasm-opt` as before in order to not break existing workflows.

I think that adding a warning when no flag or the `--wasm-opt` flag is given 
but `wasm-opt` wasn't found in the path may be relevant here. It allows people 
using `wasm-opt` to be aware of if it have been used on their produced binary 
or not. The only downside I see to this is that people already using the 
toolchain with the `-O` and `-Werror` flags but without `wasm-opt` in the path 
will see their toolchain break (with an easy fix: either adding `--no-wasm-opt` 
or add `wasm-opt` to the path). I haven't implemented this here because I 
haven't figured out how to add such a warning, and I don't know if this warning 
should be added here or in another PR.

CC @sunfishcode that proposed in the associated issue to review this 
patch.

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


3 Files Affected:

- (modified) clang/include/clang/Basic/LangOptions.h (+4) 
- (modified) clang/include/clang/Driver/Options.td (+8) 
- (modified) clang/lib/Driver/ToolChains/WebAssembly.cpp (+37-35) 


``diff
diff --git a/clang/include/clang/Basic/LangOptions.h 
b/clang/include/clang/Basic/LangOptions.h
index 75e88afbd9705..91f1c2f2e6239 100644
--- a/clang/include/clang/Basic/LangOptions.h
+++ b/clang/include/clang/Basic/LangOptions.h
@@ -575,6 +575,10 @@ class LangOptions : public LangOptionsBase {
   // implementation on real-world examples.
   std::string OpenACCMacroOverride;
 
+  // Indicates if the wasm-opt binary must be ignored in the case of a
+  // WebAssembly target.
+  bool NoWasmOpt = false;
+
   LangOptions();
 
   /// Set language defaults for the given input language and
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d44faa55c456f..22a400c9707b1 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8740,3 +8740,11 @@ def spirv : DXCFlag<"spirv">,
 def fspv_target_env_EQ : Joined<["-"], "fspv-target-env=">, Group,
   HelpText<"Specify the target environment">,
   Values<"vulkan1.2, vulkan1.3">;
+def no_wasm_opt : Flag<["--"], "no-wasm-opt">,
+  Group,
+  HelpText<"Disable the wasm-opt optimizer">,
+  MarshallingInfoFlag>;
+def wasm_opt : Flag<["--"], "wasm-opt">,
+  Group,
+  HelpText<"Enable the wasm-opt optimizer (default)">,
+  MarshallingInfoNegativeFlag>;
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp 
b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index 5b763df9b3329..60bd97e0ee987 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -158,44 +158,46 @@ void wasm::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   CmdArgs.push_back("-o");
   CmdArgs.push_back(Output.getFilename());
 
-  // When optimizing, if wasm-opt is available, run it.
-  std::string WasmOptPath;
-  if (Args.getLastArg(options::OPT_O_Group)) {
-WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
-if (WasmOptPath == "wasm-opt") {
-  WasmOptPath = {};
+  if (Args.hasFlag(options::OPT_wasm_opt, options::OPT_no_wasm_opt, true)) {
+// When optimizing, if wasm-opt is available, run it.
+std::string WasmOptPath;
+if (Args.getLastArg(options::OPT_O_Group)) {
+  WasmOptPath = ToolChain.GetProgramPath("wasm-opt");
+  if (WasmOptPath == "wasm-opt") {
+WasmOptPath = {};
+  }
 }
-  }
-
-  if (!WasmOptPath.empty()) {
-CmdArgs.push_back("--keep-section=target_features");
-  }
 
-  C.addCommand(std::make_unique(JA, *this,
- ResponseFileSupport::AtFileCurCP(),
- Linker, CmdArgs, Inputs, Output));
-
-  if (Arg *A = Args.getLastArg(options::OPT_O_Group)) {
 if (!WasmOptPath.empty()) {
-  StringRef OOpt = "s";
-  if (A->getOption().matches(options::OPT_O4) ||
-  A->getOption().matches(options::OPT_Ofast))
-OOpt = "4";
-  else if (A->getOption().matches(options::OPT_O0))
-OOpt = "0";
-  else if (A->getOption().matches(options::OPT_O))
-OOpt = A->getValue();
-
-  if (OOpt != "0") {
-const char *WasmOpt = Args.MakeArgString(WasmOptPath);
-ArgStringList OptArgs;
-OptArgs.push_back(Output.getFilename());
-OptArgs.push_back(Args.MakeArgString(llvm::Twine("-O") + OOpt));
-OptArgs.push_back("-o");
-OptArgs.push_back(Output.getFilename());
-C.addCommand(std::make_unique(
-JA, *this, ResponseFileSupport::AtFileCurCP(), WasmOpt, OptArgs,
-Inputs, Output));
+  CmdArgs.push_back("--keep-section=target_features");
+}
+
+C.addCommand(std::make_unique(JA, *this,
+

[clang] [analyzer] Refine invalidation caused by `fread` (PR #93408)

2024-06-12 Thread Balazs Benics via cfe-commits


@@ -0,0 +1,443 @@
+// RUN: %clang_analyze_cc1 -verify %s \
+// RUN:   -triple x86_64-linux-gnu  \
+// RUN:   -analyzer-checker=core,unix.Stream,alpha.security.taint \
+// RUN:   -analyzer-checker=debug.ExprInspection
+
+#include "Inputs/system-header-simulator-for-simple-stream.h"
+
+#define EOF (-1)
+
+void clang_analyzer_dump(int);
+void clang_analyzer_isTainted(int);
+void clang_analyzer_warnIfReached(void);
+
+// A stream is only tracked by StreamChecker if it results from a call to 
"fopen".
+// Otherwise, there is no specific modelling of "fread".
+void untracked_stream(FILE *fp) {
+  char c;
+  if (1 == fread(&c, 1, 1, fp)) {
+char p = c; // Unknown value but not garbage and not modeled by checker.
+  } else {
+char p = c; // Possibly indeterminate value but not modeled by checker.
+  }
+}
+
+void fgetc_props_taint(void) {
+  FILE *fp = fopen("/home/test", "rb+");
+  if (fp) {
+int c = fgetc(fp); // c is tainted.
+if (c != EOF) {
+  clang_analyzer_isTainted(c); // expected-warning{{YES}}
+}
+fclose(fp);
+  }
+}
+
+void fread_props_taint(void) {
+  FILE *fp = fopen("/home/test", "rb+");
+  if (fp) {
+char buffer[10];
+int c = fread(buffer, 1, 10, fp); // c is tainted.
+if (c != 10) {
+  // If the read failed, then the number of bytes successfully read should 
be tainted.
+  clang_analyzer_isTainted(c); // expected-warning{{YES}}
+}
+fclose(fp);
+  }
+}
+
+void read_one_byte1(void) {
+  FILE *fp = fopen("/home/test", "rb+");
+  if (fp) {
+char c;
+if (1 == fread(&c, 1, 1, fp)) {
+  char p = c; // Unknown value but not garbage.
+  clang_analyzer_isTainted(p); // expected-warning{{YES}}
+} else {
+  char p = c; // Possibly indeterminate value but not modeled by checker.
+  clang_analyzer_isTainted(p); // expected-warning{{YES}}
+}
+fclose(fp);
+  }
+}
+
+void read_one_byte2(char *buffer) {
+  FILE *fp = fopen("/home/test", "rb+");
+  if (fp) {
+if (1 == fread(buffer, 1, 1, fp)) {
+  char p = buffer[0]; // Unknown value but not garbage.
+  clang_analyzer_isTainted(p); // expected-warning{{YES}}
+} else {
+  char p = buffer[0]; // Possibly indeterminate value but not modeled by 
checker.
+  clang_analyzer_isTainted(p); // expected-warning{{YES}}
+}
+fclose(fp);
+  }
+}
+
+void read_one_byte3(char *buffer) {
+  buffer[1] = 10;
+  FILE *fp = fopen("/home/test", "rb+");
+  if (fp) {
+// buffer[1] is not mutated by fread and remains not tainted.
+fread(buffer, 1, 1, fp);
+char p = buffer[1];
+clang_analyzer_isTainted(p); // expected-warning{{NO}}
+clang_analyzer_dump(buffer[1]); // expected-warning{{10 S32b}}
+fclose(fp);
+  }
+}
+
+void read_many_bytes(char *buffer) {
+  FILE *fp = fopen("/home/test", "rb+");
+  if (fp) {
+if (42 == fread(buffer, 1, 42, fp)) {
+  char p = buffer[0]; // Unknown value but not garbage.
+  clang_analyzer_isTainted(p); // expected-warning{{YES}}
+} else {
+  char p = buffer[0]; // Possibly indeterminate value but not modeled.
+  clang_analyzer_isTainted(p); // expected-warning{{YES}}
+}
+fclose(fp);
+  }
+}
+
+void random_access_read1(int index) {
+  FILE *fp = fopen("/home/test", "rb+");
+  if (fp) {
+long c[4];
+int success = 2 == fread(c + 1, sizeof(long), 2, fp);
+
+switch (index) {
+case 0:
+  // c[0] is not mutated by fread.
+  if (success) {
+char p = c[0]; // expected-warning {{Assigned value is garbage or 
undefined}} We kept the first byte intact.
+  } else {
+char p = c[0]; // expected-warning {{Assigned value is garbage or 
undefined}} We kept the first byte intact.
+  }
+  break;
+
+case 1:
+  if (success) {
+// Unknown value but not garbage.
+clang_analyzer_isTainted(c[1]); // expected-warning {{YES}}
+clang_analyzer_dump(c[1]); // expected-warning {{conj_}}
+  } else {
+// Possibly indeterminate value but not modeled.
+clang_analyzer_isTainted(c[1]); // expected-warning {{YES}}
+clang_analyzer_dump(c[1]); // expected-warning {{conj_}}
+  }
+  break;
+
+case 2:
+  if (success) {
+long p = c[2]; // Unknown value but not garbage.
+// FIXME: Taint analysis only marks the first byte of a memory region. 
See getPointeeOf in GenericTaintChecker.cpp.
+clang_analyzer_isTainted(c[2]); // expected-warning {{NO}}
+clang_analyzer_dump(c[2]); // expected-warning {{conj_}}
+  } else {
+// Possibly indeterminate value but not modeled.
+clang_analyzer_isTainted(c[2]); // expected-warning {{NO}} // FIXME: 
See above.
+clang_analyzer_dump(c[2]); // expected-warning {{conj_}}
+  }
+  break;
+
+case 3:
+  // c[3] is not mutated by fread.
+  if (success) {
+long p = c[3]; // expected-warning {{Assigned value is garbage or 
undefined}}
+  } else {
+long p = c[3]; // exp

[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-12 Thread Braden Helmer via cfe-commits

bradenhelmer wrote:

> Do you have access to press the "Squash and merge" button, or should I do it?

You'll have to, i dont have access yet, thx

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


[clang] 83a54e7 - [clang] Implement -Wmissing-include-dirs (#94827)

2024-06-12 Thread via cfe-commits

Author: Braden Helmer
Date: 2024-06-12T11:30:10+02:00
New Revision: 83a54e75c1229be99875901139f7722be643ce87

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

LOG: [clang] Implement -Wmissing-include-dirs (#94827)

Implements -Wmissing-include-dirs #92015 

This is my first contribution and would love some feedback. Thanks!

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticDriverKinds.td
clang/include/clang/Basic/DiagnosticGroups.td
clang/lib/Driver/Driver.cpp
clang/test/Driver/warning-options.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td 
b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 773b234cd68fe..1ca2cb85565a1 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -809,4 +809,7 @@ def warn_android_unversioned_fallback : Warning<
 
 def err_drv_triple_version_invalid : Error<
   "version '%0' in target triple '%1' is invalid">;
+
+def warn_missing_include_dirs : Warning<
+  "no such include directory: '%0'">, InGroup, 
DefaultIgnore;
 }

diff  --git a/clang/include/clang/Basic/DiagnosticGroups.td 
b/clang/include/clang/Basic/DiagnosticGroups.td
index 7d5ba7869ec34..9b37d4bd3205b 100644
--- a/clang/include/clang/Basic/DiagnosticGroups.td
+++ b/clang/include/clang/Basic/DiagnosticGroups.td
@@ -506,7 +506,7 @@ def MaxUnsignedZero : DiagGroup<"max-unsigned-zero">;
 def MissingBraces : DiagGroup<"missing-braces">;
 def MissingDeclarations: DiagGroup<"missing-declarations">;
 def : DiagGroup<"missing-format-attribute">;
-def : DiagGroup<"missing-include-dirs">;
+def MissingIncludeDirs : DiagGroup<"missing-include-dirs">;
 def MissingNoreturn : DiagGroup<"missing-noreturn">;
 def MultiChar : DiagGroup<"multichar">;
 def : DiagGroup<"nested-externs">;

diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f5ea73a04ae5c..67bf0604acd6e 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1271,6 +1271,14 @@ Compilation *Driver::BuildCompilation(ArrayRef ArgList) {
 if (VFS->setCurrentWorkingDirectory(WD->getValue()))
   Diag(diag::err_drv_unable_to_set_working_directory) << WD->getValue();
 
+  // Check for missing include directories.
+  if (!Diags.isIgnored(diag::warn_missing_include_dirs, SourceLocation())) {
+for (auto IncludeDir : Args.getAllArgValues(options::OPT_I_Group)) {
+  if (!VFS->exists(IncludeDir))
+Diag(diag::warn_missing_include_dirs) << IncludeDir;
+}
+  }
+
   // FIXME: This stuff needs to go into the Compilation, not the driver.
   bool CCCPrintPhases;
 

diff  --git a/clang/test/Driver/warning-options.cpp 
b/clang/test/Driver/warning-options.cpp
index d836ad143a1c5..a7020ff4fc1d9 100644
--- a/clang/test/Driver/warning-options.cpp
+++ b/clang/test/Driver/warning-options.cpp
@@ -6,3 +6,7 @@
 // Check that -isysroot warns on nonexistent paths.
 // RUN: %clang -### -c -target i386-apple-darwin10 -isysroot 
%t/warning-options %s 2>&1 | FileCheck --check-prefix=CHECK-ISYSROOT %s
 // CHECK-ISYSROOT: warning: no such sysroot directory: '{{.*}}/warning-options'
+
+// Check for proper warning with -Wmissing-include-dirs
+// RUN: %clang -### -Wmissing-include-dirs -I %t/warning-options %s 2>&1 | 
FileCheck --check-prefix=CHECK-MISSING-INCLUDE-DIRS %s
+// CHECK-MISSING-INCLUDE-DIRS: warning: no such include directory: 
'{{.*}}/warning-options'



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


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-12 Thread via cfe-commits

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


[clang] [clang] Don't print extra space when dumping template names (PR #95213)

2024-06-12 Thread Haojian Wu via cfe-commits

https://github.com/hokein created 
https://github.com/llvm/llvm-project/pull/95213

None

>From c5f5d784a8cab287d3ec826a2636874ad9498563 Mon Sep 17 00:00:00 2001
From: Haojian Wu 
Date: Wed, 12 Jun 2024 11:24:10 +0200
Subject: [PATCH] [clang] Don't print extra blank when dump the template name.

---
 clang/lib/AST/TextNodeDumper.cpp   | 2 +-
 clang/test/AST/ast-dump-ctad-alias.cpp | 4 ++--
 clang/test/AST/ast-dump-template-decls.cpp | 6 +++---
 clang/test/AST/ast-dump-using-template.cpp | 8 
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index e1a2709507eff..a26f50f0719c1 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1140,7 +1140,7 @@ void TextNodeDumper::dumpTemplateName(TemplateName TN, 
StringRef Label) {
 llvm::raw_svector_ostream SS(Str);
 TN.print(SS, PrintPolicy);
   }
-  OS << " '" << Str << "'";
+  OS << "'" << Str << "'";
 
   if (Context) {
 if (TemplateName CanonTN = Context->getCanonicalTemplateName(TN);
diff --git a/clang/test/AST/ast-dump-ctad-alias.cpp 
b/clang/test/AST/ast-dump-ctad-alias.cpp
index cd3b8c6821344..a4b6f06547443 100644
--- a/clang/test/AST/ast-dump-ctad-alias.cpp
+++ b/clang/test/AST/ast-dump-ctad-alias.cpp
@@ -36,11 +36,11 @@ Out2::AInner t(1.0);
 // CHECK-NEXT: | | |   `-TemplateTypeParmType {{.*}} 'type-parameter-1-0' 
dependent depth 1 index 0
 // CHECK-NEXT: | | `-TypeTraitExpr {{.*}} 'bool' __is_deducible
 // CHECK-NEXT: | |   |-DeducedTemplateSpecializationType {{.*}} 
'Out2::AInner' dependent
-// CHECK-NEXT: | |   | `-name:  'Out2::AInner'
+// CHECK-NEXT: | |   | `-name: 'Out2::AInner'
 // CHECK-NEXT: | |   |   `-TypeAliasTemplateDecl {{.+}} AInner{{$}}
 // CHECK-NEXT: | |   `-ElaboratedType {{.*}} 'Inner' 
sugar dependent
 // CHECK-NEXT: | | `-TemplateSpecializationType {{.*}} 
'Inner' dependent
-// CHECK-NEXT: | |   |-name:  'Inner':'Out::Inner' qualified
+// CHECK-NEXT: | |   |-name: 'Inner':'Out::Inner' qualified
 // CHECK-NEXT: | |   | `-ClassTemplateDecl {{.+}} Inner{{$}}
 // CHECK-NEXT: | |   `-TemplateArgument type 'type-parameter-1-0'
 // CHECK-NEXT: | | `-SubstTemplateTypeParmType {{.*}} 
'type-parameter-1-0'
diff --git a/clang/test/AST/ast-dump-template-decls.cpp 
b/clang/test/AST/ast-dump-template-decls.cpp
index fea14abb3b2f4..f0a6204ce3cfa 100644
--- a/clang/test/AST/ast-dump-template-decls.cpp
+++ b/clang/test/AST/ast-dump-template-decls.cpp
@@ -117,7 +117,7 @@ using type2 = typename C::type1;
 // CHECK:  TypeAliasDecl 0x{{[^ ]*}}  col:7 
type2 'typename C::type1':'void (int)'
 // CHECK-NEXT: ElaboratedType 0x{{[^ ]*}} 'typename C::type1' sugar
 // CHECK-NEXT: TemplateSpecializationType 0x{{[^ ]*}} 'type1' sugar alias
-// CHECK-NEXT: name:  'C::type1':'PR55886::C::type1' qualified
+// CHECK-NEXT: name: 'C::type1':'PR55886::C::type1' qualified
 // CHECK-NEXT: NestedNameSpecifier TypeSpec 'C':'PR55886::C'
 // CHECK-NEXT: TypeAliasTemplateDecl {{.+}} type1
 // CHECK-NEXT: TemplateArgument type 'void'
@@ -153,7 +153,7 @@ template  struct D {
 };
 using t2 = D::B;
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar 
alias{{$}}
-// CHECK-NEXT: name:  'D::B':'PR56099::D::B' 
qualified
+// CHECK-NEXT: name: 'D::B':'PR56099::D::B' qualified
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int 
(*)(char, short))' cdecl
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
 // CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar typename 
depth 0 index 0 ... T pack_index 1
@@ -175,7 +175,7 @@ template class E {};
 using test1 = D;
 // CHECK:  TypeAliasDecl 0x{{[^ ]*}}  col:7 
test1 'D':'subst_default_argument::E>'
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'A' sugar
-// CHECK-NEXT: |-name:  'A':'subst_default_argument::A' qualified
+// CHECK-NEXT: |-name: 'A':'subst_default_argument::A' qualified
 // CHECK-NEXT: | `-ClassTemplateDecl {{.+}} A
 // CHECK-NEXT: |-TemplateArgument type 'int'
 // CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar class 
depth 0 index 1 D2
diff --git a/clang/test/AST/ast-dump-using-template.cpp 
b/clang/test/AST/ast-dump-using-template.cpp
index 22b9b76612add..75db5eb5a9d1c 100644
--- a/clang/test/AST/ast-dump-using-template.cpp
+++ b/clang/test/AST/ast-dump-using-template.cpp
@@ -21,7 +21,7 @@ using A = S;
 // CHECK:  TypeAliasDecl
 // CHECK-NEXT: `-ElaboratedType {{.*}} 'S' sugar dependent
 // CHECK-NEXT:   `-TemplateSpecializationType {{.*}} 'S' dependent
-// CHECK-NEXT: |-name:  'S':'ns::S' qualified
+// CHECK-NEXT: |-name: 'S':'ns::S' qualified
 // CHECk-NEXT: | |-UsingShadowDecl {{.+}} ClassTemplate {{.+}} 'S'
 
 // TemplateName in TemplateArgument.
@@ -30,7 +30,7 @@ using B = X;
 // CHECK:  TypeAliasDecl
 // CHECK-NEXT: `-ElaboratedType {{.*}} '

[clang] [clang] Don't print extra space when dumping template names (PR #95213)

2024-06-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Haojian Wu (hokein)


Changes



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


4 Files Affected:

- (modified) clang/lib/AST/TextNodeDumper.cpp (+1-1) 
- (modified) clang/test/AST/ast-dump-ctad-alias.cpp (+2-2) 
- (modified) clang/test/AST/ast-dump-template-decls.cpp (+3-3) 
- (modified) clang/test/AST/ast-dump-using-template.cpp (+4-4) 


``diff
diff --git a/clang/lib/AST/TextNodeDumper.cpp b/clang/lib/AST/TextNodeDumper.cpp
index e1a2709507eff..a26f50f0719c1 100644
--- a/clang/lib/AST/TextNodeDumper.cpp
+++ b/clang/lib/AST/TextNodeDumper.cpp
@@ -1140,7 +1140,7 @@ void TextNodeDumper::dumpTemplateName(TemplateName TN, 
StringRef Label) {
 llvm::raw_svector_ostream SS(Str);
 TN.print(SS, PrintPolicy);
   }
-  OS << " '" << Str << "'";
+  OS << "'" << Str << "'";
 
   if (Context) {
 if (TemplateName CanonTN = Context->getCanonicalTemplateName(TN);
diff --git a/clang/test/AST/ast-dump-ctad-alias.cpp 
b/clang/test/AST/ast-dump-ctad-alias.cpp
index cd3b8c6821344..a4b6f06547443 100644
--- a/clang/test/AST/ast-dump-ctad-alias.cpp
+++ b/clang/test/AST/ast-dump-ctad-alias.cpp
@@ -36,11 +36,11 @@ Out2::AInner t(1.0);
 // CHECK-NEXT: | | |   `-TemplateTypeParmType {{.*}} 'type-parameter-1-0' 
dependent depth 1 index 0
 // CHECK-NEXT: | | `-TypeTraitExpr {{.*}} 'bool' __is_deducible
 // CHECK-NEXT: | |   |-DeducedTemplateSpecializationType {{.*}} 
'Out2::AInner' dependent
-// CHECK-NEXT: | |   | `-name:  'Out2::AInner'
+// CHECK-NEXT: | |   | `-name: 'Out2::AInner'
 // CHECK-NEXT: | |   |   `-TypeAliasTemplateDecl {{.+}} AInner{{$}}
 // CHECK-NEXT: | |   `-ElaboratedType {{.*}} 'Inner' 
sugar dependent
 // CHECK-NEXT: | | `-TemplateSpecializationType {{.*}} 
'Inner' dependent
-// CHECK-NEXT: | |   |-name:  'Inner':'Out::Inner' qualified
+// CHECK-NEXT: | |   |-name: 'Inner':'Out::Inner' qualified
 // CHECK-NEXT: | |   | `-ClassTemplateDecl {{.+}} Inner{{$}}
 // CHECK-NEXT: | |   `-TemplateArgument type 'type-parameter-1-0'
 // CHECK-NEXT: | | `-SubstTemplateTypeParmType {{.*}} 
'type-parameter-1-0'
diff --git a/clang/test/AST/ast-dump-template-decls.cpp 
b/clang/test/AST/ast-dump-template-decls.cpp
index fea14abb3b2f4..f0a6204ce3cfa 100644
--- a/clang/test/AST/ast-dump-template-decls.cpp
+++ b/clang/test/AST/ast-dump-template-decls.cpp
@@ -117,7 +117,7 @@ using type2 = typename C::type1;
 // CHECK:  TypeAliasDecl 0x{{[^ ]*}}  col:7 
type2 'typename C::type1':'void (int)'
 // CHECK-NEXT: ElaboratedType 0x{{[^ ]*}} 'typename C::type1' sugar
 // CHECK-NEXT: TemplateSpecializationType 0x{{[^ ]*}} 'type1' sugar alias
-// CHECK-NEXT: name:  'C::type1':'PR55886::C::type1' qualified
+// CHECK-NEXT: name: 'C::type1':'PR55886::C::type1' qualified
 // CHECK-NEXT: NestedNameSpecifier TypeSpec 'C':'PR55886::C'
 // CHECK-NEXT: TypeAliasTemplateDecl {{.+}} type1
 // CHECK-NEXT: TemplateArgument type 'void'
@@ -153,7 +153,7 @@ template  struct D {
 };
 using t2 = D::B;
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'B' sugar 
alias{{$}}
-// CHECK-NEXT: name:  'D::B':'PR56099::D::B' 
qualified
+// CHECK-NEXT: name: 'D::B':'PR56099::D::B' qualified
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (int (*)(float, int), int 
(*)(char, short))' cdecl
 // CHECK:  FunctionProtoType 0x{{[^ ]*}} 'int (float, int)' cdecl
 // CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar typename 
depth 0 index 0 ... T pack_index 1
@@ -175,7 +175,7 @@ template class E {};
 using test1 = D;
 // CHECK:  TypeAliasDecl 0x{{[^ ]*}}  col:7 
test1 'D':'subst_default_argument::E>'
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'A' sugar
-// CHECK-NEXT: |-name:  'A':'subst_default_argument::A' qualified
+// CHECK-NEXT: |-name: 'A':'subst_default_argument::A' qualified
 // CHECK-NEXT: | `-ClassTemplateDecl {{.+}} A
 // CHECK-NEXT: |-TemplateArgument type 'int'
 // CHECK-NEXT: | `-SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar class 
depth 0 index 1 D2
diff --git a/clang/test/AST/ast-dump-using-template.cpp 
b/clang/test/AST/ast-dump-using-template.cpp
index 22b9b76612add..75db5eb5a9d1c 100644
--- a/clang/test/AST/ast-dump-using-template.cpp
+++ b/clang/test/AST/ast-dump-using-template.cpp
@@ -21,7 +21,7 @@ using A = S;
 // CHECK:  TypeAliasDecl
 // CHECK-NEXT: `-ElaboratedType {{.*}} 'S' sugar dependent
 // CHECK-NEXT:   `-TemplateSpecializationType {{.*}} 'S' dependent
-// CHECK-NEXT: |-name:  'S':'ns::S' qualified
+// CHECK-NEXT: |-name: 'S':'ns::S' qualified
 // CHECk-NEXT: | |-UsingShadowDecl {{.+}} ClassTemplate {{.+}} 'S'
 
 // TemplateName in TemplateArgument.
@@ -30,7 +30,7 @@ using B = X;
 // CHECK:  TypeAliasDecl
 // CHECK-NEXT: `-ElaboratedType {{.*}} 'X' sugar
 // CHECK-NEXT:   `-TemplateSpecializationType {{.*}} 'X' sugar
-// CHECK-NEXT: |-name:  'X' qualified
+// CHECK-NEXT:   

[clang] [analyzer] Refine invalidation caused by `fread` (PR #93408)

2024-06-12 Thread Balazs Benics via cfe-commits

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

>From f9e841ddaa865d529c806b2d115d5ddbc7109243 Mon Sep 17 00:00:00 2001
From: Balazs Benics 
Date: Sun, 26 May 2024 11:40:01 +0200
Subject: [PATCH 01/17] [analyzer] Refine invalidation caused by `fread`

This change enables more accurate modeling of the write effects of `fread`.
In particular, instead of invalidating the whole buffer, in a best-effort
basis, we would try to invalidate the actually accesses elements of the buffer.
This preserves the previous value of the buffer of the unaffected slots.
As a result, diagnose more uninitialized buffer uses for example.

Currently, this refined invalidation only triggers for `fread` if and
only if the `count` parameter and the buffer pointer's index component
are concrete or perfectly-constrained symbols.
Additionally, if the `fread` would read more than 64 elements, the whole
buffer is invalidated as before. This is to have safeguards against
performance issues.

Refer to the comments of the assertions in the following example to see
the changes in the diagnostics:

```c++
void demo() {
  FILE *fp = fopen("/home/test", "rb+");
  if (!fp) return;
  int buffer[10]; // uninitialized
  int read_items = fread(buffer+1, sizeof(int), 5, fp);
  if (5 == read_items) {
int v1 = buffer[1]; // Unknown value but not garbage.
clang_analyzer_isTainted(v1); // expected-warning {{YES}} <-- Would be "NO" 
without this patch.
clang_analyzer_dump(v1); // expected-warning {{conj_}} <-- Not a "derived" 
symbol, so it's directly invalidated now.
int v0 = buffer[0]; // expected-warning {{Assigned value is garbage or 
undefined}} <-- Had no report here before.
(void)(v1 + v0);
  } else {
// If 'fread' had an error.
int v0 = buffer[0]; // expected-warning {{Assigned value is garbage or 
undefined}} <-- Had no report here before.
(void)v0;
  }
  fclose(fp);
}
```

[CPP-3247](https://sonarsource.atlassian.net/browse/CPP-3247)

Patch by Marco Borgeaud (marco-antognini-sonarsource)
---
 .../StaticAnalyzer/Checkers/StreamChecker.cpp |  88 -
 clang/test/Analysis/fread.cpp | 328 ++
 2 files changed, 405 insertions(+), 11 deletions(-)
 create mode 100644 clang/test/Analysis/fread.cpp

diff --git a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp 
b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
index d4e020f7a72a0..7b42c4f72b322 100644
--- a/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp
@@ -717,18 +717,71 @@ const ExplodedNode 
*StreamChecker::getAcquisitionSite(const ExplodedNode *N,
   return nullptr;
 }
 
+/// Invalidate only the requested elements instead of the whole buffer.
+/// This is basically a refinement of the more generic 'escapeArgs' or
+/// the plain old 'invalidateRegions'.
+/// This only works if the \p StartIndex and \p Count are concrete or
+/// perfectly-constrained.
+static ProgramStateRef
+escapeByStartIndexAndCount(ProgramStateRef State, CheckerContext &C,
+   const CallEvent &Call, const MemRegion *Buffer,
+   QualType ElemType, SVal StartIndex, SVal Count) {
+  if (!llvm::isa_and_nonnull(Buffer))
+return State;
+
+  auto UnboxAsInt = [&C, &State](SVal V) -> std::optional {
+auto &SVB = C.getSValBuilder();
+if (const llvm::APSInt *Int = SVB.getKnownValue(State, V))
+  return Int->tryExtValue();
+return std::nullopt;
+  };
+
+  auto StartIndexVal = UnboxAsInt(StartIndex);
+  auto CountVal = UnboxAsInt(Count);
+
+  // FIXME: Maybe we could make this more generic, and expose this by the
+  // 'invalidateRegions' API. After doing so, it might make sense to make this
+  // limit configurable.
+  constexpr int MaxInvalidatedElementsLimit = 64;
+  if (!StartIndexVal || !CountVal || *CountVal > MaxInvalidatedElementsLimit) {
+return State->invalidateRegions({loc::MemRegionVal{Buffer}},
+Call.getOriginExpr(), C.blockCount(),
+C.getLocationContext(),
+/*CausesPointerEscape=*/false);
+  }
+
+  constexpr auto DoNotInvalidateSuperRegion =
+  RegionAndSymbolInvalidationTraits::InvalidationKinds::
+  TK_DoNotInvalidateSuperRegion;
+
+  auto &RegionManager = Buffer->getMemRegionManager();
+  SmallVector EscapingVals;
+  EscapingVals.reserve(*CountVal);
+
+  RegionAndSymbolInvalidationTraits ITraits;
+  for (auto Idx : llvm::seq(*StartIndexVal, *StartIndexVal + *CountVal)) {
+NonLoc Index = C.getSValBuilder().makeArrayIndex(Idx);
+const auto *Element = RegionManager.getElementRegion(
+ElemType, Index, cast(Buffer), C.getASTContext());
+EscapingVals.push_back(loc::MemRegionVal(Element));
+ITraits.setTrait(Element, DoNotInvalidateSuperRegion);
+  }
+  return State->invalidateRegions(EscapingVals, Call.getOriginExpr(),
+  

[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-06-12 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 updated 
https://github.com/llvm/llvm-project/pull/75912

>From cf8be3c418dde67b74d4a5a4ea98a33f0e2fbd72 Mon Sep 17 00:00:00 2001
From: Chuanqi Xu 
Date: Tue, 19 Dec 2023 17:00:59 +0800
Subject: [PATCH 1/5] [C++20] [Modules] [Itanium ABI] Generate the vtable in
 the module unit of dynamic classes

Close https://github.com/llvm/llvm-project/issues/70585 and reflect
https://github.com/itanium-cxx-abi/cxx-abi/issues/170.

The significant change of the patch is: for dynamic classes attached to
module units, we generate the vtable to the attached module units
directly and the key functions for such classes is meaningless.
---
 clang/include/clang/AST/DeclBase.h|  3 ++
 clang/lib/AST/DeclBase.cpp|  9 +
 clang/lib/CodeGen/CGVTables.cpp   | 28 ++
 clang/lib/CodeGen/CodeGenModule.cpp   |  7 
 clang/lib/CodeGen/ItaniumCXXABI.cpp   |  3 ++
 clang/lib/Sema/SemaDecl.cpp   |  9 +
 clang/lib/Sema/SemaDeclCXX.cpp| 12 --
 clang/lib/Serialization/ASTReaderDecl.cpp |  6 +++
 clang/lib/Serialization/ASTWriterDecl.cpp |  6 +++
 clang/test/CodeGenCXX/modules-vtable.cppm | 31 +--
 clang/test/CodeGenCXX/pr70585.cppm| 47 +++
 11 files changed, 138 insertions(+), 23 deletions(-)
 create mode 100644 clang/test/CodeGenCXX/pr70585.cppm

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 600ce73c7f019..f38386381853b 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -670,6 +670,9 @@ class alignas(8) Decl {
   /// Whether this declaration comes from another module unit.
   bool isInAnotherModuleUnit() const;
 
+  /// Whether this declaration comes from the same module unit being compiled.
+  bool isInCurrentModuleUnit() const;
+
   /// Whether the definition of the declaration should be emitted in external
   /// sources.
   bool shouldEmitInExternalSource() const;
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index 1e9c879e371bc..153dc3351dae5 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -1106,6 +1106,15 @@ bool Decl::isInAnotherModuleUnit() const {
   return M != getASTContext().getCurrentNamedModule();
 }
 
+bool Decl::isInCurrentModuleUnit() const {
+  auto *M = getOwningModule();
+
+  if (!M || !M->isNamedModule())
+return false;
+
+  return M == getASTContext().getCurrentNamedModule();
+}
+
 bool Decl::shouldEmitInExternalSource() const {
   ExternalASTSource *Source = getASTContext().getExternalSource();
   if (!Source)
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 001633453f242..55c3032dc9332 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -1051,6 +1051,11 @@ CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) 
{
   if (!RD->isExternallyVisible())
 return llvm::GlobalVariable::InternalLinkage;
 
+  // V-tables for non-template classes with an owning module are always
+  // uniquely emitted in that module.
+  if (RD->isInNamedModule())
+return llvm::GlobalVariable::ExternalLinkage;
+
   // We're at the end of the translation unit, so the current key
   // function is fully correct.
   const CXXMethodDecl *keyFunction = Context.getCurrentKeyFunction(RD);
@@ -1185,6 +1190,21 @@ bool CodeGenVTables::isVTableExternal(const 
CXXRecordDecl *RD) {
   TSK == TSK_ExplicitInstantiationDefinition)
 return false;
 
+  // Itanium C++ ABI [5.2.3]:
+  // Virtual tables for dynamic classes are emitted as follows:
+  //
+  // - If the class is templated, the tables are emitted in every object that
+  // references any of them.
+  // - Otherwise, if the class is attached to a module, the tables are uniquely
+  // emitted in the object for the module unit in which it is defined.
+  // - Otherwise, if the class has a key function (see below), the tables are
+  // emitted in the object for the translation unit containing the definition 
of
+  // the key function. This is unique if the key function is not inline.
+  // - Otherwise, the tables are emitted in every object that references any of
+  // them.
+  if (RD->isInNamedModule())
+return RD->shouldEmitInExternalSource();
+
   // Otherwise, if the class doesn't have a key function (possibly
   // anymore), the vtable must be defined here.
   const CXXMethodDecl *keyFunction = 
CGM.getContext().getCurrentKeyFunction(RD);
@@ -1194,13 +1214,7 @@ bool CodeGenVTables::isVTableExternal(const 
CXXRecordDecl *RD) {
   const FunctionDecl *Def;
   // Otherwise, if we don't have a definition of the key function, the
   // vtable must be defined somewhere else.
-  if (!keyFunction->hasBody(Def))
-return true;
-
-  assert(Def && "The body of the key function is not assigned to Def?");
-  // If the non-inline key function comes from another module unit, the vtable
-  // must be defined there.
-  return Def->sho

[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-06-12 Thread Chuanqi Xu via cfe-commits


@@ -1227,7 +1241,8 @@ void CodeGenModule::EmitDeferredVTables() {
 #endif
 
   for (const CXXRecordDecl *RD : DeferredVTables)
-if (shouldEmitVTableAtEndOfTranslationUnit(*this, RD))
+if (shouldEmitVTableAtEndOfTranslationUnit(*this, RD) &&
+!RD->shouldEmitInExternalSource())

ChuanqiXu9 wrote:

Yes, done.

https://github.com/llvm/llvm-project/pull/75912
___
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 Cortex-A725 and Cortex-X925 (PR #95214)

2024-06-12 Thread Jonathan Thackray via cfe-commits

https://github.com/jthackray created 
https://github.com/llvm/llvm-project/pull/95214

Cortex-A725 and Cortex-X925 are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Cortex-A725:
   https://developer.arm.com/documentation/107652/latest

Technical Reference Manual for Cortex-X925:
   https://developer.arm.com/documentation/102807/latest

>From 1e0bb8109b06d29c177765dd7279c7f8f62d1c1d Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 29 May 2024 22:14:28 +0100
Subject: [PATCH] [AArch64] Add support for Cortex-A725 and Cortex-X925

Cortex-A725 and Cortex-X925 are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Cortex-A725:
   https://developer.arm.com/documentation/107652/latest

Technical Reference Manual for Cortex-X925:
   https://developer.arm.com/documentation/102807/latest
---
 clang/docs/ReleaseNotes.rst   |  6 ++--
 clang/test/Driver/aarch64-mcpu.c  |  4 +++
 clang/test/Misc/target-invalid-cpu-note.c |  4 +--
 llvm/docs/ReleaseNotes.rst|  4 +--
 .../llvm/TargetParser/AArch64TargetParser.h   | 12 +++
 llvm/lib/Target/AArch64/AArch64Processors.td  | 30 
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 ++
 llvm/lib/TargetParser/Host.cpp|  2 ++
 .../TargetParser/TargetParserTest.cpp | 36 ++-
 9 files changed, 93 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cf1ba02cbc4b2..148ff05008552 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -903,11 +903,13 @@ Arm and AArch64 Support
   a feature modifier for -march and -mcpu as well as via target attributes
   like ``target_version`` or ``target_clones``.
 - Support has been added for the following processors (-mcpu identifiers in 
parenthesis):
+* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-R82AE (cortex-r82ae).
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
-* Arm Cortex-R82AE (cortex-r82ae).
-* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-A725 (cortex-a725).
+* Arm Cortex-X925 (cortex-x925).
 * Arm Neoverse-N3 (neoverse-n3).
 * Arm Neoverse-V3 (neoverse-v3).
 * Arm Neoverse-V3AE (neoverse-v3ae).
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index ad4a5f9ac6fb8..97303510d6881 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -46,6 +46,8 @@
 // CORTEXX3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x3"
 // RUN: %clang --target=aarch64 -mcpu=cortex-x4 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X4 %s
 // CORTEX-X4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x4"
+// RUN: %clang --target=aarch64 -mcpu=cortex-x925 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X925 %s
+// CORTEX-X925: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-x925"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEXA78 %s
 // CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78c  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A78C %s
@@ -58,6 +60,8 @@
 // CORTEX-A720: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a720ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=CORTEX-A720AE %s
 // CORTEX-A720AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720ae"
+// RUN: %clang --target=aarch64 -mcpu=cortex-a725  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A725 %s
+// CORTEX-A725: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a725"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-e1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-E1 %s
 // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-e1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V1 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 2439025609b9f..790dbd9e07475 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-r82ae, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n

[clang] [llvm] [AArch64] Add support for Cortex-A725 and Cortex-X925 (PR #95214)

2024-06-12 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Jonathan Thackray (jthackray)


Changes

Cortex-A725 and Cortex-X925 are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Cortex-A725:
   https://developer.arm.com/documentation/107652/latest

Technical Reference Manual for Cortex-X925:
   https://developer.arm.com/documentation/102807/latest

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


9 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+4-2) 
- (modified) clang/test/Driver/aarch64-mcpu.c (+4) 
- (modified) clang/test/Misc/target-invalid-cpu-note.c (+2-2) 
- (modified) llvm/docs/ReleaseNotes.rst (+2-2) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+12) 
- (modified) llvm/lib/Target/AArch64/AArch64Processors.td (+30) 
- (modified) llvm/lib/Target/AArch64/AArch64Subtarget.cpp (+2) 
- (modified) llvm/lib/TargetParser/Host.cpp (+2) 
- (modified) llvm/unittests/TargetParser/TargetParserTest.cpp (+35-1) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cf1ba02cbc4b2..148ff05008552 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -903,11 +903,13 @@ Arm and AArch64 Support
   a feature modifier for -march and -mcpu as well as via target attributes
   like ``target_version`` or ``target_clones``.
 - Support has been added for the following processors (-mcpu identifiers in 
parenthesis):
+* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-R82AE (cortex-r82ae).
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
-* Arm Cortex-R82AE (cortex-r82ae).
-* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-A725 (cortex-a725).
+* Arm Cortex-X925 (cortex-x925).
 * Arm Neoverse-N3 (neoverse-n3).
 * Arm Neoverse-V3 (neoverse-v3).
 * Arm Neoverse-V3AE (neoverse-v3ae).
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index ad4a5f9ac6fb8..97303510d6881 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -46,6 +46,8 @@
 // CORTEXX3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x3"
 // RUN: %clang --target=aarch64 -mcpu=cortex-x4 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X4 %s
 // CORTEX-X4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x4"
+// RUN: %clang --target=aarch64 -mcpu=cortex-x925 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X925 %s
+// CORTEX-X925: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-x925"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEXA78 %s
 // CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78c  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A78C %s
@@ -58,6 +60,8 @@
 // CORTEX-A720: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a720ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=CORTEX-A720AE %s
 // CORTEX-A720AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720ae"
+// RUN: %clang --target=aarch64 -mcpu=cortex-a725  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A725 %s
+// CORTEX-A725: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a725"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-e1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-E1 %s
 // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-e1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V1 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 2439025609b9f..790dbd9e07475 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-r82ae, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, 
neoverse-v3, neoverse-v3ae, 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, thunde

[clang] [C++20] [Modules] [Itanium ABI] Generate the vtable in the module unit of dynamic classes (PR #75912)

2024-06-12 Thread Chuanqi Xu via cfe-commits


@@ -6853,6 +6853,13 @@ void CodeGenModule::EmitTopLevelDecl(Decl *D) {
 if (ES->hasExternalDefinitions(D) == ExternalASTSource::EK_Never)
   DI->completeUnusedClass(*CRD);
 }
+// If we're emitting a dynamic class from the importable module we're
+// emitting, we always need to emit the virtual table according to the ABI
+// requirement.
+if (CRD->getDefinition() && CRD->isDynamicClass() &&
+CRD->isInCurrentModuleUnit())
+  EmitVTable(CRD);

ChuanqiXu9 wrote:

> So DefineUsedVTables is called, but the ASTWriter eats the call without 
> actually recording the fact anywhere? Okay, that makes more sense. So I guess 
> that gives a potential alternate approach; we could teach ASTWriter to record 
> the fact that HandleVTable was called, and replay it later.

Done. Although it is somewhat not efficient, I made it if it makes the 
structure more clear.

> But if we can reliably handle emitting vtables in EmitTopLevelDecl, it's 
> probably simpler to just eliminate HandleVTable.

I tried but it looks not so easy. The problem is that `EmitTopLevelDecl` 
getting called on the fly during the parsing but `Sema::DefineUsedVTables` is 
only get called after Sema finished parsing the translation unit. So we still 
need some special function to replace `HandleVTable`, but then it is 
meaningless.

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


[clang] [clang] Implement -Wmissing-include-dirs (PR #94827)

2024-06-12 Thread via cfe-commits

github-actions[bot] wrote:



@bradenhelmer Congratulations on having your first Pull Request (PR) merged 
into the LLVM Project!

Your changes will be combined with recent changes from other authors, then 
tested
by our [build bots](https://lab.llvm.org/buildbot/). If there is a problem with 
a build, you may receive a report in an email or a comment on this PR.

Please check whether problems have been caused by your change specifically, as
the builds can include changes from many authors. It is not uncommon for your
change to be included in a build that fails due to someone else's changes, or
infrastructure issues.

How to do this, and the rest of the post-merge process, is covered in detail 
[here](https://llvm.org/docs/MyFirstTypoFix.html#myfirsttypofix-issues-after-landing-your-pr).

If your change does cause a problem, it may be reverted, or you can revert it 
yourself.
This is a normal part of [LLVM 
development](https://llvm.org/docs/DeveloperPolicy.html#patch-reversion-policy).
 You can fix your changes and open a new PR to merge them again.

If you don't get any reports, no action is required from you. Your changes are 
working as expected, well done!


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


[clang] cece0a1 - Revert "[ConstantFold] Drop gep of gep fold entirely (#95126)"

2024-06-12 Thread Nikita Popov via cfe-commits

Author: Nikita Popov
Date: 2024-06-12T11:52:12+02:00
New Revision: cece0a105b29dcbb9d88d0aa264c4745c07a8456

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

LOG: Revert "[ConstantFold] Drop gep of gep fold entirely (#95126)"

This reverts commit 3b3b839c66dc49674fd6646650525a2173030690.

This broke the flang+openmp+offload buildbot, as reported in
https://github.com/llvm/llvm-project/pull/95126#issuecomment-2162424019.

Added: 


Modified: 
clang/test/CodeGenCUDA/managed-var.cu
clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist.cpp
clang/test/CodeGenCXX/ms-inline-asm-fields.cpp
clang/test/OpenMP/threadprivate_codegen.cpp
llvm/include/llvm/IR/ConstantFold.h
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/Constants.cpp

Removed: 




diff  --git a/clang/test/CodeGenCUDA/managed-var.cu 
b/clang/test/CodeGenCUDA/managed-var.cu
index 07e1a1e692c75..5206acc62fe00 100644
--- a/clang/test/CodeGenCUDA/managed-var.cu
+++ b/clang/test/CodeGenCUDA/managed-var.cu
@@ -127,10 +127,9 @@ __device__ __host__ float load2() {
 
 // HOST-LABEL: define {{.*}}@_Z5load3v()
 // HOST:  %ld.managed = load ptr, ptr @v2, align 16
-// HOST:  %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, 
i64 0, i64 1
-// HOST:  %1 = getelementptr inbounds %struct.vec, ptr %0, i32 0, i32 1
-// HOST:  %2 = load float, ptr %1, align 4
-// HOST:  ret float %2
+// HOST:  %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, 
i64 0, i64 1, i32 1
+// HOST:  %1 = load float, ptr %0, align 4
+// HOST:  ret float %1
 float load3() {
   return v2[1].y;
 }
@@ -140,11 +139,10 @@ float load3() {
 // HOST:  %0 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed, 
i64 0, i64 1
 // HOST:  %1 = ptrtoint ptr %0 to i64
 // HOST:  %ld.managed1 = load ptr, ptr @v2, align 16
-// HOST:  %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, 
i64 0, i64 1
-// HOST:  %3 = getelementptr inbounds %struct.vec, ptr %2, i32 0, i32 1
-// HOST:  %4 = ptrtoint ptr %3 to i64
-// HOST:  %5 = sub i64 %4, %1
-// HOST:  %sub.ptr.div = sdiv exact i64 %5, 4
+// HOST:  %2 = getelementptr inbounds [100 x %struct.vec], ptr %ld.managed1, 
i64 0, i64 1, i32 1
+// HOST:  %3 = ptrtoint ptr %2 to i64
+// HOST:  %4 = sub i64 %3, %1
+// HOST:  %sub.ptr.div = sdiv exact i64 %4, 4
 // HOST:  %conv = sitofp i64 %sub.ptr.div to float
 // HOST:  ret float %conv
 float addr_taken2() {

diff  --git a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp 
b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
index 14557829268ef..4033adc8f0390 100644
--- a/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
+++ b/clang/test/CodeGenCXX/2011-12-19-init-list-ctor.cpp
@@ -21,6 +21,6 @@ struct S {
 // CHECK: store i32 0, ptr @arr
 // CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i32 0, i32 1), ptr noundef @.str)
 // CHECK: store i32 1, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1)
-// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 1), i32 0, i32 
1), ptr noundef @.str.1)
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 1, i32 1), ptr noundef @.str.1)
 // CHECK: store i32 2, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2)
-// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr getelementptr inbounds (%struct.S, ptr @arr, i64 2), i32 0, i32 
1), ptr noundef @.str.2)
+// CHECK: call void @_ZN1AC1EPKc(ptr {{[^,]*}} getelementptr inbounds 
(%struct.S, ptr @arr, i64 2, i32 1), ptr noundef @.str.2)

diff  --git 
a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp 
b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
index caa92f47a93c2..6fbe4c7fd17a7 100644
--- a/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
+++ b/clang/test/CodeGenCXX/cxx0x-initializer-stdinitializerlist-pr12086.cpp
@@ -79,12 +79,12 @@ std::initializer_list> nested = {
 // CHECK-DYNAMIC-BL: store i32 {{.*}}, ptr getelementptr inbounds (i32, ptr 
@_ZGR6nested1_, i64 1)
 // CHECK-DYNAMIC-BL: store ptr @_ZGR6nested1_,
 // CHECK-DYNAMIC-BL:   ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 1), align 8
-// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr 
getelementptr inbounds ({{.*}}, ptr @_ZGR6nested_, i64 1), i32 0, i32 1), align 
8
+// CHECK-DYNAMIC-BL: store i64 2, ptr getelementptr inbounds ({{.*}}, ptr 
@_ZGR6nested_, i64 1, i32 1), align 8
 // CH

[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)

2024-06-12 Thread Nikita Popov via cfe-commits

nikic wrote:

> I believe this broke our flang+openmp+offload bot: 
> https://lab.llvm.org/staging/#/builders/140/builds/10168 Happy to help 
> looking into it.

That's for the heads-up, I've reverted this patch in 
https://github.com/llvm/llvm-project/commit/cece0a105b29dcbb9d88d0aa264c4745c07a8456.

I would appreciate some help with debugging this, I don't think I can run this 
test locally. Probably just having the pre-optimization LLVM IR/bitcode would 
be enough. (Though with offload, there is probably more than one module 
involved?)

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


[clang] [clang] fix broken canonicalization of DeducedTemplateSpecializationType (PR #95202)

2024-06-12 Thread Haojian Wu via cfe-commits

https://github.com/hokein commented:

good catch, the fix looks good to me overall, I will leave the final stamp to 
@ChuanqiXu9.

(I agree that it would be nice to have a regression test if it is not too hard 
to reduce from libcxx)

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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-12 Thread Paul Heidekrüger via cfe-commits

https://github.com/PBHDK created https://github.com/llvm/llvm-project/pull/95220

This PR is based on the PR #90043 by @sebwolf-de, who has given us (@leunam99 
and myself) [permission to continue his 
work](https://github.com/llvm/llvm-project/pull/90043#issuecomment-2137455627).

The original PR message reads:

> The string based test to find out whether the check is applicable on the 
> class is not ideal, but I did not find a more elegant way, yet.
> If there is more clang-query magic available, that I'm not aware of, I'm 
> happy to adapt that.

As part of the reviews for that PR, @sebwolf-de changed the following: 

- Detect viable classes automatically instead of looking for fixed names
- Disable fix-it suggestions 

This PR contains the same changes and, in addition, addresses further feedback 
provided by the maintainers.

Changes in addition to the original PR:
- Exclude `std::map`, `std::flat_map`, and `std::unordered_set` from the 
analysis by default, and add the ability for users to exclude additional 
classes from the analysis
- Add the tests @PiotrZSL requested 
[here](https://github.com/llvm/llvm-project/pull/90043#discussion_r1579858850)
- Rename the analysis from AvoidBoundsErrorsCheck to 
PreferAtOverSubscriptOperatorCheck as requested by @PiotrZSL 
[here](https://github.com/llvm/llvm-project/pull/90043#discussion_r1579853430) 
- Add a more detailed description of what the analysis does as requested by 
@PiotrZSL 
[here](https://github.com/llvm/llvm-project/pull/90043#discussion_r1579847155)
 

We explicitly don't ignore unused code with `TK_IgnoreUnlessSpelledInSource`, 
as requested by @PiotrZSL 
[here](https://github.com/llvm/llvm-project/pull/90043#discussion_r1579844550), 
because it caused the template-related tests to fail.

We are not sure what the best behaviour for templates is; should we:

-  not warn if using `at()` will make a different instantiation not compile?
- warn at the place that requires the template instantiation?
- keep the warning and add the name of the class of the object / the template 
parameters that lead to the message?
- not warn in templates at all because the code is implicit?

@carlosgalvezp and @HerrCai0907 discussed the possibility of disabling the 
check when exceptions are disabled, but we were unsure whether they'd reached a 
conclusion and whether it was still relevant when fix-it suggestions are 
disabled.

What do you think?

From 37292995de0c5aa87408586749795a97468d4725 Mon Sep 17 00:00:00 2001
From: Sebastian Wolf 
Date: Wed, 17 Apr 2024 16:16:35 +0200
Subject: [PATCH 1/8] Enforce SL.con.3: Add check to replace operator[] with
 at() on std containers

---
 .../AvoidBoundsErrorsCheck.cpp| 81 +++
 .../AvoidBoundsErrorsCheck.h  | 32 
 .../cppcoreguidelines/CMakeLists.txt  |  1 +
 .../CppCoreGuidelinesTidyModule.cpp   |  3 +
 clang-tools-extra/docs/ReleaseNotes.rst   |  5 ++
 .../cppcoreguidelines/avoid-bounds-errors.rst | 20 +
 .../docs/clang-tidy/checks/list.rst   |  1 +
 .../cppcoreguidelines/avoid-bounds-errors.cpp | 66 +++
 8 files changed, 209 insertions(+)
 create mode 100644 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
 create mode 100644 
clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/avoid-bounds-errors.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/avoid-bounds-errors.cpp

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
new file mode 100644
index 0..524c21b5bdb81
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidBoundsErrorsCheck.cpp
@@ -0,0 +1,81 @@
+//===--- AvoidBoundsErrorsCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "AvoidBoundsErrorsCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+#include 
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::cppcoreguidelines {
+
+bool isApplicable(const QualType &Type) {
+  const auto TypeStr = Type.getAsString();
+  bool Result = false;
+  // Only check for containers in the std namespace
+  if (TypeStr.find("std::vector") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::array") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::deque") != std::string::npos) {
+Result = true;
+  }
+  if (TypeStr.find("std::map") != std::string::npos) {
+Result = true;
+  }

[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() (PR #90043)

2024-06-12 Thread Paul Heidekrüger via cfe-commits

PBHDK wrote:

> Yes, you can just submit new PR, reference this one.

Done! Here it is: https://github.com/llvm/llvm-project/pull/95220

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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-12 Thread via cfe-commits
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= 
Message-ID:
In-Reply-To: 


github-actions[bot] wrote:



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

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

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

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

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

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

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

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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-12 Thread via cfe-commits
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= 
Message-ID:
In-Reply-To: 


llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Paul Heidekrüger (PBHDK)


Changes

This PR is based on the PR #90043 by @sebwolf-de, who has given 
us (@leunam99 and myself) [permission to continue his 
work](https://github.com/llvm/llvm-project/pull/90043#issuecomment-2137455627).

The original PR message reads:

> The string based test to find out whether the check is applicable on the 
class is not ideal, but I did not find a more elegant way, yet.
> If there is more clang-query magic available, that I'm not aware of, I'm 
happy to adapt that.

As part of the reviews for that PR, @sebwolf-de changed the following: 

- Detect viable classes automatically instead of looking for fixed names
- Disable fix-it suggestions 

This PR contains the same changes and, in addition, addresses further feedback 
provided by the maintainers.

Changes in addition to the original PR:
- Exclude `std::map`, `std::flat_map`, and `std::unordered_set` from the 
analysis by default, and add the ability for users to exclude additional 
classes from the analysis
- Add the tests @PiotrZSL requested 
[here](https://github.com/llvm/llvm-project/pull/90043#discussion_r1579858850)
- Rename the analysis from AvoidBoundsErrorsCheck to 
PreferAtOverSubscriptOperatorCheck as requested by @PiotrZSL 
[here](https://github.com/llvm/llvm-project/pull/90043#discussion_r1579853430) 
- Add a more detailed description of what the analysis does as requested by 
@PiotrZSL 
[here](https://github.com/llvm/llvm-project/pull/90043#discussion_r1579847155)
 

We explicitly don't ignore unused code with `TK_IgnoreUnlessSpelledInSource`, 
as requested by @PiotrZSL 
[here](https://github.com/llvm/llvm-project/pull/90043#discussion_r1579844550), 
because it caused the template-related tests to fail.

We are not sure what the best behaviour for templates is; should we:

-  not warn if using `at()` will make a different instantiation not compile?
- warn at the place that requires the template instantiation?
- keep the warning and add the name of the class of the object / the template 
parameters that lead to the message?
- not warn in templates at all because the code is implicit?

@carlosgalvezp and @HerrCai0907 discussed the possibility of 
disabling the check when exceptions are disabled, but we were unsure whether 
they'd reached a conclusion and whether it was still relevant when fix-it 
suggestions are disabled.

What do you think?

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


8 Files Affected:

- (modified) clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt (+1) 
- (modified) 
clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp 
(+3) 
- (added) 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferAtOverSubscriptOperatorCheck.cpp
 (+124) 
- (added) 
clang-tools-extra/clang-tidy/cppcoreguidelines/PreferAtOverSubscriptOperatorCheck.h
 (+40) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+5) 
- (added) 
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/prefer-at-over-subscript-operator.rst
 (+31) 
- (modified) clang-tools-extra/docs/clang-tidy/checks/list.rst (+1) 
- (added) 
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/prefer-at-over-subscript-operator.cpp
 (+142) 


``diff
diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
index eb35bbc6a538f..fd436859ad04a 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -20,6 +20,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule
   NoMallocCheck.cpp
   NoSuspendWithLockCheck.cpp
   OwningMemoryCheck.cpp
+  PreferAtOverSubscriptOperatorCheck.cpp
   PreferMemberInitializerCheck.cpp
   ProBoundsArrayToPointerDecayCheck.cpp
   ProBoundsConstantArrayIndexCheck.cpp
diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
index e9f0201615616..565a99a865519 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -34,6 +34,7 @@
 #include "NoMallocCheck.h"
 #include "NoSuspendWithLockCheck.h"
 #include "OwningMemoryCheck.h"
+#include "PreferAtOverSubscriptOperatorCheck.h"
 #include "PreferMemberInitializerCheck.h"
 #include "ProBoundsArrayToPointerDecayCheck.h"
 #include "ProBoundsConstantArrayIndexCheck.h"
@@ -102,6 +103,8 @@ class CppCoreGuidelinesModule : public ClangTidyModule {
 "cppcoreguidelines-non-private-member-variables-in-classes");
 CheckFactories.registerCheck(
 "cppcoregui

[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)

2024-06-12 Thread Jan Patrick Lehr via cfe-commits

jplehr wrote:

Thank you @nikic. 
I'll see to reproduce locally and narrow down as much as possible to provide 
small reproducer.

https://github.com/llvm/llvm-project/pull/95126
___
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 Cortex-A725 and Cortex-X925 (PR #95214)

2024-06-12 Thread Jonathan Thackray via cfe-commits

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

>From 1e0bb8109b06d29c177765dd7279c7f8f62d1c1d Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 29 May 2024 22:14:28 +0100
Subject: [PATCH] [AArch64] Add support for Cortex-A725 and Cortex-X925

Cortex-A725 and Cortex-X925 are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Cortex-A725:
   https://developer.arm.com/documentation/107652/latest

Technical Reference Manual for Cortex-X925:
   https://developer.arm.com/documentation/102807/latest
---
 clang/docs/ReleaseNotes.rst   |  6 ++--
 clang/test/Driver/aarch64-mcpu.c  |  4 +++
 clang/test/Misc/target-invalid-cpu-note.c |  4 +--
 llvm/docs/ReleaseNotes.rst|  4 +--
 .../llvm/TargetParser/AArch64TargetParser.h   | 12 +++
 llvm/lib/Target/AArch64/AArch64Processors.td  | 30 
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 ++
 llvm/lib/TargetParser/Host.cpp|  2 ++
 .../TargetParser/TargetParserTest.cpp | 36 ++-
 9 files changed, 93 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cf1ba02cbc4b2..148ff05008552 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -903,11 +903,13 @@ Arm and AArch64 Support
   a feature modifier for -march and -mcpu as well as via target attributes
   like ``target_version`` or ``target_clones``.
 - Support has been added for the following processors (-mcpu identifiers in 
parenthesis):
+* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-R82AE (cortex-r82ae).
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
-* Arm Cortex-R82AE (cortex-r82ae).
-* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-A725 (cortex-a725).
+* Arm Cortex-X925 (cortex-x925).
 * Arm Neoverse-N3 (neoverse-n3).
 * Arm Neoverse-V3 (neoverse-v3).
 * Arm Neoverse-V3AE (neoverse-v3ae).
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index ad4a5f9ac6fb8..97303510d6881 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -46,6 +46,8 @@
 // CORTEXX3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x3"
 // RUN: %clang --target=aarch64 -mcpu=cortex-x4 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X4 %s
 // CORTEX-X4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x4"
+// RUN: %clang --target=aarch64 -mcpu=cortex-x925 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X925 %s
+// CORTEX-X925: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-x925"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEXA78 %s
 // CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78c  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A78C %s
@@ -58,6 +60,8 @@
 // CORTEX-A720: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a720ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=CORTEX-A720AE %s
 // CORTEX-A720AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720ae"
+// RUN: %clang --target=aarch64 -mcpu=cortex-a725  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A725 %s
+// CORTEX-A725: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a725"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-e1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-E1 %s
 // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-e1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V1 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 2439025609b9f..790dbd9e07475 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-r82ae, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, 
neoverse-v3, neoverse-v3ae, 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

[clang] [llvm] [AArch64] Add support for Cortex-A725 and Cortex-X925 (PR #95214)

2024-06-12 Thread Jonathan Thackray via cfe-commits

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

>From 2cdb7257614201cc0907d7908a5f7cb3d300fd51 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 29 May 2024 22:14:28 +0100
Subject: [PATCH] [AArch64] Add support for Cortex-A725 and Cortex-X925

Cortex-A725 and Cortex-X925 are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Cortex-A725:
   https://developer.arm.com/documentation/107652/latest

Technical Reference Manual for Cortex-X925:
   https://developer.arm.com/documentation/102807/latest
---
 clang/docs/ReleaseNotes.rst   |  6 ++--
 clang/test/Driver/aarch64-mcpu.c  |  4 +++
 clang/test/Misc/target-invalid-cpu-note.c |  4 +--
 llvm/docs/ReleaseNotes.rst|  4 +--
 .../llvm/TargetParser/AArch64TargetParser.h   | 12 +++
 llvm/lib/Target/AArch64/AArch64Processors.td  | 30 
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 ++
 llvm/lib/TargetParser/Host.cpp|  2 ++
 .../TargetParser/TargetParserTest.cpp | 36 ++-
 9 files changed, 93 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cf1ba02cbc4b2..148ff05008552 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -903,11 +903,13 @@ Arm and AArch64 Support
   a feature modifier for -march and -mcpu as well as via target attributes
   like ``target_version`` or ``target_clones``.
 - Support has been added for the following processors (-mcpu identifiers in 
parenthesis):
+* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-R82AE (cortex-r82ae).
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
-* Arm Cortex-R82AE (cortex-r82ae).
-* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-A725 (cortex-a725).
+* Arm Cortex-X925 (cortex-x925).
 * Arm Neoverse-N3 (neoverse-n3).
 * Arm Neoverse-V3 (neoverse-v3).
 * Arm Neoverse-V3AE (neoverse-v3ae).
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index ad4a5f9ac6fb8..97303510d6881 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -46,6 +46,8 @@
 // CORTEXX3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x3"
 // RUN: %clang --target=aarch64 -mcpu=cortex-x4 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X4 %s
 // CORTEX-X4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x4"
+// RUN: %clang --target=aarch64 -mcpu=cortex-x925 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X925 %s
+// CORTEX-X925: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-x925"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEXA78 %s
 // CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78c  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A78C %s
@@ -58,6 +60,8 @@
 // CORTEX-A720: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a720ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=CORTEX-A720AE %s
 // CORTEX-A720AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720ae"
+// RUN: %clang --target=aarch64 -mcpu=cortex-a725  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A725 %s
+// CORTEX-A725: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a725"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-e1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-E1 %s
 // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-e1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V1 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 2439025609b9f..790dbd9e07475 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-r82ae, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, 
neoverse-v3, neoverse-v3ae, 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

[clang] [Driver] Add winsysroot alias to the GNU driver (PR #94731)

2024-06-12 Thread via cfe-commits

https://github.com/Andarwinux updated 
https://github.com/llvm/llvm-project/pull/94731

>From 200ed88dcefc5610678765e1cdd235d982d9c407 Mon Sep 17 00:00:00 2001
From: Andarwinux <144242044+andarwi...@users.noreply.github.com>
Date: Fri, 7 Jun 2024 07:07:40 +
Subject: [PATCH] [Driver] Add winsysroot alias to the GNU driver

fixes #91216
---
 clang/include/clang/Driver/Options.td | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 9f7904dd94b94..a512e5385d532 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8575,6 +8575,8 @@ def : Separate<["-"], "Xmicrosoft-windows-sdk-root">,
 Alias<_SLASH_winsdkdir>;
 def : Separate<["-"], "Xmicrosoft-windows-sdk-version">,
 Alias<_SLASH_winsdkversion>;
+def : Separate<["-"], "Xmicrosoft-windows-sys-root">,
+Alias<_SLASH_winsysroot>;
 
 // Ignored:
 

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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-12 Thread Carlos Galvez via cfe-commits
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= 
Message-ID:
In-Reply-To: 


carlosgalvezp wrote:

> Rename the analysis from AvoidBoundsErrorsCheck to 
> PreferAtOverSubscriptOperatorCheck as requested by @PiotrZSL 

I'm strongly opposed to this, because it's conflating "how to solve the 
problem" with "what the problem is".

If we want to focus on the problem, the check could be named 
"AvoidSubscriptOperator". This way, the solution to the problem is open for 
users to decide.

> discussed the possibility of disabling the check when exceptions are 
> disabled, 

I don't think this is a good idea, as it introduces a dependency towards Clang 
compiler. And it's a lot more complicated than what I'm proposing.

I would appreciate more elaboration as to why this check *must* use at() and 
cannot be made optional. 

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


[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-12 Thread via cfe-commits

https://github.com/Lukacma created 
https://github.com/llvm/llvm-project/pull/95224

To enable function multi-versioning (FMV), current checks which rely on cmd 
line options or global macros to see if target feature is present need to be 
removed. This patch removes those for NEON and also implements changes to NEON 
header file as proposed in 
[ACLE](https://github.com/ARM-software/acle/pull/321).

>From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001
From: Marian Lukac 
Date: Wed, 12 Jun 2024 11:13:48 +
Subject: [PATCH] fix for mve

---
 clang/lib/Sema/SemaType.cpp| 18 --
 clang/test/Sema/arm-vector-types-support.c | 11 ++-
 clang/test/SemaCUDA/neon-attrs.cu  | 22 --
 clang/utils/TableGen/NeonEmitter.cpp   |  5 -
 4 files changed, 14 insertions(+), 42 deletions(-)
 delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 441fdcca0758f..9c0d043725dde 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
 
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-S.Context.getTargetInfo().hasFeature("sve") ||
-S.Context.getTargetInfo().hasFeature("sme") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::Neon) {
+  VecKind == VectorKind::Neon && 
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon', 'mve', 'sve' or 'sme'";
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::NeonPoly) {
+  VecKind == VectorKind::NeonPoly &&
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon' or 'mve'";
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
diff --git a/clang/test/Sema/arm-vector-types-support.c 
b/clang/test/Sema/arm-vector-types-support.c
index ed5f5ba175a94..e648d791a2687 100644
--- a/clang/test/Sema/arm-vector-types-support.c
+++ b/clang/test/Sema/arm-vector-types-support.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
-// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify
-// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi 
aapcs-soft -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type
+// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi 
aapcs-soft -fsyntax-only -verify=sve-type
 
-typedef __attribute__((neon_vector_type(2))) int int32x2_t; // 
expected-error{{'neon_vector_type' attribute is not supported on targets 
missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or 
-mcpu=}}
-typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // 
expected-error{{'neon_polyvector_type' attribute is not supported on targets 
missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_vector_type(2))) int int32x2_t; // 
expected-error{{'neon_vector_type' attribute is not supported on targets 
missing 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // 
expected-error{{'neon_polyvector_type' attribute is not supported on targets 
missing 'mve'; specify an appropriate -march= or -mcpu=}}
 typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // 
expected-error{{'arm_sve_vector_bits' attribute is not supported on targets 
missing 'sve'; specify an appropriate -march= or -mcpu=}}
+  // 
sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets 
missing 'sve'; specify an appropriate -march= or -mcpu=}}
diff --git a/clang/test/SemaCUDA/neon-attrs.cu 
b/clang/test/SemaCUDA/neon-attrs.cu
deleted file mode 100644
index 129056741ac9a..0
--- a/clang/test/SemaCUDA/neon-attrs.cu
+++ /dev/null
@@ -1,22 +0,0 @@
-// CPU-side compilation on ARM with neon enabled (no errors expected).
-// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify=quiet %s
-
-// CPU-side compilation on ARM with neon disabled.
-// RUN: %clang_cc1 -tr

[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: None (Lukacma)


Changes

To enable function multi-versioning (FMV), current checks which rely on cmd 
line options or global macros to see if target feature is present need to be 
removed. This patch removes those for NEON and also implements changes to NEON 
header file as proposed in 
[ACLE](https://github.com/ARM-software/acle/pull/321).

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


4 Files Affected:

- (modified) clang/lib/Sema/SemaType.cpp (+8-10) 
- (modified) clang/test/Sema/arm-vector-types-support.c (+6-5) 
- (removed) clang/test/SemaCUDA/neon-attrs.cu (-22) 
- (modified) clang/utils/TableGen/NeonEmitter.cpp (-5) 


``diff
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 441fdcca0758f..9c0d043725dde 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
 
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-S.Context.getTargetInfo().hasFeature("sve") ||
-S.Context.getTargetInfo().hasFeature("sme") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::Neon) {
+  VecKind == VectorKind::Neon && 
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon', 'mve', 'sve' or 'sme'";
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::NeonPoly) {
+  VecKind == VectorKind::NeonPoly &&
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon' or 'mve'";
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
diff --git a/clang/test/Sema/arm-vector-types-support.c 
b/clang/test/Sema/arm-vector-types-support.c
index ed5f5ba175a94..e648d791a2687 100644
--- a/clang/test/Sema/arm-vector-types-support.c
+++ b/clang/test/Sema/arm-vector-types-support.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
-// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify
-// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi 
aapcs-soft -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type
+// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi 
aapcs-soft -fsyntax-only -verify=sve-type
 
-typedef __attribute__((neon_vector_type(2))) int int32x2_t; // 
expected-error{{'neon_vector_type' attribute is not supported on targets 
missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or 
-mcpu=}}
-typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // 
expected-error{{'neon_polyvector_type' attribute is not supported on targets 
missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_vector_type(2))) int int32x2_t; // 
expected-error{{'neon_vector_type' attribute is not supported on targets 
missing 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // 
expected-error{{'neon_polyvector_type' attribute is not supported on targets 
missing 'mve'; specify an appropriate -march= or -mcpu=}}
 typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // 
expected-error{{'arm_sve_vector_bits' attribute is not supported on targets 
missing 'sve'; specify an appropriate -march= or -mcpu=}}
+  // 
sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets 
missing 'sve'; specify an appropriate -march= or -mcpu=}}
diff --git a/clang/test/SemaCUDA/neon-attrs.cu 
b/clang/test/SemaCUDA/neon-attrs.cu
deleted file mode 100644
index 129056741ac9a..0
--- a/clang/test/SemaCUDA/neon-attrs.cu
+++ /dev/null
@@ -1,22 +0,0 @@
-// CPU-side compilation on ARM with neon enabled (no errors expected).
-// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify=quiet %s
-
-// CPU-side compilation on ARM with neon disabled.
-// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify %s
-
-// GPU-side compilation on ARM (no errors expected).
-// RUN: %clang_cc1 -triple nvptx64 -aux-triple a

[clang] [libcxxabi] [llvm] Add support for WASI builds (PR #91051)

2024-06-12 Thread via cfe-commits

whitequark wrote:

FWIW I plan to finish the other one in a week or two; I'm busy with my job this 
week and on vacation the next one.

https://github.com/llvm/llvm-project/pull/91051
___
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 Cortex-A725 and Cortex-X925 (PR #95214)

2024-06-12 Thread Jonathan Thackray via cfe-commits

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

>From f48ed213e7c1c9e8ab32f4916622c2089e67a628 Mon Sep 17 00:00:00 2001
From: Jonathan Thackray 
Date: Wed, 29 May 2024 22:14:28 +0100
Subject: [PATCH] [AArch64] Add support for Cortex-A725 and Cortex-X925

Cortex-A725 and Cortex-X925 are Armv9.2 AArch64 CPUs.

Technical Reference Manual for Cortex-A725:
   https://developer.arm.com/documentation/107652/latest

Technical Reference Manual for Cortex-X925:
   https://developer.arm.com/documentation/102807/latest
---
 clang/docs/ReleaseNotes.rst   |  6 ++--
 clang/test/Driver/aarch64-mcpu.c  |  4 +++
 clang/test/Misc/target-invalid-cpu-note.c |  4 +--
 llvm/docs/ReleaseNotes.rst|  4 +--
 .../llvm/TargetParser/AArch64TargetParser.h   | 12 +++
 llvm/lib/Target/AArch64/AArch64Processors.td  | 30 
 llvm/lib/Target/AArch64/AArch64Subtarget.cpp  |  2 ++
 llvm/lib/TargetParser/Host.cpp|  2 ++
 .../TargetParser/TargetParserTest.cpp | 36 ++-
 9 files changed, 93 insertions(+), 7 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index cf1ba02cbc4b2..148ff05008552 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -903,11 +903,13 @@ Arm and AArch64 Support
   a feature modifier for -march and -mcpu as well as via target attributes
   like ``target_version`` or ``target_clones``.
 - Support has been added for the following processors (-mcpu identifiers in 
parenthesis):
+* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-R82AE (cortex-r82ae).
 * Arm Cortex-A78AE (cortex-a78ae).
 * Arm Cortex-A520AE (cortex-a520ae).
 * Arm Cortex-A720AE (cortex-a720ae).
-* Arm Cortex-R82AE (cortex-r82ae).
-* Arm Cortex-R52+ (cortex-r52plus).
+* Arm Cortex-A725 (cortex-a725).
+* Arm Cortex-X925 (cortex-x925).
 * Arm Neoverse-N3 (neoverse-n3).
 * Arm Neoverse-V3 (neoverse-v3).
 * Arm Neoverse-V3AE (neoverse-v3ae).
diff --git a/clang/test/Driver/aarch64-mcpu.c b/clang/test/Driver/aarch64-mcpu.c
index ad4a5f9ac6fb8..97303510d6881 100644
--- a/clang/test/Driver/aarch64-mcpu.c
+++ b/clang/test/Driver/aarch64-mcpu.c
@@ -46,6 +46,8 @@
 // CORTEXX3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x3"
 // RUN: %clang --target=aarch64 -mcpu=cortex-x4 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X4 %s
 // CORTEX-X4: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-x4"
+// RUN: %clang --target=aarch64 -mcpu=cortex-x925 -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-X925 %s
+// CORTEX-X925: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-x925"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEXA78 %s
 // CORTEXA78: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "cortex-a78"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a78c  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A78C %s
@@ -58,6 +60,8 @@
 // CORTEX-A720: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720"
 // RUN: %clang --target=aarch64 -mcpu=cortex-a720ae  -### -c %s 2>&1 | 
FileCheck -check-prefix=CORTEX-A720AE %s
 // CORTEX-A720AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a720ae"
+// RUN: %clang --target=aarch64 -mcpu=cortex-a725  -### -c %s 2>&1 | FileCheck 
-check-prefix=CORTEX-A725 %s
+// CORTEX-A725: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"cortex-a725"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-e1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-E1 %s
 // NEOVERSE-E1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" 
"neoverse-e1"
 // RUN: %clang --target=aarch64 -mcpu=neoverse-v1  -### -c %s 2>&1 | FileCheck 
-check-prefix=NEOVERSE-V1 %s
diff --git a/clang/test/Misc/target-invalid-cpu-note.c 
b/clang/test/Misc/target-invalid-cpu-note.c
index 2439025609b9f..5362c6f882c25 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-r82ae, cortex-x1, 
cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, 
neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, 
neoverse-v3, neoverse-v3ae, 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

[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-12 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 a45080f09181517c9c5eb5099a6b6ac67a48424a 
d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 -- clang/lib/Sema/SemaType.cpp 
clang/test/Sema/arm-vector-types-support.c clang/utils/TableGen/NeonEmitter.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 9c0d043725..c49c59f2b7 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8088,10 +8088,9 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
   // not to need a separate attribute)
   if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::Neon && 
+  VecKind == VectorKind::Neon &&
   S.Context.getTargetInfo().getTriple().isArmMClass()) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'mve'";
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
@@ -8099,8 +8098,7 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
 IsTargetCUDAAndHostARM) &&
   VecKind == VectorKind::NeonPoly &&
   S.Context.getTargetInfo().getTriple().isArmMClass()) {
-S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'mve'";
+S.Diag(Attr.getLoc(), diag::err_attribute_unsupported) << Attr << "'mve'";
 Attr.setInvalid();
 return;
   }

``




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


[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-12 Thread via cfe-commits

https://github.com/Lukacma updated 
https://github.com/llvm/llvm-project/pull/95224

>From d5caa1a22c90c7d3b1fd995c3ae980f02e4c14c9 Mon Sep 17 00:00:00 2001
From: Marian Lukac 
Date: Wed, 12 Jun 2024 11:13:48 +
Subject: [PATCH 1/2] fix for mve

---
 clang/lib/Sema/SemaType.cpp| 18 --
 clang/test/Sema/arm-vector-types-support.c | 11 ++-
 clang/test/SemaCUDA/neon-attrs.cu  | 22 --
 clang/utils/TableGen/NeonEmitter.cpp   |  5 -
 4 files changed, 14 insertions(+), 42 deletions(-)
 delete mode 100644 clang/test/SemaCUDA/neon-attrs.cu

diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index 441fdcca0758f..9c0d043725dde 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -8086,23 +8086,21 @@ static void HandleNeonVectorTypeAttr(QualType &CurType, 
const ParsedAttr &Attr,
 
   // Target must have NEON (or MVE, whose vectors are similar enough
   // not to need a separate attribute)
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
-S.Context.getTargetInfo().hasFeature("sve") ||
-S.Context.getTargetInfo().hasFeature("sme") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::Neon) {
+  VecKind == VectorKind::Neon && 
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon', 'mve', 'sve' or 'sme'";
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
-  if (!(S.Context.getTargetInfo().hasFeature("neon") ||
-S.Context.getTargetInfo().hasFeature("mve") ||
+  if (!(S.Context.getTargetInfo().hasFeature("mve") ||
 IsTargetCUDAAndHostARM) &&
-  VecKind == VectorKind::NeonPoly) {
+  VecKind == VectorKind::NeonPoly &&
+  S.Context.getTargetInfo().getTriple().isArmMClass()) {
 S.Diag(Attr.getLoc(), diag::err_attribute_unsupported)
-<< Attr << "'neon' or 'mve'";
+<< Attr << "'mve'";
 Attr.setInvalid();
 return;
   }
diff --git a/clang/test/Sema/arm-vector-types-support.c 
b/clang/test/Sema/arm-vector-types-support.c
index ed5f5ba175a94..e648d791a2687 100644
--- a/clang/test/Sema/arm-vector-types-support.c
+++ b/clang/test/Sema/arm-vector-types-support.c
@@ -1,7 +1,8 @@
-// RUN: %clang_cc1 %s -triple armv7 -fsyntax-only -verify
-// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify
-// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi 
aapcs-soft -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple armv8.1m.main -fsyntax-only -verify
+// RUN: %clang_cc1 %s -triple aarch64 -fsyntax-only -verify=sve-type
+// RUN: %clang_cc1 %s -triple aarch64 -target-feature -fp-armv8 -target-abi 
aapcs-soft -fsyntax-only -verify=sve-type
 
-typedef __attribute__((neon_vector_type(2))) int int32x2_t; // 
expected-error{{'neon_vector_type' attribute is not supported on targets 
missing 'neon', 'mve', 'sve' or 'sme'; specify an appropriate -march= or 
-mcpu=}}
-typedef __attribute__((neon_polyvector_type(16))) short poly8x16_t; // 
expected-error{{'neon_polyvector_type' attribute is not supported on targets 
missing 'neon' or 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_vector_type(2))) int int32x2_t; // 
expected-error{{'neon_vector_type' attribute is not supported on targets 
missing 'mve'; specify an appropriate -march= or -mcpu=}}
+typedef __attribute__((neon_polyvector_type(16))) unsigned char poly8x16_t; // 
expected-error{{'neon_polyvector_type' attribute is not supported on targets 
missing 'mve'; specify an appropriate -march= or -mcpu=}}
 typedef __attribute__((arm_sve_vector_bits(256))) void nosveflag; // 
expected-error{{'arm_sve_vector_bits' attribute is not supported on targets 
missing 'sve'; specify an appropriate -march= or -mcpu=}}
+  // 
sve-type-error@-1{{'arm_sve_vector_bits' attribute is not supported on targets 
missing 'sve'; specify an appropriate -march= or -mcpu=}}
diff --git a/clang/test/SemaCUDA/neon-attrs.cu 
b/clang/test/SemaCUDA/neon-attrs.cu
deleted file mode 100644
index 129056741ac9a..0
--- a/clang/test/SemaCUDA/neon-attrs.cu
+++ /dev/null
@@ -1,22 +0,0 @@
-// CPU-side compilation on ARM with neon enabled (no errors expected).
-// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature +neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify=quiet %s
-
-// CPU-side compilation on ARM with neon disabled.
-// RUN: %clang_cc1 -triple arm64-linux-gnu -target-feature -neon -aux-triple 
nvptx64 -x cuda -fsyntax-only -verify %s
-
-// GPU-side compilation on ARM (no errors expected).
-// RUN: %clang_cc1 -triple nvptx64 -aux-triple arm64-linux-gnu 
-fcuda-is-device -x cuda -fsyntax-only -verify=quiet %s
-
-// Regular C++ compilation on ARM with

[clang] [Clang] Remove preprocessor guards and global feature checks for NEON (PR #95224)

2024-06-12 Thread via cfe-commits

Lukacma wrote:

Due to me screwing up on git rebase I recreated the PR. This PR has fix for MVE

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-06-12 Thread Vikram Hegde via cfe-commits

vikramRH wrote:

> @jayfoad's testcase fails and the same test should be repeated for all 3 
> intrinsics

added MIR tests for 3 intrinsics. The issue is that Im not able to attach the 
glue nodes to newly created laneop pieces since they fail at selection. 
https://github.com/llvm/llvm-project/pull/87509 should enable this,

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


[clang-tools-extra] Enforce SL.con.3: Add check to replace operator[] with at() [Cont.] (PR #95220)

2024-06-12 Thread Manuel Pietsch via cfe-commits
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= ,
Paul =?utf-8?q?Heidekrüger?= 
Message-ID:
In-Reply-To: 


leunam99 wrote:

> I still think "AvoidBoundErrors" is the best name since it maps exactly to 
> what the guidelines call it.

For me, this sounds to general for what the check currently does. The 
Enforcement section at the end of the rule SL.con.3 states:
> Issue a diagnostic for any call to a standard-library function that is not 
> bounds-checked.

The guidelines do not provide a list of such functions and we are not familliar 
enough with the standard library to create a comprehensive list ourself, so at 
this time, we are unable to implement the full rule.


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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-06-12 Thread Matt Arsenault via cfe-commits


@@ -0,0 +1,46 @@
+# RUN: not --crash llc -mtriple=amdgcn -run-pass=none -verify-machineinstrs -o 
/dev/null %s 2>&1 | FileCheck %s

arsenm wrote:

You should not need to introduce any new machine verifier tests, they are not 
useful. The useful test would be the IR that produces the verifier error, which 
ideally would be fixed 

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-06-12 Thread Vikram Hegde via cfe-commits


@@ -0,0 +1,46 @@
+# RUN: not --crash llc -mtriple=amdgcn -run-pass=none -verify-machineinstrs -o 
/dev/null %s 2>&1 | FileCheck %s

vikramRH wrote:

Okay, I'll update with IR's

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-06-12 Thread Sameer Sahasrabuddhe via cfe-commits

ssahasra wrote:

> > @jayfoad's testcase fails and the same test should be repeated for all 3 
> > intrinsics
> 
> added MIR tests for 3 intrinsics. The issue is that Im not able to attach the 
> glue nodes to newly created laneop pieces since they fail at selection. 
> #87509 should enable this,

I am not really comfortable waiting for #87509 to fix convergence tokens in 
this expansion. Is it really true that this expansion cannot be fixed 
independent of future work on `CONVERGENCE_GLUE`? There is no way to manually 
handle the same glue operands??

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


[clang] 66a9e26 - [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr comparison (#95190)

2024-06-12 Thread via cfe-commits

Author: Qizhi Hu
Date: 2024-06-12T20:04:41+08:00
New Revision: 66a9e26438cbb5c547fd348a428ef3d1e775360c

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

LOG: [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr 
comparison (#95190)

improve `ASTStructuralEquivalenceTest`:

1. compare the depth and index of NTTP
2. provide comparison of `CXXDependentScopeMemberExpr` to `StmtCompare`.

Co-authored-by: huqizhi <836744...@qq.com>

Added: 


Modified: 
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/unittests/AST/StructuralEquivalenceTest.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTStructuralEquivalence.cpp 
b/clang/lib/AST/ASTStructuralEquivalence.cpp
index d56bf21b459e0..37555c324282f 100644
--- a/clang/lib/AST/ASTStructuralEquivalence.cpp
+++ b/clang/lib/AST/ASTStructuralEquivalence.cpp
@@ -348,6 +348,15 @@ class StmtComparer {
 return true;
   }
 
+  bool IsStmtEquivalent(const CXXDependentScopeMemberExpr *E1,
+const CXXDependentScopeMemberExpr *E2) {
+if (!IsStructurallyEquivalent(Context, E1->getMember(), E2->getMember())) {
+  return false;
+}
+return IsStructurallyEquivalent(Context, E1->getBaseType(),
+E2->getBaseType());
+  }
+
   bool IsStmtEquivalent(const UnaryExprOrTypeTraitExpr *E1,
 const UnaryExprOrTypeTraitExpr *E2) {
 if (E1->getKind() != E2->getKind())
@@ -1997,7 +2006,10 @@ static bool 
IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
 }
 return false;
   }
-
+  if (!Context.IgnoreTemplateParmDepth && D1->getDepth() != D2->getDepth())
+return false;
+  if (D1->getIndex() != D2->getIndex())
+return false;
   // Check types.
   if (!IsStructurallyEquivalent(Context, D1->getType(), D2->getType())) {
 if (Context.Complain) {

diff  --git a/clang/unittests/AST/StructuralEquivalenceTest.cpp 
b/clang/unittests/AST/StructuralEquivalenceTest.cpp
index 91dd717d7b25e..952c83be0cb64 100644
--- a/clang/unittests/AST/StructuralEquivalenceTest.cpp
+++ b/clang/unittests/AST/StructuralEquivalenceTest.cpp
@@ -1877,6 +1877,34 @@ TEST_F(StructuralEquivalenceCacheTest, 
VarDeclWithDifferentStorageClassNoEq) {
   EXPECT_FALSE(Ctx.IsEquivalent(Var.first, Var.second));
 }
 
+TEST_F(StructuralEquivalenceCacheTest,
+   NonTypeTemplateParmWithDifferentPositionNoEq) {
+  auto TU = makeTuDecls(
+  R"(
+  template
+  struct A {
+template
+void foo() {}
+  };
+  )",
+  R"(
+  template
+  struct A {
+template
+void foo() {}
+  };
+  )",
+  Lang_CXX03);
+
+  StructuralEquivalenceContext Ctx(
+  get<0>(TU)->getASTContext(), get<1>(TU)->getASTContext(),
+  NonEquivalentDecls, StructuralEquivalenceKind::Default, false, false);
+
+  auto NTTP = findDeclPair(
+  TU, nonTypeTemplateParmDecl(hasName("T")));
+  EXPECT_FALSE(Ctx.IsEquivalent(NTTP.first, NTTP.second));
+}
+
 TEST_F(StructuralEquivalenceCacheTest, VarDeclWithInitNoEq) {
   auto TU = makeTuDecls(
   R"(
@@ -2441,8 +2469,7 @@ TEST_F(StructuralEquivalenceStmtTest, 
NonTypeTemplateParm) {
   void foo(A);
   )",
   Lang_CXX11);
-  // FIXME: These should not match,
-  EXPECT_TRUE(testStructuralMatch(t));
+  EXPECT_FALSE(testStructuralMatch(t));
 }
 
 TEST_F(StructuralEquivalenceStmtTest, UnresolvedLookupDifferentName) {
@@ -2595,5 +2622,31 @@ TEST_F(StructuralEquivalenceStmtTest, DeclRefExpr) {
   EXPECT_FALSE(testStructuralMatch(t));
 }
 
+TEST_F(StructuralEquivalenceCacheTest, CXXDependentScopeMemberExprNoEq) {
+  auto S = makeStmts(
+  R"(
+  template 
+  void foo() {
+(void)T().x;
+  }
+  struct A { int x; };
+  void bar() {
+foo();
+  }
+  )",
+  R"(
+  template 
+  void foo() {
+(void)T().y;
+  }
+  struct A { int y; };
+  void bar() {
+foo();
+  }
+  )",
+  Lang_CXX11, cxxDependentScopeMemberExpr());
+  EXPECT_FALSE(testStructuralMatch(S));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang



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


[clang] [StructuralEquivalence] improve NTTP and CXXDependentScopeMemberExpr comparison (PR #95190)

2024-06-12 Thread Qizhi Hu via cfe-commits

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


[clang] [llvm] [AMDGPU] Extend readlane, writelane and readfirstlane intrinsic lowering for generic types (PR #89217)

2024-06-12 Thread Sameer Sahasrabuddhe via cfe-commits


@@ -0,0 +1,46 @@
+# RUN: not --crash llc -mtriple=amdgcn -run-pass=none -verify-machineinstrs -o 
/dev/null %s 2>&1 | FileCheck %s

ssahasra wrote:

All it needs is one new file in `test/CodeGen/AMDGPU` where 64-bit lane ops are 
used with a convergence tokens. Mark that as XFAIL. When the issue is fixed, 
that file can be merged into the existing tests. We don't need to test each of 
the convergence control intrinsics. It's enough to just have a token on a 
readlane.

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


[clang] [llvm] Reland "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95231)

2024-06-12 Thread Alexandros Lamprineas via cfe-commits

https://github.com/labrinea created 
https://github.com/llvm/llvm-project/pull/95231

My reverted attempt to decouple feature dependency expansion (see #95056) made 
it evident that some features are still using the FMV dependencies in the 
target attribute.

The original commit broke the llvm test suite. This was addressed here: 
https://github.com/llvm/llvm-test-suite/pull/133. I am now relanding it.

>From 8edd8aa244303f9d5ef79d3f33c9b4e05393fc33 Mon Sep 17 00:00:00 2001
From: Alexandros Lamprineas 
Date: Wed, 12 Jun 2024 12:33:23 +0100
Subject: [PATCH] Reland "[AArch64] Decouple feature dependency expansion.
 (#94279)"

My reverted attempt to decouple feature dependency expansion (see #95056)
made it evident that some features are still using the FMV dependencies
in the target attribute.

The original commit broke the llvm test suite. This was addressed here:
https://github.com/llvm/llvm-test-suite/pull/133. I am now relanding it.
---
 clang/include/clang/AST/ASTContext.h  |   3 -
 clang/lib/AST/ASTContext.cpp  |  59 +-
 clang/lib/AST/CMakeLists.txt  |   2 +
 clang/lib/Basic/Targets/AArch64.cpp   | 105 ++---
 clang/lib/Basic/Targets/AArch64.h |   4 -
 .../CodeGen/aarch64-cpu-supports-target.c |   4 +-
 .../aarch64-sme-attrs.cpp |   2 +-
 clang/test/CodeGen/aarch64-targetattr.c   |  48 
 clang/test/CodeGen/attr-target-version.c  |  46 
 clang/test/Sema/aarch64-neon-target.c |   4 +-
 .../llvm/TargetParser/AArch64TargetParser.h   | 107 +++---
 llvm/lib/TargetParser/AArch64TargetParser.cpp |  51 ++---
 12 files changed, 213 insertions(+), 222 deletions(-)

diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index a1d1d1c51cd41..8bce4812f0d48 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3203,9 +3203,6 @@ class ASTContext : public RefCountedBase {
   /// valid feature names.
   ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
 
-  std::vector
-  filterFunctionTargetVersionAttrs(const TargetVersionAttr *TV) const;
-
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
  const FunctionDecl *) const;
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index bf74e56a14799..cd76b8aa271da 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -87,6 +87,7 @@
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/AArch64TargetParser.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
 #include 
@@ -13663,17 +13664,20 @@ QualType 
ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const {
   }
 }
 
-std::vector ASTContext::filterFunctionTargetVersionAttrs(
-const TargetVersionAttr *TV) const {
-  assert(TV != nullptr);
-  llvm::SmallVector Feats;
-  std::vector ResFeats;
-  TV->getFeatures(Feats);
-  for (auto &Feature : Feats)
-if (Target->validateCpuSupports(Feature.str()))
-  // Use '?' to mark features that came from TargetVersion.
-  ResFeats.push_back("?" + Feature.str());
-  return ResFeats;
+// Given a list of FMV features, return a concatenated list of the
+// corresponding backend features (which may contain duplicates).
+static std::vector getFMVBackendFeaturesFor(
+const llvm::SmallVectorImpl &FMVFeatStrings) {
+  std::vector BackendFeats;
+  for (StringRef F : FMVFeatStrings) {
+if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) {
+  SmallVector Feats;
+  FMVExt->DependentFeatures.split(Feats, ',', -1, false);
+  for (StringRef F : Feats)
+BackendFeats.push_back(F.str());
+}
+  }
+  return BackendFeats;
 }
 
 ParsedTargetAttr
@@ -13708,10 +13712,12 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-ParsedAttr.Features.insert(
-ParsedAttr.Features.begin(),
-Target->getTargetOpts().FeaturesAsWritten.begin(),
-Target->getTargetOpts().FeaturesAsWritten.end());
+// AArch64 handles command line option features in parseTargetAttr().
+if (!Target->getTriple().isAArch64())
+  ParsedAttr.Features.insert(
+  ParsedAttr.Features.begin(),
+  Target->getTargetOpts().FeaturesAsWritten.begin(),
+  Target->getTargetOpts().FeaturesAsWritten.end());
 
 if (ParsedAttr.CPU != "" && Target->isValidCPUName(ParsedAttr.CPU))
   TargetCPU = ParsedAttr.CPU;
@@ -13732,32 +13738,31 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 Target->getTargetOpts().FeaturesAsWritten.end());
 Target->initFeatureMa

[clang] [llvm] Reland "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95231)

2024-06-12 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Alexandros Lamprineas (labrinea)


Changes

My reverted attempt to decouple feature dependency expansion (see #95056) made it evident that some features are still using the FMV 
dependencies in the target attribute.

The original commit broke the llvm test suite. This was addressed here: 
https://github.com/llvm/llvm-test-suite/pull/133. I am now relanding it.

---

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


12 Files Affected:

- (modified) clang/include/clang/AST/ASTContext.h (-3) 
- (modified) clang/lib/AST/ASTContext.cpp (+32-27) 
- (modified) clang/lib/AST/CMakeLists.txt (+2) 
- (modified) clang/lib/Basic/Targets/AArch64.cpp (+33-72) 
- (modified) clang/lib/Basic/Targets/AArch64.h (-4) 
- (modified) clang/test/CodeGen/aarch64-cpu-supports-target.c (+2-2) 
- (modified) clang/test/CodeGen/aarch64-sme-intrinsics/aarch64-sme-attrs.cpp 
(+1-1) 
- (modified) clang/test/CodeGen/aarch64-targetattr.c (+20-28) 
- (modified) clang/test/CodeGen/attr-target-version.c (+23-23) 
- (modified) clang/test/Sema/aarch64-neon-target.c (+2-2) 
- (modified) llvm/include/llvm/TargetParser/AArch64TargetParser.h (+65-42) 
- (modified) llvm/lib/TargetParser/AArch64TargetParser.cpp (+33-18) 


``diff
diff --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index a1d1d1c51cd41..8bce4812f0d48 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -3203,9 +3203,6 @@ class ASTContext : public RefCountedBase {
   /// valid feature names.
   ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const;
 
-  std::vector
-  filterFunctionTargetVersionAttrs(const TargetVersionAttr *TV) const;
-
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
  const FunctionDecl *) const;
   void getFunctionFeatureMap(llvm::StringMap &FeatureMap,
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index bf74e56a14799..cd76b8aa271da 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -87,6 +87,7 @@
 #include "llvm/Support/MD5.h"
 #include "llvm/Support/MathExtras.h"
 #include "llvm/Support/raw_ostream.h"
+#include "llvm/TargetParser/AArch64TargetParser.h"
 #include "llvm/TargetParser/Triple.h"
 #include 
 #include 
@@ -13663,17 +13664,20 @@ QualType 
ASTContext::getCorrespondingSignedFixedPointType(QualType Ty) const {
   }
 }
 
-std::vector ASTContext::filterFunctionTargetVersionAttrs(
-const TargetVersionAttr *TV) const {
-  assert(TV != nullptr);
-  llvm::SmallVector Feats;
-  std::vector ResFeats;
-  TV->getFeatures(Feats);
-  for (auto &Feature : Feats)
-if (Target->validateCpuSupports(Feature.str()))
-  // Use '?' to mark features that came from TargetVersion.
-  ResFeats.push_back("?" + Feature.str());
-  return ResFeats;
+// Given a list of FMV features, return a concatenated list of the
+// corresponding backend features (which may contain duplicates).
+static std::vector getFMVBackendFeaturesFor(
+const llvm::SmallVectorImpl &FMVFeatStrings) {
+  std::vector BackendFeats;
+  for (StringRef F : FMVFeatStrings) {
+if (auto FMVExt = llvm::AArch64::parseArchExtension(F)) {
+  SmallVector Feats;
+  FMVExt->DependentFeatures.split(Feats, ',', -1, false);
+  for (StringRef F : Feats)
+BackendFeats.push_back(F.str());
+}
+  }
+  return BackendFeats;
 }
 
 ParsedTargetAttr
@@ -13708,10 +13712,12 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 
 // Make a copy of the features as passed on the command line into the
 // beginning of the additional features from the function to override.
-ParsedAttr.Features.insert(
-ParsedAttr.Features.begin(),
-Target->getTargetOpts().FeaturesAsWritten.begin(),
-Target->getTargetOpts().FeaturesAsWritten.end());
+// AArch64 handles command line option features in parseTargetAttr().
+if (!Target->getTriple().isAArch64())
+  ParsedAttr.Features.insert(
+  ParsedAttr.Features.begin(),
+  Target->getTargetOpts().FeaturesAsWritten.begin(),
+  Target->getTargetOpts().FeaturesAsWritten.end());
 
 if (ParsedAttr.CPU != "" && Target->isValidCPUName(ParsedAttr.CPU))
   TargetCPU = ParsedAttr.CPU;
@@ -13732,32 +13738,31 @@ void 
ASTContext::getFunctionFeatureMap(llvm::StringMap &FeatureMap,
 Target->getTargetOpts().FeaturesAsWritten.end());
 Target->initFeatureMap(FeatureMap, getDiagnostics(), TargetCPU, Features);
   } else if (const auto *TC = FD->getAttr()) {
-std::vector Features;
 if (Target->getTriple().isAArch64()) {
-  // TargetClones for AArch64
   llvm::SmallVector Feats;
   TC->getFeatures(Feats, GD.getMultiVersionIndex());
-  for (StringRef Feat : Feats)
-if (Target->validateCpuSupports(Feat.str()))
-  /

[clang] [APINotes] Update the documentation with new features (PR #95162)

2024-06-12 Thread Egor Zhdan via cfe-commits

egorzhdan wrote:

The test failures are unrelated to this change.

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


[clang] 058486c - [APINotes] Update the documentation with new features

2024-06-12 Thread via cfe-commits

Author: Egor Zhdan
Date: 2024-06-12T13:12:57+01:00
New Revision: 058486c9e8820efee748f946fa773b56c4654feb

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

LOG: [APINotes] Update the documentation with new features

This adds the documentation for a few recently added Clang API Notes
features: C++ namespaces, `SwiftImportAs` and `SwiftCopyable`.

-

Co-authored-by: Saleem Abdulrasool 

Added: 


Modified: 
clang/docs/APINotes.rst

Removed: 




diff  --git a/clang/docs/APINotes.rst b/clang/docs/APINotes.rst
index a6e200e8bffde..bc09b16bab5d2 100644
--- a/clang/docs/APINotes.rst
+++ b/clang/docs/APINotes.rst
@@ -80,11 +80,12 @@ entries:
 
 Name: MyFramework
 
-:Classes, Protocols, Tags, Typedefs, Globals, Enumerators, Functions:
+:Classes, Protocols, Tags, Typedefs, Globals, Enumerators, Functions, 
Namespaces:
 
   Arrays of top-level declarations. Each entry in the array must have a
-  'Name' key with its Objective-C name. "Tags" refers to structs, enums, and
-  unions; "Enumerators" refers to enum cases.
+  'Name' key with its Objective-C or C++ name. "Tags" refers to structs,
+  C++ classes, enums, and unions; "Classes" refers to Objective-C classes;
+  "Enumerators" refers to enum cases.
 
   ::
 
@@ -157,6 +158,36 @@ declaration kind), all of which are optional:
 - Class: NSBundle
   SwiftName: Bundle
 
+:SwiftImportAs:
+
+  For a class, possible values are ``owned`` (equivalent to
+  ``SWIFT_SELF_CONTAINED``) or ``reference`` (equivalent to
+  ``SWIFT_SHARED_REFERENCE``, also requires specifying ``SwiftReleaseOp`` and
+  ``SwiftRetainOp``).
+
+  For a method, possible values are ``unsafe`` (equivalent
+  to ``SWIFT_RETURNS_INDEPENDENT_VALUE``) or ``computed_property`` (equivalent 
to
+  ``SWIFT_COMPUTED_PROPERTY``).
+
+  ::
+
+Tags:
+- Name: RefCountedStorage
+  SwiftImportAs: reference
+  SwiftReleaseOp: RCRelease
+  SwiftRetainOp: RCRetain
+
+:SwiftCopyable:
+
+  Allows annotating a C++ class as non-copyable in Swift. Equivalent to
+  ``SWIFT_NONCOPYABLE``, or to an explicit conformance ``: ~Copyable``.
+
+  ::
+
+Tags:
+- Name: tzdb
+  SwiftCopyable: false
+
 :Availability, AvailabilityMsg:
 
   A value of "nonswift" is equivalent to ``NS_SWIFT_UNAVAILABLE``. A value of



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


[clang] [APINotes] Update the documentation with new features (PR #95162)

2024-06-12 Thread Egor Zhdan via cfe-commits

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


[clang] [llvm] Reland "[AArch64] Decouple feature dependency expansion. (#94279)" (PR #95231)

2024-06-12 Thread Tomas Matheson via cfe-commits

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


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


[clang] [clang] [test] Skip a test that sets PATH= on Windows (PR #95096)

2024-06-12 Thread Martin Storsjö via cfe-commits

https://github.com/mstorsjo updated 
https://github.com/llvm/llvm-project/pull/95096

From 11b577825a15bcd6139863adb047ef5f7b161a36 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Martin=20Storsj=C3=B6?= 
Date: Tue, 11 Jun 2024 13:14:47 +0300
Subject: [PATCH] [clang] [test] Skip a test that sets PATH= on Windows

The same has been done in a couple other existing tests, that also
are skipped on Windows (e.g. ld-path.c). Some tests that really
do want to test setting the path on Windows does it differently,
see e.g. ps4-ps5-linker-win.c.

Since a65771fce4a2f25f16d4b3918ad6a11370637f7b, the spirv-toolchain.cl
test does one test where PATH is set. Setting PATH does work in
some build configurations - however, if built with e.g. llvm-mingw,
the built Clang executable depends on libc++.dll (and libunwind.dll)
which are found in PATH. If the PATH is overridden, the newly built
Clang executable no longer can run.

Split the test that requires setting PATH to a separate file,
and mark it as unsupported on Windows.
---
 clang/test/Driver/spirv-toolchain.cl | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/clang/test/Driver/spirv-toolchain.cl 
b/clang/test/Driver/spirv-toolchain.cl
index de818177cb19f..eff02f809ce83 100644
--- a/clang/test/Driver/spirv-toolchain.cl
+++ b/clang/test/Driver/spirv-toolchain.cl
@@ -80,10 +80,15 @@
 
 //-
 // Check llvm-spirv- is used if it is found in PATH.
+//
+// This test uses the PATH environment variable; on Windows, we may need to 
retain
+// the original path for the built Clang binary to be able to execute (as it is
+// used for locating dependent DLLs). Therefore, skip this test on 
system-windows.
+//
 // RUN: mkdir -p %t/versioned
 // RUN: touch %t/versioned/llvm-spirv-%llvm-version-major \
 // RUN:   && chmod +x %t/versioned/llvm-spirv-%llvm-version-major
-// RUN: env "PATH=%t/versioned" %clang -### --target=spirv64 -x cl -c %s 2>&1 \
-// RUN:   | FileCheck -DVERSION=%llvm-version-major --check-prefix=VERSIONED %s
+// RUN: %if !system-windows %{ env "PATH=%t/versioned" %clang -### 
--target=spirv64 -x cl -c %s 2>&1 \
+// RUN:   | FileCheck -DVERSION=%llvm-version-major --check-prefix=VERSIONED 
%s %}
 
 // VERSIONED: {{.*}}llvm-spirv-[[VERSION]]

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


  1   2   3   4   5   >