[clang] [clang-tools-extra] [clangd] Update clangDaemonTweaks to set symbol visibility macros (PR #112304)

2024-11-17 Thread Thomas Fransham via cfe-commits


@@ -47,7 +47,7 @@ endmacro()
 
 macro(add_clang_library name)
   cmake_parse_arguments(ARG
-"SHARED;STATIC;INSTALL_WITH_TOOLCHAIN"
+"SHARED;STATIC;INSTALL_WITH_TOOLCHAIN;CLANG_IMPORT"

fsfod wrote:

Its not possible to infer if a OBJECT target should be importing or exporting 
clang symbols, this option allows OBJECT target to specify it should be 
importing Clang symbols.

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


[clang] [llvm] [Driver][SYCL] Add initial SYCL offload compilation support (PR #107493)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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

```
Step 2 (annotate) failure: 'python 
../sanitizer_buildbot/sanitizers/zorg/buildbot/builders/sanitizers/buildbot_selector.py'
 (failure)
...
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24:
 note: (llvm-libc++-shared.cfg.in) Using %{flags} substitution: '-pthread 
--target=aarch64-unknown-linux-gnu -g -fno-omit-frame-pointer 
-fsanitize=address'
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24:
 note: (llvm-libc++-shared.cfg.in) Using %{compile_flags} substitution: 
'-nostdinc++ -I %{target-include-dir} -I %{include-dir} -I 
%{libcxx-dir}/test/support -std=c++26 -Werror -Wall -Wctad-maybe-unsupported 
-Wextra -Wshadow -Wundef -Wunused-template -Wno-unused-command-line-argument 
-Wno-attributes -Wno-pessimizing-move -Wno-noexcept-type -Wno-atomic-alignment 
-Wno-reserved-module-identifier -Wdeprecated-copy -Wdeprecated-copy-dtor 
-Wno-user-defined-literals -Wno-tautological-compare -Wsign-compare 
-Wunused-variable -Wunused-parameter -Wunreachable-code 
-Wno-unused-local-typedef -Wno-local-type-template-args -Wno-c++11-extensions 
-Wno-unknown-pragmas -Wno-pass-failed -Wno-mismatched-new-delete 
-Wno-redundant-move -Wno-self-move -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER 
-D_LIBCPP_ENABLE_EXPERIMENTAL 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_NONE -Werror=thread-safety 
-Wuser-defined-warnings'
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24:
 note: (llvm-libc++-shared.cfg.in) Using %{link_flags} substitution: 
'-lc++experimental -nostdlib++ -L %{lib-dir} -Wl,-rpath,%{lib-dir} -lc++ 
-latomic'
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24:
 note: (llvm-libc++-shared.cfg.in) Using %{benchmark_flags} substitution: '-I 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/libcxx/test/benchmarks/google-benchmark/include
 -L 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/libcxx/test/benchmarks/google-benchmark/lib
 -l benchmark'
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24:
 note: (llvm-libc++-shared.cfg.in) Using %{exec} substitution: '%{executor} 
--execdir %T -- '
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/libcxx/utils/libcxx/test/config.py:24:
 note: (llvm-libc++-shared.cfg.in) All available features: 
-faligned-allocation, -fsized-deallocation, add-latomic-workaround, asan, 
buildhost=linux, c++26, c++experimental, can-create-symlinks, clang, clang-20, 
clang-20.0, clang-20.0.0, diagnose-if-support, enable-benchmarks=dry-run, 
gcc-style-warnings, glibc-old-ru_RU-decimal-point, has-1024-bit-atomics, 
has-64-bit-atomics, has-fblocks, has-fconstexpr-steps, has-unix-headers, 
large_tests, libcpp-abi-version=1, libcpp-hardening-mode=none, 
libcpp-has-no-availability-markup, libcpp-has-thread-api-pthread, linux, lsan, 
objective-c++, optimization=none, sanitizer-new-delete, stdlib=libc++, 
stdlib=llvm-libc++, target=aarch64-unknown-linux-gnu, thread-safety, 
verify-support
llvm-lit: 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/llvm/utils/lit/lit/main.py:72:
 note: The test suite configuration requested an individual test timeout of 0 
seconds but a timeout of 1500 seconds was requested on the command line. 
Forcing timeout to be 1500 seconds.
-- Testing: 9909 of 9929 tests, 48 workers --
Testing:  0.. 10.. 20.. 30.. 40.. 50.. 60.. 70
TIMEOUT: llvm-libc++-shared.cfg.in :: benchmarks/variant_visit_3.bench.cpp 
(7276 of 9909)
 TEST 'llvm-libc++-shared.cfg.in :: 
benchmarks/variant_visit_3.bench.cpp' FAILED 
Exit Code: -9
Timeout: Reached timeout of 1500 seconds

Command Output (stdout):
--
# COMPILED WITH
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm_build0/bin/clang++ 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/libcxx/test/benchmarks/variant_visit_3.bench.cpp
 -pthread --target=aarch64-unknown-linux-gnu -g -fno-omit-frame-pointer 
-fsanitize=address -nostdinc++ -I 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/libcxx/test-suite-install/include/c++/v1
 -I 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/libcxx_build_asan/libcxx/test-suite-install/include/c++/v1
 -I 
/home/b/sanitizer-aarch64-linux-bootstrap-asan/build/llvm-project/libcxx/test/support
 -std=c++26 -Werror -Wall -Wctad-maybe-unsupported -Wextra -Wshadow -Wundef 
-Wunused-

[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-17 Thread Aaron Puchert via cfe-commits

https://github.com/aaronpuchert created 
https://github.com/llvm/llvm-project/pull/116556

The situation that required symbol versions on the LLVM shared library can also 
happen for clang-cpp, although it is less common: different tools require 
different versions of the library, and through transitive dependencies a 
process ends up with multiple copies of clang-cpp. This causes havoc with ELF, 
because calls meant to go one version of the library end up with another.

I've also considered introducing a symbol version globally, but for example the 
clang (C) library and other targets outside of LLVM/Clang, e.g. libc++, would 
not want that. So it's probably best if we keep it to those libraries.

>From c7c190d0809bc8fe86e04d1ff4d6719d7acdcbe2 Mon Sep 17 00:00:00 2001
From: Aaron Puchert 
Date: Sun, 17 Nov 2024 21:17:35 +0100
Subject: [PATCH] Introduce symbol versioning for clang-cpp

The situation that required symbol versions on the LLVM shared library
can also happen for clang-cpp, although it is less common: different
tools require different versions of the library, and through transitive
dependencies a process ends up with multiple copies of clang-cpp. This
causes havoc with ELF, because calls meant to go one version of the
library end up with another.

I've also considered introducing a symbol version globally, but for
example the clang (C) library and other targets outside of LLVM/Clang,
e.g. libc++, would not want that. So it's probably best if we keep it to
those libraries.
---
 clang/tools/clang-shlib/CMakeLists.txt   | 8 
 clang/tools/clang-shlib/simple_version_script.map.in | 1 +
 llvm/CMakeLists.txt  | 2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)
 create mode 100644 clang/tools/clang-shlib/simple_version_script.map.in

diff --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index 298d3a9d18fec8..830f2b138ffa16 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -48,6 +48,14 @@ add_clang_library(clang-cpp
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
+
+configure_file(simple_version_script.map.in simple_version_script.map)
+
+if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
+  # Solaris ld does not accept global: *; so there is no way to version *all* 
global symbols
+  target_link_options(clang-cpp PRIVATE 
LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
+endif()
+
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
 if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
diff --git a/clang/tools/clang-shlib/simple_version_script.map.in 
b/clang/tools/clang-shlib/simple_version_script.map.in
new file mode 100644
index 00..cb2306d1f59682
--- /dev/null
+++ b/clang/tools/clang-shlib/simple_version_script.map.in
@@ -0,0 +1 @@
+@LLVM_SHLIB_SYMBOL_VERSION@ { global: *; };
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index cde4a999ea2e74..304197667dad6e 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -27,7 +27,7 @@ if (NOT PACKAGE_VERSION)
 endif()
 
 if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION)
-  # "Symbol version prefix for libLLVM.so"
+  # "Symbol version prefix for libLLVM.so and libclang-cpp.so"
   set(LLVM_SHLIB_SYMBOL_VERSION 
"LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
 endif()
 

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


[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Aaron Puchert (aaronpuchert)


Changes

The situation that required symbol versions on the LLVM shared library can also 
happen for clang-cpp, although it is less common: different tools require 
different versions of the library, and through transitive dependencies a 
process ends up with multiple copies of clang-cpp. This causes havoc with ELF, 
because calls meant to go one version of the library end up with another.

I've also considered introducing a symbol version globally, but for example the 
clang (C) library and other targets outside of LLVM/Clang, e.g. libc++, would 
not want that. So it's probably best if we keep it to those libraries.

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


3 Files Affected:

- (modified) clang/tools/clang-shlib/CMakeLists.txt (+8) 
- (added) clang/tools/clang-shlib/simple_version_script.map.in (+1) 
- (modified) llvm/CMakeLists.txt (+1-1) 


``diff
diff --git a/clang/tools/clang-shlib/CMakeLists.txt 
b/clang/tools/clang-shlib/CMakeLists.txt
index 298d3a9d18fec8..830f2b138ffa16 100644
--- a/clang/tools/clang-shlib/CMakeLists.txt
+++ b/clang/tools/clang-shlib/CMakeLists.txt
@@ -48,6 +48,14 @@ add_clang_library(clang-cpp
   ${_OBJECTS}
   LINK_LIBS
   ${_DEPS})
+
+configure_file(simple_version_script.map.in simple_version_script.map)
+
+if (NOT LLVM_LINKER_IS_SOLARISLD AND NOT MINGW)
+  # Solaris ld does not accept global: *; so there is no way to version *all* 
global symbols
+  target_link_options(clang-cpp PRIVATE 
LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
+endif()
+
 # Optimize function calls for default visibility definitions to avoid PLT and
 # reduce dynamic relocations.
 if (NOT APPLE AND NOT MINGW AND NOT LLVM_LINKER_IS_SOLARISLD_ILLUMOS)
diff --git a/clang/tools/clang-shlib/simple_version_script.map.in 
b/clang/tools/clang-shlib/simple_version_script.map.in
new file mode 100644
index 00..cb2306d1f59682
--- /dev/null
+++ b/clang/tools/clang-shlib/simple_version_script.map.in
@@ -0,0 +1 @@
+@LLVM_SHLIB_SYMBOL_VERSION@ { global: *; };
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index cde4a999ea2e74..304197667dad6e 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -27,7 +27,7 @@ if (NOT PACKAGE_VERSION)
 endif()
 
 if(NOT DEFINED LLVM_SHLIB_SYMBOL_VERSION)
-  # "Symbol version prefix for libLLVM.so"
+  # "Symbol version prefix for libLLVM.so and libclang-cpp.so"
   set(LLVM_SHLIB_SYMBOL_VERSION 
"LLVM_${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
 endif()
 

``




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


[clang-tools-extra] [clangd] Check for other clangd extension capabilities under 'experimental' (PR #116531)

2024-11-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: Nathan Ridge (HighCommander4)


Changes

This is a follow-up to PR114699, with the same motivation: to support clients 
which only support adding custom (language-specific or server-specific) 
capabilities under 'experimental'.

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


2 Files Affected:

- (modified) clang-tools-extra/clangd/Protocol.cpp (+22) 
- (modified) clang-tools-extra/clangd/Protocol.h (+3) 


``diff
diff --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 761f96846d4538..2b26e16598821c 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -511,6 +511,28 @@ bool fromJSON(const llvm::json::Value &Params, 
ClientCapabilities &R,
 if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
   R.CompletionFixes |= *EditsNearCursor;
   }
+  if (auto *References = TextDocument->getObject("references")) {
+if (auto ContainerSupport = References->getBoolean("container")) {
+  R.ReferenceContainer |= *ContainerSupport;
+}
+  }
+  if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
+if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline")) {
+  R.DiagnosticFixes |= *CodeActions;
+}
+  }
+}
+if (auto *Window = Experimental->getObject("window")) {
+  if (auto Implicit =
+  Window->getBoolean("implicitWorkDoneProgressCreate")) {
+R.ImplicitProgressCreation |= *Implicit;
+  }
+}
+if (auto *OffsetEncoding = Experimental->get("offsetEncoding")) {
+  R.offsetEncoding.emplace();
+  if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
+P.field("offsetEncoding")))
+return false;
 }
   }
 
diff --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 5b28095758198d..c7ef1a13e6e39e 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -452,6 +452,7 @@ struct ClientCapabilities {
   std::optional WorkspaceSymbolKinds;
 
   /// Whether the client accepts diagnostics with codeActions attached inline.
+  /// This is a clangd extension.
   /// textDocument.publishDiagnostics.codeActionsInline.
   bool DiagnosticFixes = false;
 
@@ -475,6 +476,7 @@ struct ClientCapabilities {
 
   /// Client supports displaying a container string for results of
   /// textDocument/reference (clangd extension)
+  /// textDocument.references.container
   bool ReferenceContainer = false;
 
   /// Client supports hierarchical document symbols.
@@ -563,6 +565,7 @@ struct ClientCapabilities {
 
   /// Whether the client supports the textDocument/inactiveRegions
   /// notification. This is a clangd extension.
+  /// textDocument.inactiveRegionsCapabilities.inactiveRegions
   bool InactiveRegions = false;
 };
 bool fromJSON(const llvm::json::Value &, ClientCapabilities &,

``




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


[clang-tools-extra] [clangd] Check for other clangd extension capabilities under 'experimental' (PR #116531)

2024-11-17 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 created 
https://github.com/llvm/llvm-project/pull/116531

This is a follow-up to PR114699, with the same motivation: to support clients 
which only support adding custom (language-specific or server-specific) 
capabilities under 'experimental'.

>From bdc4d0a15a866bbdd2a455c53ff6c5f9306ae83e Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Sun, 17 Nov 2024 02:43:43 -0500
Subject: [PATCH] [clangd] Check for other clangd extension capabilities under
 'experimental'

This is a follow-up to PR114699, with the same motivation: to support
clients which only support adding custom (language-specific or
server-specific) capabilities under 'experimental'.
---
 clang-tools-extra/clangd/Protocol.cpp | 22 ++
 clang-tools-extra/clangd/Protocol.h   |  3 +++
 2 files changed, 25 insertions(+)

diff --git a/clang-tools-extra/clangd/Protocol.cpp 
b/clang-tools-extra/clangd/Protocol.cpp
index 761f96846d4538..2b26e16598821c 100644
--- a/clang-tools-extra/clangd/Protocol.cpp
+++ b/clang-tools-extra/clangd/Protocol.cpp
@@ -511,6 +511,28 @@ bool fromJSON(const llvm::json::Value &Params, 
ClientCapabilities &R,
 if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
   R.CompletionFixes |= *EditsNearCursor;
   }
+  if (auto *References = TextDocument->getObject("references")) {
+if (auto ContainerSupport = References->getBoolean("container")) {
+  R.ReferenceContainer |= *ContainerSupport;
+}
+  }
+  if (auto *Diagnostics = TextDocument->getObject("publishDiagnostics")) {
+if (auto CodeActions = Diagnostics->getBoolean("codeActionsInline")) {
+  R.DiagnosticFixes |= *CodeActions;
+}
+  }
+}
+if (auto *Window = Experimental->getObject("window")) {
+  if (auto Implicit =
+  Window->getBoolean("implicitWorkDoneProgressCreate")) {
+R.ImplicitProgressCreation |= *Implicit;
+  }
+}
+if (auto *OffsetEncoding = Experimental->get("offsetEncoding")) {
+  R.offsetEncoding.emplace();
+  if (!fromJSON(*OffsetEncoding, *R.offsetEncoding,
+P.field("offsetEncoding")))
+return false;
 }
   }
 
diff --git a/clang-tools-extra/clangd/Protocol.h 
b/clang-tools-extra/clangd/Protocol.h
index 5b28095758198d..c7ef1a13e6e39e 100644
--- a/clang-tools-extra/clangd/Protocol.h
+++ b/clang-tools-extra/clangd/Protocol.h
@@ -452,6 +452,7 @@ struct ClientCapabilities {
   std::optional WorkspaceSymbolKinds;
 
   /// Whether the client accepts diagnostics with codeActions attached inline.
+  /// This is a clangd extension.
   /// textDocument.publishDiagnostics.codeActionsInline.
   bool DiagnosticFixes = false;
 
@@ -475,6 +476,7 @@ struct ClientCapabilities {
 
   /// Client supports displaying a container string for results of
   /// textDocument/reference (clangd extension)
+  /// textDocument.references.container
   bool ReferenceContainer = false;
 
   /// Client supports hierarchical document symbols.
@@ -563,6 +565,7 @@ struct ClientCapabilities {
 
   /// Whether the client supports the textDocument/inactiveRegions
   /// notification. This is a clangd extension.
+  /// textDocument.inactiveRegionsCapabilities.inactiveRegions
   bool InactiveRegions = false;
 };
 bool fromJSON(const llvm::json::Value &, ClientCapabilities &,

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


[clang] [Clang] Fix name lookup for dependent bases (PR #114978)

2024-11-17 Thread Vladislav Belov via cfe-commits

https://github.com/vbe-sc updated 
https://github.com/llvm/llvm-project/pull/114978

>From f3b8ee95f1b3759f7d0dbc12f856a13ca9f01e0f Mon Sep 17 00:00:00 2001
From: vb-sc 
Date: Tue, 5 Nov 2024 15:46:57 +0300
Subject: [PATCH] [clang] Fix name lookup for dependent bases

---
 clang/lib/AST/CXXInheritance.cpp | 16 +++
 clang/test/CXX/drs/cwg5xx.cpp| 48 ++--
 2 files changed, 57 insertions(+), 7 deletions(-)

diff --git a/clang/lib/AST/CXXInheritance.cpp b/clang/lib/AST/CXXInheritance.cpp
index eb265a872c1259..3edc1f54837deb 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -170,13 +170,21 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
 QualType BaseType =
 Context.getCanonicalType(BaseSpec.getType()).getUnqualifiedType();
 
+bool isCurrentInstantiation = isa(BaseType);
+if (!isCurrentInstantiation) {
+  if (auto *BaseRecord =
+  cast(BaseSpec.getType()->getAsRecordDecl()))
+isCurrentInstantiation = BaseRecord->isDependentContext() &&
+ BaseRecord->isCurrentInstantiation(Record);
+}
 // C++ [temp.dep]p3:
 //   In the definition of a class template or a member of a class template,
 //   if a base class of the class template depends on a template-parameter,
 //   the base class scope is not examined during unqualified name lookup
 //   either at the point of definition of the class template or member or
 //   during an instantiation of the class tem- plate or member.
-if (!LookupInDependent && BaseType->isDependentType())
+if (!LookupInDependent &&
+(BaseType->isDependentType() && !isCurrentInstantiation))
   continue;
 
 // Determine whether we need to visit this base class at all,
@@ -244,9 +252,8 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
 return FoundPath;
   }
 } else if (VisitBase) {
-  CXXRecordDecl *BaseRecord;
+  CXXRecordDecl *BaseRecord = nullptr;
   if (LookupInDependent) {
-BaseRecord = nullptr;
 const TemplateSpecializationType *TST =
 BaseSpec.getType()->getAs();
 if (!TST) {
@@ -265,8 +272,7 @@ bool CXXBasePaths::lookupInBases(ASTContext &Context,
 BaseRecord = nullptr;
 }
   } else {
-BaseRecord = cast(
-BaseSpec.getType()->castAs()->getDecl());
+BaseRecord = 
cast(BaseSpec.getType()->getAsRecordDecl());
   }
   if (BaseRecord &&
   lookupInBases(Context, BaseRecord, BaseMatches, LookupInDependent)) {
diff --git a/clang/test/CXX/drs/cwg5xx.cpp b/clang/test/CXX/drs/cwg5xx.cpp
index ed0c7159dfc889..0d53a9d07d76de 100644
--- a/clang/test/CXX/drs/cwg5xx.cpp
+++ b/clang/test/CXX/drs/cwg5xx.cpp
@@ -1178,17 +1178,61 @@ namespace cwg590 { // cwg590: yes
   template typename A::B::C A::B::C::f(A::B::C) {}
 }
 
-namespace cwg591 { // cwg591: no
+namespace cwg591 { // cwg591: yes
   template struct A {
 typedef int M;
 struct B {
   typedef void M;
   struct C;
+  struct D;
+};
+  };
+
+  template struct G {
+struct B {
+  typedef int M;
+  struct C {
+typedef void M;
+struct D;
+  };
+};
+  };
+
+  template struct H {
+template struct B {
+  typedef int M;
+  template struct C {
+typedef void M;
+struct D;
+struct P;
+  };
 };
   };
 
   template struct A::B::C : A {
-// FIXME: Should find member of non-dependent base class A.
+M m;
+  };
+
+  template struct G::B::C::D : B {
+M m;
+  };
+
+  template
+  template
+  template
+  struct H::B::C::D : B {
+M m;
+  };
+
+  template struct A::B::D : A {
+M m;
+// expected-error@-1 {{field has incomplete type 'M' (aka 'void'}}
+  };
+
+  template
+  template
+  template
+  struct H::B::C::P : B {
 M m;
 // expected-error@-1 {{field has incomplete type 'M' (aka 'void'}}
   };

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits


@@ -3229,6 +3230,52 @@ void Sema::CheckArgAlignment(SourceLocation Loc, 
NamedDecl *FDecl,
 << ParamName << (FDecl != nullptr) << FDecl;
 }
 
+void Sema::checkLifetimeCaptureBy(FunctionDecl *FD, bool IsMemberFunction,
+  const Expr *ThisArg,
+  ArrayRef Args) {
+  auto GetArgAt = [&](int Idx) -> Expr * {
+if (Idx == LifetimeCaptureByAttr::GLOBAL ||
+Idx == LifetimeCaptureByAttr::UNKNOWN)
+  return nullptr;
+if (IsMemberFunction && Idx == 0)
+  return const_cast(ThisArg);
+return const_cast(Args[Idx - int(IsMemberFunction)]);
+  };
+  for (unsigned I = 0; I < FD->getNumParams(); ++I) {
+auto *CapturedByAttr =
+FD->getParamDecl(I)->getAttr();
+if (!CapturedByAttr)
+  continue;
+for (int CapturingParamIdx : CapturedByAttr->params()) {
+  Expr *Capturing = GetArgAt(CapturingParamIdx);
+  Expr *Captured = GetArgAt(I + IsMemberFunction);
+  CapturingEntity CE{Capturing};
+  // Ensure that 'Captured' outlives the 'Capturing' entity.
+  checkExprLifetime(*this, CE, Captured);
+}
+  }
+  // Check when the 'this' object is captured.
+  if (IsMemberFunction) {
+TypeSourceInfo *TSI = FD->getTypeSourceInfo();
+if (!TSI)
+  return;
+AttributedTypeLoc ATL;
+for (TypeLoc TL = TSI->getTypeLoc();
+ (ATL = TL.getAsAdjusted());
+ TL = ATL.getModifiedLoc()) {
+  auto *CapturedByAttr = ATL.getAttrAs();
+  if (!CapturedByAttr)
+continue;
+  Expr *Captured = GetArgAt(0);
+  for (int CapturingParamIdx : CapturedByAttr->params()) {
+Expr *Capturing = GetArgAt(CapturingParamIdx);
+CapturingEntity CE{Capturing};
+checkExprLifetime(*this, CE, Captured);
+  }

usx95 wrote:

Makes sense. Done.

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


[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread Freddy Ye via cfe-commits

FreddyLeaf wrote:

> Looks like this breaks tests: http://45.33.8.238/linux/153081/step_6.txt
> 
> Please take a look and revert for now if it takes a while to fix.

Thanks reminding. Revert first.

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


[clang] [clang] Set FPOptions at the beginning of CompoundStmt (PR #111654)

2024-11-17 Thread John McCall via cfe-commits

rjmccall wrote:

I'm sorry if you've explained this before, but I thought our general approach 
was to just store the options in individual expressions, and CodeGen should in 
general already be paying attention to those options.  Is there a specific 
reason we also need to honor these at the compound statement level?  If so, is 
there an expected invariant we can take advantage of to avoid all the 
bookkeeping work we end up doing when creating and emitting individual 
expressions?

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits


@@ -0,0 +1,220 @@
+// RUN: %clang_cc1 --std=c++20 -fsyntax-only -Wdangling -Wdangling-field 
-Wreturn-stack-address -verify %s
+
+#include "Inputs/lifetime-analysis.h"
+
+struct X {
+  const int *x;
+  void captureInt(const int& x [[clang::lifetime_capture_by(this)]]) { this->x 
= &x; }
+  void captureSV(std::string_view sv [[clang::lifetime_capture_by(this)]]);
+};
+///
+// Detect dangling cases.
+///
+void captureInt(const int &i [[clang::lifetime_capture_by(x)]], X &x);
+void captureRValInt(int &&i [[clang::lifetime_capture_by(x)]], X &x);
+void noCaptureInt(int i [[clang::lifetime_capture_by(x)]], X &x);
+
+std::string_view substr(const std::string& s [[clang::lifetimebound]]);
+std::string_view strcopy(const std::string& s);
+
+void captureSV(std::string_view s [[clang::lifetime_capture_by(x)]], X &x);
+void captureRValSV(std::string_view &&sv [[clang::lifetime_capture_by(x)]], X 
&x);
+void noCaptureSV(std::string_view sv, X &x);
+void captureS(const std::string &s [[clang::lifetime_capture_by(x)]], X &x);
+void captureRValS(std::string &&s [[clang::lifetime_capture_by(x)]], X &x);
+
+const std::string& getLB(const std::string &s [[clang::lifetimebound]]);
+const std::string& getLB(std::string_view sv [[clang::lifetimebound]]);
+const std::string* getPointerLB(const std::string &s [[clang::lifetimebound]]);
+const std::string* getPointerNoLB(const std::string &s);
+
+void capturePointer(const std::string* sp [[clang::lifetime_capture_by(x)]], X 
&x);
+
+struct ThisIsCaptured {
+  void capture(X &x) [[clang::lifetime_capture_by(x)]];
+};
+
+void captureByGlobal(std::string_view s 
[[clang::lifetime_capture_by(global)]]);
+void captureByUnknown(std::string_view s 
[[clang::lifetime_capture_by(unknown)]]);
+
+void use() {
+  std::string_view local_sv;
+  std::string local_s;
+  X x;
+  // Capture an 'int'.
+  int local;
+  captureInt(1, // expected-warning {{object whose reference is captured by 
'x' will be destroyed at the end of the full-expression}}
+x);
+  captureRValInt(1, x); // expected-warning {{object whose reference is 
captured by 'x'}}
+  captureInt(local, x);
+  noCaptureInt(1, x);
+  noCaptureInt(local, x);
+
+  // Capture using std::string_view.
+  captureSV(local_sv, x);
+  captureSV(std::string(), // expected-warning {{object whose reference is 
captured by 'x'}}
+x);
+  captureSV(substr(
+  std::string() // expected-warning {{object whose reference is captured 
by 'x'}}
+  ), x);
+  captureSV(substr(local_s), x);
+  captureSV(strcopy(std::string()), x);
+  captureRValSV(std::move(local_sv), x);
+  captureRValSV(std::string(), x); // expected-warning {{object whose 
reference is captured by 'x'}}
+  captureRValSV(std::string_view{"abcd"}, x);
+  captureRValSV(substr(local_s), x);
+  captureRValSV(substr(std::string()), x); // expected-warning {{object whose 
reference is captured by 'x'}}
+  captureRValSV(strcopy(std::string()), x);
+  noCaptureSV(local_sv, x);
+  noCaptureSV(std::string(), x);
+  noCaptureSV(substr(std::string()), x);
+
+  // Capture using std::string.
+  captureS(std::string(), x); // expected-warning {{object whose reference is 
captured by 'x'}}
+  captureS(local_s, x);
+  captureRValS(std::move(local_s), x);
+  captureRValS(std::string(), x); // expected-warning {{object whose reference 
is captured by 'x'}}
+
+  // Capture with lifetimebound.
+  captureSV(getLB(std::string()), x); // expected-warning {{object whose 
reference is captured by 'x'}}
+  captureSV(getLB(substr(std::string())), x); // expected-warning {{object 
whose reference is captured by 'x'}}
+  captureSV(getLB(getLB(
+std::string()  // expected-warning {{object whose reference is captured by 
'x'}}
+)), x);
+  capturePointer(getPointerLB(std::string()), x); // expected-warning {{object 
whose reference is captured by 'x'}}
+  capturePointer(getPointerLB(*getPointerLB(
+std::string()  // expected-warning {{object whose reference is captured by 
'x'}}
+)), x);
+  capturePointer(getPointerNoLB(std::string()), x);
+
+  // Member functions.
+  x.captureInt(1); // expected-warning {{object whose reference is captured by 
'x'}}
+  x.captureSV(std::string()); // expected-warning {{object whose reference is 
captured by 'x'}}
+  x.captureSV(substr(std::string())); // expected-warning {{object whose 
reference is captured by 'x'}}
+  x.captureSV(strcopy(std::string()));
+
+  // 'this' is captured.
+  ThisIsCaptured{}.capture(x); // expected-warning {{object whose reference is 
captured by 'x'}}
+  ThisIsCaptured TIS;
+  TIS.capture(x);
+
+  // capture by global.
+  captureByGlobal(std::string()); // expected-warning {{object whose reference 
is captured will be destroyed at the end of the full-expression}}
+  captureByGlobal(substr(std::string())); // expected-warning {{captured}}
+  captureByGlobal(local_s);
+  captureByGlobal(local_sv);
+
+  // // capture by unknown.
+  captureByGlobal(std::s

[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits


@@ -0,0 +1,220 @@
+// RUN: %clang_cc1 --std=c++20 -fsyntax-only -Wdangling -Wdangling-field 
-Wreturn-stack-address -verify %s
+
+#include "Inputs/lifetime-analysis.h"
+
+struct X {
+  const int *x;
+  void captureInt(const int& x [[clang::lifetime_capture_by(this)]]) { this->x 
= &x; }
+  void captureSV(std::string_view sv [[clang::lifetime_capture_by(this)]]);
+};
+///
+// Detect dangling cases.
+///
+void captureInt(const int &i [[clang::lifetime_capture_by(x)]], X &x);
+void captureRValInt(int &&i [[clang::lifetime_capture_by(x)]], X &x);
+void noCaptureInt(int i [[clang::lifetime_capture_by(x)]], X &x);
+
+std::string_view substr(const std::string& s [[clang::lifetimebound]]);
+std::string_view strcopy(const std::string& s);
+
+void captureSV(std::string_view s [[clang::lifetime_capture_by(x)]], X &x);
+void captureRValSV(std::string_view &&sv [[clang::lifetime_capture_by(x)]], X 
&x);
+void noCaptureSV(std::string_view sv, X &x);
+void captureS(const std::string &s [[clang::lifetime_capture_by(x)]], X &x);
+void captureRValS(std::string &&s [[clang::lifetime_capture_by(x)]], X &x);
+
+const std::string& getLB(const std::string &s [[clang::lifetimebound]]);

usx95 wrote:

Added a comment: `// Return reference to the argument through lifetimebound.`

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-17 Thread Campbell Barton via cfe-commits


@@ -206,20 +191,30 @@ which can be passed directly to ‘clang-format’."
((= status 0) nil)
;; Return of 1 indicates found diffs and no error.
((= status 1)
-;; Iterate through all lines in diff buffer and collect all
-;; lines in current buffer that have a diff.
-(goto-char (point-min))
-(while (not (eobp))
-  (let ((diff-line (clang-format--vc-diff-match-diff-line
-(buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)
-(when diff-line
-  ;; Create list line regions with diffs to pass to
-  ;; clang-format.
-  (push (concat "--lines=" diff-line) diff-lines)))
-  (forward-line 1))
-(reverse diff-lines))
+;; Find and collect all diff lines.
+;; We are matching something like:
+;; "@@ -80 +80 @@" or "@@ -80,2 +80,2 @@"
+(let ((diff-lines-re
+   "^@@\s-[0-9,]+\s\\+\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\s@@$")
+  (index 0)
+  (all-lines
+   (buffer-substring-no-properties (point-min) (point-max

ideasman42 wrote:

Did you try searching within the current buffer?

It's quite strange to make a copy of the whole buffer just to search it.

Even if you can measure some performance improvement, I think it's reasonable 
to use common practices, instead of relying on performance characteristics of 
the current implementation. Unless there are really significant user visible 
advantages. Based on my own experience with ELisp, I've never seen scripts 
duplicate a buffer into a string to search it. Besides relying on some details 
of the performance of your version of emacs, subtle changes to ELisp may render 
this odd way of searching the buffer invalid. There is also the down side of 
storing the buffer twice in memory - probably it's not going to cause problems 
on modern systems, but it could cause some GC/performance issues with very 
large buffers still.

Furthermore `(while (re-search-forward ...) ...)` is such a common pattern, any 
bottleneck here could be caused by the arguments your using ... or some other 
buffer setting (case sensitivity.. or other arguments that control behavior). 
It seems quite suspicious that there should be a significant difference.

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-17 Thread Campbell Barton via cfe-commits

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


[clang] 97836be - Reland "[X86] Support -march=diamondrapids (#113881)" (#116564)

2024-11-17 Thread via cfe-commits

Author: Freddy Ye
Date: 2024-11-18T10:40:32+08:00
New Revision: 97836bed6357664f9b2fb87cfe10656b08309bac

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

LOG: Reland "[X86] Support -march=diamondrapids (#113881)" (#116564)

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Basic/Targets/X86.cpp
clang/test/CodeGen/attr-cpuspecific-cpus.c
clang/test/CodeGen/attr-target-mv.c
clang/test/CodeGen/target-builtin-noerror.c
clang/test/Driver/x86-march.c
clang/test/Misc/target-invalid-cpu-note/x86.c
clang/test/Preprocessor/predefined-arch-macros.c
compiler-rt/lib/builtins/cpu_model/x86.c
llvm/docs/ReleaseNotes.md
llvm/include/llvm/TargetParser/X86TargetParser.def
llvm/include/llvm/TargetParser/X86TargetParser.h
llvm/lib/Target/X86/X86.td
llvm/lib/TargetParser/Host.cpp
llvm/lib/TargetParser/X86TargetParser.cpp
llvm/test/CodeGen/X86/cpus-intel.ll

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8830a5658c7da..044f62e770a7a0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,6 +769,8 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
+- Supported ``-march/tune=diamondrapids``
+
 Arm and AArch64 Support
 ^^^
 

diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 086b4415412e67..5993257e27d5a9 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,6 +667,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
+  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1651,6 +1652,7 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
+case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7

diff  --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index dd154fd227b25b..1dd095ec9e191f 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,6 +43,7 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
+ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}

diff  --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 2c4b95ca04370a..6911b55203b7e7 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,6 +29,7 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
+int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {

diff  --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 1e53621bc6b5ae..0bbd8c3e5ddd81 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,4 +209,5 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
+  (void)__builtin_cpu_is("diamondrapids");
 }

diff  --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 3bc2a82ae778d6..341f01c8d668df 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,6 +120,10 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
+// RUN:   | FileCheck %s -check-prefix=diamondrapids
+// diamondrapids: "-target-cpu" "diamondrapids"
+//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"

diff  --git a/clang/test/Misc/target-invalid-cpu-note/x86.c 
b/clang/test/Misc/target-invalid-cpu-note/x86.c
index 

[clang] [compiler-rt] [llvm] Reland "[X86] Support -march=diamondrapids (#113881)" (PR #116564)

2024-11-17 Thread Freddy Ye via cfe-commits

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


[clang] [TargetVersion] Only enable on RISC-V and AArch64 (PR #115991)

2024-11-17 Thread Piyou Chen via cfe-commits

https://github.com/BeMg updated https://github.com/llvm/llvm-project/pull/115991

>From 28f7a2adc055ec6f30790e1e9535c71241a08e29 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Tue, 12 Nov 2024 20:56:47 -0800
Subject: [PATCH 1/7] [TargetVersion] Only enable on RISC-V and AArch64

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 ++
 clang/lib/Sema/SemaDeclAttr.cpp  | 5 +
 2 files changed, 7 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 509d45c0867590..6170c3c10b00ca 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3282,6 +3282,8 @@ def warn_unsupported_target_attribute
   "attribute string; 
'%select{target|target_clones|target_version}3' "
   "attribute ignored">,
   InGroup;
+def err_target_version_unsupported
+: Error<"target_version attribute is not supported in this target">;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported on targets missing %1;"
 " specify an appropriate -march= or -mcpu=">;
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index d05d326178e1b8..e2eaa00c666fc2 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3040,6 +3040,11 @@ bool Sema::checkTargetVersionAttr(SourceLocation 
LiteralLoc, Decl *D,
   enum FirstParam { Unsupported };
   enum SecondParam { None };
   enum ThirdParam { Target, TargetClones, TargetVersion };
+
+  if (!Context.getTargetInfo().getTriple().isRISCV() &&
+  !Context.getTargetInfo().getTriple().isAArch64())
+return Diag(LiteralLoc, diag::err_target_version_unsupported);
+
   llvm::SmallVector Features;
   if (Context.getTargetInfo().getTriple().isRISCV()) {
 llvm::SmallVector AttrStrs;

>From 5355896434206bce33ff2442189aaff4d6b605ad Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Wed, 13 Nov 2024 22:25:05 -0800
Subject: [PATCH 2/7] Add testcase

---
 clang/test/Sema/attr-target-version-unsupported.c | 4 
 1 file changed, 4 insertions(+)
 create mode 100644 clang/test/Sema/attr-target-version-unsupported.c

diff --git a/clang/test/Sema/attr-target-version-unsupported.c 
b/clang/test/Sema/attr-target-version-unsupported.c
new file mode 100644
index 00..7a868e4085f20e
--- /dev/null
+++ b/clang/test/Sema/attr-target-version-unsupported.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown  -fsyntax-only -verify %s
+
+//expected-error@+1 {{target_version attribute is not supported in this 
target}}
+int __attribute__((target_version("aes"))) foo(void) { return 3; }

>From 659b628a12e05610ff82421dd358292c53940e93 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Wed, 13 Nov 2024 22:28:30 -0800
Subject: [PATCH 3/7] in this target -> on this target

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td  | 2 +-
 clang/test/Sema/attr-target-version-unsupported.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6170c3c10b00ca..0e3e8f90e52252 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3283,7 +3283,7 @@ def warn_unsupported_target_attribute
   "attribute ignored">,
   InGroup;
 def err_target_version_unsupported
-: Error<"target_version attribute is not supported in this target">;
+: Error<"target_version attribute is not supported on this target">;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported on targets missing %1;"
 " specify an appropriate -march= or -mcpu=">;
diff --git a/clang/test/Sema/attr-target-version-unsupported.c 
b/clang/test/Sema/attr-target-version-unsupported.c
index 7a868e4085f20e..056cbd25bd90d4 100644
--- a/clang/test/Sema/attr-target-version-unsupported.c
+++ b/clang/test/Sema/attr-target-version-unsupported.c
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown  -fsyntax-only -verify %s
 
-//expected-error@+1 {{target_version attribute is not supported in this 
target}}
+//expected-error@+1 {{target_version attribute is not supported on this 
target}}
 int __attribute__((target_version("aes"))) foo(void) { return 3; }

>From 5f7a3ebe81f2dc6af7d558d012d8d05543fa7115 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Thu, 14 Nov 2024 22:34:18 -0800
Subject: [PATCH 4/7] Using the TargetSpecificAttr instead of InheritableAttr

---
 clang/include/clang/Basic/Attr.td | 2 +-
 clang/include/clang/Basic/DiagnosticSemaKinds.td  | 2 --
 clang/lib/Sema/SemaDeclAttr.cpp   | 4 
 clang/test/Sema/attr-target-version-unsupported.c | 2 +-
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index a631e81d40aa68

[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-17 Thread via cfe-commits

https://github.com/goldsteinn updated 
https://github.com/llvm/llvm-project/pull/112792

>From 802764e879862541e205ba1a070824b71d2fef9a Mon Sep 17 00:00:00 2001
From: Noah Goldstein 
Date: Thu, 17 Oct 2024 17:31:24 -0500
Subject: [PATCH 01/15] [emacs][clang-format] Add elisp API for clang-format on
 git diffs

New proposed function `clang-format-git-diffs`.

It is the same as calling `clang-format-region` on all diffs between
the content of a buffer-file and the content of the file at git
revision HEAD. This is essentially the same thing as:
`git-clang-format -f {filename}`
If the current buffer is saved.

The motivation is many project (LLVM included) both have code that is
non-compliant with there clang-format style and disallow unrelated
format diffs in PRs. This means users can't just run
`clang-format-buffer` on the buffer they are working on, and need to
manually go through all the regions by hand to get them
formatted. This is both an error prone and annoying workflow.
---
 clang/tools/clang-format/clang-format.el | 159 ---
 1 file changed, 144 insertions(+), 15 deletions(-)

diff --git a/clang/tools/clang-format/clang-format.el 
b/clang/tools/clang-format/clang-format.el
index fb943b7b722f8a..d3f874de41c550 100644
--- a/clang/tools/clang-format/clang-format.el
+++ b/clang/tools/clang-format/clang-format.el
@@ -146,18 +146,97 @@ is a zero-based file offset, assuming ‘utf-8-unix’ 
coding."
 (lambda (byte &optional _quality _coding-system)
   (byte-to-position (1+ byte)
 
-;;;###autoload
-(defun clang-format-region (start end &optional style assume-file-name)
-  "Use clang-format to format the code between START and END according to 
STYLE.
-If called interactively uses the region or the current statement if there is no
-no active region. If no STYLE is given uses `clang-format-style'. Use
-ASSUME-FILE-NAME to locate a style config file, if no ASSUME-FILE-NAME is given
-uses the function `buffer-file-name'."
-  (interactive
-   (if (use-region-p)
-   (list (region-beginning) (region-end))
- (list (point) (point
-
+(defun clang-format--git-diffs-get-diff-lines (file-orig file-new)
+  "Return all line regions that contain diffs between FILE-ORIG and
+FILE-NEW.  If there is no diff 'nil' is returned. Otherwise the
+return is a 'list' of lines in the format '--lines=:'
+which can be passed directly to 'clang-format'"
+  ;; Temporary buffer for output of diff.
+  (with-temp-buffer
+(let ((status (call-process
+   "diff"
+   nil
+   (current-buffer)
+   nil
+   ;; Binary diff has different behaviors that we
+   ;; aren't interested in.
+   "-a"
+   ;; Printout changes as only the line groups.
+   "--changed-group-format=--lines=%dF:%dL "
+   ;; Ignore unchanged content.
+   "--unchanged-group-format="
+   file-orig
+   file-new
+   )
+  )
+  (stderr (concat (if (zerop (buffer-size)) "" ": ")
+  (buffer-substring-no-properties
+   (point-min) (line-end-position)
+  (when (stringp status)
+(error "(diff killed by signal %s%s)" status stderr))
+  (unless (= status 0)
+(unless (= status 1)
+  (error "(diff returned unsuccessfully %s%s)" status stderr)))
+
+
+  (if (= status 0)
+  ;; Status == 0 -> no Diff.
+  nil
+(progn
+  ;; Split "--lines=:... --lines=:" output to
+  ;; a list for return.
+  (s-split
+   " "
+   (string-trim
+(buffer-substring-no-properties
+ (point-min) (point-max)
+
+(defun clang-format--git-diffs-get-git-head-file ()
+  "Returns a temporary file with the content of 'buffer-file-name' at
+git revision HEAD. If the current buffer is either not a file or not
+in a git repo, this results in an error"
+  ;; Needs current buffer to be a file
+  (unless (buffer-file-name)
+(error "Buffer is not visiting a file"))
+  ;; Need to be able to find version control (git) root
+  (unless (vc-root-dir)
+(error "File not known to git"))
+  ;; Need version control to in fact be git
+  (unless (string-equal (vc-backend (buffer-file-name)) "Git")
+(error "Not using git"))
+
+  (let ((tmpfile-git-head (make-temp-file 
"clang-format-tmp-git-head-content")))
+;; Get filename relative to git root
+(let ((git-file-name (substring
+  (expand-file-name (buffer-file-name))
+  (string-width (expand-file-name (vc-root-dir)))
+  nil)))
+  (let ((status (call-process
+ "git"
+ nil
+ `(:file, tmpfile-git-head)
+ nil
+ "show" (concat "HEAD:" git-file-nam

[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-17 Thread via cfe-commits


@@ -206,20 +191,30 @@ which can be passed directly to ‘clang-format’."
((= status 0) nil)
;; Return of 1 indicates found diffs and no error.
((= status 1)
-;; Iterate through all lines in diff buffer and collect all
-;; lines in current buffer that have a diff.
-(goto-char (point-min))
-(while (not (eobp))
-  (let ((diff-line (clang-format--vc-diff-match-diff-line
-(buffer-substring-no-properties
- (line-beginning-position)
- (line-end-position)
-(when diff-line
-  ;; Create list line regions with diffs to pass to
-  ;; clang-format.
-  (push (concat "--lines=" diff-line) diff-lines)))
-  (forward-line 1))
-(reverse diff-lines))
+;; Find and collect all diff lines.
+;; We are matching something like:
+;; "@@ -80 +80 @@" or "@@ -80,2 +80,2 @@"
+(let ((diff-lines-re
+   "^@@\s-[0-9,]+\s\\+\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\s@@$")
+  (index 0)
+  (all-lines
+   (buffer-substring-no-properties (point-min) (point-max

goldsteinn wrote:

Fixed

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-17 Thread Campbell Barton via cfe-commits


@@ -146,18 +146,124 @@ is a zero-based file offset, assuming ‘utf-8-unix’ 
coding."
 (lambda (byte &optional _quality _coding-system)
   (byte-to-position (1+ byte)
 
-;;;###autoload
-(defun clang-format-region (start end &optional style assume-file-name)
-  "Use clang-format to format the code between START and END according to 
STYLE.
-If called interactively uses the region or the current statement if there is no
-no active region. If no STYLE is given uses `clang-format-style'. Use
-ASSUME-FILE-NAME to locate a style config file, if no ASSUME-FILE-NAME is given
-uses the function `buffer-file-name'."
-  (interactive
-   (if (use-region-p)
-   (list (region-beginning) (region-end))
- (list (point) (point
+(defmacro clang-format--with-delete-files-guard (bind-files-to-delete &rest 
body)
+  "Execute BODY which may add temp files to BIND-FILES-TO-DELETE."
+  (declare (indent 1))
+  `(let ((,bind-files-to-delete nil))
+ (unwind-protect
+ (progn
+   ,@body)
+   (while ,bind-files-to-delete
+ (with-demoted-errors "failed to remove file: %S"
+   (delete-file (pop ,bind-files-to-delete)))
+
+
+(defun clang-format--vc-diff-get-diff-lines (file-orig file-new)
+  "Return all line regions that contain diffs between FILE-ORIG and
+FILE-NEW.  If there is no diff ‘nil’ is returned. Otherwise the
+return is a ‘list’ of lines in the format ‘--lines=:’
+which can be passed directly to ‘clang-format’."
+  ;; Use temporary buffer for output of diff.
+  (with-temp-buffer
+;; We could use diff.el:diff-no-select here. The reason we don't
+;; is diff-no-select requires extra copies on the buffers which
+;; induces noticeable slowdowns, especially on larger files.
+(let ((status (call-process
+   diff-command
+   nil
+   (current-buffer)
+   nil
+   ;; Binary diff has different behaviors that we
+   ;; aren't interested in.
+   "-a"
+   ;; Get minimal diff (copy diff config for git-clang-format).
+   "-U0"
+   file-orig
+   file-new))
+  (stderr (concat (if (zerop (buffer-size)) "" ": ")
+  (buffer-substring-no-properties
+   (point-min) (line-end-position
+  (diff-lines '()))
+  (cond
+   ((stringp status)
+(error "(diff killed by signal %s%s)" status stderr))
+   ;; Return of 0 indicates no diff.
+   ((= status 0) nil)
+   ;; Return of 1 indicates found diffs and no error.
+   ((= status 1)
+;; Find and collect all diff lines.
+;; We are matching something like:
+;; "@@ -80 +80 @@" or "@@ -80,2 +80,2 @@"
+(goto-char (point-min))
+(while (re-search-forward
+"^@@\s-[0-9,]+\s\\+\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\s@@$"
+nil
+t
+1)
+  (let ((match1 (string-to-number (match-string 1)))
+(match3 (if (match-string 3)

ideasman42 wrote:

`\s-` uses the syntax-table, in this case I think it's reasonable to be more 
explicit (space-or-tab)

This is a similar regex I used for the package `diff-at-point`.

Not saying you \*should\* use this, but in general I find `[:blank:]` 
preferable when `a space or tab character` is appropriate, see: 
https://www.emacswiki.org/emacs/RegularExpression
``
(concat
  "^\\(@@\\)[[:blank:]]+"
  ;; Previous (ignore).
  "-"
  
"\\([[:digit:]]+\\),\\([[:digit:]]+\\)"
  "[[:blank:]]+"
  ;; Current (use).
  "\\+"
  
"\\([[:digit:]]+\\),\\([[:digit:]]+\\)"
  "[[:blank:]]+@@")
```

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-17 Thread Campbell Barton via cfe-commits

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


[clang] 63aa8cf - [NFC][Clang][TableGen] Fix file header comments (#116491)

2024-11-17 Thread via cfe-commits

Author: Rahul Joshi
Date: 2024-11-17T07:54:10-08:00
New Revision: 63aa8cf6becbeb4983e3d1a7fa3cd8a7c7147118

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

LOG: [NFC][Clang][TableGen] Fix file header comments (#116491)

Added: 


Modified: 
clang/utils/TableGen/ASTTableGen.cpp
clang/utils/TableGen/ClangASTNodesEmitter.cpp
clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
clang/utils/TableGen/ClangBuiltinsEmitter.cpp
clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
clang/utils/TableGen/ClangCommentHTMLNamedCharacterReferenceEmitter.cpp
clang/utils/TableGen/ClangCommentHTMLTagsEmitter.cpp
clang/utils/TableGen/ClangDataCollectorsEmitter.cpp
clang/utils/TableGen/ClangDiagnosticsEmitter.cpp
clang/utils/TableGen/ClangOpcodesEmitter.cpp
clang/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
clang/utils/TableGen/ClangOptionDocEmitter.cpp
clang/utils/TableGen/ClangSACheckersEmitter.cpp
clang/utils/TableGen/ClangSyntaxEmitter.cpp
clang/utils/TableGen/ClangTypeNodesEmitter.cpp
clang/utils/TableGen/MveEmitter.cpp
clang/utils/TableGen/NeonEmitter.cpp
clang/utils/TableGen/RISCVVEmitter.cpp
clang/utils/TableGen/SveEmitter.cpp
clang/utils/TableGen/TableGen.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ASTTableGen.cpp 
b/clang/utils/TableGen/ASTTableGen.cpp
index e689a67c5ed810..6fa744fb547e2d 100644
--- a/clang/utils/TableGen/ASTTableGen.cpp
+++ b/clang/utils/TableGen/ASTTableGen.cpp
@@ -1,4 +1,4 @@
-//=== ASTTableGen.cpp - Helper functions for working with AST records 
-===//
+//===-- ASTTableGen.cpp - Helper functions for working with AST records 
---===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git a/clang/utils/TableGen/ClangASTNodesEmitter.cpp 
b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
index 9421f48d5487ca..16749d11836246 100644
--- a/clang/utils/TableGen/ClangASTNodesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTNodesEmitter.cpp
@@ -1,4 +1,4 @@
-//=== ClangASTNodesEmitter.cpp - Generate Clang AST node tables -*- C++ 
-*-===//
+//===-- ClangASTNodesEmitter.cpp - Generate Clang AST node tables 
-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp 
b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
index da64f006dd3bd1..acff6febeb8cfa 100644
--- a/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
+++ b/clang/utils/TableGen/ClangASTPropertiesEmitter.cpp
@@ -1,4 +1,4 @@
-//=== ClangASTPropsEmitter.cpp - Generate Clang AST properties --*- C++ 
-*-===//
+//===-- ClangASTPropsEmitter.cpp - Generate Clang AST properties 
--===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git a/clang/utils/TableGen/ClangAttrEmitter.cpp 
b/clang/utils/TableGen/ClangAttrEmitter.cpp
index b36633f9a59aa5..4aa7594ffa6eb7 100644
--- a/clang/utils/TableGen/ClangAttrEmitter.cpp
+++ b/clang/utils/TableGen/ClangAttrEmitter.cpp
@@ -1,4 +1,4 @@
-//===- ClangAttrEmitter.cpp - Generate Clang attribute handling =-*- C++ 
-*--=//
+//===-- ClangAttrEmitter.cpp - Generate Clang attribute handling 
--===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp 
b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
index 57a1fc06b26b16..6c3604adc92b99 100644
--- a/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
+++ b/clang/utils/TableGen/ClangBuiltinsEmitter.cpp
@@ -1,4 +1,4 @@
-//=- ClangBuiltinsEmitter.cpp - Generate Clang builtins tables -*- C++ 
-*-//
+//===-- ClangBuiltinsEmitter.cpp - Generate Clang builtins tables 
-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.

diff  --git a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp 
b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
index 45a97425ef920a..f15e30cd3f8f40 100644
--- a/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
+++ b/clang/utils/TableGen/ClangCommentCommandInfoEmitter.cpp
@@ -1,4 +1,4 @@
-//===--- ClangCommentCommandInfoEmitter.cpp - Generate command lists 
-//
+//===-- ClangCommentCommandInfoEmitter.cpp - Generate command lists 
---===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with 

[clang] [NFC][Clang][TableGen] Fix file header comments (PR #116491)

2024-11-17 Thread Rahul Joshi via cfe-commits

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-17 Thread Campbell Barton via cfe-commits


@@ -146,18 +146,124 @@ is a zero-based file offset, assuming ‘utf-8-unix’ 
coding."
 (lambda (byte &optional _quality _coding-system)
   (byte-to-position (1+ byte)
 
-;;;###autoload
-(defun clang-format-region (start end &optional style assume-file-name)
-  "Use clang-format to format the code between START and END according to 
STYLE.
-If called interactively uses the region or the current statement if there is no
-no active region. If no STYLE is given uses `clang-format-style'. Use
-ASSUME-FILE-NAME to locate a style config file, if no ASSUME-FILE-NAME is given
-uses the function `buffer-file-name'."
-  (interactive
-   (if (use-region-p)
-   (list (region-beginning) (region-end))
- (list (point) (point
+(defmacro clang-format--with-delete-files-guard (bind-files-to-delete &rest 
body)
+  "Execute BODY which may add temp files to BIND-FILES-TO-DELETE."
+  (declare (indent 1))
+  `(let ((,bind-files-to-delete nil))
+ (unwind-protect
+ (progn
+   ,@body)
+   (while ,bind-files-to-delete
+ (with-demoted-errors "failed to remove file: %S"
+   (delete-file (pop ,bind-files-to-delete)))
+
+
+(defun clang-format--vc-diff-get-diff-lines (file-orig file-new)
+  "Return all line regions that contain diffs between FILE-ORIG and
+FILE-NEW.  If there is no diff ‘nil’ is returned. Otherwise the
+return is a ‘list’ of lines in the format ‘--lines=:’
+which can be passed directly to ‘clang-format’."
+  ;; Use temporary buffer for output of diff.
+  (with-temp-buffer
+;; We could use diff.el:diff-no-select here. The reason we don't
+;; is diff-no-select requires extra copies on the buffers which
+;; induces noticeable slowdowns, especially on larger files.
+(let ((status (call-process
+   diff-command
+   nil
+   (current-buffer)
+   nil
+   ;; Binary diff has different behaviors that we
+   ;; aren't interested in.
+   "-a"
+   ;; Get minimal diff (copy diff config for git-clang-format).
+   "-U0"
+   file-orig
+   file-new))
+  (stderr (concat (if (zerop (buffer-size)) "" ": ")
+  (buffer-substring-no-properties
+   (point-min) (line-end-position
+  (diff-lines '()))
+  (cond
+   ((stringp status)
+(error "(diff killed by signal %s%s)" status stderr))
+   ;; Return of 0 indicates no diff.
+   ((= status 0) nil)
+   ;; Return of 1 indicates found diffs and no error.
+   ((= status 1)
+;; Find and collect all diff lines.
+;; We are matching something like:
+;; "@@ -80 +80 @@" or "@@ -80,2 +80,2 @@"
+(goto-char (point-min))
+(while (re-search-forward
+"^@@\s-[0-9,]+\s\\+\\([0-9]+\\)\\(,\\([0-9]+\\)\\)?\s@@$"
+nil
+t
+1)
+  (let ((match1 (string-to-number (match-string 1)))
+(match3 (if (match-string 3)

ideasman42 wrote:

Minor point, suggest to use the result of the first `(match-string 3)` call 
instead of throwing the result away & calling again.

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


[clang] [emacs][clang-format] Add elisp API for clang-format on git diffs (PR #112792)

2024-11-17 Thread Campbell Barton via cfe-commits

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


[clang-tools-extra] [clangd] Let DefineOutline tweak handle member function templates (PR #112345)

2024-11-17 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] [clangd] Let DefineOutline tweak handle member function templates (PR #112345)

2024-11-17 Thread Nathan Ridge via cfe-commits

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

LGTM with minor comments addressed

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


[clang-tools-extra] [clangd] Let DefineOutline tweak handle member function templates (PR #112345)

2024-11-17 Thread Nathan Ridge via cfe-commits


@@ -202,7 +218,8 @@ deleteTokensWithKind(const syntax::TokenBuffer &TokBuf, 
tok::TokenKind Kind,
 llvm::Expected
 getFunctionSourceCode(const FunctionDecl *FD, const DeclContext *TargetContext,
   const syntax::TokenBuffer &TokBuf,
-  const HeuristicResolver *Resolver) {
+  const HeuristicResolver *Resolver,
+  bool targetFileIsHeader) {

HighCommander4 wrote:

nit: please use UpperCamelCase per project convention

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


[clang] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits

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


[clang] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits


@@ -249,7 +254,7 @@ static void 
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
   LocalVisitor Visit);
 
 template  static bool isRecordWithAttr(QualType Type) {
-  if (auto *RD = Type->getAsCXXRecordDecl())
+  if (auto *RD = Type.getNonReferenceType()->getAsCXXRecordDecl())

usx95 wrote:

I will remove this for now from this PR and leave the tests with a FIXME. 
Probably needs a separate PR to keep this PR simpler.
It is not possible to do before this PR because I do not have 
non-lifetime_capture_by tests for it.

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


[clang] [compiler-rt] [llvm] Revert "[X86] Support -march=diamondrapids (#113881)" (PR #116563)

2024-11-17 Thread Freddy Ye via cfe-commits

https://github.com/FreddyLeaf created 
https://github.com/llvm/llvm-project/pull/116563

This reverts commit 826b845c9e97448395431be3e4e5da585bd98c5e.


>From e349e24b3e10a44414593252d117bf2936b4bc91 Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Mon, 18 Nov 2024 08:43:26 +0800
Subject: [PATCH] Revert "[X86] Support -march=diamondrapids (#113881)"

This reverts commit 826b845c9e97448395431be3e4e5da585bd98c5e.
---
 clang/docs/ReleaseNotes.rst   |  2 -
 clang/lib/Basic/Targets/X86.cpp   |  2 -
 clang/test/CodeGen/attr-cpuspecific-cpus.c|  1 -
 clang/test/CodeGen/attr-target-mv.c   |  1 -
 clang/test/CodeGen/target-builtin-noerror.c   |  1 -
 clang/test/Driver/x86-march.c |  4 --
 clang/test/Misc/target-invalid-cpu-note/x86.c |  4 --
 .../Preprocessor/predefined-arch-macros.c | 54 ---
 compiler-rt/lib/builtins/cpu_model/x86.c  | 14 -
 llvm/docs/ReleaseNotes.md |  2 -
 .../llvm/TargetParser/X86TargetParser.def |  1 -
 .../llvm/TargetParser/X86TargetParser.h   |  1 -
 llvm/lib/Target/X86/X86.td| 29 --
 llvm/lib/TargetParser/Host.cpp| 13 -
 llvm/lib/TargetParser/X86TargetParser.cpp | 10 
 llvm/test/CodeGen/X86/cpus-intel.ll   |  2 -
 16 files changed, 141 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 044f62e770a7a0..a8830a5658c7da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,8 +769,6 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
-- Supported ``-march/tune=diamondrapids``
-
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 5993257e27d5a9..086b4415412e67 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,7 +667,6 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
-  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1652,7 +1651,6 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
-case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7
diff --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index 1dd095ec9e191f..dd154fd227b25b 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,7 +43,6 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
-ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}
diff --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 6911b55203b7e7..2c4b95ca04370a 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,7 +29,6 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
-int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 0bbd8c3e5ddd81..1e53621bc6b5ae 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,5 +209,4 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
-  (void)__builtin_cpu_is("diamondrapids");
 }
diff --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 341f01c8d668df..3bc2a82ae778d6 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,10 +120,6 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
-// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
-// RUN:   | FileCheck %s -check-prefix=diamondrapids
-// diamondrapids: "-target-cpu" "diamondrapids"
-//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu"

[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`llvm-clang-x86_64-gcc-ubuntu` running on `sie-linux-worker3` while building 
`clang,compiler-rt,llvm` at step 6 "test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Preprocessor/predefined-arch-macros.c' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i386 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
-match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
-match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i386 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 11: not 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i386 -m64 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
-match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ not /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i386 -m64 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
-match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
RUN: at line 16: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i486 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
-match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i486 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
-match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
RUN: at line 25: not 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i486 -m64 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
-match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/FileCheck 
-match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ not /home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i486 -m64 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 30: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/bin/clang 
-march=i586 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/clang/test/Preprocessor/predefined-arch-mac

[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-x86_64-sie-win` 
running on `sie-win-worker` while building `clang,compiler-rt,llvm` at step 7 
"test-build-unified-tree-check-all".

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Preprocessor/predefined-arch-macros.c' 
FAILED 
Exit Code: 1

Command Output (stdout):
--
# RUN: at line 3
z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe -march=i386 -m32 -E -dM 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe -match-full-lines 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe' 
-march=i386 -m32 -E -dM 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -o - -target i386-unknown-linux
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe' 
-match-full-lines 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -check-prefix=CHECK_I386_M32
# RUN: at line 11
not z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe -march=i386 -m64 -E -dM 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe -match-full-lines 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
# executed command: not 'z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe' 
-march=i386 -m64 -E -dM 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -o - -target i386-unknown-linux
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe' 
-match-full-lines 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -check-prefix=CHECK_I386_M64
# RUN: at line 16
z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe -march=i486 -m32 -E -dM 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe -match-full-lines 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe' 
-march=i486 -m32 -E -dM 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -o - -target i386-unknown-linux
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe' 
-match-full-lines 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -check-prefix=CHECK_I486_M32
# RUN: at line 25
not z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe -march=i486 -m64 -E -dM 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe -match-full-lines 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
# executed command: not 'z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe' 
-march=i486 -m64 -E -dM 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -o - -target i386-unknown-linux
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe' 
-match-full-lines 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -check-prefix=CHECK_I486_M64
# RUN: at line 30
z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe -march=i586 -m32 -E -dM 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe -match-full-lines 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c
 -check-prefix=CHECK_I586_M32
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\clang.exe' 
-march=i586 -m32 -E -dM 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -o - -target i386-unknown-linux
# executed command: 'z:\b\llvm-clang-x86_64-sie-win\build\bin\filecheck.exe' 
-match-full-lines 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\Preprocessor\predefined-arch-macros.c'
 -check-prefix=CHEC

[clang] [lld] [llvm] Add _Coroutine unit tests (PR #116561)

2024-11-17 Thread Abdur Javaid via cfe-commits

https://github.com/abdurj created 
https://github.com/llvm/llvm-project/pull/116561

Adds a simple FileCheck test for _Coroutine. For some reason, we broke a 
previous test but we can figure this out later.

## Testing:
`ninja -C build check-clang`

>From ec2e4574378f4b248277789c4951781a7244be6e Mon Sep 17 00:00:00 2001
From: SongRe <49730299+son...@users.noreply.github.com>
Date: Fri, 15 Nov 2024 23:13:45 -0500
Subject: [PATCH 1/2] Add new _Coroutine Keyword  (#1)

* _Coroutine recognized by editor as its own type
---
 .gitignore   |  1 +
 clang/include/clang/AST/Decl.h   |  2 +-
 clang/include/clang/AST/Type.h   |  8 +++-
 clang/include/clang/Basic/Specifiers.h   |  1 +
 clang/include/clang/Basic/TokenKinds.def |  1 +
 clang/include/clang/Sema/DeclSpec.h  |  3 ++-
 clang/lib/AST/Type.cpp   | 11 +++
 clang/lib/Index/USRGeneration.cpp|  3 +++
 clang/lib/Parse/ParseDecl.cpp|  3 +++
 clang/lib/Parse/ParseDeclCXX.cpp | 10 --
 clang/lib/Parse/Parser.cpp   |  1 +
 clang/lib/Sema/DeclSpec.cpp  |  2 ++
 clang/lib/Sema/SemaCodeComplete.cpp  | 12 +++-
 clang/lib/Sema/SemaDecl.cpp  |  8 
 clang/lib/Sema/SemaTemplateVariadic.cpp  |  1 +
 clang/lib/Sema/SemaType.cpp  |  1 +
 clang/utils/ClangVisualizers/clang.natvis|  4 ++--
 lld/test/MachO/compact-unwind-generated.test |  1 +
 llvm/test/tools/opt-viewer/lit.local.cfg |  2 ++
 19 files changed, 67 insertions(+), 8 deletions(-)

diff --git a/.gitignore b/.gitignore
index 0e7c6c79001338..06ad856af2d175 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,3 +71,4 @@ pythonenv*
 /clang/utils/analyzer/projects/*/RefScanBuildResults
 # automodapi puts generated documentation files here.
 /lldb/docs/python_api/
+llvm-project.code-workspace
\ No newline at end of file
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 8c39ef3d5a9fa6..6d5dba6c88c5e8 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -3768,7 +3768,7 @@ class TagDecl : public TypeDecl,
 
   bool isStruct() const { return getTagKind() == TagTypeKind::Struct; }
   bool isInterface() const { return getTagKind() == TagTypeKind::Interface; }
-  bool isClass() const { return getTagKind() == TagTypeKind::Class; }
+  bool isClass() const { return getTagKind() == TagTypeKind::Class || 
getTagKind() == TagTypeKind::Coroutine; }
   bool isUnion() const { return getTagKind() == TagTypeKind::Union; }
   bool isEnum() const { return getTagKind() == TagTypeKind::Enum; }
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1ed5c22361ca68..8bcd6172668b6d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6859,6 +6859,9 @@ enum class ElaboratedTypeKeyword {
   /// \c typename T::type.
   Typename,
 
+  /// The "Coroutine" keyword also introduces elaborated-type specifier
+  Coroutine,
+
   /// No keyword precedes the qualified type name.
   None
 };
@@ -6878,7 +6881,10 @@ enum class TagTypeKind {
   Class,
 
   /// The "enum" keyword.
-  Enum
+  Enum,
+
+  /// The "_Coroutine" keyword.
+  Coroutine
 };
 
 /// A helper class for Type nodes having an ElaboratedTypeKeyword.
diff --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index 9c089908fdc130..d39523cd90a009 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -79,6 +79,7 @@ namespace clang {
 TST_enum,
 TST_union,
 TST_struct,
+TST_coroutine,
 TST_class, // C++ class type
 TST_interface, // C++ (Microsoft-specific) __interface type
 TST_typename,  // Typedef, C++ class-name or enum name, etc.
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 2c692c999bdff5..deac64dca22598 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -336,6 +336,7 @@ KEYWORD(_Atomic , KEYALL|KEYNOOPENCL)
 KEYWORD(_Bool   , KEYNOCXX)
 KEYWORD(_Complex, KEYALL)
 KEYWORD(_Generic, KEYALL)
+KEYWORD(_Coroutine  , KEYALL)
 // Note, C2y removed support for _Imaginary; we retain it as a keyword because
 // 1) it's a reserved identifier, so we're allowed to steal it, 2) there's no
 // good way to specify a keyword in earlier but not later language modes within
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 06243f2624876f..67be14d7ffa539 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -303,6 +303,7 @@ class DeclSpec {
   static const TST TST_struct = clang::TST_struct;
   static const TST TST_interface = clang::T

[clang] [lld] [llvm] Add _Coroutine unit tests (PR #116561)

2024-11-17 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/116561
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] Add _Coroutine unit tests (PR #116561)

2024-11-17 Thread Abdur Javaid via cfe-commits

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


[clang] 90e9223 - Revert "[X86] Support -march=diamondrapids (#113881)" (#116563)

2024-11-17 Thread via cfe-commits

Author: Freddy Ye
Date: 2024-11-18T08:45:28+08:00
New Revision: 90e92239bd0706c44ef4add018c702e53101b253

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

LOG: Revert "[X86] Support -march=diamondrapids (#113881)" (#116563)

This reverts commit 826b845c9e97448395431be3e4e5da585bd98c5e.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Basic/Targets/X86.cpp
clang/test/CodeGen/attr-cpuspecific-cpus.c
clang/test/CodeGen/attr-target-mv.c
clang/test/CodeGen/target-builtin-noerror.c
clang/test/Driver/x86-march.c
clang/test/Misc/target-invalid-cpu-note/x86.c
clang/test/Preprocessor/predefined-arch-macros.c
compiler-rt/lib/builtins/cpu_model/x86.c
llvm/docs/ReleaseNotes.md
llvm/include/llvm/TargetParser/X86TargetParser.def
llvm/include/llvm/TargetParser/X86TargetParser.h
llvm/lib/Target/X86/X86.td
llvm/lib/TargetParser/Host.cpp
llvm/lib/TargetParser/X86TargetParser.cpp
llvm/test/CodeGen/X86/cpus-intel.ll

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 044f62e770a7a0..a8830a5658c7da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,8 +769,6 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
-- Supported ``-march/tune=diamondrapids``
-
 Arm and AArch64 Support
 ^^^
 

diff  --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 5993257e27d5a9..086b4415412e67 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,7 +667,6 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
-  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1652,7 +1651,6 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
-case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7

diff  --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index 1dd095ec9e191f..dd154fd227b25b 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,7 +43,6 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
-ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}

diff  --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 6911b55203b7e7..2c4b95ca04370a 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,7 +29,6 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
-int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {

diff  --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 0bbd8c3e5ddd81..1e53621bc6b5ae 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,5 +209,4 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
-  (void)__builtin_cpu_is("diamondrapids");
 }

diff  --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 341f01c8d668df..3bc2a82ae778d6 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,10 +120,6 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
-// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
-// RUN:   | FileCheck %s -check-prefix=diamondrapids
-// diamondrapids: "-target-cpu" "diamondrapids"
-//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"

diff  --git a/clang/test/Misc/target-invalid-cpu-note/x86.c 
b/clang/test/Misc/target-invalid-cpu-note/x86.c

[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-x86_64-debian-dylib` 
running on `gribozavr4` while building `clang,compiler-rt,llvm` at step 6 
"test-build-unified-tree-check-clang".

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


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

```
Step 6 (test-build-unified-tree-check-clang) failure: test (failure)
 TEST 'Clang :: Preprocessor/predefined-arch-macros.c' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i386 -m32 
-E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i386 -m32 -E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 11: not /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i386 
-m64 -E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ not /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i386 -m64 -E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 16: /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i486 -m32 
-E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i486 -m32 -E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
RUN: at line 25: not /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i486 
-m64 -E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ not /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i486 -m64 -E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
RUN: at line 30: /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i586 -m32 
-E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I586_M32
+ /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i586 -m32 -E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I586_M32
RUN: at line 42: not /b/1/llvm-x86_64-debian-dylib/build/bin/clang -march=i586 
-m64 -E -dM 
/b/1/llvm-x86_64-debian-dylib/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/llvm-x86_64-debian-dylib/build/bin/FileCheck -match-full-lines 
/b/1/llvm-x86_64-debian-dylib/llvm-p

[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`openmp-offload-sles-build-only` running on `rocm-worker-hw-04-sles` while 
building `clang,compiler-rt,llvm` at step 6 "Add check check-clang".

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


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

```
Step 6 (Add check check-clang) failure: test (failure)
 TEST 'Clang :: Preprocessor/predefined-arch-macros.c' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i386 -m32 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-match-full-lines 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i386 -m32 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-match-full-lines 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
RUN: at line 11: not 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i386 -m64 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-match-full-lines 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ not 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i386 -m64 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-match-full-lines 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
RUN: at line 16: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i486 -m32 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-match-full-lines 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-match-full-lines 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ /home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i486 -m32 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 25: not 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i486 -m64 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-match-full-lines 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileCheck 
-match-full-lines 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ not 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i486 -m64 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 30: 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/clang 
-march=i586 -m32 -E -dM 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/botworker/bbot/builds/openmp-offload-sles-build/llvm.build/bin/FileC

[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-x86_64-debian-fast` 
running on `gribozavr4` while building `clang,compiler-rt,llvm` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Preprocessor/predefined-arch-macros.c' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -march=i386 
-m32 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -march=i386 -m32 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
RUN: at line 11: not /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang 
-march=i386 -m64 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ not /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -march=i386 -m64 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
RUN: at line 16: /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -march=i486 
-m32 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -march=i486 -m32 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 25: not /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang 
-march=i486 -m64 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ not /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -march=i486 -m64 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 30: /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -march=i586 
-m32 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I586_M32
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang -march=i586 -m32 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I586_M32
RUN: at line 42: not /b/1/clang-x86_64-debian-fast/llvm.obj/bin/clang 
-march=i586 -m64 -E -dM 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/b/1/clang-x86_64-debian-fast/llvm.obj/bin/FileCheck -match-full-lines 
/b/1/clang-x86_64-debian-fast/llvm.src/clang/test/Preproce

[clang] [compiler-rt] [llvm] Reland "[X86] Support -march=diamondrapids (#113881)" (PR #116564)

2024-11-17 Thread Freddy Ye via cfe-commits

https://github.com/FreddyLeaf created 
https://github.com/llvm/llvm-project/pull/116564

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368


>From 043c82617a6b1aec08915f294b8ede449705b09d Mon Sep 17 00:00:00 2001
From: Freddy Ye 
Date: Mon, 18 Nov 2024 08:47:24 +0800
Subject: [PATCH] Reland "[X86] Support -march=diamondrapids (#113881)"

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368
---
 clang/docs/ReleaseNotes.rst   |  2 +
 clang/lib/Basic/Targets/X86.cpp   |  2 +
 clang/test/CodeGen/attr-cpuspecific-cpus.c|  1 +
 clang/test/CodeGen/attr-target-mv.c   |  1 +
 clang/test/CodeGen/target-builtin-noerror.c   |  1 +
 clang/test/Driver/x86-march.c |  4 ++
 clang/test/Misc/target-invalid-cpu-note/x86.c |  4 ++
 .../Preprocessor/predefined-arch-macros.c | 54 +++
 compiler-rt/lib/builtins/cpu_model/x86.c  | 14 +
 llvm/docs/ReleaseNotes.md |  2 +
 .../llvm/TargetParser/X86TargetParser.def |  1 +
 .../llvm/TargetParser/X86TargetParser.h   |  1 +
 llvm/lib/Target/X86/X86.td| 29 ++
 llvm/lib/TargetParser/Host.cpp| 13 +
 llvm/lib/TargetParser/X86TargetParser.cpp | 10 
 llvm/test/CodeGen/X86/cpus-intel.ll   |  2 +
 16 files changed, 141 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8830a5658c7da..044f62e770a7a0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,6 +769,8 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
+- Supported ``-march/tune=diamondrapids``
+
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 086b4415412e67..5993257e27d5a9 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,6 +667,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
+  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1651,6 +1652,7 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
+case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7
diff --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index dd154fd227b25b..1dd095ec9e191f 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,6 +43,7 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
+ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}
diff --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 2c4b95ca04370a..6911b55203b7e7 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,6 +29,7 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
+int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 1e53621bc6b5ae..0bbd8c3e5ddd81 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,4 +209,5 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
+  (void)__builtin_cpu_is("diamondrapids");
 }
diff --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 3bc2a82ae778d6..341f01c8d668df 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,6 +120,10 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
+// RUN:   | FileCheck %s -check-prefix=diamondrapids
+// diamondrapids: "-target-cpu" "diamondrapids"
+//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"
d

[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Nicolas van Kempen via cfe-commits


@@ -36,221 +36,224 @@ void test(std::string s, std::string_view sv, sub_string 
ss, sub_sub_string sss,
   string_like sl, string_like_camel slc, prefer_underscore_version puv,
   prefer_underscore_version_flip puvf) {
   s.find("a") == 0;
-  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with instead 
of find() == 0
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with instead 
of find == [modernize-use-starts-ends-with]

nicovank wrote:

I wasn't clear, leave previous tests as-is, this PR is not changing the 
diagnostic message. If needed they can be adjusted in separate PR. It's fine 
for them to only match part of the diagnostic for succinctness.

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


[clang] [compiler-rt] [llvm] Reland "[X86] Support -march=diamondrapids (#113881)" (PR #116564)

2024-11-17 Thread Phoebe Wang via cfe-commits

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


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


[clang-tools-extra] [clangd] Let DefineOutline tweak handle member function templates (PR #112345)

2024-11-17 Thread Nathan Ridge via cfe-commits


@@ -130,23 +129,40 @@ getFunctionSourceAfterReplacements(const FunctionDecl *FD,
 return QualifiedFunc.takeError();
 
   std::string TemplatePrefix;
+  auto AddToTemplatePrefixIfApplicable = [&](const Decl *D, bool append) {
+const TemplateParameterList *Params = D->getDescribedTemplateParams();
+if (!Params)
+  return;
+for (Decl *P : *Params) {
+  if (auto *TTP = dyn_cast(P))
+TTP->removeDefaultArgument();
+  else if (auto *NTTP = dyn_cast(P))
+NTTP->removeDefaultArgument();
+  else if (auto *TTPD = dyn_cast(P))
+TTPD->removeDefaultArgument();
+}
+std::string S;
+llvm::raw_string_ostream Stream(S);
+Params->print(Stream, FD->getASTContext());
+if (!S.empty())
+  *S.rbegin() = '\n'; // Replace space with newline
+if (append)
+  TemplatePrefix.append(S);
+else
+  TemplatePrefix.insert(0, S);
+  };
   if (auto *MD = llvm::dyn_cast(FD)) {
 for (const CXXRecordDecl *Parent = MD->getParent(); Parent;
  Parent =
  llvm::dyn_cast_or_null(Parent->getParent())) 
{
-  if (const TemplateParameterList *Params =
-  Parent->getDescribedTemplateParams()) {
-std::string S;
-llvm::raw_string_ostream Stream(S);
-Params->print(Stream, FD->getASTContext());
-if (!S.empty())
-  *S.rbegin() = '\n'; // Replace space with newline
-TemplatePrefix.insert(0, S);
-  }
+  AddToTemplatePrefixIfApplicable(Parent, false);
 }
   }
 
+  AddToTemplatePrefixIfApplicable(FD, true);
   auto Source = QualifiedFunc->substr(FuncBegin, FuncEnd - FuncBegin + 1);

HighCommander4 wrote:

This is really a comment on the pre-existing code, but could you move this 
declaration of `Source` further up, to before `TemplatePrefix`?

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


[clang-tools-extra] [clangd] Let DefineOutline tweak handle member function templates (PR #112345)

2024-11-17 Thread Nathan Ridge via cfe-commits


@@ -130,23 +129,40 @@ getFunctionSourceAfterReplacements(const FunctionDecl *FD,
 return QualifiedFunc.takeError();
 
   std::string TemplatePrefix;
+  auto AddToTemplatePrefixIfApplicable = [&](const Decl *D, bool append) {

HighCommander4 wrote:

nit: UpperCamelCase for `append`

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


[clang] [compiler-rt] [llvm] Revert "[X86] Support -march=diamondrapids (#113881)" (PR #116563)

2024-11-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-backend-x86

Author: Freddy Ye (FreddyLeaf)


Changes

This reverts commit 826b845c9e97448395431be3e4e5da585bd98c5e.


---

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


16 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (-2) 
- (modified) clang/lib/Basic/Targets/X86.cpp (-2) 
- (modified) clang/test/CodeGen/attr-cpuspecific-cpus.c (-1) 
- (modified) clang/test/CodeGen/attr-target-mv.c (-1) 
- (modified) clang/test/CodeGen/target-builtin-noerror.c (-1) 
- (modified) clang/test/Driver/x86-march.c (-4) 
- (modified) clang/test/Misc/target-invalid-cpu-note/x86.c (-4) 
- (modified) clang/test/Preprocessor/predefined-arch-macros.c (-54) 
- (modified) compiler-rt/lib/builtins/cpu_model/x86.c (-14) 
- (modified) llvm/docs/ReleaseNotes.md (-2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (-1) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.h (-1) 
- (modified) llvm/lib/Target/X86/X86.td (-29) 
- (modified) llvm/lib/TargetParser/Host.cpp (-13) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (-10) 
- (modified) llvm/test/CodeGen/X86/cpus-intel.ll (-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 044f62e770a7a0..a8830a5658c7da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,8 +769,6 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
-- Supported ``-march/tune=diamondrapids``
-
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 5993257e27d5a9..086b4415412e67 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,7 +667,6 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
-  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1652,7 +1651,6 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
-case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7
diff --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index 1dd095ec9e191f..dd154fd227b25b 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,7 +43,6 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
-ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}
diff --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 6911b55203b7e7..2c4b95ca04370a 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,7 +29,6 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
-int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 0bbd8c3e5ddd81..1e53621bc6b5ae 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,5 +209,4 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
-  (void)__builtin_cpu_is("diamondrapids");
 }
diff --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 341f01c8d668df..3bc2a82ae778d6 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,10 +120,6 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
-// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
-// RUN:   | FileCheck %s -check-prefix=diamondrapids
-// diamondrapids: "-target-cpu" "diamondrapids"
-//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"
diff --git a/clang/test/Misc/target-invalid-cpu-note/x86.c 
b/clang/test/Misc/target-invalid-cpu-note/x86

[clang] [compiler-rt] [llvm] Revert "[X86] Support -march=diamondrapids (#113881)" (PR #116563)

2024-11-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Freddy Ye (FreddyLeaf)


Changes

This reverts commit 826b845c9e97448395431be3e4e5da585bd98c5e.


---

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


16 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (-2) 
- (modified) clang/lib/Basic/Targets/X86.cpp (-2) 
- (modified) clang/test/CodeGen/attr-cpuspecific-cpus.c (-1) 
- (modified) clang/test/CodeGen/attr-target-mv.c (-1) 
- (modified) clang/test/CodeGen/target-builtin-noerror.c (-1) 
- (modified) clang/test/Driver/x86-march.c (-4) 
- (modified) clang/test/Misc/target-invalid-cpu-note/x86.c (-4) 
- (modified) clang/test/Preprocessor/predefined-arch-macros.c (-54) 
- (modified) compiler-rt/lib/builtins/cpu_model/x86.c (-14) 
- (modified) llvm/docs/ReleaseNotes.md (-2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (-1) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.h (-1) 
- (modified) llvm/lib/Target/X86/X86.td (-29) 
- (modified) llvm/lib/TargetParser/Host.cpp (-13) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (-10) 
- (modified) llvm/test/CodeGen/X86/cpus-intel.ll (-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 044f62e770a7a0..a8830a5658c7da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,8 +769,6 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
-- Supported ``-march/tune=diamondrapids``
-
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 5993257e27d5a9..086b4415412e67 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,7 +667,6 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
-  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1652,7 +1651,6 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
-case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7
diff --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index 1dd095ec9e191f..dd154fd227b25b 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,7 +43,6 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
-ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}
diff --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 6911b55203b7e7..2c4b95ca04370a 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,7 +29,6 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
-int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 0bbd8c3e5ddd81..1e53621bc6b5ae 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,5 +209,4 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
-  (void)__builtin_cpu_is("diamondrapids");
 }
diff --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 341f01c8d668df..3bc2a82ae778d6 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,10 +120,6 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
-// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
-// RUN:   | FileCheck %s -check-prefix=diamondrapids
-// diamondrapids: "-target-cpu" "diamondrapids"
-//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"
diff --git a/clang/test/Misc/target-invalid-cpu-note/x86.c 
b/clang/test/Misc/target-invalid-cpu-note/x8

[clang] [compiler-rt] [llvm] Revert "[X86] Support -march=diamondrapids (#113881)" (PR #116563)

2024-11-17 Thread Freddy Ye via cfe-commits

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


[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `llvm-clang-aarch64-darwin` 
running on `doug-worker-5` while building `clang,compiler-rt,llvm` at step 6 
"test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Preprocessor/predefined-arch-macros.c' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-march=i386 -m32 -E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -march=i386 -m32 
-E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
RUN: at line 11: not 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -march=i386 -m64 
-E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ not /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -march=i386 
-m64 -E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
RUN: at line 16: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-march=i486 -m32 -E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -march=i486 -m32 
-E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
RUN: at line 25: not 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -march=i486 -m64 
-E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ not /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -march=i486 
-m64 -E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
RUN: at line 30: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang 
-march=i586 -m32 -E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck 
-match-full-lines 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I586_M32
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/clang -march=i586 -m32 
-E -dM 
/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/clang/test/Preprocessor/pred

[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `premerge-monolithic-linux` 
running on `premerge-linux-1` while building `clang,compiler-rt,llvm` at step 7 
"test-build-unified-tree-check-all".

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


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

```
Step 7 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Preprocessor/predefined-arch-macros.c' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: /build/buildbot/premerge-monolithic-linux/build/bin/clang 
-march=i386 -m32 -E -dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck -match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -march=i386 -m32 -E 
-dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
-match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
RUN: at line 11: not /build/buildbot/premerge-monolithic-linux/build/bin/clang 
-march=i386 -m64 -E -dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck -match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ not /build/buildbot/premerge-monolithic-linux/build/bin/clang -march=i386 
-m64 -E -dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
-match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
RUN: at line 16: /build/buildbot/premerge-monolithic-linux/build/bin/clang 
-march=i486 -m32 -E -dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck -match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -march=i486 -m32 -E 
-dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
-match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
RUN: at line 25: not /build/buildbot/premerge-monolithic-linux/build/bin/clang 
-march=i486 -m64 -E -dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck -match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck 
-match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ not /build/buildbot/premerge-monolithic-linux/build/bin/clang -march=i486 
-m64 -E -dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 30: /build/buildbot/premerge-monolithic-linux/build/bin/clang 
-march=i586 -m32 -E -dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/build/buildbot/premerge-monolithic-linux/build/bin/FileCheck -match-full-lines 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I586_M32
+ /build/buildbot/premerge-monolithic-linux/build/bin/clang -march=i586 -m32 -E 
-dM 
/build/buildbot/premerge-monolithic-linux/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ /build/buildbot/premerge-monolithic-linux/build/bin/FileCheck

[clang] [compiler-rt] [llvm] Reland "[X86] Support -march=diamondrapids (#113881)" (PR #116564)

2024-11-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Freddy Ye (FreddyLeaf)


Changes

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368


---

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


16 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Basic/Targets/X86.cpp (+2) 
- (modified) clang/test/CodeGen/attr-cpuspecific-cpus.c (+1) 
- (modified) clang/test/CodeGen/attr-target-mv.c (+1) 
- (modified) clang/test/CodeGen/target-builtin-noerror.c (+1) 
- (modified) clang/test/Driver/x86-march.c (+4) 
- (modified) clang/test/Misc/target-invalid-cpu-note/x86.c (+4) 
- (modified) clang/test/Preprocessor/predefined-arch-macros.c (+54) 
- (modified) compiler-rt/lib/builtins/cpu_model/x86.c (+14) 
- (modified) llvm/docs/ReleaseNotes.md (+2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (+1) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.h (+1) 
- (modified) llvm/lib/Target/X86/X86.td (+29) 
- (modified) llvm/lib/TargetParser/Host.cpp (+13) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (+10) 
- (modified) llvm/test/CodeGen/X86/cpus-intel.ll (+2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8830a5658c7da..044f62e770a7a0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,6 +769,8 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
+- Supported ``-march/tune=diamondrapids``
+
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 086b4415412e67..5993257e27d5a9 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,6 +667,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
+  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1651,6 +1652,7 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
+case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7
diff --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index dd154fd227b25b..1dd095ec9e191f 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,6 +43,7 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
+ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}
diff --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 2c4b95ca04370a..6911b55203b7e7 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,6 +29,7 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
+int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 1e53621bc6b5ae..0bbd8c3e5ddd81 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,4 +209,5 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
+  (void)__builtin_cpu_is("diamondrapids");
 }
diff --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 3bc2a82ae778d6..341f01c8d668df 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,6 +120,10 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
+// RUN:   | FileCheck %s -check-prefix=diamondrapids
+// diamondrapids: "-target-cpu" "diamondrapids"
+//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"
diff --git a/clang/test/Misc/target-invalid-cpu-note/x86.c 
b/clang/test/Misc/target-invalid-cpu-note/x86.c
ind

[clang] [compiler-rt] [llvm] Reland "[X86] Support -march=diamondrapids (#113881)" (PR #116564)

2024-11-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Freddy Ye (FreddyLeaf)


Changes

Ref.: https://cdrdv2.intel.com/v1/dl/getContent/671368


---

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


16 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (+2) 
- (modified) clang/lib/Basic/Targets/X86.cpp (+2) 
- (modified) clang/test/CodeGen/attr-cpuspecific-cpus.c (+1) 
- (modified) clang/test/CodeGen/attr-target-mv.c (+1) 
- (modified) clang/test/CodeGen/target-builtin-noerror.c (+1) 
- (modified) clang/test/Driver/x86-march.c (+4) 
- (modified) clang/test/Misc/target-invalid-cpu-note/x86.c (+4) 
- (modified) clang/test/Preprocessor/predefined-arch-macros.c (+54) 
- (modified) compiler-rt/lib/builtins/cpu_model/x86.c (+14) 
- (modified) llvm/docs/ReleaseNotes.md (+2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (+1) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.h (+1) 
- (modified) llvm/lib/Target/X86/X86.td (+29) 
- (modified) llvm/lib/TargetParser/Host.cpp (+13) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (+10) 
- (modified) llvm/test/CodeGen/X86/cpus-intel.ll (+2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a8830a5658c7da..044f62e770a7a0 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,6 +769,8 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
+- Supported ``-march/tune=diamondrapids``
+
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 086b4415412e67..5993257e27d5a9 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,6 +667,7 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
+  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1651,6 +1652,7 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
+case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7
diff --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index dd154fd227b25b..1dd095ec9e191f 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,6 +43,7 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
+ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}
diff --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 2c4b95ca04370a..6911b55203b7e7 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,6 +29,7 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
+int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 1e53621bc6b5ae..0bbd8c3e5ddd81 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,4 +209,5 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
+  (void)__builtin_cpu_is("diamondrapids");
 }
diff --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 3bc2a82ae778d6..341f01c8d668df 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,6 +120,10 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
+// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
+// RUN:   | FileCheck %s -check-prefix=diamondrapids
+// diamondrapids: "-target-cpu" "diamondrapids"
+//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"
diff --git a/clang/test/Misc/target-invalid-cpu-note/x86.c 
b/clang/test/Misc/target-invalid-cpu-note/x86.c
index 7879

[clang] [compiler-rt] [llvm] Revert "[X86] Support -march=diamondrapids (#113881)" (PR #116563)

2024-11-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Freddy Ye (FreddyLeaf)


Changes

This reverts commit 826b845c9e97448395431be3e4e5da585bd98c5e.


---

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


16 Files Affected:

- (modified) clang/docs/ReleaseNotes.rst (-2) 
- (modified) clang/lib/Basic/Targets/X86.cpp (-2) 
- (modified) clang/test/CodeGen/attr-cpuspecific-cpus.c (-1) 
- (modified) clang/test/CodeGen/attr-target-mv.c (-1) 
- (modified) clang/test/CodeGen/target-builtin-noerror.c (-1) 
- (modified) clang/test/Driver/x86-march.c (-4) 
- (modified) clang/test/Misc/target-invalid-cpu-note/x86.c (-4) 
- (modified) clang/test/Preprocessor/predefined-arch-macros.c (-54) 
- (modified) compiler-rt/lib/builtins/cpu_model/x86.c (-14) 
- (modified) llvm/docs/ReleaseNotes.md (-2) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.def (-1) 
- (modified) llvm/include/llvm/TargetParser/X86TargetParser.h (-1) 
- (modified) llvm/lib/Target/X86/X86.td (-29) 
- (modified) llvm/lib/TargetParser/Host.cpp (-13) 
- (modified) llvm/lib/TargetParser/X86TargetParser.cpp (-10) 
- (modified) llvm/test/CodeGen/X86/cpus-intel.ll (-2) 


``diff
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 044f62e770a7a0..a8830a5658c7da 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -769,8 +769,6 @@ X86 Support
 - Support ISA of ``AMX-TF32``.
 - Support ISA of ``MOVRS``.
 
-- Supported ``-march/tune=diamondrapids``
-
 Arm and AArch64 Support
 ^^^
 
diff --git a/clang/lib/Basic/Targets/X86.cpp b/clang/lib/Basic/Targets/X86.cpp
index 5993257e27d5a9..086b4415412e67 100644
--- a/clang/lib/Basic/Targets/X86.cpp
+++ b/clang/lib/Basic/Targets/X86.cpp
@@ -667,7 +667,6 @@ void X86TargetInfo::getTargetDefines(const LangOptions 
&Opts,
   case CK_GraniterapidsD:
   case CK_Emeraldrapids:
   case CK_Clearwaterforest:
-  case CK_Diamondrapids:
 // FIXME: Historically, we defined this legacy name, it would be nice to
 // remove it at some point. We've never exposed fine-grained names for
 // recent primary x86 CPUs, and we should keep it that way.
@@ -1652,7 +1651,6 @@ std::optional 
X86TargetInfo::getCPUCacheLineSize() const {
 case CK_GraniterapidsD:
 case CK_Emeraldrapids:
 case CK_Clearwaterforest:
-case CK_Diamondrapids:
 case CK_KNL:
 case CK_KNM:
 // K7
diff --git a/clang/test/CodeGen/attr-cpuspecific-cpus.c 
b/clang/test/CodeGen/attr-cpuspecific-cpus.c
index 1dd095ec9e191f..dd154fd227b25b 100644
--- a/clang/test/CodeGen/attr-cpuspecific-cpus.c
+++ b/clang/test/CodeGen/attr-cpuspecific-cpus.c
@@ -43,7 +43,6 @@ ATTR(cpu_specific(icelake_client)) void CPU(void){}
 ATTR(cpu_specific(tigerlake)) void CPU(void){}
 ATTR(cpu_specific(alderlake)) void CPU(void){}
 ATTR(cpu_specific(sapphirerapids)) void CPU(void){}
-ATTR(cpu_specific(diamondrapids)) void CPU(void){}
 
 // ALIAS CPUs
 ATTR(cpu_specific(pentium_iii_no_xmm_regs)) void CPU0(void){}
diff --git a/clang/test/CodeGen/attr-target-mv.c 
b/clang/test/CodeGen/attr-target-mv.c
index 6911b55203b7e7..2c4b95ca04370a 100644
--- a/clang/test/CodeGen/attr-target-mv.c
+++ b/clang/test/CodeGen/attr-target-mv.c
@@ -29,7 +29,6 @@ int __attribute__((target("arch=lunarlake"))) foo(void) 
{return 23;}
 int __attribute__((target("arch=gracemont"))) foo(void) {return 24;}
 int __attribute__((target("arch=pantherlake"))) foo(void) {return 25;}
 int __attribute__((target("arch=clearwaterforest"))) foo(void) {return 26;}
-int __attribute__((target("arch=diamondrapids"))) foo(void) {return 27;}
 int __attribute__((target("default"))) foo(void) { return 2; }
 
 int bar(void) {
diff --git a/clang/test/CodeGen/target-builtin-noerror.c 
b/clang/test/CodeGen/target-builtin-noerror.c
index 0bbd8c3e5ddd81..1e53621bc6b5ae 100644
--- a/clang/test/CodeGen/target-builtin-noerror.c
+++ b/clang/test/CodeGen/target-builtin-noerror.c
@@ -209,5 +209,4 @@ void verifycpustrings(void) {
   (void)__builtin_cpu_is("znver3");
   (void)__builtin_cpu_is("znver4");
   (void)__builtin_cpu_is("znver5");
-  (void)__builtin_cpu_is("diamondrapids");
 }
diff --git a/clang/test/Driver/x86-march.c b/clang/test/Driver/x86-march.c
index 341f01c8d668df..3bc2a82ae778d6 100644
--- a/clang/test/Driver/x86-march.c
+++ b/clang/test/Driver/x86-march.c
@@ -120,10 +120,6 @@
 // RUN:   | FileCheck %s -check-prefix=clearwaterforest
 // clearwaterforest: "-target-cpu" "clearwaterforest"
 //
-// RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=diamondrapids 
2>&1 \
-// RUN:   | FileCheck %s -check-prefix=diamondrapids
-// diamondrapids: "-target-cpu" "diamondrapids"
-//
 // RUN: %clang -target x86_64-unknown-unknown -c -### %s -march=lakemont 2>&1 \
 // RUN:   | FileCheck %s -check-prefix=lakemont
 // lakemont: "-target-cpu" "lakemont"
diff --git a/clang/test/Misc/target-invalid-cpu-note/x86.c 
b/clang/test/Misc/target-invalid-cpu-note/x86.c
ind

[clang] [lld] [llvm] Add _Coroutine unit tests (PR #116561)

2024-11-17 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-lld-macho

@llvm/pr-subscribers-clang

Author: Abdur Javaid (abdurj)


Changes

Adds a simple FileCheck test for _Coroutine. For some reason, we broke a 
previous test but we can figure this out later.

## Testing:
`ninja -C build check-clang`

---

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


21 Files Affected:

- (modified) .gitignore (+1) 
- (modified) clang/include/clang/AST/Decl.h (+1-1) 
- (modified) clang/include/clang/AST/Type.h (+7-1) 
- (modified) clang/include/clang/Basic/Specifiers.h (+1) 
- (modified) clang/include/clang/Basic/TokenKinds.def (+1) 
- (modified) clang/include/clang/Sema/DeclSpec.h (+2-1) 
- (modified) clang/lib/AST/Type.cpp (+11) 
- (modified) clang/lib/Index/USRGeneration.cpp (+3) 
- (modified) clang/lib/Parse/ParseDecl.cpp (+3) 
- (modified) clang/lib/Parse/ParseDeclCXX.cpp (+8-2) 
- (modified) clang/lib/Parse/Parser.cpp (+1) 
- (modified) clang/lib/Sema/DeclSpec.cpp (+2) 
- (modified) clang/lib/Sema/SemaCodeComplete.cpp (+11-1) 
- (modified) clang/lib/Sema/SemaDecl.cpp (+8) 
- (modified) clang/lib/Sema/SemaTemplateVariadic.cpp (+1) 
- (modified) clang/lib/Sema/SemaType.cpp (+1) 
- (modified) clang/test/CodeCompletion/ordinary-name-cxx11.cpp (+1-1) 
- (modified) clang/test/CodeCompletion/ordinary-name.cpp (+1-1) 
- (modified) clang/utils/ClangVisualizers/clang.natvis (+2-2) 
- (modified) lld/test/MachO/compact-unwind-generated.test (+1) 
- (modified) llvm/test/tools/opt-viewer/lit.local.cfg (+2) 


``diff
diff --git a/.gitignore b/.gitignore
index 0e7c6c79001338..06ad856af2d175 100644
--- a/.gitignore
+++ b/.gitignore
@@ -71,3 +71,4 @@ pythonenv*
 /clang/utils/analyzer/projects/*/RefScanBuildResults
 # automodapi puts generated documentation files here.
 /lldb/docs/python_api/
+llvm-project.code-workspace
\ No newline at end of file
diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h
index 8c39ef3d5a9fa6..6d5dba6c88c5e8 100644
--- a/clang/include/clang/AST/Decl.h
+++ b/clang/include/clang/AST/Decl.h
@@ -3768,7 +3768,7 @@ class TagDecl : public TypeDecl,
 
   bool isStruct() const { return getTagKind() == TagTypeKind::Struct; }
   bool isInterface() const { return getTagKind() == TagTypeKind::Interface; }
-  bool isClass() const { return getTagKind() == TagTypeKind::Class; }
+  bool isClass() const { return getTagKind() == TagTypeKind::Class || 
getTagKind() == TagTypeKind::Coroutine; }
   bool isUnion() const { return getTagKind() == TagTypeKind::Union; }
   bool isEnum() const { return getTagKind() == TagTypeKind::Enum; }
 
diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 1ed5c22361ca68..8bcd6172668b6d 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -6859,6 +6859,9 @@ enum class ElaboratedTypeKeyword {
   /// \c typename T::type.
   Typename,
 
+  /// The "Coroutine" keyword also introduces elaborated-type specifier
+  Coroutine,
+
   /// No keyword precedes the qualified type name.
   None
 };
@@ -6878,7 +6881,10 @@ enum class TagTypeKind {
   Class,
 
   /// The "enum" keyword.
-  Enum
+  Enum,
+
+  /// The "_Coroutine" keyword.
+  Coroutine
 };
 
 /// A helper class for Type nodes having an ElaboratedTypeKeyword.
diff --git a/clang/include/clang/Basic/Specifiers.h 
b/clang/include/clang/Basic/Specifiers.h
index 9c089908fdc130..d39523cd90a009 100644
--- a/clang/include/clang/Basic/Specifiers.h
+++ b/clang/include/clang/Basic/Specifiers.h
@@ -79,6 +79,7 @@ namespace clang {
 TST_enum,
 TST_union,
 TST_struct,
+TST_coroutine,
 TST_class, // C++ class type
 TST_interface, // C++ (Microsoft-specific) __interface type
 TST_typename,  // Typedef, C++ class-name or enum name, etc.
diff --git a/clang/include/clang/Basic/TokenKinds.def 
b/clang/include/clang/Basic/TokenKinds.def
index 2c692c999bdff5..deac64dca22598 100644
--- a/clang/include/clang/Basic/TokenKinds.def
+++ b/clang/include/clang/Basic/TokenKinds.def
@@ -336,6 +336,7 @@ KEYWORD(_Atomic , KEYALL|KEYNOOPENCL)
 KEYWORD(_Bool   , KEYNOCXX)
 KEYWORD(_Complex, KEYALL)
 KEYWORD(_Generic, KEYALL)
+KEYWORD(_Coroutine  , KEYALL)
 // Note, C2y removed support for _Imaginary; we retain it as a keyword because
 // 1) it's a reserved identifier, so we're allowed to steal it, 2) there's no
 // good way to specify a keyword in earlier but not later language modes within
diff --git a/clang/include/clang/Sema/DeclSpec.h 
b/clang/include/clang/Sema/DeclSpec.h
index 06243f2624876f..67be14d7ffa539 100644
--- a/clang/include/clang/Sema/DeclSpec.h
+++ b/clang/include/clang/Sema/DeclSpec.h
@@ -303,6 +303,7 @@ class DeclSpec {
   static const TST TST_struct = clang::TST_struct;
   static const TST TST_interface = clang::TST_interface;
   static const TST TST_class = clang::TST_cl

[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread Freddy Ye via cfe-commits

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


[clang] [compiler-rt] [llvm] [X86] Support -march=diamondrapids (PR #113881)

2024-11-17 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`llvm-clang-x86_64-sie-ubuntu-fast` running on `sie-linux-worker` while 
building `clang,compiler-rt,llvm` at step 6 "test-build-unified-tree-check-all".

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


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

```
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
 TEST 'Clang :: Preprocessor/predefined-arch-macros.c' 
FAILED 
Exit Code: 1

Command Output (stderr):
--
RUN: at line 3: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-march=i386 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 -match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-march=i386 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 -match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M32
RUN: at line 11: not 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-march=i386 -m64 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 -match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 -match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I386_M64
+ not 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-march=i386 -m64 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
RUN: at line 16: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-march=i486 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 -match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-march=i486 -m32 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 -match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M32
RUN: at line 25: not 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-march=i486 -m64 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - 2>&1  -target i386-unknown-linux| 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 -match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
+ not 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/clang 
-march=i486 -m64 -E -dM 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -o - -target i386-unknown-linux
+ 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/build/bin/FileCheck
 -match-full-lines 
/home/buildbot/buildbot-root/llvm-clang-x86_64-sie-ubuntu-fast/llvm-project/clang/test/Preprocessor/predefined-arch-macros.c
 -check-prefix=CHECK_I486_M64
RUN: at line 30: 
/home/buildbot/buildbot-root/llvm-clang-x

[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Congcong Cai via cfe-commits


@@ -30,6 +30,17 @@ struct NotLengthExprForStringNode {
IntegerLiteralSizeNode->getValue().getZExtValue();
   }
 
+  if (const auto *DeclRefNode = Node.get()) {

HerrCai0907 wrote:

llvm code guideline wants to ignore `{}` for `if` / `for` with single statement 
in body.

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 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 5845688e91d85d46c0f47daaf4edfdfc772853cf 
23b4bcdf52041aad1c5581e0f7dc01028770a154 --extensions h,cpp -- 
clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.h 
clang-tools-extra/test/clang-tidy/checkers/modernize/use-starts-ends-with.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
index 12ff31dfa0..6aabbf809d 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.cpp
@@ -187,16 +187,15 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   cxxOperatorCallExpr(
   hasAnyOperatorName("==", "!="),
   anyOf(
-  hasOperands(
-  cxxMemberCallExpr(
-  argumentCountIs(2), hasArgument(0, ZeroLiteral),
-  hasArgument(1, lengthExprForStringNode("needle")),
-  callee(
-  cxxMethodDecl(hasName("substr"),
-ofClass(OnClassWithStartsWithFunction))
-  .bind("find_fun")))
-  .bind("find_expr"),
-  expr().bind("needle")),
+  hasOperands(cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, 
lengthExprForStringNode("needle")),
+  callee(cxxMethodDecl(
+ hasName("substr"),
+ 
ofClass(OnClassWithStartsWithFunction))
+ .bind("find_fun")))
+  .bind("find_expr"),
+  expr().bind("needle")),
   hasOperands(expr().bind("needle"),
   cxxMemberCallExpr(
   argumentCountIs(2), hasArgument(0, ZeroLiteral),
@@ -210,31 +209,31 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
   this);
 }
 
-bool UseStartsEndsWithCheck::isNegativeComparison(const Expr* ComparisonExpr) {
+bool UseStartsEndsWithCheck::isNegativeComparison(const Expr *ComparisonExpr) {
   // Handle direct != operator
   if (const auto *BO = llvm::dyn_cast(ComparisonExpr)) {
 return BO->getOpcode() == BO_NE;
   }
-  
+
   // Handle operator!= call
   if (const auto *Op = llvm::dyn_cast(ComparisonExpr)) {
 return Op->getOperator() == OO_ExclaimEqual;
   }
-  
+
   // Handle rewritten !(expr == expr)
   if (const auto *UO = llvm::dyn_cast(ComparisonExpr)) {
 if (UO->getOpcode() == UO_LNot) {
-  if (const auto *InnerBO = 
-  llvm::dyn_cast(UO->getSubExpr()->IgnoreParens())) {
+  if (const auto *InnerBO = llvm::dyn_cast(
+  UO->getSubExpr()->IgnoreParens())) {
 return InnerBO->getOpcode() == BO_EQ;
   }
-  if (const auto *InnerOp = 
-  
llvm::dyn_cast(UO->getSubExpr()->IgnoreParens())) {
+  if (const auto *InnerOp = llvm::dyn_cast(
+  UO->getSubExpr()->IgnoreParens())) {
 return InnerOp->getOperator() == OO_EqualEqual;
   }
 }
   }
-  
+
   return false;
 }
 
diff --git a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.h 
b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.h
index 9a19206847..be2bddbf19 100644
--- a/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.h
+++ b/clang-tools-extra/clang-tidy/modernize/UseStartsEndsWithCheck.h
@@ -25,7 +25,7 @@ public:
   UseStartsEndsWithCheck(StringRef Name, ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
-  bool isNegativeComparison(const Expr* ComparisonExpr);
+  bool isNegativeComparison(const Expr *ComparisonExpr);
   bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
 return LangOpts.CPlusPlus;
   }

``




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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Congcong Cai via cfe-commits

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

LGTM. Thanks!

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Congcong Cai via cfe-commits


@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
  hasRHS(lengthExprForStringNode("needle")
   .bind("expr"),
   this);
+
+  Finder->addMatcher(
+  cxxOperatorCallExpr(
+  hasAnyOperatorName("==", "!="),
+  anyOf(
+  hasOperands(
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, lengthExprForStringNode("needle")),
+  callee(
+  cxxMethodDecl(hasName("substr"),
+ofClass(OnClassWithStartsWithFunction))
+  .bind("find_fun")))
+  .bind("find_expr"),
+  expr().bind("needle")),
+  hasOperands(expr().bind("needle"),
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, 
lengthExprForStringNode("needle")),
+  callee(cxxMethodDecl(
+ hasName("substr"),
+ 
ofClass(OnClassWithStartsWithFunction))
+ .bind("find_fun")))
+  .bind("find_expr"
+  .bind("expr"),
+  this);
+}
+
+bool UseStartsEndsWithCheck::isNegativeComparison(const Expr* ComparisonExpr) {

HerrCai0907 wrote:

This function don't need to be exposed. it could be static function instead of 
class method to save the build time.

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Congcong Cai via cfe-commits


@@ -266,3 +269,53 @@ void test(std::string s, std::string_view sv, sub_string 
ss, sub_sub_string sss,
   s.compare(0, 1, "ab") == 0;
   s.rfind(suffix, 1) == s.size() - suffix.size();
 }
+
+void test_substr() {
+std::string str("hello world");
+std::string prefix = "hello";
+
+// Basic pattern
+str.substr(0, 5) == "hello";
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+// CHECK-FIXES: str.starts_with("hello");
+
+// With string literal on left side
+"hello" == str.substr(0, 5);
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+// CHECK-FIXES: str.starts_with("hello");
+
+// Inequality comparison
+str.substr(0, 5) != "world";
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr != [modernize-use-starts-ends-with]
+// CHECK-FIXES: !str.starts_with("world");
+
+// Ensure non-zero start position is not transformed
+str.substr(1, 5) == "hello";
+str.substr(0, 4) == "hello"; // Length mismatch
+
+size_t len = 5;
+str.substr(0, len) == "hello"; // Non-constant length
+
+// String literal with size calculation
+str.substr(0, strlen("hello")) == "hello";
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+// CHECK-FIXES: str.starts_with("hello");
+
+str.substr(0, prefix.size()) == prefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+// CHECK-FIXES: str.starts_with(prefix);
+
+  // Tests to verify macro behavior
+#define STARTS_WITH(X, Y) (X).substr(0, (Y).size()) == (Y)
+STARTS_WITH(str, prefix);
+
+#define SUBSTR(X, A, B) (X).substr((A), (B))
+SUBSTR(str, 0, 6) == "prefix";
+
+#define STR() str
+SUBSTR(STR(), 0, 6) == "prefix";
+
+"prefix" == SUBSTR(STR(), 0, 6);
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]

HerrCai0907 wrote:

You can try to check whether fixhint location is invalid.

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


[clang] [TargetVersion] Only enable on RISC-V and AArch64 (PR #115991)

2024-11-17 Thread Piyou Chen via cfe-commits

https://github.com/BeMg updated https://github.com/llvm/llvm-project/pull/115991

>From 28f7a2adc055ec6f30790e1e9535c71241a08e29 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Tue, 12 Nov 2024 20:56:47 -0800
Subject: [PATCH 1/6] [TargetVersion] Only enable on RISC-V and AArch64

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td | 2 ++
 clang/lib/Sema/SemaDeclAttr.cpp  | 5 +
 2 files changed, 7 insertions(+)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 509d45c0867590..6170c3c10b00ca 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3282,6 +3282,8 @@ def warn_unsupported_target_attribute
   "attribute string; 
'%select{target|target_clones|target_version}3' "
   "attribute ignored">,
   InGroup;
+def err_target_version_unsupported
+: Error<"target_version attribute is not supported in this target">;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported on targets missing %1;"
 " specify an appropriate -march= or -mcpu=">;
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index d05d326178e1b8..e2eaa00c666fc2 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -3040,6 +3040,11 @@ bool Sema::checkTargetVersionAttr(SourceLocation 
LiteralLoc, Decl *D,
   enum FirstParam { Unsupported };
   enum SecondParam { None };
   enum ThirdParam { Target, TargetClones, TargetVersion };
+
+  if (!Context.getTargetInfo().getTriple().isRISCV() &&
+  !Context.getTargetInfo().getTriple().isAArch64())
+return Diag(LiteralLoc, diag::err_target_version_unsupported);
+
   llvm::SmallVector Features;
   if (Context.getTargetInfo().getTriple().isRISCV()) {
 llvm::SmallVector AttrStrs;

>From 5355896434206bce33ff2442189aaff4d6b605ad Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Wed, 13 Nov 2024 22:25:05 -0800
Subject: [PATCH 2/6] Add testcase

---
 clang/test/Sema/attr-target-version-unsupported.c | 4 
 1 file changed, 4 insertions(+)
 create mode 100644 clang/test/Sema/attr-target-version-unsupported.c

diff --git a/clang/test/Sema/attr-target-version-unsupported.c 
b/clang/test/Sema/attr-target-version-unsupported.c
new file mode 100644
index 00..7a868e4085f20e
--- /dev/null
+++ b/clang/test/Sema/attr-target-version-unsupported.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown  -fsyntax-only -verify %s
+
+//expected-error@+1 {{target_version attribute is not supported in this 
target}}
+int __attribute__((target_version("aes"))) foo(void) { return 3; }

>From 659b628a12e05610ff82421dd358292c53940e93 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Wed, 13 Nov 2024 22:28:30 -0800
Subject: [PATCH 3/6] in this target -> on this target

---
 clang/include/clang/Basic/DiagnosticSemaKinds.td  | 2 +-
 clang/test/Sema/attr-target-version-unsupported.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 6170c3c10b00ca..0e3e8f90e52252 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3283,7 +3283,7 @@ def warn_unsupported_target_attribute
   "attribute ignored">,
   InGroup;
 def err_target_version_unsupported
-: Error<"target_version attribute is not supported in this target">;
+: Error<"target_version attribute is not supported on this target">;
 def err_attribute_unsupported
 : Error<"%0 attribute is not supported on targets missing %1;"
 " specify an appropriate -march= or -mcpu=">;
diff --git a/clang/test/Sema/attr-target-version-unsupported.c 
b/clang/test/Sema/attr-target-version-unsupported.c
index 7a868e4085f20e..056cbd25bd90d4 100644
--- a/clang/test/Sema/attr-target-version-unsupported.c
+++ b/clang/test/Sema/attr-target-version-unsupported.c
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 -triple x86_64-unknown-unknown  -fsyntax-only -verify %s
 
-//expected-error@+1 {{target_version attribute is not supported in this 
target}}
+//expected-error@+1 {{target_version attribute is not supported on this 
target}}
 int __attribute__((target_version("aes"))) foo(void) { return 3; }

>From 5f7a3ebe81f2dc6af7d558d012d8d05543fa7115 Mon Sep 17 00:00:00 2001
From: Piyou Chen 
Date: Thu, 14 Nov 2024 22:34:18 -0800
Subject: [PATCH 4/6] Using the TargetSpecificAttr instead of InheritableAttr

---
 clang/include/clang/Basic/Attr.td | 2 +-
 clang/include/clang/Basic/DiagnosticSemaKinds.td  | 2 --
 clang/lib/Sema/SemaDeclAttr.cpp   | 4 
 clang/test/Sema/attr-target-version-unsupported.c | 2 +-
 4 files changed, 2 insertions(+), 8 deletions(-)

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index a631e81d40aa68

[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Nicolas van Kempen via cfe-commits


@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
  hasRHS(lengthExprForStringNode("needle")
   .bind("expr"),
   this);
+
+  Finder->addMatcher(
+  cxxOperatorCallExpr(
+  hasAnyOperatorName("==", "!="),
+  anyOf(
+  hasOperands(
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, lengthExprForStringNode("needle")),
+  callee(
+  cxxMethodDecl(hasName("substr"),
+ofClass(OnClassWithStartsWithFunction))
+  .bind("find_fun")))
+  .bind("find_expr"),
+  expr().bind("needle")),
+  hasOperands(expr().bind("needle"),
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, 
lengthExprForStringNode("needle")),
+  callee(cxxMethodDecl(
+ hasName("substr"),
+ 
ofClass(OnClassWithStartsWithFunction))
+ .bind("find_fun")))
+  .bind("find_expr"
+  .bind("expr"),
+  this);

nicovank wrote:

`hasOperands` already does this "one way or the other" commutative logic. In 
fact here, `expr().bind("needle")` needs to be first, because then we use the 
binding for the second operand (`lengthExprForStringNode("needle")`). The other 
option would never yield a match.

```suggestion
Finder->addMatcher(
cxxOperatorCallExpr(
hasAnyOperatorName("==", "!="),
hasOperands(
expr().bind("needle"),
cxxMemberCallExpr(
argumentCountIs(2), hasArgument(0, ZeroLiteral),
hasArgument(1, lengthExprForStringNode("needle")),
callee(cxxMethodDecl(hasName("substr"),
 ofClass(OnClassWithStartsWithFunction))
   .bind("find_fun")))
.bind("find_expr")))
.bind("expr"),
this);
```

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Nicolas van Kempen via cfe-commits

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


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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Nicolas van Kempen via cfe-commits


@@ -25,6 +25,7 @@ class UseStartsEndsWithCheck : public ClangTidyCheck {
   UseStartsEndsWithCheck(StringRef Name, ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  bool isNegativeComparison(const Expr* ComparisonExpr);

nicovank wrote:

Function should be static in `.cpp` file at top of file.
```suggestion
```

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Nicolas van Kempen via cfe-commits


@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
  hasRHS(lengthExprForStringNode("needle")
   .bind("expr"),
   this);
+
+  Finder->addMatcher(
+  cxxOperatorCallExpr(
+  hasAnyOperatorName("==", "!="),
+  anyOf(
+  hasOperands(
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, lengthExprForStringNode("needle")),
+  callee(
+  cxxMethodDecl(hasName("substr"),
+ofClass(OnClassWithStartsWithFunction))
+  .bind("find_fun")))
+  .bind("find_expr"),
+  expr().bind("needle")),
+  hasOperands(expr().bind("needle"),
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, 
lengthExprForStringNode("needle")),
+  callee(cxxMethodDecl(
+ hasName("substr"),
+ 
ofClass(OnClassWithStartsWithFunction))
+ .bind("find_fun")))
+  .bind("find_expr"
+  .bind("expr"),
+  this);
+}
+
+bool UseStartsEndsWithCheck::isNegativeComparison(const Expr* ComparisonExpr) {
+  // Handle direct != operator

nicovank wrote:

Comments are misleading IMO, in fact every operator handled here is `!=`, just 
under different AST nodes. I think just remove the comments, it's pretty clear 
with the casting what's happening.

```suggestion
```

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Nicolas van Kempen via cfe-commits


@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
  hasRHS(lengthExprForStringNode("needle")
   .bind("expr"),
   this);
+
+  Finder->addMatcher(
+  cxxOperatorCallExpr(
+  hasAnyOperatorName("==", "!="),
+  anyOf(
+  hasOperands(
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, lengthExprForStringNode("needle")),
+  callee(
+  cxxMethodDecl(hasName("substr"),
+ofClass(OnClassWithStartsWithFunction))
+  .bind("find_fun")))
+  .bind("find_expr"),
+  expr().bind("needle")),
+  hasOperands(expr().bind("needle"),
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, 
lengthExprForStringNode("needle")),
+  callee(cxxMethodDecl(
+ hasName("substr"),
+ 
ofClass(OnClassWithStartsWithFunction))
+ .bind("find_fun")))
+  .bind("find_expr"
+  .bind("expr"),
+  this);
+}
+
+bool UseStartsEndsWithCheck::isNegativeComparison(const Expr* ComparisonExpr) {
+  // Handle direct != operator
+  if (const auto *BO = llvm::dyn_cast(ComparisonExpr)) {
+return BO->getOpcode() == BO_NE;
+  }
+  
+  // Handle operator!= call
+  if (const auto *Op = llvm::dyn_cast(ComparisonExpr)) {
+return Op->getOperator() == OO_ExclaimEqual;
+  }
+  
+  // Handle rewritten !(expr == expr)
+  if (const auto *UO = llvm::dyn_cast(ComparisonExpr)) {
+if (UO->getOpcode() == UO_LNot) {
+  if (const auto *InnerBO = 
+  llvm::dyn_cast(UO->getSubExpr()->IgnoreParens())) {
+return InnerBO->getOpcode() == BO_EQ;
+  }
+  if (const auto *InnerOp = 
+  
llvm::dyn_cast(UO->getSubExpr()->IgnoreParens())) {
+return InnerOp->getOperator() == OO_EqualEqual;
+  }
+}
+  }
+  

nicovank wrote:

This will never happen anyway because the matcher specifically matches 
`cxxOperatorCallExpr` or `binaryOperator`. Tomorrow I'll write a test case that 
triggers the `CXXRewrittenBinaryOperator` case I mentioned. IMO it is okay to 
make this change in a subsequent PR if it turns out there are false negatives.

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Nicolas van Kempen via cfe-commits


@@ -171,10 +182,64 @@ void UseStartsEndsWithCheck::registerMatchers(MatchFinder 
*Finder) {
  hasRHS(lengthExprForStringNode("needle")
   .bind("expr"),
   this);
+
+  Finder->addMatcher(
+  cxxOperatorCallExpr(
+  hasAnyOperatorName("==", "!="),
+  anyOf(
+  hasOperands(
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, lengthExprForStringNode("needle")),
+  callee(
+  cxxMethodDecl(hasName("substr"),
+ofClass(OnClassWithStartsWithFunction))
+  .bind("find_fun")))
+  .bind("find_expr"),
+  expr().bind("needle")),
+  hasOperands(expr().bind("needle"),
+  cxxMemberCallExpr(
+  argumentCountIs(2), hasArgument(0, ZeroLiteral),
+  hasArgument(1, 
lengthExprForStringNode("needle")),
+  callee(cxxMethodDecl(
+ hasName("substr"),
+ 
ofClass(OnClassWithStartsWithFunction))
+ .bind("find_fun")))
+  .bind("find_expr"
+  .bind("expr"),
+  this);
+}
+
+bool UseStartsEndsWithCheck::isNegativeComparison(const Expr* ComparisonExpr) {
+  // Handle direct != operator
+  if (const auto *BO = llvm::dyn_cast(ComparisonExpr)) {
+return BO->getOpcode() == BO_NE;
+  }
+  
+  // Handle operator!= call

nicovank wrote:

```suggestion
```

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Nicolas van Kempen via cfe-commits


@@ -30,6 +30,17 @@ struct NotLengthExprForStringNode {
IntegerLiteralSizeNode->getValue().getZExtValue();
   }
 
+  if (const auto *DeclRefNode = Node.get()) {
+if (const auto *VD = dyn_cast(DeclRefNode->getDecl())) {
+  if (VD->hasInit() && VD->getType().isConstQualified()) {
+if (const auto *Init = dyn_cast(VD->getInit())) {
+  return StringLiteralNode->getLength() !=
+ Init->getValue().getZExtValue();
+}
+  }
+}
+  }
+

nicovank wrote:

I'm not sure exactly, what case is this adding? IMO changing 
`lengthExprForStringNode` can/should happen in subsequent PR; it affects 
existing `compare`/`find`/`rfind` branches as well.

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


[clang-tools-extra] [clang-tidy] Enhance modernize-use-starts-ends-with to handle substr patterns (PR #116033)

2024-11-17 Thread Congcong Cai via cfe-commits


@@ -266,3 +269,53 @@ void test(std::string s, std::string_view sv, sub_string 
ss, sub_sub_string sss,
   s.compare(0, 1, "ab") == 0;
   s.rfind(suffix, 1) == s.size() - suffix.size();
 }
+
+void test_substr() {
+std::string str("hello world");
+std::string prefix = "hello";
+
+// Basic pattern
+str.substr(0, 5) == "hello";
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+// CHECK-FIXES: str.starts_with("hello");
+
+// With string literal on left side
+"hello" == str.substr(0, 5);
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+// CHECK-FIXES: str.starts_with("hello");
+
+// Inequality comparison
+str.substr(0, 5) != "world";
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr != [modernize-use-starts-ends-with]
+// CHECK-FIXES: !str.starts_with("world");
+
+// Ensure non-zero start position is not transformed
+str.substr(1, 5) == "hello";
+str.substr(0, 4) == "hello"; // Length mismatch
+
+size_t len = 5;
+str.substr(0, len) == "hello"; // Non-constant length
+
+// String literal with size calculation
+str.substr(0, strlen("hello")) == "hello";
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+// CHECK-FIXES: str.starts_with("hello");
+
+str.substr(0, prefix.size()) == prefix;
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+// CHECK-FIXES: str.starts_with(prefix);
+
+  // Tests to verify macro behavior
+#define STARTS_WITH(X, Y) (X).substr(0, (Y).size()) == (Y)
+STARTS_WITH(str, prefix);
+
+#define SUBSTR(X, A, B) (X).substr((A), (B))
+SUBSTR(str, 0, 6) == "prefix";
+
+#define STR() str
+SUBSTR(STR(), 0, 6) == "prefix";
+
+"prefix" == SUBSTR(STR(), 0, 6);
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: use starts_with 
instead of substr == [modernize-use-starts-ends-with]
+
+}

HerrCai0907 wrote:

file should be finished with empty line is the rule of unix like os.

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


[clang-tools-extra] [clang-tidy] Fix false positive in cppcoreguidelines-avoid-const-or-ref-data-members when detecting templated classes with inheritance (PR #115180)

2024-11-17 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy] Fix false positive in cppcoreguidelines-avoid-const-or-ref-data-members when detecting templated classes with inheritance (PR #115180)

2024-11-17 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 updated 
https://github.com/llvm/llvm-project/pull/115180

>From 428283c7b61ca50d40ffd3ddc5c08aca39f39533 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Thu, 7 Nov 2024 00:35:47 +0800
Subject: [PATCH 1/3] [clang-tidy] fix false positive when detecting templated
 classes with inheritance

`hasSimpleCopyConstructor` series of functions are not reliable when these 
functions are not resolved. We need to manually resolve the status of these 
functions from its base classes.
Fixes: #111985.
---
 .../AvoidConstOrRefDataMembersCheck.cpp   | 122 ++
 clang-tools-extra/docs/ReleaseNotes.rst   |   4 +
 .../avoid-const-or-ref-data-members.cpp   |  22 
 3 files changed, 93 insertions(+), 55 deletions(-)

diff --git 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
index 6a6e620a4387b0..e1914eabd93f08 100644
--- 
a/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
+++ 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/AvoidConstOrRefDataMembersCheck.cpp
@@ -19,75 +19,87 @@ AST_MATCHER(FieldDecl, isMemberOfLambda) {
   return Node.getParent()->isLambda();
 }
 
-struct MemberFunctionInfo {
-  bool Declared{};
-  bool Deleted{};
-};
-
-struct MemberFunctionPairInfo {
-  MemberFunctionInfo Copy{};
-  MemberFunctionInfo Move{};
-};
-
-MemberFunctionPairInfo getConstructorsInfo(CXXRecordDecl const &Node) {
-  MemberFunctionPairInfo Constructors{};
-
-  for (CXXConstructorDecl const *Ctor : Node.ctors()) {
-if (Ctor->isCopyConstructor()) {
-  Constructors.Copy.Declared = true;
-  if (Ctor->isDeleted())
-Constructors.Copy.Deleted = true;
-}
-if (Ctor->isMoveConstructor()) {
-  Constructors.Move.Declared = true;
-  if (Ctor->isDeleted())
-Constructors.Move.Deleted = true;
+bool hasCopyConstructor(CXXRecordDecl const &Node) {
+  if (Node.needsOverloadResolutionForCopyConstructor() &&
+  Node.needsImplicitCopyConstructor()) {
+// unresolved
+for (CXXBaseSpecifier const &BS : Node.bases()) {
+  CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
+  if (BRD != nullptr)
+if (!hasCopyConstructor(*BRD))
+  return false;
 }
   }
-
-  return Constructors;
+  if (Node.hasSimpleCopyConstructor())
+return true;
+  for (CXXConstructorDecl const *Ctor : Node.ctors())
+if (Ctor->isCopyConstructor())
+  return !Ctor->isDeleted();
+  return false;
 }
 
-MemberFunctionPairInfo getAssignmentsInfo(CXXRecordDecl const &Node) {
-  MemberFunctionPairInfo Assignments{};
-
-  for (CXXMethodDecl const *Method : Node.methods()) {
-if (Method->isCopyAssignmentOperator()) {
-  Assignments.Copy.Declared = true;
-  if (Method->isDeleted())
-Assignments.Copy.Deleted = true;
+bool hasMoveConstructor(CXXRecordDecl const &Node) {
+  if (Node.needsOverloadResolutionForMoveConstructor() &&
+  Node.needsImplicitMoveConstructor()) {
+// unresolved
+for (CXXBaseSpecifier const &BS : Node.bases()) {
+  CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
+  if (BRD != nullptr)
+if (!hasMoveConstructor(*BRD))
+  return false;
 }
+  }
+  if (Node.hasSimpleMoveConstructor())
+return true;
+  for (CXXConstructorDecl const *Ctor : Node.ctors())
+if (Ctor->isMoveConstructor())
+  return !Ctor->isDeleted();
+  return false;
+}
 
-if (Method->isMoveAssignmentOperator()) {
-  Assignments.Move.Declared = true;
-  if (Method->isDeleted())
-Assignments.Move.Deleted = true;
+bool hasCopyAssignment(CXXRecordDecl const &Node) {
+  if (Node.needsOverloadResolutionForCopyAssignment() &&
+  Node.needsImplicitCopyAssignment()) {
+// unresolved
+for (CXXBaseSpecifier const &BS : Node.bases()) {
+  CXXRecordDecl const *BRD = BS.getType()->getAsCXXRecordDecl();
+  if (BRD != nullptr)
+if (!hasCopyAssignment(*BRD))
+  return false;
 }
   }
-
-  return Assignments;
+  if (Node.hasSimpleCopyAssignment())
+return true;
+  for (CXXMethodDecl const *Method : Node.methods())
+if (Method->isCopyAssignmentOperator())
+  return !Method->isDeleted();
+  return false;
 }
 
-AST_MATCHER(CXXRecordDecl, isCopyableOrMovable) {
-  MemberFunctionPairInfo Constructors = getConstructorsInfo(Node);
-  MemberFunctionPairInfo Assignments = getAssignmentsInfo(Node);
-
-  if (Node.hasSimpleCopyConstructor() ||
-  (Constructors.Copy.Declared && !Constructors.Copy.Deleted))
-return true;
-  if (Node.hasSimpleMoveConstructor() ||
-  (Constructors.Move.Declared && !Constructors.Move.Deleted))
-return true;
-  if (Node.hasSimpleCopyAssignment() ||
-  (Assignments.Copy.Declared && !Assignments.Copy.Deleted))
-return true;
-  if (Node.hasSimpleMoveAssignment() ||
-  (Assignments.Move.Declared && !Assignments.Move.Delete

[clang] [AArch64][ARM] Treat __bf16 as vendor extension type for C++ name mangling substitution (PR #115956)

2024-11-17 Thread John McCall via cfe-commits

rjmccall wrote:

The ABI spec is pretty clear about this, and demangling is likely to get very 
screwed up because of the inconsistency.

I think should do the following:

- We should file a bug with GCC pointing out the problem.
- We should fix the bug under new `-fclang-abi-compat=` versions, but leave it 
around for old ones.
- We should add a release note.

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


[clang-tools-extra] [clangd] Support symbolTags for document symbol (PR #113669)

2024-11-17 Thread via cfe-commits

https://github.com/chouzz updated 
https://github.com/llvm/llvm-project/pull/113669

>From 02124e4cfd7dbc395d4974c7561d5f110980aaa5 Mon Sep 17 00:00:00 2001
From: chouzz 
Date: Fri, 25 Oct 2024 17:42:04 +0800
Subject: [PATCH 1/4] [clangd] Support symbolTags for document symbol

---
 clang-tools-extra/clangd/AST.cpp  | 63 ++
 clang-tools-extra/clangd/AST.h| 31 +++
 clang-tools-extra/clangd/FindSymbols.cpp  | 30 +++
 clang-tools-extra/clangd/Protocol.h   | 29 ++-
 .../clangd/SemanticHighlighting.cpp   | 85 ---
 5 files changed, 151 insertions(+), 87 deletions(-)

diff --git a/clang-tools-extra/clangd/AST.cpp b/clang-tools-extra/clangd/AST.cpp
index f3eee1c6335f98..52578699b159b8 100644
--- a/clang-tools-extra/clangd/AST.cpp
+++ b/clang-tools-extra/clangd/AST.cpp
@@ -169,6 +169,69 @@ bool isImplementationDetail(const Decl *D) {
 D->getASTContext().getSourceManager());
 }
 
+// Whether T is const in a loose sense - is a variable with this type readonly?
+bool isConst(QualType T) {
+  if (T.isNull())
+return false;
+  T = T.getNonReferenceType();
+  if (T.isConstQualified())
+return true;
+  if (const auto *AT = T->getAsArrayTypeUnsafe())
+return isConst(AT->getElementType());
+  if (isConst(T->getPointeeType()))
+return true;
+  return false;
+}
+
+bool isConst(const Decl *D) {
+  if (llvm::isa(D) || llvm::isa(D))
+return true;
+  if (llvm::isa(D) || llvm::isa(D) ||
+  llvm::isa(D) || llvm::isa(D)) {
+if (isConst(llvm::cast(D)->getType()))
+  return true;
+  }
+  if (const auto *OCPD = llvm::dyn_cast(D)) {
+if (OCPD->isReadOnly())
+  return true;
+  }
+  if (const auto *MPD = llvm::dyn_cast(D)) {
+if (!MPD->hasSetter())
+  return true;
+  }
+  if (const auto *CMD = llvm::dyn_cast(D)) {
+if (CMD->isConst())
+  return true;
+  }
+  return false;
+}
+
+bool isStatic(const Decl *D) {
+  if (const auto *CMD = llvm::dyn_cast(D))
+return CMD->isStatic();
+  if (const VarDecl *VD = llvm::dyn_cast(D))
+return VD->isStaticDataMember() || VD->isStaticLocal();
+  if (const auto *OPD = llvm::dyn_cast(D))
+return OPD->isClassProperty();
+  if (const auto *OMD = llvm::dyn_cast(D))
+return OMD->isClassMethod();
+  return false;
+}
+
+bool isAbstract(const Decl *D) {
+  if (const auto *CMD = llvm::dyn_cast(D))
+return CMD->isPureVirtual();
+  if (const auto *CRD = llvm::dyn_cast(D))
+return CRD->hasDefinition() && CRD->isAbstract();
+  return false;
+}
+
+bool isVirtual(const Decl *D) {
+  if (const auto *CMD = llvm::dyn_cast(D))
+return CMD->isVirtual();
+  return false;
+}
+
 SourceLocation nameLocation(const clang::Decl &D, const SourceManager &SM) {
   auto L = D.getLocation();
   // For `- (void)foo` we want `foo` not the `-`.
diff --git a/clang-tools-extra/clangd/AST.h b/clang-tools-extra/clangd/AST.h
index fb0722d697cd06..b7eb7ddedc1666 100644
--- a/clang-tools-extra/clangd/AST.h
+++ b/clang-tools-extra/clangd/AST.h
@@ -152,6 +152,37 @@ bool isImplicitTemplateInstantiation(const NamedDecl *D);
 ///   explicit specialization.
 bool isExplicitTemplateSpecialization(const NamedDecl *D);
 
+// Whether T is const in a loose sense - is a variable with this type readonly?
+bool isConst(QualType T);
+
+// Whether D is const in a loose sense (should it be highlighted as such?)
+// FIXME: This is separate from whether *a particular usage* can mutate D.
+//We may want V in V.size() to be readonly even if V is mutable.
+bool isConst(const Decl *D);
+
+// "Static" means many things in C++, only some get the "static" modifier.
+//
+// Meanings that do:
+// - Members associated with the class rather than the instance.
+//   This is what 'static' most often means across languages.
+// - static local variables
+//   These are similarly "detached from their context" by the static keyword.
+//   In practice, these are rarely used inside classes, reducing confusion.
+//
+// Meanings that don't:
+// - Namespace-scoped variables, which have static storage class.
+//   This is implicit, so the keyword "static" isn't so strongly associated.
+//   If we want a modifier for these, "global scope" is probably the concept.
+// - Namespace-scoped variables/functions explicitly marked "static".
+//   There the keyword changes *linkage* , which is a totally different 
concept.
+//   If we want to model this, "file scope" would be a nice modifier.
+//
+// This is confusing, and maybe we should use another name, but because 
"static"
+// is a standard LSP modifier, having one with that name has advantages.
+bool isStatic(const Decl *D);
+bool isAbstract(const Decl *D);
+bool isVirtual(const Decl *D);
+
 /// Returns a nested name specifier loc of \p ND if it was present in the
 /// source, e.g.
 /// void ns::something::foo() -> returns 'ns::something'
diff --git a/clang-tools-extra/clangd/FindSymbols.cpp 
b/clang-tools-extra/clangd/FindSymbols.c

[clang] [llvm] [NFC][clang][FMV][TargetInfo] Refactor API for FMV feature priority. (PR #116257)

2024-11-17 Thread Piyou Chen via cfe-commits


@@ -4216,22 +4216,11 @@ static void 
ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old,
   llvm::Function *NewFn);
 
 static unsigned
-TargetMVPriority(const TargetInfo &TI,
- const CodeGenFunction::MultiVersionResolverOption &RO) {
-  unsigned Priority = 0;
-  unsigned NumFeatures = 0;
-  for (StringRef Feat : RO.Conditions.Features) {
-Priority = std::max(Priority, TI.multiVersionSortPriority(Feat));
-NumFeatures++;
-  }
-
-  if (!RO.Conditions.Architecture.empty())
-Priority = std::max(
-Priority, TI.multiVersionSortPriority(RO.Conditions.Architecture));
-
-  Priority += TI.multiVersionFeatureCost() * NumFeatures;
-
-  return Priority;
+getFMVPriority(const TargetInfo &TI,
+   const CodeGenFunction::MultiVersionResolverOption &RO) {
+  llvm::SmallVector Features{RO.Conditions.Features};
+  Features.push_back(RO.Conditions.Architecture);
+  return TI.getFMVPriority(Features);

BeMg wrote:

My concern is that `RISCVTargetInfo::getFMVPriority` needs to retrieve 
`Features[0]` for processing. If we modified the function signature to 
`RISCVTargetInfo::getFMVPriority(ArrayRef Features, 
ArrayRef Architecture)`, it would help avoid unclear access behavior.

```
unsigned RISCVTargetInfo::getFMVPriority(ArrayRef Features) const {
  SmallVector Attrs;
  Features[0].split(Attrs, ';');
```

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


[clang] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits


@@ -249,7 +254,7 @@ static void 
visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
   LocalVisitor Visit);
 
 template  static bool isRecordWithAttr(QualType Type) {
-  if (auto *RD = Type->getAsCXXRecordDecl())
+  if (auto *RD = Type.getNonReferenceType()->getAsCXXRecordDecl())

usx95 wrote:

I will remove this for now from this PR and leave the tests with a FIXME. 
Probably needs a separate PR to keep this PR simpler.

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits


@@ -0,0 +1,220 @@
+// RUN: %clang_cc1 --std=c++20 -fsyntax-only -Wdangling -Wdangling-field 
-Wreturn-stack-address -verify %s
+
+#include "Inputs/lifetime-analysis.h"

usx95 wrote:

I don't think that would be useful. Both lifetimebound and lifetime_capture 
share the semantics of STL types specially the inferred lifetimebound and 
gsl::Pointer/Owner. 

Also, I think it is useful to test how the stl types interact with other use 
defined types.

We often duplicate tests for both stl types and user defined types and I would 
prefer to keep the redundancy together in one place as compared to repeating 
similar tests to two different files.

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits


@@ -1460,7 +1502,15 @@ void checkExprLifetime(Sema &SemaRef, const 
AssignedEntity &Entity,
 
   checkExprLifetimeImpl(SemaRef, /*InitEntity=*/nullptr,
 /*ExtendingEntity=*/nullptr, LK_Assignment, &Entity,
-Init);
+/*CapEntity=*/nullptr, Init);
+}
+
+void checkExprLifetime(Sema &SemaRef, const CapturingEntity &Entity,

usx95 wrote:

Named the functions differently.

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


[clang] [llvm] [clang] Implement lifetime analysis for lifetime_capture_by(X) (PR #115921)

2024-11-17 Thread Utkarsh Saxena via cfe-commits


@@ -1110,13 +1117,14 @@ static bool shouldRunGSLAssignmentAnalysis(const Sema 
&SemaRef,
isAssignmentOperatorLifetimeBound(Entity.AssignmentOperator)));
 }
 
-static void checkExprLifetimeImpl(Sema &SemaRef,
-  const InitializedEntity *InitEntity,
-  const InitializedEntity *ExtendingEntity,
-  LifetimeKind LK,
-  const AssignedEntity *AEntity, Expr *Init) {
-  assert((AEntity && LK == LK_Assignment) ||
- (InitEntity && LK != LK_Assignment));
+static void
+checkExprLifetimeImpl(Sema &SemaRef, const InitializedEntity *InitEntity,
+  const InitializedEntity *ExtendingEntity, LifetimeKind 
LK,
+  const AssignedEntity *AEntity,
+  const CapturingEntity *CapEntity, Expr *Init) {
+  assert(!AEntity || LK == LK_Assignment);
+  assert(!CapEntity || LK == LK_LifetimeCapture);
+  assert(!InitEntity || (LK != LK_Assignment && LK != LK_LifetimeCapture));

usx95 wrote:

Yeah. That is a valid concern. I had previously proposed to change this to a 
class and have separate member functions instead of passing these lambdas in 
each function call (specially the temporary visitor).

This was added as a FIXME just few lines below:
```
  // FIXME: consider moving the TemporaryVisitor and visitLocalsRetained*
  // functions to a dedicated class.
```
This is a larger refactoring. I prefer to do this in a separate PR.

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


[clang] [ARM] Fix NaN behaviour for MVE compare intrinsics (PR #116371)

2024-11-17 Thread David Green via cfe-commits

https://github.com/davemgreen commented:

This seems to match what we do in the backend. LGTM

> The MVE intrinsics are defined as having the same behaviour as the 
> instructions which they correspond to.

(They are defined to match the instructions they correspond to inside the 
current fp environment. i.e. they don't have side effects without trapping math 
and fast-math applies to them as required. That doesn't make a difference here 
though, they should still get the olt vs ult correct.)

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


[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2024-11-17 Thread Younan Zhang via cfe-commits


@@ -13044,6 +13045,17 @@ class Sema final : public SemaBase {
   bool SkipForSpecialization = false,
   bool ForDefaultArgumentSubstitution = false);
 
+  /// Apart from storing the result to \p Result, this behaves the same as
+  /// another overload.
+  void getTemplateInstantiationArgs(
+  MultiLevelTemplateArgumentList &Result, const NamedDecl *D,
+  const DeclContext *DC = nullptr, bool Final = false,
+  std::optional> Innermost = std::nullopt,
+  bool RelativeToPrimary = false, const FunctionDecl *Pattern = nullptr,
+  bool ForConstraintInstantiation = false,
+  bool SkipForSpecialization = false,
+  bool ForDefaultArgumentSubstitution = false);
+

zyn0217 wrote:

This was taken from #110387, which has also been reverted due to its dependency 
on the refactoring work. 

The extra parameters can certainly be removed alongside the relanding of that 
huge patch.

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


[clang-tools-extra] [clangd] Check for editsNearCursor client capability under experimental capabilities (PR #114699)

2024-11-17 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

> > (No action required) – we have other extensions in clangd e.g. 
> > `references.container` `offsetEncoding`. Do we plan to do the same thing 
> > for them?
> 
> Good question; I was initially thinking of doing it as needed / when someone 
> asks for it. But maybe it would be better to add them all up front, so when a 
> need for another one arises, the support is already in a clangd release. I 
> can do that in a follow-up patch.

Sent out https://github.com/llvm/llvm-project/pull/116531 for this.

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


[clang] [AST] Avoid repeated hash lookups (NFC) (PR #116549)

2024-11-17 Thread Kazu Hirata via cfe-commits

https://github.com/kazutakahirata created 
https://github.com/llvm/llvm-project/pull/116549

Identified with misc-include-cleaner.


>From a11ea3a089d42b2e11d5a32cc490665f7fd4efbd Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 17 Nov 2024 09:04:05 -0800
Subject: [PATCH] [AST] Avoid repeated hash lookups (NFC)

Identified with misc-include-cleaner.
---
 clang/lib/AST/ASTConcept.cpp| 1 -
 clang/lib/AST/ASTContext.cpp| 3 ---
 clang/lib/AST/ASTDumper.cpp | 1 -
 clang/lib/AST/ASTImporter.cpp   | 2 --
 clang/lib/AST/ASTStructuralEquivalence.cpp  | 1 -
 clang/lib/AST/ByteCode/ByteCodeEmitter.cpp  | 2 --
 clang/lib/AST/ByteCode/Descriptor.cpp   | 1 -
 clang/lib/AST/ByteCode/EvalEmitter.cpp  | 1 -
 clang/lib/AST/ByteCode/EvaluationResult.cpp | 1 -
 clang/lib/AST/ByteCode/Function.cpp | 1 -
 clang/lib/AST/ByteCode/Interp.cpp   | 4 
 clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp | 4 
 clang/lib/AST/ByteCode/PrimType.cpp | 1 -
 clang/lib/AST/ByteCode/Program.cpp  | 1 -
 clang/lib/AST/CXXInheritance.cpp| 3 +--
 clang/lib/AST/CommentCommandTraits.cpp  | 1 -
 clang/lib/AST/CommentSema.cpp   | 1 -
 clang/lib/AST/Decl.cpp  | 1 -
 clang/lib/AST/DeclBase.cpp  | 3 ---
 clang/lib/AST/DeclCXX.cpp   | 1 -
 clang/lib/AST/DeclFriend.cpp| 3 +--
 clang/lib/AST/DeclObjC.cpp  | 2 --
 clang/lib/AST/DeclTemplate.cpp  | 3 ---
 clang/lib/AST/DeclarationName.cpp   | 2 --
 clang/lib/AST/Expr.cpp  | 1 -
 clang/lib/AST/ExprCXX.cpp   | 1 -
 clang/lib/AST/ExprConcepts.cpp  | 3 ---
 clang/lib/AST/ExprConstant.cpp  | 1 -
 clang/lib/AST/ExprObjC.cpp  | 2 --
 clang/lib/AST/ExternalASTSource.cpp | 2 --
 clang/lib/AST/ItaniumCXXABI.cpp | 1 -
 clang/lib/AST/ItaniumMangle.cpp | 2 --
 clang/lib/AST/Mangle.cpp| 5 ++---
 clang/lib/AST/MicrosoftMangle.cpp   | 2 --
 clang/lib/AST/NestedNameSpecifier.cpp   | 2 --
 clang/lib/AST/ODRHash.cpp   | 1 -
 clang/lib/AST/OSLog.cpp | 1 -
 clang/lib/AST/OpenMPClause.cpp  | 1 -
 clang/lib/AST/ParentMap.cpp | 1 -
 clang/lib/AST/QualTypeNames.cpp | 6 +-
 clang/lib/AST/Randstruct.cpp| 2 --
 clang/lib/AST/RawCommentList.cpp| 2 --
 clang/lib/AST/RecordLayoutBuilder.cpp   | 3 +--
 clang/lib/AST/Stmt.cpp  | 2 --
 clang/lib/AST/StmtIterator.cpp  | 1 -
 clang/lib/AST/StmtOpenACC.cpp   | 1 -
 clang/lib/AST/StmtPrinter.cpp   | 3 ---
 clang/lib/AST/TemplateBase.cpp  | 3 ---
 clang/lib/AST/TemplateName.cpp  | 1 -
 clang/lib/AST/Type.cpp  | 4 
 clang/lib/AST/TypePrinter.cpp   | 2 --
 clang/lib/AST/VTTBuilder.cpp| 1 -
 52 files changed, 6 insertions(+), 95 deletions(-)

diff --git a/clang/lib/AST/ASTConcept.cpp b/clang/lib/AST/ASTConcept.cpp
index d8efbe44dbecbb..bdc713ca3e791e 100644
--- a/clang/lib/AST/ASTConcept.cpp
+++ b/clang/lib/AST/ASTConcept.cpp
@@ -14,7 +14,6 @@
 #include "clang/AST/ASTConcept.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/PrettyPrinter.h"
-#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringExtras.h"
 
 using namespace clang;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 5226ca6f5d0191..14fbadbc35ae5d 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -32,7 +32,6 @@
 #include "clang/AST/DependenceFlags.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
-#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/MangleNumberingContext.h"
@@ -41,7 +40,6 @@
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
-#include "clang/AST/StmtOpenACC.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -81,7 +79,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/Support/Capacity.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MD5.h"
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index 864d0393f9a78e..5e4487e0687d32 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/lib/AST/ASTDumper.cpp
@@ -16,7 +16,6 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclLoo

[clang] [AST] Avoid repeated hash lookups (NFC) (PR #116549)

2024-11-17 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)


Changes

Identified with misc-include-cleaner.


---

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


52 Files Affected:

- (modified) clang/lib/AST/ASTConcept.cpp (-1) 
- (modified) clang/lib/AST/ASTContext.cpp (-3) 
- (modified) clang/lib/AST/ASTDumper.cpp (-1) 
- (modified) clang/lib/AST/ASTImporter.cpp (-2) 
- (modified) clang/lib/AST/ASTStructuralEquivalence.cpp (-1) 
- (modified) clang/lib/AST/ByteCode/ByteCodeEmitter.cpp (-2) 
- (modified) clang/lib/AST/ByteCode/Descriptor.cpp (-1) 
- (modified) clang/lib/AST/ByteCode/EvalEmitter.cpp (-1) 
- (modified) clang/lib/AST/ByteCode/EvaluationResult.cpp (-1) 
- (modified) clang/lib/AST/ByteCode/Function.cpp (-1) 
- (modified) clang/lib/AST/ByteCode/Interp.cpp (-4) 
- (modified) clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp (-4) 
- (modified) clang/lib/AST/ByteCode/PrimType.cpp (-1) 
- (modified) clang/lib/AST/ByteCode/Program.cpp (-1) 
- (modified) clang/lib/AST/CXXInheritance.cpp (+1-2) 
- (modified) clang/lib/AST/CommentCommandTraits.cpp (-1) 
- (modified) clang/lib/AST/CommentSema.cpp (-1) 
- (modified) clang/lib/AST/Decl.cpp (-1) 
- (modified) clang/lib/AST/DeclBase.cpp (-3) 
- (modified) clang/lib/AST/DeclCXX.cpp (-1) 
- (modified) clang/lib/AST/DeclFriend.cpp (+1-2) 
- (modified) clang/lib/AST/DeclObjC.cpp (-2) 
- (modified) clang/lib/AST/DeclTemplate.cpp (-3) 
- (modified) clang/lib/AST/DeclarationName.cpp (-2) 
- (modified) clang/lib/AST/Expr.cpp (-1) 
- (modified) clang/lib/AST/ExprCXX.cpp (-1) 
- (modified) clang/lib/AST/ExprConcepts.cpp (-3) 
- (modified) clang/lib/AST/ExprConstant.cpp (-1) 
- (modified) clang/lib/AST/ExprObjC.cpp (-2) 
- (modified) clang/lib/AST/ExternalASTSource.cpp (-2) 
- (modified) clang/lib/AST/ItaniumCXXABI.cpp (-1) 
- (modified) clang/lib/AST/ItaniumMangle.cpp (-2) 
- (modified) clang/lib/AST/Mangle.cpp (+2-3) 
- (modified) clang/lib/AST/MicrosoftMangle.cpp (-2) 
- (modified) clang/lib/AST/NestedNameSpecifier.cpp (-2) 
- (modified) clang/lib/AST/ODRHash.cpp (-1) 
- (modified) clang/lib/AST/OSLog.cpp (-1) 
- (modified) clang/lib/AST/OpenMPClause.cpp (-1) 
- (modified) clang/lib/AST/ParentMap.cpp (-1) 
- (modified) clang/lib/AST/QualTypeNames.cpp (+1-5) 
- (modified) clang/lib/AST/Randstruct.cpp (-2) 
- (modified) clang/lib/AST/RawCommentList.cpp (-2) 
- (modified) clang/lib/AST/RecordLayoutBuilder.cpp (+1-2) 
- (modified) clang/lib/AST/Stmt.cpp (-2) 
- (modified) clang/lib/AST/StmtIterator.cpp (-1) 
- (modified) clang/lib/AST/StmtOpenACC.cpp (-1) 
- (modified) clang/lib/AST/StmtPrinter.cpp (-3) 
- (modified) clang/lib/AST/TemplateBase.cpp (-3) 
- (modified) clang/lib/AST/TemplateName.cpp (-1) 
- (modified) clang/lib/AST/Type.cpp (-4) 
- (modified) clang/lib/AST/TypePrinter.cpp (-2) 
- (modified) clang/lib/AST/VTTBuilder.cpp (-1) 


``diff
diff --git a/clang/lib/AST/ASTConcept.cpp b/clang/lib/AST/ASTConcept.cpp
index d8efbe44dbecbb..bdc713ca3e791e 100644
--- a/clang/lib/AST/ASTConcept.cpp
+++ b/clang/lib/AST/ASTConcept.cpp
@@ -14,7 +14,6 @@
 #include "clang/AST/ASTConcept.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/PrettyPrinter.h"
-#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringExtras.h"
 
 using namespace clang;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 5226ca6f5d0191..14fbadbc35ae5d 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -32,7 +32,6 @@
 #include "clang/AST/DependenceFlags.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
-#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/MangleNumberingContext.h"
@@ -41,7 +40,6 @@
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
-#include "clang/AST/StmtOpenACC.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -81,7 +79,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/Support/Capacity.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MD5.h"
diff --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index 864d0393f9a78e..5e4487e0687d32 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/lib/AST/ASTDumper.cpp
@@ -16,7 +16,6 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclLookups.h"
 #include "clang/AST/JSONNodeDumper.h"
-#include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/raw_ostream.h"
 
diff --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 35aba41f0052af..baed1416635432 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -53,13 +53,11 @@
 #include

[clang] [AST] Remove unused includes (NFC) (PR #116549)

2024-11-17 Thread Kazu Hirata via cfe-commits

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


[clang] [AST] Avoid repeated hash lookups (NFC) (PR #116549)

2024-11-17 Thread Nikita Popov via cfe-commits

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


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


[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-17 Thread Nikita Popov via cfe-commits

nikic wrote:

There's an existing PR for this here: 
https://github.com/llvm/llvm-project/pull/110758

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


[clang] 3155199 - Thread safety analysis: Eliminate unneeded const_cast, NFC

2024-11-17 Thread Aaron Puchert via cfe-commits

Author: Aaron Puchert
Date: 2024-11-17T22:40:09+01:00
New Revision: 315519917368dce841f1cb1e7b296846d13497c3

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

LOG: Thread safety analysis: Eliminate unneeded const_cast, NFC

Added: 


Modified: 
clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h

Removed: 




diff  --git a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h 
b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
index 2f202607bd3fa9..9f365d1a3b6557 100644
--- a/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
+++ b/clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
@@ -1363,11 +1363,7 @@ class Terminator : public SExpr {
   }
 
   /// Return the list of basic blocks that this terminator can branch to.
-  ArrayRef successors();
-
-  ArrayRef successors() const {
-return const_cast(this)->successors();
-  }
+  ArrayRef successors() const;
 };
 
 /// Jump to another basic block.
@@ -1391,7 +1387,7 @@ class Goto : public Terminator {
   unsigned index() const { return Index; }
 
   /// Return the list of basic blocks that this terminator can branch to.
-  ArrayRef successors() { return TargetBlock; }
+  ArrayRef successors() const { return TargetBlock; }
 
   template 
   typename V::R_SExpr traverse(V &Vs, typename V::R_Ctx Ctx) {
@@ -1439,7 +1435,7 @@ class Branch : public Terminator {
   BasicBlock *elseBlock() { return Branches[1]; }
 
   /// Return the list of basic blocks that this terminator can branch to.
-  ArrayRef successors() { return llvm::ArrayRef(Branches); }
+  ArrayRef successors() const { return llvm::ArrayRef(Branches); 
}
 
   template 
   typename V::R_SExpr traverse(V &Vs, typename V::R_Ctx Ctx) {
@@ -1470,7 +1466,7 @@ class Return : public Terminator {
   static bool classof(const SExpr *E) { return E->opcode() == COP_Return; }
 
   /// Return an empty list.
-  ArrayRef successors() { return {}; }
+  ArrayRef successors() const { return {}; }
 
   SExpr *returnValue() { return Retval; }
   const SExpr *returnValue() const { return Retval; }
@@ -1490,7 +1486,7 @@ class Return : public Terminator {
   SExpr* Retval;
 };
 
-inline ArrayRef Terminator::successors() {
+inline ArrayRef Terminator::successors() const {
   switch (opcode()) {
 case COP_Goto:   return cast(this)->successors();
 case COP_Branch: return cast(this)->successors();



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


[clang] [llvm] Introduce symbol versioning for clang-cpp (PR #116556)

2024-11-17 Thread Aaron Puchert via cfe-commits

aaronpuchert wrote:

@nikic, thanks for letting me know! That is indeed pretty much the same change.

@tstellar, maybe you want to copy the change to `llvm/CMakeLists.txt`, 
otherwise I'd close this.

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


[clang] [ObjC] Expand isClassLayoutKnownStatically to base classes as long as the implementation of it is known (PR #85465)

2024-11-17 Thread via cfe-commits

AreaZR wrote:

Going to ping @rjmccall 

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


[clang] [AST] Remove unused includes (NFC) (PR #116549)

2024-11-17 Thread Kazu Hirata via cfe-commits

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


[clang] [clang-tools-extra] [analyzer] Remove alpha.core.IdenticalExpr Checker (PR #114715)

2024-11-17 Thread via cfe-commits

vabridgers wrote:

Thanks @HerrCai0907 and @5chmidti for the constructive comments. I believe all 
have been addressed and a way forward has been described. Please let me know 
how we can move this forward. Thank you! 

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


[clang] [clang-tools-extra] [analyzer] Remove alpha.core.IdenticalExpr Checker (PR #114715)

2024-11-17 Thread via cfe-commits

https://github.com/vabridgers updated 
https://github.com/llvm/llvm-project/pull/114715

>From 6bcbe9f09060dc2bdcdb9a9c6e576466e24e08cb Mon Sep 17 00:00:00 2001
From: Vince Bridgers 
Date: Thu, 7 Nov 2024 01:58:21 +0100
Subject: [PATCH] [analyzer] Port alpha.core.IdenticalExpr to Tidy checks and
 remove

This change removes the alpha.core.IdenticalExpr static analysis
checker since it's checks are present in the clang-tidy checks
misc-redundant-expression and bugprone-branch-clone. This check was
implemented as a static analysis check using AST matching, and since
alpha and duplicated in 2 clang-tidy checks may be removed. The
existing LIT test was checked case by case, and the tidy checks
were improved to maintain alpha.core.IdenticalExpr features.
---
 .../clang-tidy/bugprone/BranchCloneCheck.cpp  | 220 
 .../misc/RedundantExpressionCheck.cpp |  70 ++-
 clang-tools-extra/docs/ReleaseNotes.rst   |   9 +
 .../checks/bugprone/branch-clone.rst  |  21 +-
 .../checks/misc/redundant-expression.rst  |  19 +
 .../bugprone/alpha-core-identicalexpr.cpp | 335 +++
 clang/docs/ReleaseNotes.rst   |   4 +
 clang/docs/analyzer/checkers.rst  |  30 -
 .../clang/StaticAnalyzer/Checkers/Checkers.td |   4 -
 .../StaticAnalyzer/Checkers/CMakeLists.txt|   1 -
 .../Checkers/IdenticalExprChecker.cpp | 519 --
 11 files changed, 569 insertions(+), 663 deletions(-)
 rename clang/test/Analysis/identical-expressions.cpp => 
clang-tools-extra/test/clang-tidy/checkers/bugprone/alpha-core-identicalexpr.cpp
 (57%)
 delete mode 100644 clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
index 356acf968db921..9702f0632ead59 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BranchCloneCheck.cpp
@@ -102,6 +102,211 @@ void BranchCloneCheck::registerMatchers(MatchFinder 
*Finder) {
   this);
   Finder->addMatcher(switchStmt().bind("switch"), this);
   Finder->addMatcher(conditionalOperator().bind("condOp"), this);
+  Finder->addMatcher(
+  ifStmt((hasThen(hasDescendant(ifStmt().bind("ifWithDescendantIf"),
+  this);
+}
+
+/// Determines whether two statement trees are identical regarding
+/// operators and symbols.
+///
+/// Exceptions: expressions containing macros or functions with possible side
+/// effects are never considered identical.
+/// Limitations: (t + u) and (u + t) are not considered identical.
+/// t*(u + t) and t*u + t*t are not considered identical.
+///
+static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
+const Stmt *Stmt2, bool IgnoreSideEffects) {
+
+  if (!Stmt1 || !Stmt2)
+return !Stmt1 && !Stmt2;
+
+  // If Stmt1 & Stmt2 are of different class then they are not
+  // identical statements.
+  if (Stmt1->getStmtClass() != Stmt2->getStmtClass())
+return false;
+
+  const auto *Expr1 = dyn_cast(Stmt1);
+  const auto *Expr2 = dyn_cast(Stmt2);
+
+  if (Expr1 && Expr2) {
+// If Stmt1 has side effects then don't warn even if expressions
+// are identical.
+if (!IgnoreSideEffects && Expr1->HasSideEffects(Ctx))
+  return false;
+// If either expression comes from a macro then don't warn even if
+// the expressions are identical.
+if ((Expr1->getExprLoc().isMacroID()) || (Expr2->getExprLoc().isMacroID()))
+  return false;
+
+// If all children of two expressions are identical, return true.
+Expr::const_child_iterator I1 = Expr1->child_begin();
+Expr::const_child_iterator I2 = Expr2->child_begin();
+while (I1 != Expr1->child_end() && I2 != Expr2->child_end()) {
+  if (!*I1 || !*I2 || !isIdenticalStmt(Ctx, *I1, *I2, IgnoreSideEffects))
+return false;
+  ++I1;
+  ++I2;
+}
+// If there are different number of children in the statements, return
+// false.
+if (I1 != Expr1->child_end())
+  return false;
+if (I2 != Expr2->child_end())
+  return false;
+  }
+
+  switch (Stmt1->getStmtClass()) {
+  default:
+return false;
+  case Stmt::CallExprClass:
+  case Stmt::ArraySubscriptExprClass:
+  case Stmt::ArraySectionExprClass:
+  case Stmt::OMPArrayShapingExprClass:
+  case Stmt::OMPIteratorExprClass:
+  case Stmt::ImplicitCastExprClass:
+  case Stmt::ParenExprClass:
+  case Stmt::BreakStmtClass:
+  case Stmt::ContinueStmtClass:
+  case Stmt::NullStmtClass:
+return true;
+  case Stmt::CStyleCastExprClass: {
+const auto *CastExpr1 = cast(Stmt1);
+const auto *CastExpr2 = cast(Stmt2);
+
+return CastExpr1->getTypeAsWritten() == CastExpr2->getTypeAsWritten();
+  }
+  case Stmt::ReturnStmtClass: {
+const auto *ReturnStmt1 = cast(Stmt1);
+const auto *ReturnStmt2 = cast(Stmt2);
+
+return isIdenticalStmt(Ctx, ReturnStmt1->getRetValue(),
+  

[clang] dec6324 - [AST] Remove unused includes (NFC) (#116549)

2024-11-17 Thread via cfe-commits

Author: Kazu Hirata
Date: 2024-11-17T09:36:48-08:00
New Revision: dec6324cb05ac1d339c1b2bd43add968f2931c62

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

LOG: [AST] Remove unused includes (NFC) (#116549)

Identified with misc-include-cleaner.

Added: 


Modified: 
clang/lib/AST/ASTConcept.cpp
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTDumper.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/ByteCode/ByteCodeEmitter.cpp
clang/lib/AST/ByteCode/Descriptor.cpp
clang/lib/AST/ByteCode/EvalEmitter.cpp
clang/lib/AST/ByteCode/EvaluationResult.cpp
clang/lib/AST/ByteCode/Function.cpp
clang/lib/AST/ByteCode/Interp.cpp
clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp
clang/lib/AST/ByteCode/PrimType.cpp
clang/lib/AST/ByteCode/Program.cpp
clang/lib/AST/CXXInheritance.cpp
clang/lib/AST/CommentCommandTraits.cpp
clang/lib/AST/CommentSema.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/DeclBase.cpp
clang/lib/AST/DeclCXX.cpp
clang/lib/AST/DeclFriend.cpp
clang/lib/AST/DeclObjC.cpp
clang/lib/AST/DeclTemplate.cpp
clang/lib/AST/DeclarationName.cpp
clang/lib/AST/Expr.cpp
clang/lib/AST/ExprCXX.cpp
clang/lib/AST/ExprConcepts.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/ExprObjC.cpp
clang/lib/AST/ExternalASTSource.cpp
clang/lib/AST/ItaniumCXXABI.cpp
clang/lib/AST/ItaniumMangle.cpp
clang/lib/AST/Mangle.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/AST/NestedNameSpecifier.cpp
clang/lib/AST/ODRHash.cpp
clang/lib/AST/OSLog.cpp
clang/lib/AST/OpenMPClause.cpp
clang/lib/AST/ParentMap.cpp
clang/lib/AST/QualTypeNames.cpp
clang/lib/AST/Randstruct.cpp
clang/lib/AST/RawCommentList.cpp
clang/lib/AST/RecordLayoutBuilder.cpp
clang/lib/AST/Stmt.cpp
clang/lib/AST/StmtIterator.cpp
clang/lib/AST/StmtOpenACC.cpp
clang/lib/AST/StmtPrinter.cpp
clang/lib/AST/TemplateBase.cpp
clang/lib/AST/TemplateName.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/AST/VTTBuilder.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTConcept.cpp b/clang/lib/AST/ASTConcept.cpp
index d8efbe44dbecbb..bdc713ca3e791e 100644
--- a/clang/lib/AST/ASTConcept.cpp
+++ b/clang/lib/AST/ASTConcept.cpp
@@ -14,7 +14,6 @@
 #include "clang/AST/ASTConcept.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/PrettyPrinter.h"
-#include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringExtras.h"
 
 using namespace clang;

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 5226ca6f5d0191..14fbadbc35ae5d 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -32,7 +32,6 @@
 #include "clang/AST/DependenceFlags.h"
 #include "clang/AST/Expr.h"
 #include "clang/AST/ExprCXX.h"
-#include "clang/AST/ExprConcepts.h"
 #include "clang/AST/ExternalASTSource.h"
 #include "clang/AST/Mangle.h"
 #include "clang/AST/MangleNumberingContext.h"
@@ -41,7 +40,6 @@
 #include "clang/AST/RawCommentList.h"
 #include "clang/AST/RecordLayout.h"
 #include "clang/AST/Stmt.h"
-#include "clang/AST/StmtOpenACC.h"
 #include "clang/AST/TemplateBase.h"
 #include "clang/AST/TemplateName.h"
 #include "clang/AST/Type.h"
@@ -81,7 +79,6 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Frontend/OpenMP/OMPIRBuilder.h"
 #include "llvm/Support/Capacity.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/Compiler.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MD5.h"

diff  --git a/clang/lib/AST/ASTDumper.cpp b/clang/lib/AST/ASTDumper.cpp
index 864d0393f9a78e..5e4487e0687d32 100644
--- a/clang/lib/AST/ASTDumper.cpp
+++ b/clang/lib/AST/ASTDumper.cpp
@@ -16,7 +16,6 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/DeclLookups.h"
 #include "clang/AST/JSONNodeDumper.h"
-#include "clang/Basic/Builtins.h"
 #include "clang/Basic/SourceManager.h"
 #include "llvm/Support/raw_ostream.h"
 

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 35aba41f0052af..baed1416635432 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -53,13 +53,11 @@
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
 #include "clang/Basic/Specifiers.h"
-#include "llvm/ADT/APSInt.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/ADT/ScopeExit.h"
 #include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Casting.h"
 #include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/MemoryBuffer.h"
 #include 

diff  --git a/clang/lib/AST/ASTStructuralEquivalence.cpp 
b/clang/lib/AST/ASTStructuralEquivalence.cpp
index bf2f42932f25d4..308551c306151

[libcxx] [libunwind] [llvm] [libc++] Enable -Wmissing-prototypes (PR #116261)

2024-11-17 Thread Nikolas Klauser via cfe-commits

https://github.com/philnik777 updated 
https://github.com/llvm/llvm-project/pull/116261

>From 811186764d1add4d83972db3ad0d2e7c96bb15a7 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Sat, 16 Nov 2024 19:23:20 +0100
Subject: [PATCH 1/2] [libc++] Fix a few problems found by clang-tidy

---
 libcxx/include/__flat_map/flat_map.h  | 4 ++--
 libcxx/include/__locale_dir/locale_base_api.h | 6 +++---
 libcxx/include/__ranges/to.h  | 8 
 3 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/libcxx/include/__flat_map/flat_map.h 
b/libcxx/include/__flat_map/flat_map.h
index 073b63cd8f0a66..58b362ad7a706f 100644
--- a/libcxx/include/__flat_map/flat_map.h
+++ b/libcxx/include/__flat_map/flat_map.h
@@ -113,7 +113,7 @@ class flat_map {
   class value_compare {
   private:
 key_compare __comp_;
-value_compare(key_compare __c) : __comp_(__c) {}
+_LIBCPP_HIDE_FROM_ABI value_compare(key_compare __c) : __comp_(__c) {}
 friend flat_map;
 
   public:
@@ -659,7 +659,7 @@ class flat_map {
 
   template 
 requires __has_input_iterator_category<_InputIterator>::value
-  void insert(sorted_unique_t, _InputIterator __first, _InputIterator __last) {
+  _LIBCPP_HIDE_FROM_ABI void insert(sorted_unique_t, _InputIterator __first, 
_InputIterator __last) {
 if constexpr (sized_sentinel_for<_InputIterator, _InputIterator>) {
   __reserve(__last - __first);
 }
diff --git a/libcxx/include/__locale_dir/locale_base_api.h 
b/libcxx/include/__locale_dir/locale_base_api.h
index 5cbe91207ca74e..8ed4c29cb8732f 100644
--- a/libcxx/include/__locale_dir/locale_base_api.h
+++ b/libcxx/include/__locale_dir/locale_base_api.h
@@ -265,17 +265,17 @@ _LIBCPP_GCC_DIAGNOSTIC_IGNORED("-Wformat-nonliteral") // 
GCC doesn't support [[g
 template 
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 4, 5) int 
__snprintf(
 char* __s, size_t __n, __locale_t __loc, const char* __format, _Args&&... 
__args) {
-  return __libcpp_snprintf_l(__s, __n, __loc, __format, 
std::forward<_Args>(__args)...);
+  return std::__libcpp_snprintf_l(__s, __n, __loc, __format, 
std::forward<_Args>(__args)...);
 }
 template 
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__printf__, 3, 4) int 
__asprintf(
 char** __s, __locale_t __loc, const char* __format, _Args&&... __args) {
-  return __libcpp_asprintf_l(__s, __loc, __format, 
std::forward<_Args>(__args)...);
+  return std::__libcpp_asprintf_l(__s, __loc, __format, 
std::forward<_Args>(__args)...);
 }
 template 
 _LIBCPP_HIDE_FROM_ABI _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT(__scanf__, 3, 4) int 
__sscanf(
 const char* __s, __locale_t __loc, const char* __format, _Args&&... 
__args) {
-  return __libcpp_sscanf_l(__s, __loc, __format, 
std::forward<_Args>(__args)...);
+  return std::__libcpp_sscanf_l(__s, __loc, __format, 
std::forward<_Args>(__args)...);
 }
 _LIBCPP_DIAGNOSTIC_POP
 #  undef _LIBCPP_VARIADIC_ATTRIBUTE_FORMAT
diff --git a/libcxx/include/__ranges/to.h b/libcxx/include/__ranges/to.h
index 76249bdd9891c8..c937b0656de87d 100644
--- a/libcxx/include/__ranges/to.h
+++ b/libcxx/include/__ranges/to.h
@@ -111,14 +111,14 @@ template 
 
   for (auto&& __ref : __range) {
 using _Ref = decltype(__ref);
-if constexpr (requires { __result.emplace_back(declval<_Ref>()); }) {
+if constexpr (requires { __result.emplace_back(std::declval<_Ref>()); 
}) {
   __result.emplace_back(std::forward<_Ref>(__ref));
-} else if constexpr (requires { __result.push_back(declval<_Ref>()); 
}) {
+} else if constexpr (requires { 
__result.push_back(std::declval<_Ref>()); }) {
   __result.push_back(std::forward<_Ref>(__ref));
-} else if constexpr (requires { __result.emplace(__result.end(), 
declval<_Ref>()); }) {
+} else if constexpr (requires { __result.emplace(__result.end(), 
std::declval<_Ref>()); }) {
   __result.emplace(__result.end(), std::forward<_Ref>(__ref));
 } else {
-  static_assert(requires { __result.insert(__result.end(), 
declval<_Ref>()); });
+  static_assert(requires { __result.insert(__result.end(), 
std::declval<_Ref>()); });
   __result.insert(__result.end(), std::forward<_Ref>(__ref));
 }
   }

>From 62231cdc5d9438f3bc0be46290464aea3a805952 Mon Sep 17 00:00:00 2001
From: Nikolas Klauser 
Date: Thu, 14 Nov 2024 18:30:39 +0100
Subject: [PATCH 2/2] [libc++] Enable -Wmissing-prototypes

---
 libcxx/src/charconv.cpp| 5 -
 libcxx/src/filesystem/int128_builtins.cpp  | 2 ++
 libcxx/src/include/from_chars_floating_point.h | 4 ++--
 libcxx/src/legacy_pointer_safety.cpp   | 4 
 libunwind/src/UnwindLevel1.c   | 1 -
 libunwind/src/libunwind_ext.h  | 1 +
 runtimes/cmake/Modules/WarningFlags.cmake  | 1 +
 7 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/libcxx/src/charconv.cpp b/libcxx/src/charconv.cpp
index 5e8cb7d977

[clang] [libcxx] [Clang] Implement CWG2369 "Ordering between constraints and substitution" (PR #102857)

2024-11-17 Thread Younan Zhang via cfe-commits

zyn0217 wrote:

@cor3ntin Not much, we just need to move the handling of the friend declaration 
outside of `getTemplateInstantiationArgs()` :)

Do you see any other outstanding issues? If not, can we go ahead with the 
status quo so we have sufficient timeframe in clang 20 cycle in case something 
else goes wrong?

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


[clang] [clang] Fix ASTWriter crash after merging named enums (PR #114240)

2024-11-17 Thread Michael Jabbour via cfe-commits

michael-jabbour-sonarsource wrote:

Gentle ping :smile:

The aim of the PR is to fix an ASTWriter crash that currently happens when 
serializing merged enums. Such a case was encountered while parsing Objective-C 
code that uses the XCode 16 SDK. If any of the changes look risky, I am happy 
to rework them and/or add more tests to increase confidence.

Thanks in advance.

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


[clang] c4eeef3 - [TBAA] Add test for generating pointer-tbaa for unnamed structs.

2024-11-17 Thread Florian Hahn via cfe-commits

Author: Florian Hahn
Date: 2024-11-17T20:04:36Z
New Revision: c4eeef32d5dc8ec7560edabf18ac29416a7551e5

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

LOG: [TBAA] Add test for generating pointer-tbaa for unnamed structs.

Currently we generate incorrect metadata not considering compatible
types in C.

Added: 


Modified: 
clang/test/CodeGen/tbaa-pointers.c

Removed: 




diff  --git a/clang/test/CodeGen/tbaa-pointers.c 
b/clang/test/CodeGen/tbaa-pointers.c
index f33281ada9903f..cf6061486b6ee4 100644
--- a/clang/test/CodeGen/tbaa-pointers.c
+++ b/clang/test/CodeGen/tbaa-pointers.c
@@ -186,6 +186,28 @@ void vla1(int n, int ptr[][n], int idx) {
 ptr[idx][0] = 0;
 }
 
+typedef struct {
+  int i1;
+} TypedefS;
+
+// FIXME: The !tbaa tag for unnamed structs doesn't account for compatible
+// types in C.
+void unamed_struct_typedef(TypedefS *ptr) {
+// COMMON-LABEL: define void @unamed_struct_typedef(
+// COMMON-SAME: ptr noundef %ptr)
+// COMMON-NEXT: entry:
+// COMMON-NEXT:   [[PTR_ADDR:%.+]]  = alloca ptr, align 8
+// DEFAULT-NEXT:  store ptr %ptr, ptr [[PTR_ADDR]], align 8, !tbaa [[ANYPTR]]
+// DEFAULT-NEXT:  [[L0:%.+]] = load ptr, ptr  [[PTR_ADDR]], align 8, !tbaa  
[[ANYPTR]]
+// ENABLED-NEXT:  store ptr %ptr, ptr [[PTR_ADDR]], align 8, !tbaa 
[[P1TYPEDEF:!.+]]
+// ENABLED-NEXT:  [[L0:%.+]] = load ptr, ptr [[PTR_ADDR]], align 8, !tbaa  
[[P1TYPEDEF]]
+// COMMON-NEXT:   [[GEP:%.+]]  = getelementptr inbounds nuw %struct.TypedefS, 
ptr [[L0]], i32 0, i32 0
+// COMMON-NEXT:   store i32 0, ptr [[GEP]], align 4
+// COMMON-NEXT:   ret void
+
+  ptr->i1 = 0;
+}
+
 // ENABLED: [[P2INT_0]] = !{[[P2INT:!.+]], [[P2INT]], i64 0}
 // ENABLED: [[P2INT]] = !{!"p2 int", [[ANY_POINTER:!.+]], i64 0}
 // DEFAULT: [[ANYPTR]] = !{[[ANY_POINTER:!.+]], [[ANY_POINTER]], i64 0}
@@ -217,3 +239,5 @@ void vla1(int n, int ptr[][n], int idx) {
 // DEFAULT: [[S2_TY]]  = !{!"S2", [[ANY_POINTER]], i64 0}
 // COMMON:  [[INT_TAG]] = !{[[INT_TY:!.+]], [[INT_TY]], i64 0}
 // COMMON:  [[INT_TY]] = !{!"int", [[CHAR]], i64 0}
+// ENABLED: [[P1TYPEDEF]] = !{[[P1TYPEDEF_TY:!.+]],  [[P1TYPEDEF_TY]], i64 0}
+// ENABLED: [[P1TYPEDEF_TY]] = !{!"p1 _ZTS8TypedefS", [[ANY_POINTER]], i64 0}



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


  1   2   >