[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2025-01-12 Thread Piotr Zegar via cfe-commits

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


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


[clang-tools-extra] a536444 - [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (#119974)

2025-01-12 Thread via cfe-commits

Author: Barnabás Pőcze
Date: 2025-01-12T10:07:52+01:00
New Revision: a536bd0dbbd60e83ee6cf11adabd72f4df54

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

LOG: [clang-tidy] performance-unnecessary-copy-initialization: Consider static 
functions (#119974)

Static member functions can be considered the same way as free functions
are, so do that.

Added: 


Modified: 
clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
clang-tools-extra/docs/ReleaseNotes.rst

clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp

Removed: 




diff  --git 
a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp 
b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
index 034894c11bf2c0..dc2e8a38a3e97a 100644
--- a/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ b/clang-tools-extra/clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -104,15 +104,18 @@ AST_MATCHER_FUNCTION_P(StatementMatcher,
 hasArgument(0, hasType(ReceiverType);
 }
 
+AST_MATCHER(CXXMethodDecl, isStatic) { return Node.isStatic(); }
+
 AST_MATCHER_FUNCTION(StatementMatcher, isConstRefReturningFunctionCall) {
-  // Only allow initialization of a const reference from a free function if it
-  // has no arguments. Otherwise it could return an alias to one of its
-  // arguments and the arguments need to be checked for const use as well.
-  return callExpr(callee(functionDecl(returns(hasCanonicalType(
-  matchers::isReferenceToConst(
- .bind(FunctionDeclId)),
-  argumentCountIs(0), unless(callee(cxxMethodDecl(
-  .bind(InitFunctionCallId);
+  // Only allow initialization of a const reference from a free function or
+  // static member function if it has no arguments. Otherwise it could return
+  // an alias to one of its arguments and the arguments need to be checked
+  // for const use as well.
+  return callExpr(argumentCountIs(0),
+  
callee(functionDecl(returns(hasCanonicalType(matchers::isReferenceToConst())),
+  
unless(cxxMethodDecl(unless(isStatic()
+ .bind(FunctionDeclId)))
+ .bind(InitFunctionCallId);
 }
 
 AST_MATCHER_FUNCTION_P(StatementMatcher, initializerReturnsReferenceToConst,
@@ -232,7 +235,7 @@ 
UnnecessaryCopyInitialization::UnnecessaryCopyInitialization(
   Options.get("ExcludedContainerTypes", ""))) {}
 
 void UnnecessaryCopyInitialization::registerMatchers(MatchFinder *Finder) {
-  auto LocalVarCopiedFrom = [this](const internal::Matcher &CopyCtorArg) 
{
+  auto LocalVarCopiedFrom = [this](const ast_matchers::internal::Matcher 
&CopyCtorArg) {
 return compoundStmt(
forEachDescendant(
declStmt(

diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 5c7ba4333e3816..08156325369e61 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -339,6 +339,10 @@ Changes in existing checks
   ` check to fix a crash when
   an argument type is declared but not defined.
 
+- Improved :doc:`performance-unnecessary-copy-initialization`
+   check
+  to consider static member functions the same way as free functions.
+
 - Improved :doc:`readability-container-contains
   ` check to let it work on
   any class that has a ``contains`` method. Fix some false negatives in the

diff  --git 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
index d02bb98cf583cb..b5325776f54c61 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/performance/unnecessary-copy-initialization.cpp
@@ -28,6 +28,8 @@ struct ExpensiveToCopyType {
   template 
   const A &templatedAccessor() const;
   operator int() const; // Implicit conversion to int.
+
+  static const ExpensiveToCopyType &instance();
 };
 
 template 
@@ -100,6 +102,28 @@ void PositiveFunctionCall() {
   VarCopyConstructed.constMethod();
 }
 
+void PositiveStaticMethodCall() {
+  const auto AutoAssigned = ExpensiveToCopyType::instance();
+  // CHECK-MESSAGES: [[@LINE-1]]:14: warning: the const qualified variable 
'AutoAssigned' is copy-constructed from a const reference; consider making it a 
const reference [performance-unnecessary-copy-initialization]
+  // CHECK-FIXES: const auto& AutoAssigned = ExpensiveToCopyType::instance();
+  AutoAssigned.constM

[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2025-01-12 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2025-01-12 Thread Piotr Zegar via cfe-commits

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


[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)

2025-01-12 Thread Owen Pan via cfe-commits


@@ -2252,6 +2252,25 @@ struct FormatStyle {
   /// \version 16
   BreakBeforeInlineASMColonStyle BreakBeforeInlineASMColon;
 
+  /// If ``true``, a line break will be placed before the ``>`` in a multiline
+  /// template declaration.
+  /// \code
+  ///true:
+  ///template <
+  ///typename Foo,
+  ///typename Bar,
+  ///typename Baz
+  ///>
+  ///
+  ///false:
+  ///template <
+  ///typename Foo,
+  ///typename Bar,
+  ///typename Baz>

owenca wrote:

> Would `Always` look like:
> 
> ```
> template >
> ```

Yes, except that there is a space between `template` and `<` by `LLVM` default.

> So, should I change this from a true/false to an enum of Multiline/Never?

Yes. I haven't looked at your implementation yet, but are you doing 
`BreakBeforeTemplateCloser` or `TemplateCloserOnItsOwnLine`?

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


[clang] [Driver] Warn when using msan on Android (PR #122540)

2025-01-12 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang] fdfe7e7 - [Driver] Error when using msan on Android (#122540)

2025-01-12 Thread via cfe-commits

Author: Sharjeel Khan
Date: 2025-01-12T17:36:00+08:00
New Revision: fdfe7e7fabc85ed7293ca6f5f234d41812644584

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

LOG: [Driver] Error when using msan on Android (#122540)

Msan is not supported on Android as mentioned in google/sanitizers#1381.
We proactively give the warning saying it is unsupported to fix
android/ndk#1958.

Added: 


Modified: 
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/fsanitize.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Linux.cpp 
b/clang/lib/Driver/ToolChains/Linux.cpp
index 1c56355136df86..c2a85be8198169 100644
--- a/clang/lib/Driver/ToolChains/Linux.cpp
+++ b/clang/lib/Driver/ToolChains/Linux.cpp
@@ -823,6 +823,7 @@ SanitizerMask Linux::getSupportedSanitizers() const {
   const bool IsRISCV64 = getTriple().getArch() == llvm::Triple::riscv64;
   const bool IsSystemZ = getTriple().getArch() == llvm::Triple::systemz;
   const bool IsHexagon = getTriple().getArch() == llvm::Triple::hexagon;
+  const bool IsAndroid = getTriple().isAndroid();
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   Res |= SanitizerKind::Address;
   Res |= SanitizerKind::PointerCompare;
@@ -831,7 +832,6 @@ SanitizerMask Linux::getSupportedSanitizers() const {
   Res |= SanitizerKind::Fuzzer;
   Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::KernelAddress;
-  Res |= SanitizerKind::Memory;
   Res |= SanitizerKind::Vptr;
   Res |= SanitizerKind::SafeStack;
   if (IsX86_64 || IsMIPS64 || IsAArch64 || IsLoongArch64)
@@ -857,6 +857,8 @@ SanitizerMask Linux::getSupportedSanitizers() const {
   }
   if (IsX86_64)
 Res |= SanitizerKind::NumericalStability;
+  if (!IsAndroid)
+Res |= SanitizerKind::Memory;
 
   // Work around "Cannot represent a 
diff erence across sections".
   if (getTriple().getArch() == llvm::Triple::ppc64)

diff  --git a/clang/test/Driver/fsanitize.c b/clang/test/Driver/fsanitize.c
index 1d3caec748d77a..429dc51b3356d6 100644
--- a/clang/test/Driver/fsanitize.c
+++ b/clang/test/Driver/fsanitize.c
@@ -399,6 +399,11 @@
 // RUN: %clang --target=arm-linux-androideabi %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-ANDROID-NO-ASAN
 // CHECK-ANDROID-NO-ASAN: "-mrelocation-model" "pic"
 
+// RUN: not %clang --target=aarch64-linux-android -fsanitize=memory %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
+// RUN: not %clang --target=i386-linux-android -fsanitize=memory %s -### 2>&1 
| FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
+// RUN: not %clang --target=x86_64-linux-android -fsanitize=memory %s -### 
2>&1 | FileCheck %s --check-prefix=CHECK-MSAN-ANDROID
+// CHECK-MSAN-ANDROID: unsupported option '-fsanitize=memory' for target
+
 // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined -### 2>&1 | 
FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN
 // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined 
-fsanitize-recover -### 2>&1 | FileCheck %s --check-prefix=CHECK-RECOVER-UBSAN
 // RUN: %clang --target=x86_64-linux-gnu %s -fsanitize=undefined 
-fsanitize-recover=all -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-RECOVER-UBSAN



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


[clang] [Driver] Warn when using msan on Android (PR #122540)

2025-01-12 Thread Carlo Cabrera via cfe-commits

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


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


[clang] [Driver] Warn when using msan on Android (PR #122540)

2025-01-12 Thread Carlo Cabrera via cfe-commits

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


[clang] [clang] fix uefi target for aarch64 & x86_64 (PR #120632)

2025-01-12 Thread Roland McGrath via cfe-commits


@@ -713,8 +713,8 @@ class LLVM_LIBRARY_VISIBILITY X86_64TargetInfo : public 
X86TargetInfo {
   X86_64TargetInfo(const llvm::Triple &Triple, const TargetOptions &Opts)
   : X86TargetInfo(Triple, Opts) {
 const bool IsX32 = getTriple().isX32();
-bool IsWinCOFF =
-getTriple().isOSWindows() && getTriple().isOSBinFormatCOFF();
+bool IsWinCOFF = (getTriple().isOSWindows() || getTriple().isUEFI()) &&
+ getTriple().isOSBinFormatCOFF();
 LongWidth = LongAlign = PointerWidth = PointerAlign = IsX32 ? 32 : 64;

frobtech wrote:

> @frobtech Yeah, that's kinda why I am unsure of the changes suggested.

Here AFAICT `IsWinCOFF` is being used only to choose the [datalayout 
string](https://llvm.org/docs/LangRef.html#langref-datalayout).  The only 
difference I see is `m:w` vs `m:e`, which is about assembler symbol naming 
details.  That's about the rules and conventions for PE-COFF compilers, 
assemblers, and linkers. This one case I don't think is something where UEFI 
users would ever need an option to differ from Windows users. There's probably 
only one right way to interface with the linker.

It seems to be called `IsWinCOFF` mainly because the way it's been checked for 
is "is COFF and is Windows".  I suspect that "is COFF" is true for other forms 
of COFF that aren't PE-COFF, but there isn't an `isOSBinFormatPECOFF()` that 
distinguishes, so this has been used as a proxy without explanation.  For this 
case, `IsPECOFF` would be better name locally, anyway, to express what it is 
that matters to the check.

IMHO it would be wisest *not* to go around making lots of things write out 
`...isOsWindows() || ...isOsUEFI()`.  Instead there should be an 
`.IsOSBinFormatPECOFF()` or the like (probably written as just that same OR 
anyway), where it's clearly expressed in the name of the call what property it 
is that is the determinant for each use case.

Just in this same file there are other local variables called `IsWinCOFF`, 
presumably likewise named because they are set the same way rather than clearly 
expressing what they are really checking for.  But that other use is do set 
`MaxVectorAlign`, which seems a lot like something that's really about runtime 
ABI subtleties, perhaps such as the expectations about stack and heap 
alignment.  Something like that very well may more properly be for Windows (and 
I don't know why it's for Windows&&COFF instead of just for Windows, maybe 
there's a distinction), and not for "all PE-COFF" and thus not for UEFI.

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


[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits


@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s

zwuis wrote:

> I think this test should go in `clang/test/Sema/conditional-expr.c` and we 
> should add a section of the GNU extension there.
> 
> I am also a bit concerned that we don't have a specific set of sema tests for 
> the GNU form of the conditional expression. So it makes me much left 
> confident that we will catch any breaks with this change.

I copied most test cases from 'clang/test/Sema/conditional-expr.c' and 
'clang/test/SemaCXX/conditional-expr.cpp' to new files, and modified them to 
FNU extension form.

Please let me know if the test cases still should be merged into one file or we 
need other test cases.

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


[clang-tools-extra] 8ebc35f - [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (#102299)

2025-01-12 Thread via cfe-commits

Author: MichelleCDjunaidi
Date: 2025-01-12T11:04:40+01:00
New Revision: 8ebc35f8d041f097a2b973b455dc3533420af6bf

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

LOG: [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check 
(#102299)

This checks that classes/structs inheriting from
``std::enable_shared_from_this`` does so with public inheritance, so it
prevents crashes due to ``std::make_shared`` and ``shared_from_this()``
getting called when the internal weak pointer was not initialized (e.g.
due to private inheritance).

Added: 
clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp
clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.h

clang-tools-extra/docs/clang-tidy/checks/bugprone/incorrect-enable-shared-from-this.rst

clang-tools-extra/test/clang-tidy/checkers/bugprone/incorrect-enable-shared-from-this.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index b27616f3dcc658..c5f0b5b28418f8 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -33,6 +33,7 @@
 #include "InaccurateEraseCheck.h"
 #include "IncDecInConditionsCheck.h"
 #include "IncorrectEnableIfCheck.h"
+#include "IncorrectEnableSharedFromThisCheck.h"
 #include "IncorrectRoundingsCheck.h"
 #include "InfiniteLoopCheck.h"
 #include "IntegerDivisionCheck.h"
@@ -144,6 +145,8 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck(
+"bugprone-incorrect-enable-shared-from-this");
 CheckFactories.registerCheck(
 "bugprone-return-const-ref-from-parameter");
 CheckFactories.registerCheck(

diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 8bd5646c5fe05a..e8309c68b7fcaa 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -27,6 +27,11 @@ add_clang_library(clangTidyBugproneModule STATIC
   ForwardingReferenceOverloadCheck.cpp
   ImplicitWideningOfMultiplicationResultCheck.cpp
   InaccurateEraseCheck.cpp
+  IncorrectEnableIfCheck.cpp
+  IncorrectEnableSharedFromThisCheck.cpp
+  ReturnConstRefFromParameterCheck.cpp
+  SuspiciousStringviewDataUsageCheck.cpp
+  SwitchMissingDefaultCaseCheck.cpp
   IncDecInConditionsCheck.cpp
   IncorrectEnableIfCheck.cpp
   IncorrectRoundingsCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp
new file mode 100644
index 00..425e46cf6c88cd
--- /dev/null
+++ 
b/clang-tools-extra/clang-tidy/bugprone/IncorrectEnableSharedFromThisCheck.cpp
@@ -0,0 +1,65 @@
+//===--- IncorrectEnableSharedFromThisCheck.cpp - clang-tidy 
--===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "IncorrectEnableSharedFromThisCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+void IncorrectEnableSharedFromThisCheck::registerMatchers(MatchFinder *Finder) 
{
+  const auto EnableSharedFromThis =
+  cxxRecordDecl(hasName("enable_shared_from_this"), isInStdNamespace());
+  const auto QType = hasCanonicalType(hasDeclaration(
+  cxxRecordDecl(
+  anyOf(EnableSharedFromThis.bind("enable_rec"),
+cxxRecordDecl(hasAnyBase(cxxBaseSpecifier(
+isPublic(), hasType(hasCanonicalType(
+hasDeclaration(EnableSharedFromThis
+  .bind("base_rec")));
+  Finder->addMatcher(
+  cxxRecordDecl(
+  unless(isExpansionInSystemHeader()),
+  hasDirectBase(cxxBaseSpecifier(unless(isPublic()), hasType(QType))
+.bind("base")))
+  .bind("derived"),
+  this);
+}
+
+void IncorrectEnableSharedFromThisCheck::check(
+const MatchFinder::Mat

[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2025-01-12 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2025-01-12 Thread Piotr Zegar via cfe-commits

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


[clang] [Clang][Sema] Do not perform type conversion before calculating result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits

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


[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits

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


[clang] [Driver] Warn when using msan on Android (PR #122540)

2025-01-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-aarch64-sve-vls` 
running on `linaro-g3-03` while building `clang` at step 6 "build stage 1".

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


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

```
Step 6 (build stage 1) failure: 'ninja' (failure)
...
[93/191] Linking CXX executable bin/mlir-opt
[94/191] Linking CXX executable bin/llvm-opt-fuzzer
[95/191] Linking CXX executable bin/llvm-lto
[96/191] Linking CXX executable bin/clang-nvlink-wrapper
[97/191] Linking CXX executable bin/mlir-transform-opt
[98/191] Generating ../../bin/llvm-ranlib
[99/191] Generating ../../bin/llvm-lib
[100/191] Generating ../../bin/llvm-dlltool
[101/191] Generating ../../bin/llvm-otool
[102/191] Copying llvm-locstats into 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls/stage1/./bin
command timed out: 1200 seconds without output running [b'ninja'], attempting 
to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1408.493035

```



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


[clang-tools-extra] [clang-tidy] performance-unnecessary-copy-initialization: Consider static functions (PR #119974)

2025-01-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-aarch64-sve-vls-2stage` running on `linaro-g3-02` while building 
`clang-tools-extra` at step 11 "build stage 2".

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


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

```
Step 11 (build stage 2) failure: 'ninja' (failure)
...
[8046/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-stop.cpp.o
[8047/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/openmp-modifiers.cpp.o
[8048/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-return.cpp.o
[8049/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/compute-offsets.cpp.o
[8050/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-select-type.cpp.o
[8051/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/mod-file.cpp.o
[8052/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-nullify.cpp.o
[8053/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-if-stmt.cpp.o
[8054/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-io.cpp.o
[8055/8801] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Clauses.cpp.o
FAILED: tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Clauses.cpp.o 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang++
 -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/flang/lib/Lower
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/lib/Lower 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/flang/include
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/include 
-isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/../mlir/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/mlir/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/clang/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/../clang/include
 -mcpu=neoverse-512tvb -msve-vector-bits=256 -mllvm 
-treat-scalable-fixed-error-as-warning=false -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-string-conversion 
-Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument 
-Wstring-conversion   -Wcovered-switch-default -Wno-nested-anon-types 
-O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD 
-MT tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Clauses.cpp.o -MF 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Clauses.cpp.o.d -o 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/Clauses.cpp.o -c 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/lib/Lower/OpenMP/Clauses.cpp
Killed
[8056/8801] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-omp-structure.cpp.o
FAILED: 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-omp-structure.cpp.o
 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang++
 -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/flang/lib/Semantics
 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/lib/Semantics
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/flang/include
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/include 
-isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/../mli

[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits

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


[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits

https://github.com/zwuis updated 
https://github.com/llvm/llvm-project/pull/108837

>From 7e5f88c322852939ae68c65f6adf4a5d2973d095 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Mon, 16 Sep 2024 21:50:11 +0800
Subject: [PATCH 1/3] Fix computing result type of conditional operand

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/Sema/SemaExpr.cpp|  4 +---
 clang/test/SemaCXX/conditional-gnu-ext.cpp | 19 +++
 3 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/SemaCXX/conditional-gnu-ext.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 17ec1fe0b946de..db8a7568a12114 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -389,6 +389,8 @@ Bug Fixes to C++ Support
 - Fixed a crash when clang tries to subtitute parameter pack while retaining 
the parameter
   pack. #GH63819, #GH107560
 - Fix a crash when a static assert declaration has an invalid close location. 
(#GH108687)
+- Fixed a bug in computing result type of conditional operator with omitted 
middle operand
+  (a GNU extension). (#GH15998)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8f3e15cc9a9bb7..8414a55e4868b9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8785,11 +8785,9 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation 
QuestionLoc,
   commonExpr = result.get();
 }
 // We usually want to apply unary conversions *before* saving, except
-// in the special case of a C++ l-value conditional.
+// in the special case in C++ that operands have the same type.
 if (!(getLangOpts().CPlusPlus
   && !commonExpr->isTypeDependent()
-  && commonExpr->getValueKind() == RHSExpr->getValueKind()
-  && commonExpr->isGLValue()
   && commonExpr->isOrdinaryOrBitFieldObject()
   && RHSExpr->isOrdinaryOrBitFieldObject()
   && Context.hasSameType(commonExpr->getType(), RHSExpr->getType( {
diff --git a/clang/test/SemaCXX/conditional-gnu-ext.cpp 
b/clang/test/SemaCXX/conditional-gnu-ext.cpp
new file mode 100644
index 00..83a6fff8467863
--- /dev/null
+++ b/clang/test/SemaCXX/conditional-gnu-ext.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 
-fexperimental-new-constant-interpreter
+// expected-no-diagnostics
+
+/*
+FIXME: Support constexpr
+
+constexpr int evaluate_once(int x) {
+  return (++x) ? : 10;
+}
+static_assert(evaluate_once(0) == 1, "");
+*/
+
+namespace GH15998 {
+  enum E { Zero, One };
+  E test(E e) {
+return e ? : One;
+  }
+}

>From 447c8b9c6e957308c9ff62e8c83b15b12f7fc1cb Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Mon, 16 Sep 2024 23:05:50 +0800
Subject: [PATCH 2/3] Format code

---
 clang/lib/Sema/SemaExpr.cpp | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8414a55e4868b9..c232d40ca31ac6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8786,11 +8786,10 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation 
QuestionLoc,
 }
 // We usually want to apply unary conversions *before* saving, except
 // in the special case in C++ that operands have the same type.
-if (!(getLangOpts().CPlusPlus
-  && !commonExpr->isTypeDependent()
-  && commonExpr->isOrdinaryOrBitFieldObject()
-  && RHSExpr->isOrdinaryOrBitFieldObject()
-  && Context.hasSameType(commonExpr->getType(), RHSExpr->getType( {
+if (!(getLangOpts().CPlusPlus && !commonExpr->isTypeDependent() &&
+  commonExpr->isOrdinaryOrBitFieldObject() &&
+  RHSExpr->isOrdinaryOrBitFieldObject() &&
+  Context.hasSameType(commonExpr->getType(), RHSExpr->getType( {
   ExprResult commonRes = UsualUnaryConversions(commonExpr);
   if (commonRes.isInvalid())
 return ExprError();

>From 4c3dbacae0c8935384e1bfd39bf1397d5a81ad1d Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Sun, 12 Jan 2025 18:50:29 +0800
Subject: [PATCH 3/3] Fix previously undiscovered case and address review
 feedbacks

'conditional-gnu-exp.cpp' is mainly copied and modified from 
'conditional-expr.cpp'
'conditional-gnu-ext.c' is mainly copied and modified from 'conditional-expr.c'
---
 clang/lib/Sema/SemaExpr.cpp|  12 +-
 clang/test/CXX/drs/cwg5xx.cpp  |  12 +
 clang/test/Sema/conditional-expr.c |   2 -
 clang/test/Sema/conditional-gnu-ext.c  | 111 ++
 clang/test/SemaCXX/conditional-expr.cpp|  24 --
 clang/test/SemaCXX/conditional-gnu-ext.cpp | 442 -
 6 files changed, 563 insertions(+), 40 deletions(-)
 create mode 100644 clang/test/Sema/conditional-gnu-ext.c

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index

[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread via cfe-commits


@@ -774,7 +774,15 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 const FunctionDecl *Decl = FD;
 if (const FunctionDecl* Pattern = FD->getTemplateInstantiationPattern())
   Decl = Pattern;
-const FunctionType *AFT = Decl->getType()->getAs();
+
+// The type may not be fully initialized at this point.
+// For example, in the trailing return type context of the lambda
+// expression.

cor3ntin wrote:

```suggestion
  // Bail out of the type of the function has not been set yet.
  // This can notably happen in the trailing return type of a lambda expression
```

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


[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread via cfe-commits

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


[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread via cfe-commits

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

LGTM (but i reworded the comment slightly)

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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread via cfe-commits


@@ -10757,6 +10757,17 @@ static void checkMethodTypeQualifiers(Sema &S, 
Declarator &D, unsigned DiagID) {
   }
 }
 
+static void checkMethodPointerType(Sema &S, Declarator &D, unsigned DiagID) {
+  if (D.getNumTypeObjects() > 0) {
+DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1);
+if (Chunk.Kind == DeclaratorChunk::Pointer) {
+  SourceLocation PointerLoc = Chunk.getSourceRange().getBegin();
+  S.Diag(PointerLoc, DiagID) << Chunk.getSourceRange();
+  D.setInvalidType();
+}
+  }
+}
+

cor3ntin wrote:

Can we simplify that by checking that there is only one chunk? (which is a 
function?)

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread via cfe-commits

dodicidodici wrote:

> This check sounds a bit strange. Is this issue common in real-world projects, 
> do we have some data? It's the first time I've heard of it. Why would people 
> deviate from the standard signature for move constructors?

It's anecdotal, but I've encountered it in a few places in a private codebase. 
I don't think it's a *really* common issue, but it'd be nice to have a lint 
warning for this.

> We could perhaps consider making this check a bit more general and enforce 
> that all 5 special member functions have the correct signature (including 
> ref-qualification and `noexcept`).

There's `performance-noexcept-move-constructor` and 
`performance-noexcept-destructor` that cover missing `noexcept`s. Also yes, 
making it more generic is a great idea (altough I thought there were other 
lints that were doing that).

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


[clang-tools-extra] [clang-tidy] Create bugprone-incorrect-enable-shared-from-this check (PR #102299)

2025-01-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-arm64-windows-msvc` 
running on `linaro-armv8-windows-msvc-04` while building `clang-tools-extra` at 
step 5 "ninja check 1".

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


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

```
Step 5 (ninja check 1) failure: stage 1 checked (failure)
 TEST 'LLVM :: 
CodeGen/AMDGPU/llvm.amdgcn.struct.tbuffer.store.d16.ll' FAILED 

Exit Code: 3221225539

Command Output (stdout):
--
# RUN: at line 2
c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe 
-mtriple=amdgcn-amd-amdhsa -mcpu=tonga -verify-machineinstrs < 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
 | c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe 
-check-prefixes=PREGFX10-UNPACKED 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe' 
-mtriple=amdgcn-amd-amdhsa -mcpu=tonga -verify-machineinstrs
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe' 
-check-prefixes=PREGFX10-UNPACKED 
'C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll'
# RUN: at line 3
c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe 
-mtriple=amdgcn-amd-amdhsa -mcpu=gfx810 -verify-machineinstrs < 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
 | c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe 
-check-prefixes=PREGFX10-PACKED 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe' 
-mtriple=amdgcn-amd-amdhsa -mcpu=gfx810 -verify-machineinstrs
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe' 
-check-prefixes=PREGFX10-PACKED 
'C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll'
# RUN: at line 4
c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe 
-mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs < 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
 | c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe 
-check-prefixes=PREGFX10-PACKED 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe' 
-mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -verify-machineinstrs
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe' 
-check-prefixes=PREGFX10-PACKED 
'C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll'
# RUN: at line 5
c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe 
-mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs < 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
 | c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe 
-check-prefixes=GFX10-PACKED 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe' 
-mtriple=amdgcn-amd-amdhsa -mcpu=gfx1010 -verify-machineinstrs
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe' 
-check-prefixes=GFX10-PACKED 
'C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll'
# RUN: at line 6
c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe 
-mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -amdgpu-enable-vopd=0 
-verify-machineinstrs < 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
 | c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\filecheck.exe 
-check-prefixes=GFX11-PACKED 
C:\Users\tcwg\llvm-worker\clang-arm64-windows-msvc\llvm\llvm\test\CodeGen\AMDGPU\llvm.amdgcn.struct.tbuffer.store.d16.ll
# executed command: 
'c:\users\tcwg\llvm-worker\clang-arm64-windows-msvc\stage1\bin\llc.exe' 
-mtriple=amdgcn-amd-amdhsa -mcpu=gfx1100 -amdgpu-enable-vopd=0 
-verify-machineinstrs
# executed command: 

[clang] [Clang] Use `-targets=host-x86_64-unknown-linux-gnu` as bundler target (PR #122627)

2025-01-12 Thread Shilei Tian via cfe-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/122627

>From 71bad77117ef0dedbe6c28ff578470d8266108a6 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sat, 11 Jan 2025 21:24:53 -0500
Subject: [PATCH] [Clang] Use `-targets=host-x86_64-unknown-linux-gnu` as
 bundler target

This a prime patch to support generic target when using `--offload-compress`.
---
 clang/lib/Driver/ToolChains/HIPUtility.cpp|  2 +-
 clang/test/Driver/cuda-arch-translation.cu| 34 +--
 clang/test/Driver/hip-code-object-version.hip |  8 ++---
 clang/test/Driver/hip-target-id.hip   |  6 ++--
 clang/test/Driver/hipspv-toolchain.hip|  2 +-
 clang/test/Driver/linker-wrapper.c|  8 ++---
 .../ClangLinkerWrapper.cpp|  2 +-
 7 files changed, 31 insertions(+), 31 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp 
b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index 3f81c3cb0f80e8..bfb6ec7a010583 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -291,7 +291,7 @@ void HIP::constructHIPFatbinCommand(Compilation &C, const 
JobAction &JA,
 
   // ToDo: Remove the dummy host binary entry which is required by
   // clang-offload-bundler.
-  std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
+  std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux-gnu";
   // AMDGCN:
   // For code object version 2 and 3, the offload kind in bundle ID is 'hip'
   // for backward compatibility. For code object version 4 and greater, the
diff --git a/clang/test/Driver/cuda-arch-translation.cu 
b/clang/test/Driver/cuda-arch-translation.cu
index a0ae16452692bf..e4f83740a92ebd 100644
--- a/clang/test/Driver/cuda-arch-translation.cu
+++ b/clang/test/Driver/cuda-arch-translation.cu
@@ -81,20 +81,20 @@
 // SM61:--image=profile=sm_61{{.*}}
 // SM62:--image=profile=sm_62{{.*}}
 // SM70:--image=profile=sm_70{{.*}}
-// GFX600:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx600
-// GFX601:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx601
-// GFX602:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx602
-// GFX700:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx700
-// GFX701:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx701
-// GFX702:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx702
-// GFX703:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx703
-// GFX704:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx704
-// GFX705:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx705
-// GFX801:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx801
-// GFX802:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx802
-// GFX803:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx803
-// GFX805:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx805
-// GFX810:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx810
-// GFX900:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx900
-// GFX902:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx902
-// SPIRV:-targets=host-x86_64-unknown-linux,hip-spirv64-amd-amdhsa--amdgcnspirv
+// 
GFX600:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx600
+// 
GFX601:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx601
+// 
GFX602:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx602
+// 
GFX700:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx700
+// 
GFX701:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx701
+// 
GFX702:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx702
+// 
GFX703:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx703
+// 
GFX704:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx704
+// 
GFX705:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx705
+// 
GFX801:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx801
+// 
GFX802:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx802
+// 
GFX803:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx803
+// 
GFX805:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx805
+// 
GFX810:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx810
+// 
GFX900:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx900
+// 
GFX902:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx902
+// 
SPIRV:-targets=host-x86_64-unknown-linux-gnu,hip-spirv64-amd-amdhsa--amdgcnspirv
diff --git a/clang/test/Driver/hip-code-object-version.hip 
b/clang/test/Driver/hip-code-object-version.hip
index 9d0afaeaa967d3..30d8644dff54c6 100644
--- a/clang/test/Driver/hip-code-object-version.hip
+++ b/clang/test/Driver/hip-code-object-version.hip
@@ -7,7 +7,7 @@
 
 

[clang] [Clang] Use `-targets=host-x86_64-unknown-linux-gnu` as bundler target (PR #122627)

2025-01-12 Thread Shilei Tian via cfe-commits

shiltian wrote:

### Merge activity

* **Jan 12, 10:49 AM EST**: A user started a stack merge that includes this 
pull request via 
[Graphite](https://app.graphite.dev/github/pr/llvm/llvm-project/122627).


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


[clang] 0d352b2 - [Clang] Use `-targets=host-x86_64-unknown-linux-gnu` as bundler target (#122627)

2025-01-12 Thread via cfe-commits

Author: Shilei Tian
Date: 2025-01-12T10:51:12-05:00
New Revision: 0d352b2ea767e043b47d78bfdbd6820356628314

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

LOG: [Clang] Use `-targets=host-x86_64-unknown-linux-gnu` as bundler target 
(#122627)

This a prime patch to support generic target when using `--offload-compress`.

Added: 


Modified: 
clang/lib/Driver/ToolChains/HIPUtility.cpp
clang/test/Driver/cuda-arch-translation.cu
clang/test/Driver/hip-code-object-version.hip
clang/test/Driver/hip-target-id.hip
clang/test/Driver/hipspv-toolchain.hip
clang/test/Driver/linker-wrapper.c
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/HIPUtility.cpp 
b/clang/lib/Driver/ToolChains/HIPUtility.cpp
index 3f81c3cb0f80e8..bfb6ec7a010583 100644
--- a/clang/lib/Driver/ToolChains/HIPUtility.cpp
+++ b/clang/lib/Driver/ToolChains/HIPUtility.cpp
@@ -291,7 +291,7 @@ void HIP::constructHIPFatbinCommand(Compilation &C, const 
JobAction &JA,
 
   // ToDo: Remove the dummy host binary entry which is required by
   // clang-offload-bundler.
-  std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux";
+  std::string BundlerTargetArg = "-targets=host-x86_64-unknown-linux-gnu";
   // AMDGCN:
   // For code object version 2 and 3, the offload kind in bundle ID is 'hip'
   // for backward compatibility. For code object version 4 and greater, the

diff  --git a/clang/test/Driver/cuda-arch-translation.cu 
b/clang/test/Driver/cuda-arch-translation.cu
index a0ae16452692bf..e4f83740a92ebd 100644
--- a/clang/test/Driver/cuda-arch-translation.cu
+++ b/clang/test/Driver/cuda-arch-translation.cu
@@ -81,20 +81,20 @@
 // SM61:--image=profile=sm_61{{.*}}
 // SM62:--image=profile=sm_62{{.*}}
 // SM70:--image=profile=sm_70{{.*}}
-// GFX600:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx600
-// GFX601:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx601
-// GFX602:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx602
-// GFX700:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx700
-// GFX701:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx701
-// GFX702:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx702
-// GFX703:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx703
-// GFX704:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx704
-// GFX705:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx705
-// GFX801:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx801
-// GFX802:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx802
-// GFX803:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx803
-// GFX805:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx805
-// GFX810:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx810
-// GFX900:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx900
-// GFX902:-targets=host-x86_64-unknown-linux,hipv4-amdgcn-amd-amdhsa--gfx902
-// SPIRV:-targets=host-x86_64-unknown-linux,hip-spirv64-amd-amdhsa--amdgcnspirv
+// 
GFX600:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx600
+// 
GFX601:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx601
+// 
GFX602:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx602
+// 
GFX700:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx700
+// 
GFX701:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx701
+// 
GFX702:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx702
+// 
GFX703:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx703
+// 
GFX704:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx704
+// 
GFX705:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx705
+// 
GFX801:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx801
+// 
GFX802:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx802
+// 
GFX803:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx803
+// 
GFX805:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx805
+// 
GFX810:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx810
+// 
GFX900:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx900
+// 
GFX902:-targets=host-x86_64-unknown-linux-gnu,hipv4-amdgcn-amd-amdhsa--gfx902
+// 
SPIRV:-targets=host-x86_64-unknown-linux-gnu,hip-spirv64-amd-amdhsa--amdgcnspirv

diff  --git a/clang/test/Driver/hip-code-object-version.hip 
b/clang/test/Driver/hip-code-object-version.hip
index 9d0afaeaa967d3..30d8644dff54c6 100644
--- a/clang/test/Driver/hip-code-object-version.hip
+++

[clang] [Clang] Use `-targets=host-x86_64-unknown-linux-gnu` as bundler target (PR #122627)

2025-01-12 Thread Shilei Tian via cfe-commits

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


[clang] [llvm] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to support generic target (PR #122629)

2025-01-12 Thread Shilei Tian via cfe-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/122629

>From b1dbe4f558fe282968af1ac33d58d74d3238d8d5 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sun, 12 Jan 2025 10:48:56 -0500
Subject: [PATCH] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to
 support generic target

The current parsing of target string assumes to be in a form of
`kind-triple-targetid:feature`, such as
`hipv4-amdgcn-amd-amdhsa-gfx1030:+xnack`. Specifically, the target id does not
contain any `-`, which is not the case for generic target. Also, a generic
target may contain one or more `-`, such as `gfx10-3-generic` and
`gfx12-generic`. As a result, we can no longer depend on `rstrip` to get things
work right. This patch reworks the logic to parse the target string to make it
more robust, as well as supporting generic target.
---
 clang/docs/ClangOffloadBundler.rst|  7 ++--
 clang/lib/Driver/OffloadBundler.cpp   | 40 +++
 .../Driver/clang-offload-bundler-asserts-on.c | 14 +++
 .../clang-offload-bundler-standardize.c   | 13 +++---
 .../test/Driver/clang-offload-bundler-zstd.c  | 12 +++---
 clang/test/Driver/clang-offload-bundler.c | 20 +-
 llvm/utils/lit/lit/llvm/config.py | 12 +-
 7 files changed, 57 insertions(+), 61 deletions(-)

diff --git a/clang/docs/ClangOffloadBundler.rst 
b/clang/docs/ClangOffloadBundler.rst
index 3c241027d405ca..25214c2ea6a4e1 100644
--- a/clang/docs/ClangOffloadBundler.rst
+++ b/clang/docs/ClangOffloadBundler.rst
@@ -266,15 +266,14 @@ without differentiation based on offload kind.
 The target triple of the code object. See `Target Triple
 `_.
 
-The bundler accepts target triples with or without the optional environment
-field:
+LLVM target triples can be with or without the optional environment field:
 
 ``--``, or
 ``---``
 
 However, in order to standardize outputs for tools that consume bitcode
-bundles, bundles written by the bundler internally use only the 4-field
-target triple:
+bundles, the bundler only accepts target triples with the 4-field target
+triple:
 
 ``---``
 
diff --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 2d6bdff0393be5..024536d32ecc62 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -84,31 +84,19 @@ OffloadTargetInfo::OffloadTargetInfo(const StringRef Target,
 : BundlerConfig(BC) {
 
   // TODO: Add error checking from ClangOffloadBundler.cpp
-  auto TargetFeatures = Target.split(':');
-  auto TripleOrGPU = TargetFeatures.first.rsplit('-');
-
-  if (clang::StringToOffloadArch(TripleOrGPU.second) !=
-  clang::OffloadArch::UNKNOWN) {
-auto KindTriple = TripleOrGPU.first.split('-');
-this->OffloadKind = KindTriple.first;
-
-// Enforce optional env field to standardize bundles
-llvm::Triple t = llvm::Triple(KindTriple.second);
-this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
-t.getOSName(), t.getEnvironmentName());
-
-this->TargetID = Target.substr(Target.find(TripleOrGPU.second));
-  } else {
-auto KindTriple = TargetFeatures.first.split('-');
-this->OffloadKind = KindTriple.first;
-
-// Enforce optional env field to standardize bundles
-llvm::Triple t = llvm::Triple(KindTriple.second);
-this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
-t.getOSName(), t.getEnvironmentName());
-
-this->TargetID = "";
-  }
+  // -[-]
+  //  := ---
+  SmallVector Components;
+  Target.split(':').first.split(Components, '-', /*MaxSplit=*/5);
+  assert((Components.size() == 5 || Components.size() == 6) &&
+ "malformed target string");
+
+  this->OffloadKind = Components.front();
+  this->TargetID = Components.size() == 6 ? Components.back() : "";
+  ArrayRef TripleSlice{&Components[1], /*length=*/4};
+  llvm::Triple T = llvm::Triple(llvm::join(TripleSlice, "-"));
+  this->Triple = llvm::Triple(T.getArchName(), T.getVendorName(), 
T.getOSName(),
+  T.getEnvironmentName());
 }
 
 bool OffloadTargetInfo::hasHostKind() const {
@@ -148,7 +136,7 @@ bool OffloadTargetInfo::operator==(const OffloadTargetInfo 
&Target) const {
 }
 
 std::string OffloadTargetInfo::str() const {
-  return Twine(OffloadKind + "-" + Triple.str() + "-" + TargetID).str();
+  return Twine(OffloadKind + "-" + Triple.normalize() + "-" + TargetID).str();
 }
 
 static StringRef getDeviceFileExtension(StringRef Device,
diff --git a/clang/test/Driver/clang-offload-bundler-asserts-on.c 
b/clang/test/Driver/clang-offload-bundler-asserts-on.c
index 55060c2c42e734..eec30674107b25 100644
--- a/clang/test/Driver/clang-offload-bundler-asserts-on.c
+++ b/clang/test/Driver/clang-offload-bundler-asserts-on.c
@@ -15,20 +15,20 @@
 // Check code object compatib

[clang] [llvm] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to support generic target (PR #122629)

2025-01-12 Thread Shilei Tian via cfe-commits

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


[clang] [llvm] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to support generic target (PR #122629)

2025-01-12 Thread Shilei Tian via cfe-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/122629

>From c58bbd1edcc295a03d68a311a16080550c6aea96 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sun, 12 Jan 2025 10:48:56 -0500
Subject: [PATCH] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to
 support generic target

The current parsing of target string assumes to be in a form of
`kind-triple-targetid:feature`, such as
`hipv4-amdgcn-amd-amdhsa-gfx1030:+xnack`. Specifically, the target id does not
contain any `-`, which is not the case for generic target. Also, a generic
target may contain one or more `-`, such as `gfx10-3-generic` and
`gfx12-generic`. As a result, we can no longer depend on `rstrip` to get things
work right. This patch reworks the logic to parse the target string to make it
more robust, as well as supporting generic target.
---
 clang/docs/ClangOffloadBundler.rst|  7 ++--
 clang/lib/Driver/OffloadBundler.cpp   | 40 +++
 .../Driver/clang-offload-bundler-asserts-on.c | 14 +++
 .../clang-offload-bundler-standardize.c   | 13 +++---
 .../test/Driver/clang-offload-bundler-zstd.c  | 12 +++---
 clang/test/Driver/clang-offload-bundler.c | 20 +-
 llvm/utils/lit/lit/llvm/config.py | 12 +-
 7 files changed, 57 insertions(+), 61 deletions(-)

diff --git a/clang/docs/ClangOffloadBundler.rst 
b/clang/docs/ClangOffloadBundler.rst
index 3c241027d405ca..25214c2ea6a4e1 100644
--- a/clang/docs/ClangOffloadBundler.rst
+++ b/clang/docs/ClangOffloadBundler.rst
@@ -266,15 +266,14 @@ without differentiation based on offload kind.
 The target triple of the code object. See `Target Triple
 `_.
 
-The bundler accepts target triples with or without the optional environment
-field:
+LLVM target triples can be with or without the optional environment field:
 
 ``--``, or
 ``---``
 
 However, in order to standardize outputs for tools that consume bitcode
-bundles, bundles written by the bundler internally use only the 4-field
-target triple:
+bundles, the bundler only accepts target triples with the 4-field target
+triple:
 
 ``---``
 
diff --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 2d6bdff0393be5..024536d32ecc62 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -84,31 +84,19 @@ OffloadTargetInfo::OffloadTargetInfo(const StringRef Target,
 : BundlerConfig(BC) {
 
   // TODO: Add error checking from ClangOffloadBundler.cpp
-  auto TargetFeatures = Target.split(':');
-  auto TripleOrGPU = TargetFeatures.first.rsplit('-');
-
-  if (clang::StringToOffloadArch(TripleOrGPU.second) !=
-  clang::OffloadArch::UNKNOWN) {
-auto KindTriple = TripleOrGPU.first.split('-');
-this->OffloadKind = KindTriple.first;
-
-// Enforce optional env field to standardize bundles
-llvm::Triple t = llvm::Triple(KindTriple.second);
-this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
-t.getOSName(), t.getEnvironmentName());
-
-this->TargetID = Target.substr(Target.find(TripleOrGPU.second));
-  } else {
-auto KindTriple = TargetFeatures.first.split('-');
-this->OffloadKind = KindTriple.first;
-
-// Enforce optional env field to standardize bundles
-llvm::Triple t = llvm::Triple(KindTriple.second);
-this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
-t.getOSName(), t.getEnvironmentName());
-
-this->TargetID = "";
-  }
+  // -[-]
+  //  := ---
+  SmallVector Components;
+  Target.split(':').first.split(Components, '-', /*MaxSplit=*/5);
+  assert((Components.size() == 5 || Components.size() == 6) &&
+ "malformed target string");
+
+  this->OffloadKind = Components.front();
+  this->TargetID = Components.size() == 6 ? Components.back() : "";
+  ArrayRef TripleSlice{&Components[1], /*length=*/4};
+  llvm::Triple T = llvm::Triple(llvm::join(TripleSlice, "-"));
+  this->Triple = llvm::Triple(T.getArchName(), T.getVendorName(), 
T.getOSName(),
+  T.getEnvironmentName());
 }
 
 bool OffloadTargetInfo::hasHostKind() const {
@@ -148,7 +136,7 @@ bool OffloadTargetInfo::operator==(const OffloadTargetInfo 
&Target) const {
 }
 
 std::string OffloadTargetInfo::str() const {
-  return Twine(OffloadKind + "-" + Triple.str() + "-" + TargetID).str();
+  return Twine(OffloadKind + "-" + Triple.normalize() + "-" + TargetID).str();
 }
 
 static StringRef getDeviceFileExtension(StringRef Device,
diff --git a/clang/test/Driver/clang-offload-bundler-asserts-on.c 
b/clang/test/Driver/clang-offload-bundler-asserts-on.c
index 55060c2c42e734..eec30674107b25 100644
--- a/clang/test/Driver/clang-offload-bundler-asserts-on.c
+++ b/clang/test/Driver/clang-offload-bundler-asserts-on.c
@@ -15,20 +15,20 @@
 // Check code object compatib

[clang] [llvm] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to support generic target (PR #122629)

2025-01-12 Thread Shilei Tian via cfe-commits

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


[clang] [llvm] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to support AMDGPU's generic target (PR #122629)

2025-01-12 Thread Shilei Tian via cfe-commits

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


[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits


@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 
-fexperimental-new-constant-interpreter

zwuis wrote:

> Should run with BOTH constexpr interpreters.

Sorry I don't understand the meaning. Could you give an example?

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


[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread via cfe-commits

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


[clang] d080f78 - [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (#122611)

2025-01-12 Thread via cfe-commits

Author: TilakChad
Date: 2025-01-12T15:42:04+01:00
New Revision: d080f78772acf9de4961b89062c02fdd5f82186a

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

LOG: [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) 
appears in the trailing return type of the lambda  (#122611)

The (function) type of the lambda function is null while parsing
trailing return type. The type is filled-in when the lambda body is
entered. So, resolving `__PRETTY_FUNCTION__` before the lambda body is
entered causes the crash.

Fixes #121274.

Added: 
clang/test/SemaCXX/crash-GH121274.cpp

Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/AST/Expr.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 197b3692b8a181..a14fb189c8e132 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -926,6 +926,7 @@ Bug Fixes to C++ Support
   (`LWG3929 `__.) (#GH121278)
 - Clang now identifies unexpanded parameter packs within the type constraint 
on a non-type template parameter. (#GH88866)
 - Fixed an issue while resolving type of expression indexing into a pack of 
values of non-dependent type (#GH121242)
+- Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in 
the trailing return type of the lambda (#GH121274)
 
 Bug Fixes to AST Handling
 ^

diff  --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 5331357b5d1fef..f6a4ed970cb23f 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -774,7 +774,15 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 const FunctionDecl *Decl = FD;
 if (const FunctionDecl* Pattern = FD->getTemplateInstantiationPattern())
   Decl = Pattern;
-const FunctionType *AFT = Decl->getType()->getAs();
+
+// Bail out if the type of the function has not been set yet.
+// This can notably happen in the trailing return type of a lambda
+// expression.
+const Type *Ty = Decl->getType().getTypePtrOrNull();
+if (!Ty)
+  return "";
+
+const FunctionType *AFT = Ty->getAs();
 const FunctionProtoType *FT = nullptr;
 if (FD->hasWrittenPrototype())
   FT = dyn_cast(AFT);

diff  --git a/clang/test/SemaCXX/crash-GH121274.cpp 
b/clang/test/SemaCXX/crash-GH121274.cpp
new file mode 100644
index 00..28677a0949bf9e
--- /dev/null
+++ b/clang/test/SemaCXX/crash-GH121274.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+// expected-no-diagnostics
+
+// Do not crash when __PRETTY_FUNCTION__ appears in the trailing return type 
of the lambda
+void foo() {
+   []() -> decltype(static_cast(__PRETTY_FUNCTION__)) {
+   return nullptr;
+   }();
+
+#ifdef MS
+   []() -> decltype(static_cast(__FUNCSIG__)) {
+   return nullptr;
+   }();
+#endif
+}



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


[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

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

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


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)
...
[   OK ] AddressSanitizer.StrtollOOBTest (1628 ms)
[ RUN  ] AddressSanitizer.HasFeatureAddressSanitizerTest
[   OK ] AddressSanitizer.HasFeatureAddressSanitizerTest (0 ms)
[ RUN  ] AddressSanitizer.CallocReturnsZeroMem
[   OK ] AddressSanitizer.CallocReturnsZeroMem (13 ms)
[ DISABLED ] AddressSanitizer.DISABLED_TSDTest
[ RUN  ] AddressSanitizer.IgnoreTest
[   OK ] AddressSanitizer.IgnoreTest (0 ms)
[ RUN  ] AddressSanitizer.SignalTest
[   OK ] AddressSanitizer.SignalTest (285 ms)
[ RUN  ] AddressSanitizer.ReallocFreedPointerTest
[   OK ] AddressSanitizer.ReallocFreedPointerTest (207 ms)
[ RUN  ] AddressSanitizer.DoubleFreeTest
[   OK ] AddressSanitizer.DoubleFreeTest (257 ms)
[ RUN  ] AddressSanitizer.UnderscopeLongJmpTest
[   OK ] AddressSanitizer.UnderscopeLongJmpTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_MemIntrinsicUnalignedAccessTest
[ DISABLED ] AddressSanitizer.DISABLED_LargeFunctionSymbolizeTest
[ DISABLED ] AddressSanitizer.DISABLED_MallocFreeUnwindAndSymbolizeTest
[ RUN  ] AddressSanitizer.ThreadedTest
[   OK ] AddressSanitizer.ThreadedTest (305 ms)
[ RUN  ] AddressSanitizer.StrDupTest
[   OK ] AddressSanitizer.StrDupTest (0 ms)
[ RUN  ] AddressSanitizer.StressStackReuseTest
[   OK ] AddressSanitizer.StressStackReuseTest (16 ms)
[ DISABLED ] AddressSanitizer.DISABLED_StressStackReuseAndExceptionsTest
[ RUN  ] AddressSanitizer.LargeStructCopyTest
[   OK ] AddressSanitizer.LargeStructCopyTest (0 ms)
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadedTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoThreadStackTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowIn
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowLeft
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFLowRight
[ DISABLED ] AddressSanitizer.DISABLED_DemoUAFHigh
[ DISABLED ] AddressSanitizer.DISABLED_DemoOOM
[ DISABLED ] AddressSanitizer.DISABLED_DemoDoubleFreeTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoNullDerefTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoFunctionStaticTest
[ DISABLED ] AddressSanitizer.DISABLED_DemoTooMuchMemoryTest
[ RUN  ] AddressSanitizer.pthread_getschedparam
[   OK ] AddressSanitizer.pthread_getschedparam (428 ms)
[--] 19 tests from AddressSanitizer (13177 ms total)

[--] Global test environment tear-down
[==] 22 tests from 2 test suites ran. (13179 ms total)
[  PASSED  ] 22 tests.

  YOU HAVE 3 DISABLED TESTS

Step 9 (run cmake) failure: run cmake (failure)
...
-- Performing Test HAVE_CXX_FLAG_COVERAGE
-- Performing Test HAVE_CXX_FLAG_COVERAGE - Failed
-- Compiling and running to test HAVE_GNU_POSIX_REGEX
-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
CMake Warning at 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/third-party/benchmark/CMakeLists.txt:319
 (message):
  Using std::regex with exceptions disabled is not fully supported
-- Compiling and running to test HAVE_STEADY_CLOCK
-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
CMake Warning at 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/third-party/benchmark/CMakeLists.txt:319
 (message):
  Using std::regex with exceptions disabled is not fully supported
-- Compiling and running to test HAVE_STEADY_CLOCK
-- Performing Test HAVE_GNU_POSIX_REGEX -- failed to compile
-- Compiling and running to test HAVE_POSIX_REGEX
-- Performing Test HAVE_STEADY_CLOCK -- compiled but failed to run
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Performing Test HAVE_STEADY_CLOCK -- compiled but failed to run
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Check if compiler accepts -pthread
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Compiling and running to test HAVE_PTHREAD_AFFINITY
-- Performing Test HAVE_PTHREAD_AFFINITY -- failed to compile
-- Check if compiler accepts -pthread - yes
-- Found Threads: TRUE  
-- Compiling and running to test HAVE_PTHREAD_AFFINITY
-- Performing Test HAVE_POSIX_REGEX -- compiled but failed to run
-- Compiling and running to test HAVE_STEADY_CLOCK
CMake Warning at 
/var/lib/buildbot/sanitizer-buildbot6/sanitizer-x86_64-linux-android/build/llvm-project/third-party/benchmark/CMakeLists.txt:319
 (messa

[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread via cfe-commits

TilakChad wrote:

> LGTM.
> Do you need me to merge that for you?

Thanks.

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread via cfe-commits


@@ -0,0 +1,33 @@
+//===--- ExplicitMoveConstructorCheck.h - clang-tidy *- C++ 
-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EXPLICITMOVECONSTRUCTORCHECK_H
+#define 
LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_EXPLICITMOVECONSTRUCTORCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::performance {
+
+/// Find classes that define an explicit move constructor and a (non-deleted) 
copy constructor.
+///
+/// For the user-facing documentation see:
+/// 
http://clang.llvm.org/extra/clang-tidy/checks/performance/explicit-move-constructor.html
+class ExplicitMoveConstructorCheck : public ClangTidyCheck {
+public:
+  ExplicitMoveConstructorCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  bool isLanguageVersionSupported(const LangOptions &LangOpts) const override {
+return LangOpts.CPlusPlus;

EugeneZelenko wrote:

C++11.

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread via cfe-commits


@@ -0,0 +1,73 @@
+//===--- ExplicitMoveConstructorCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ExplicitMoveConstructorCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+static SourceRange findExplicitToken(const CXXConstructorDecl *Ctor,
+ const SourceManager &Source,
+ const LangOptions &LangOpts) {
+  SourceLocation CurrentLoc = Ctor->getBeginLoc();
+  SourceLocation EndLoc = Ctor->getEndLoc();

EugeneZelenko wrote:

```suggestion
  const SourceLocation EndLoc = Ctor->getEndLoc();
```

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread via cfe-commits


@@ -0,0 +1,33 @@
+.. title:: clang-tidy - performance-explicit-move-constructor
+
+performance-explicit-move-constructor
+=
+
+Checks for classes that define an explicit move constructor and a copy

EugeneZelenko wrote:

Please synchronize first statement with Release Notes.

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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread Oleksandr T. via cfe-commits

https://github.com/a-tarasyuk updated 
https://github.com/llvm/llvm-project/pull/122621

>From b2c656afdf99eff52d019b68fcbbc6ce4bbdd7d3 Mon Sep 17 00:00:00 2001
From: Oleksandr T 
Date: Sun, 12 Jan 2025 00:51:47 +0200
Subject: [PATCH 1/2] [Clang] disallow the use of asterisks preceding
 constructor and destructor names

---
 clang/docs/ReleaseNotes.rst  |  1 +
 clang/include/clang/Basic/DiagnosticSemaKinds.td |  4 
 clang/lib/Sema/SemaDeclCXX.cpp   | 13 +
 clang/test/SemaCXX/constructor.cpp   | 10 ++
 clang/test/SemaCXX/destructor.cpp|  7 +++
 5 files changed, 35 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 197b3692b8a181..9e5bbbf6dc055a 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -764,6 +764,7 @@ Improvements to Clang's diagnostics
   scope.Unlock();
   require(scope); // Warning!  Requires mu1.
 }
+- Clang now disallows the use of asterisks preceding constructor and 
destructor names (#GH121706).
 
 Improvements to Clang's time-trace
 --
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d4e897868f1a9a..ec0be4ea8b6ce0 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2202,6 +2202,8 @@ def err_invalid_qualified_constructor : Error<
   "'%0' qualifier is not allowed on a constructor">;
 def err_ref_qualifier_constructor : Error<
   "ref-qualifier '%select{&&|&}0' is not allowed on a constructor">;
+def err_invalid_constructor_decl : Error<
+  "invalid constructor declaration">;
 
 def err_constructor_return_type : Error<
   "constructor cannot have a return type">;
@@ -2223,6 +2225,8 @@ def err_destructor_not_member : Error<
 def err_destructor_cannot_be : Error<"destructor cannot be declared '%0'">;
 def err_invalid_qualified_destructor : Error<
   "'%0' qualifier is not allowed on a destructor">;
+def err_invalid_destructor_decl : Error<
+  "invalid destructor declaration">;
 def err_ref_qualifier_destructor : Error<
   "ref-qualifier '%select{&&|&}0' is not allowed on a destructor">;
 def err_destructor_return_type : Error<"destructor cannot have a return type">;
diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index c4bee44f5ec048..bb6f6e14713d9b 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -10757,6 +10757,17 @@ static void checkMethodTypeQualifiers(Sema &S, 
Declarator &D, unsigned DiagID) {
   }
 }
 
+static void checkMethodPointerType(Sema &S, Declarator &D, unsigned DiagID) {
+  if (D.getNumTypeObjects() > 0) {
+DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1);
+if (Chunk.Kind == DeclaratorChunk::Pointer) {
+  SourceLocation PointerLoc = Chunk.getSourceRange().getBegin();
+  S.Diag(PointerLoc, DiagID) << Chunk.getSourceRange();
+  D.setInvalidType();
+}
+  }
+}
+
 QualType Sema::CheckConstructorDeclarator(Declarator &D, QualType R,
   StorageClass &SC) {
   bool isVirtual = D.getDeclSpec().isVirtualSpecified();
@@ -10792,6 +10803,7 @@ QualType Sema::CheckConstructorDeclarator(Declarator 
&D, QualType R,
   }
 
   checkMethodTypeQualifiers(*this, D, diag::err_invalid_qualified_constructor);
+  checkMethodPointerType(*this, D, diag::err_invalid_constructor_decl);
 
   // C++0x [class.ctor]p4:
   //   A constructor shall not be declared with a ref-qualifier.
@@ -10958,6 +10970,7 @@ QualType Sema::CheckDestructorDeclarator(Declarator &D, 
QualType R,
   }
 
   checkMethodTypeQualifiers(*this, D, diag::err_invalid_qualified_destructor);
+  checkMethodPointerType(*this, D, diag::err_invalid_destructor_decl);
 
   // C++0x [class.dtor]p2:
   //   A destructor shall not be declared with a ref-qualifier.
diff --git a/clang/test/SemaCXX/constructor.cpp 
b/clang/test/SemaCXX/constructor.cpp
index abd7dbe18a0e6a..c6df7be25c1fac 100644
--- a/clang/test/SemaCXX/constructor.cpp
+++ b/clang/test/SemaCXX/constructor.cpp
@@ -96,3 +96,13 @@ namespace PR38286 {
   template struct C; // expected-note {{non-type declaration found}}
   template C::~C() {} // expected-error {{identifier 'C' after 
'~' in destructor name does not name a type}}
 }
+
+namespace GH121706 {
+struct S {
+  *S();  // expected-error {{invalid constructor declaration}}
+  **S(); // expected-error {{invalid constructor declaration}}
+
+  **S(const S &); // expected-error {{invalid constructor declaration}}
+  *S(S &&);   // expected-error {{invalid constructor declaration}}
+};
+}
diff --git a/clang/test/SemaCXX/destructor.cpp 
b/clang/test/SemaCXX/destructor.cpp
index dfcd1b033af5a2..f188e95c25d174 100644
--- a/clang/test/SemaCXX/destructor.cpp
+++ b/clang/test/SemaCXX/destructor.cpp
@@ -586,4 +586,11 @@ struct Y : X {} y1{ }; // expected-error 

[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits


@@ -8785,14 +8785,11 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation 
QuestionLoc,
   commonExpr = result.get();
 }
 // We usually want to apply unary conversions *before* saving, except
-// in the special case of a C++ l-value conditional.
-if (!(getLangOpts().CPlusPlus
-  && !commonExpr->isTypeDependent()
-  && commonExpr->getValueKind() == RHSExpr->getValueKind()
-  && commonExpr->isGLValue()

zwuis wrote:

> So I don't see how losing the above two value kind exceptions fix this? Can 
> you explain this better?

I have updated the description of this PR. Please let me know if it isn't still 
clear enough.

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


[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits

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


[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits

https://github.com/zwuis updated 
https://github.com/llvm/llvm-project/pull/108837

>From 7e5f88c322852939ae68c65f6adf4a5d2973d095 Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Mon, 16 Sep 2024 21:50:11 +0800
Subject: [PATCH 1/3] Fix computing result type of conditional operand

---
 clang/docs/ReleaseNotes.rst|  2 ++
 clang/lib/Sema/SemaExpr.cpp|  4 +---
 clang/test/SemaCXX/conditional-gnu-ext.cpp | 19 +++
 3 files changed, 22 insertions(+), 3 deletions(-)
 create mode 100644 clang/test/SemaCXX/conditional-gnu-ext.cpp

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 17ec1fe0b946de..db8a7568a12114 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -389,6 +389,8 @@ Bug Fixes to C++ Support
 - Fixed a crash when clang tries to subtitute parameter pack while retaining 
the parameter
   pack. #GH63819, #GH107560
 - Fix a crash when a static assert declaration has an invalid close location. 
(#GH108687)
+- Fixed a bug in computing result type of conditional operator with omitted 
middle operand
+  (a GNU extension). (#GH15998)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8f3e15cc9a9bb7..8414a55e4868b9 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8785,11 +8785,9 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation 
QuestionLoc,
   commonExpr = result.get();
 }
 // We usually want to apply unary conversions *before* saving, except
-// in the special case of a C++ l-value conditional.
+// in the special case in C++ that operands have the same type.
 if (!(getLangOpts().CPlusPlus
   && !commonExpr->isTypeDependent()
-  && commonExpr->getValueKind() == RHSExpr->getValueKind()
-  && commonExpr->isGLValue()
   && commonExpr->isOrdinaryOrBitFieldObject()
   && RHSExpr->isOrdinaryOrBitFieldObject()
   && Context.hasSameType(commonExpr->getType(), RHSExpr->getType( {
diff --git a/clang/test/SemaCXX/conditional-gnu-ext.cpp 
b/clang/test/SemaCXX/conditional-gnu-ext.cpp
new file mode 100644
index 00..83a6fff8467863
--- /dev/null
+++ b/clang/test/SemaCXX/conditional-gnu-ext.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s 
-fexperimental-new-constant-interpreter
+// expected-no-diagnostics
+
+/*
+FIXME: Support constexpr
+
+constexpr int evaluate_once(int x) {
+  return (++x) ? : 10;
+}
+static_assert(evaluate_once(0) == 1, "");
+*/
+
+namespace GH15998 {
+  enum E { Zero, One };
+  E test(E e) {
+return e ? : One;
+  }
+}

>From 447c8b9c6e957308c9ff62e8c83b15b12f7fc1cb Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Mon, 16 Sep 2024 23:05:50 +0800
Subject: [PATCH 2/3] Format code

---
 clang/lib/Sema/SemaExpr.cpp | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 8414a55e4868b9..c232d40ca31ac6 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -8786,11 +8786,10 @@ ExprResult Sema::ActOnConditionalOp(SourceLocation 
QuestionLoc,
 }
 // We usually want to apply unary conversions *before* saving, except
 // in the special case in C++ that operands have the same type.
-if (!(getLangOpts().CPlusPlus
-  && !commonExpr->isTypeDependent()
-  && commonExpr->isOrdinaryOrBitFieldObject()
-  && RHSExpr->isOrdinaryOrBitFieldObject()
-  && Context.hasSameType(commonExpr->getType(), RHSExpr->getType( {
+if (!(getLangOpts().CPlusPlus && !commonExpr->isTypeDependent() &&
+  commonExpr->isOrdinaryOrBitFieldObject() &&
+  RHSExpr->isOrdinaryOrBitFieldObject() &&
+  Context.hasSameType(commonExpr->getType(), RHSExpr->getType( {
   ExprResult commonRes = UsualUnaryConversions(commonExpr);
   if (commonRes.isInvalid())
 return ExprError();

>From 4c3dbacae0c8935384e1bfd39bf1397d5a81ad1d Mon Sep 17 00:00:00 2001
From: Yanzuo Liu 
Date: Sun, 12 Jan 2025 18:50:29 +0800
Subject: [PATCH 3/3] Fix previously undiscovered case and address review
 feedbacks

'conditional-gnu-exp.cpp' is mainly copied and modified from 
'conditional-expr.cpp'
'conditional-gnu-ext.c' is mainly copied and modified from 'conditional-expr.c'
---
 clang/lib/Sema/SemaExpr.cpp|  12 +-
 clang/test/CXX/drs/cwg5xx.cpp  |  12 +
 clang/test/Sema/conditional-expr.c |   2 -
 clang/test/Sema/conditional-gnu-ext.c  | 111 ++
 clang/test/SemaCXX/conditional-expr.cpp|  24 --
 clang/test/SemaCXX/conditional-gnu-ext.cpp | 442 -
 6 files changed, 563 insertions(+), 40 deletions(-)
 create mode 100644 clang/test/Sema/conditional-gnu-ext.c

diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index

[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread via cfe-commits

https://github.com/TilakChad updated 
https://github.com/llvm/llvm-project/pull/122611

>From 4e5935f6631f0f0cd828559ec29ed931bc0333d3 Mon Sep 17 00:00:00 2001
From: Tilak Chad 
Date: Sun, 12 Jan 2025 00:03:32 +0545
Subject: [PATCH 1/2] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or
 __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda

---
 clang/lib/AST/Expr.cpp|  7 ++-
 clang/test/SemaCXX/crash-GH121274.cpp | 15 +++
 2 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/SemaCXX/crash-GH121274.cpp

diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 5331357b5d1fef..0caff41c8a8cf6 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -774,7 +774,12 @@ std::string 
PredefinedExpr::ComputeName(PredefinedIdentKind IK,
 const FunctionDecl *Decl = FD;
 if (const FunctionDecl* Pattern = FD->getTemplateInstantiationPattern())
   Decl = Pattern;
-const FunctionType *AFT = Decl->getType()->getAs();
+
+const Type *Ty = Decl->getType().getTypePtrOrNull();
+if (!Ty)
+  return "";
+
+const FunctionType *AFT = Ty->getAs();
 const FunctionProtoType *FT = nullptr;
 if (FD->hasWrittenPrototype())
   FT = dyn_cast(AFT);
diff --git a/clang/test/SemaCXX/crash-GH121274.cpp 
b/clang/test/SemaCXX/crash-GH121274.cpp
new file mode 100644
index 00..28677a0949bf9e
--- /dev/null
+++ b/clang/test/SemaCXX/crash-GH121274.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -std=c++11 -verify %s
+// expected-no-diagnostics
+
+// Do not crash when __PRETTY_FUNCTION__ appears in the trailing return type 
of the lambda
+void foo() {
+   []() -> decltype(static_cast(__PRETTY_FUNCTION__)) {
+   return nullptr;
+   }();
+
+#ifdef MS
+   []() -> decltype(static_cast(__FUNCSIG__)) {
+   return nullptr;
+   }();
+#endif
+}

>From 16eaeca0b827494606db24f6327f9de981f171a2 Mon Sep 17 00:00:00 2001
From: Tilak Chad 
Date: Sun, 12 Jan 2025 11:47:10 +0545
Subject: [PATCH 2/2] [Clang] Added comment and updated the clang release notes

---
 clang/docs/ReleaseNotes.rst | 1 +
 clang/lib/AST/Expr.cpp  | 3 +++
 2 files changed, 4 insertions(+)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 197b3692b8a181..a14fb189c8e132 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -926,6 +926,7 @@ Bug Fixes to C++ Support
   (`LWG3929 `__.) (#GH121278)
 - Clang now identifies unexpanded parameter packs within the type constraint 
on a non-type template parameter. (#GH88866)
 - Fixed an issue while resolving type of expression indexing into a pack of 
values of non-dependent type (#GH121242)
+- Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in 
the trailing return type of the lambda (#GH121274)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/AST/Expr.cpp b/clang/lib/AST/Expr.cpp
index 0caff41c8a8cf6..f6a4ed970cb23f 100644
--- a/clang/lib/AST/Expr.cpp
+++ b/clang/lib/AST/Expr.cpp
@@ -775,6 +775,9 @@ std::string PredefinedExpr::ComputeName(PredefinedIdentKind 
IK,
 if (const FunctionDecl* Pattern = FD->getTemplateInstantiationPattern())
   Decl = Pattern;
 
+// Bail out if the type of the function has not been set yet.
+// This can notably happen in the trailing return type of a lambda
+// expression.
 const Type *Ty = Decl->getType().getTypePtrOrNull();
 if (!Ty)
   return "";

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread Congcong Cai via cfe-commits

HerrCai0907 wrote:

I prefer to make it in bugprone and warn for all kinds of incorrect signatures 
for these special functions. what do you think.@5chmidti @carlosgalvezp 
@PiotrZSL 

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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread Oleksandr T. via cfe-commits


@@ -10757,6 +10757,17 @@ static void checkMethodTypeQualifiers(Sema &S, 
Declarator &D, unsigned DiagID) {
   }
 }
 
+static void checkMethodPointerType(Sema &S, Declarator &D, unsigned DiagID) {
+  if (D.getNumTypeObjects() > 0) {
+DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1);
+if (Chunk.Kind == DeclaratorChunk::Pointer) {
+  SourceLocation PointerLoc = Chunk.getSourceRange().getBegin();
+  S.Diag(PointerLoc, DiagID) << Chunk.getSourceRange();
+  D.setInvalidType();
+}
+  }
+}
+

a-tarasyuk wrote:

In this case, the declarator consists of two chunks: 
`[DeclaratorChunk::Function, DeclaratorChunk::Pointer]`

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


[clang] [Clang][Sema] Do not perform type conversion before computing result type of `x ? : y` in C++ (PR #108837)

2025-01-12 Thread Yanzuo Liu via cfe-commits

zwuis wrote:

> I'm also concerned about the constexpr support being 'FIXME', it seems that 
> this should just 'work' unless something odd is happening.

Sorry I forgot the restriction of constexpr function in C++11. Fixed.

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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread via cfe-commits


@@ -10757,6 +10757,17 @@ static void checkMethodTypeQualifiers(Sema &S, 
Declarator &D, unsigned DiagID) {
   }
 }
 
+static void checkMethodPointerType(Sema &S, Declarator &D, unsigned DiagID) {
+  if (D.getNumTypeObjects() > 0) {
+DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1);
+if (Chunk.Kind == DeclaratorChunk::Pointer) {
+  SourceLocation PointerLoc = Chunk.getSourceRange().getBegin();
+  S.Diag(PointerLoc, DiagID) << Chunk.getSourceRange();
+  D.setInvalidType();
+}
+  }
+}
+

cor3ntin wrote:

I know, my question is whether there is _any_ case where having more than one 
chunk would be valid?

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


[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread via cfe-commits

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

LGTM.
Do you need me to merge that for you?

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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread Oleksandr T. via cfe-commits


@@ -10757,6 +10757,17 @@ static void checkMethodTypeQualifiers(Sema &S, 
Declarator &D, unsigned DiagID) {
   }
 }
 
+static void checkMethodPointerType(Sema &S, Declarator &D, unsigned DiagID) {
+  if (D.getNumTypeObjects() > 0) {
+DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1);
+if (Chunk.Kind == DeclaratorChunk::Pointer) {
+  SourceLocation PointerLoc = Chunk.getSourceRange().getBegin();
+  S.Diag(PointerLoc, DiagID) << Chunk.getSourceRange();
+  D.setInvalidType();
+}
+  }
+}
+

a-tarasyuk wrote:

Do you mean that having more than one chunk is considered an error by default? 
I thought about that, however, I opted to use the appropriate kind check to 
ensure cases like this are handled correctly (the helper is used for 
constructors and destructors).

```cpp
struct S {
  (~S)();
};
```



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


[clang] [Clang] Fixed a crash when __PRETTY_FUNCTION__ or __FUNCSIG__ (clang-cl) appears in the trailing return type of the lambda (PR #122611)

2025-01-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-aarch64-sve-vla-2stage` running on `linaro-g3-01` while building `clang` 
at step 11 "build stage 2".

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


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

```
Step 11 (build stage 2) failure: 'ninja' (failure)
...
[7863/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/HlfirIntrinsics.cpp.o
[7864/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/ConvertType.cpp.o
[7865/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/ConvertProcedureDesignator.cpp.o
[7866/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/CustomIntrinsicCall.cpp.o
[7867/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/IterationSpace.cpp.o
[7868/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/HostAssociations.cpp.o
[7869/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/Mangler.cpp.o
[7870/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/OpenMP/PrivateReductionUtils.cpp.o
[7871/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/IO.cpp.o
[7872/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/ConvertVariable.cpp.o
command timed out: 1200 seconds without output running [b'ninja'], attempting 
to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=4374.385705

```



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


[clang] [llvm] [AArch64] Change feature dependencies of fp8 features (PR #122280)

2025-01-12 Thread via cfe-commits

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


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


[clang] [llvm] [Clang][LLVM][AArch64]Add new feature SSVE-BitPerm (PR #121947)

2025-01-12 Thread via cfe-commits


@@ -86,10 +87,11 @@
 // CHECK-NEXT: sve-aes2FEAT_SVE_AES2   
   Enable Armv9.6-A SVE multi-vector AES and multi-vector quadword 
polynomial multiply instructions
 // CHECK-NEXT: sve-b16b16  FEAT_SVE_B16B16 
   Enable SVE2 non-widening and SME2 Z-targeting non-widening 
BFloat16 instructions
 // CHECK-NEXT: sve-bfscale FEAT_SVE_BFSCALE
   Enable Armv9.6-A SVE BFloat16 scaling instructions
+// CHECK-NEXT: sve-bitperm FEAT_SVE_BitPerm
   Enable bit permutation SVE2 instructions

CarolineConcatto wrote:

I am not sure we should change, previous message already had saying it was 
SVE2, moreover these instructions requires SVE2. 

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


[clang] [llvm] [Clang][LLVM][AArch64]Add new feature SSVE-BitPerm (PR #121947)

2025-01-12 Thread via cfe-commits

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


[clang] [OpenMP] codegen support for masked combined construct masked taskloop simd (PR #121916)

2025-01-12 Thread CHANDRA GHALE via cfe-commits

https://github.com/chandraghale updated 
https://github.com/llvm/llvm-project/pull/121916

>From 7d03bd61553690f22c03b52ef2bda8a09938e7a1 Mon Sep 17 00:00:00 2001
From: Chandra Ghale 
Date: Tue, 7 Jan 2025 05:09:21 -0600
Subject: [PATCH] codegen support for masked combined construct masked taskloop
 simd

---
 clang/lib/CodeGen/CGStmt.cpp  |  3 +-
 clang/lib/CodeGen/CGStmtOpenMP.cpp| 12 +
 clang/lib/CodeGen/CodeGenFunction.h   |  2 +
 .../OpenMP/masked_taskloop_simd_codegen.c | 49 +++
 4 files changed, 65 insertions(+), 1 deletion(-)
 create mode 100644 clang/test/OpenMP/masked_taskloop_simd_codegen.c

diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index 3974739d2abb47..496a626f3be598 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -338,7 +338,8 @@ void CodeGenFunction::EmitStmt(const Stmt *S, 
ArrayRef Attrs) {
 cast(*S));
 break;
   case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
-llvm_unreachable("masked taskloop simd directive not supported yet.");
+EmitOMPMaskedTaskLoopSimdDirective(
+cast(*S));
 break;
   case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
 EmitOMPParallelMasterTaskLoopDirective(
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 6cb37b20b7aeee..fa3a82dad003b9 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -8006,6 +8006,18 @@ void CodeGenFunction::EmitOMPMasterTaskLoopSimdDirective(
   CGM.getOpenMPRuntime().emitMasterRegion(*this, CodeGen, S.getBeginLoc());
 }
 
+void CodeGenFunction::EmitOMPMaskedTaskLoopSimdDirective(
+const OMPMaskedTaskLoopSimdDirective &S) {
+  auto &&CodeGen = [this, &S](CodeGenFunction &CGF, PrePostActionTy &Action) {
+Action.Enter(CGF);
+EmitOMPTaskLoopBasedDirective(S);
+  };
+  auto LPCRegion =
+  CGOpenMPRuntime::LastprivateConditionalRAII::disable(*this, S);
+  OMPLexicalScope Scope(*this, S);
+  CGM.getOpenMPRuntime().emitMaskedRegion(*this, CodeGen, S.getBeginLoc());
+}
+
 void CodeGenFunction::EmitOMPParallelMasterTaskLoopDirective(
 const OMPParallelMasterTaskLoopDirective &S) {
   auto &&CodeGen = [this, &S](CodeGenFunction &CGF, PrePostActionTy &Action) {
diff --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 1a5c42f8f974d0..aa08985351f811 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3865,6 +3865,8 @@ class CodeGenFunction : public CodeGenTypeCache {
   void EmitOMPMasterTaskLoopDirective(const OMPMasterTaskLoopDirective &S);
   void
   EmitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &S);
+  void
+  EmitOMPMaskedTaskLoopSimdDirective(const OMPMaskedTaskLoopSimdDirective &S);
   void EmitOMPParallelMasterTaskLoopDirective(
   const OMPParallelMasterTaskLoopDirective &S);
   void EmitOMPParallelMasterTaskLoopSimdDirective(
diff --git a/clang/test/OpenMP/masked_taskloop_simd_codegen.c 
b/clang/test/OpenMP/masked_taskloop_simd_codegen.c
new file mode 100644
index 00..f786bc582beb20
--- /dev/null
+++ b/clang/test/OpenMP/masked_taskloop_simd_codegen.c
@@ -0,0 +1,49 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --prefix-filecheck-ir-name _ --version 5
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -fopenmp-version=52 
-x c -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+#define N 100
+void masked_taskloop_simd(){
+   #pragma omp masked taskloop simd
+   for( int i = 0; i < N; i++)
+   ;
+
+}
+
+int main()
+{
+ masked_taskloop_simd();
+}
+// CHECK-LABEL: define dso_local void @masked_taskloop_simd(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr 
@[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @__kmpc_masked(ptr @[[GLOB1]], i32 
[[TMP0]], i32 0)
+// CHECK-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
+// CHECK-NEXT:br i1 [[TMP2]], label %[[OMP_IF_THEN:.*]], label 
%[[OMP_IF_END:.*]]
+// CHECK:   [[OMP_IF_THEN]]:
+// CHECK-NEXT:call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:[[TMP3:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr 
@[[GLOB1]], i32 [[TMP0]], i32 1, i64 80, i64 0, ptr @.omp_task_entry.)
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds nuw 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP3]], i32 0, i32 0
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds nuw 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP4]], i32 0, i32 5
+// CHECK-NEXT:store i64 0, ptr [[TMP5]], align 8
+// CHECK-NEXT:[[TMP6:%.*]] = getelementptr inbounds nuw 
[[STRUCT_KMP_TASK_T]], ptr [[TMP4]], 

[clang] 1d2eea9 - [OpenMP] codegen support for masked combined construct masked taskloop simd (#121916)

2025-01-12 Thread via cfe-commits

Author: CHANDRA GHALE
Date: 2025-01-12T23:38:00+05:30
New Revision: 1d2eea962ac9724350f025f4c70808d42a435289

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

LOG: [OpenMP] codegen support for masked combined construct masked taskloop 
simd (#121916)

Added codegen support for combined masked constructs `masked taskloop
simd`.
Added implementation for `EmitOMPMaskedTaskLoopSimdDirective`.

Co-authored-by: Chandra Ghale 

Added: 
clang/test/OpenMP/masked_taskloop_simd_codegen.c

Modified: 
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index c87ec899798aa2..ee10e586d9250a 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -339,7 +339,8 @@ void CodeGenFunction::EmitStmt(const Stmt *S, 
ArrayRef Attrs) {
 cast(*S));
 break;
   case Stmt::OMPMaskedTaskLoopSimdDirectiveClass:
-llvm_unreachable("masked taskloop simd directive not supported yet.");
+EmitOMPMaskedTaskLoopSimdDirective(
+cast(*S));
 break;
   case Stmt::OMPParallelMasterTaskLoopDirectiveClass:
 EmitOMPParallelMasterTaskLoopDirective(

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 4e7b0dcd31ecf9..94daf059edba08 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -7994,6 +7994,18 @@ void CodeGenFunction::EmitOMPMasterTaskLoopSimdDirective(
   CGM.getOpenMPRuntime().emitMasterRegion(*this, CodeGen, S.getBeginLoc());
 }
 
+void CodeGenFunction::EmitOMPMaskedTaskLoopSimdDirective(
+const OMPMaskedTaskLoopSimdDirective &S) {
+  auto &&CodeGen = [this, &S](CodeGenFunction &CGF, PrePostActionTy &Action) {
+Action.Enter(CGF);
+EmitOMPTaskLoopBasedDirective(S);
+  };
+  auto LPCRegion =
+  CGOpenMPRuntime::LastprivateConditionalRAII::disable(*this, S);
+  OMPLexicalScope Scope(*this, S);
+  CGM.getOpenMPRuntime().emitMaskedRegion(*this, CodeGen, S.getBeginLoc());
+}
+
 void CodeGenFunction::EmitOMPParallelMasterTaskLoopDirective(
 const OMPParallelMasterTaskLoopDirective &S) {
   auto &&CodeGen = [this, &S](CodeGenFunction &CGF, PrePostActionTy &Action) {

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 23ddc869277a87..86328db345508a 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3872,6 +3872,8 @@ class CodeGenFunction : public CodeGenTypeCache {
   void EmitOMPMasterTaskLoopDirective(const OMPMasterTaskLoopDirective &S);
   void
   EmitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &S);
+  void
+  EmitOMPMaskedTaskLoopSimdDirective(const OMPMaskedTaskLoopSimdDirective &S);
   void EmitOMPParallelMasterTaskLoopDirective(
   const OMPParallelMasterTaskLoopDirective &S);
   void EmitOMPParallelMaskedTaskLoopDirective(

diff  --git a/clang/test/OpenMP/masked_taskloop_simd_codegen.c 
b/clang/test/OpenMP/masked_taskloop_simd_codegen.c
new file mode 100644
index 00..f786bc582beb20
--- /dev/null
+++ b/clang/test/OpenMP/masked_taskloop_simd_codegen.c
@@ -0,0 +1,49 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --prefix-filecheck-ir-name _ --version 5
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -fopenmp-version=52 
-x c -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+#define N 100
+void masked_taskloop_simd(){
+   #pragma omp masked taskloop simd
+   for( int i = 0; i < N; i++)
+   ;
+
+}
+
+int main()
+{
+ masked_taskloop_simd();
+}
+// CHECK-LABEL: define dso_local void @masked_taskloop_simd(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr 
@[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @__kmpc_masked(ptr @[[GLOB1]], i32 
[[TMP0]], i32 0)
+// CHECK-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
+// CHECK-NEXT:br i1 [[TMP2]], label %[[OMP_IF_THEN:.*]], label 
%[[OMP_IF_END:.*]]
+// CHECK:   [[OMP_IF_THEN]]:
+// CHECK-NEXT:call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:[[TMP3:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr 
@[[GLOB1]], i32 [[TMP0]], i32 1, i64 80, i64 0, ptr @.omp_task_entry.)
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds nuw 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP3]], i32 0, i32 0
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds nuw 
[[STRUCT_KMP_TASK_T:%.*]]

[clang] [OpenMP] codegen support for masked combined construct masked taskloop simd (PR #121916)

2025-01-12 Thread CHANDRA GHALE via cfe-commits

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


[clang] [llvm] [Clang][LLVM][AArch64]Add new feature SSVE-BitPerm (PR #121947)

2025-01-12 Thread via cfe-commits

CarolineConcatto wrote:

>  On top of comments I left I think we should also add new runlines to both 
> assembly tests for individual instructions, to check that we produce correct 
> assembly when ssve-bitperm feature is used. 

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


[clang] [OpenMP] codegen support for masked combined construct masked taskloop simd (PR #121916)

2025-01-12 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` at step 7 
"test-build-unified-tree-check-all".

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


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 :: ClangScanDeps/modules-full.cpp' FAILED 

Exit Code: 1

Command Output (stdout):
--
# RUN: at line 1
rm -rf 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir
# executed command: rm -rf 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir'
# RUN: at line 2
rm -rf 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.cdb
# executed command: rm -rf 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.cdb'
# RUN: at line 3
mkdir -p 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir
# executed command: mkdir -p 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir'
# RUN: at line 4
cp 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps\modules-full.cpp
 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/modules_cdb_input.cpp
# executed command: cp 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps\modules-full.cpp'
 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/modules_cdb_input.cpp'
# RUN: at line 5
cp 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps\modules-full.cpp
 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/modules_cdb_input2.cpp
# executed command: cp 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps\modules-full.cpp'
 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/modules_cdb_input2.cpp'
# RUN: at line 6
mkdir 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/Inputs
# executed command: mkdir 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/Inputs'
# RUN: at line 7
cp 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/header.h
 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/Inputs/header.h
# executed command: cp 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/header.h'
 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/Inputs/header.h'
# RUN: at line 8
cp 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/header2.h
 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/Inputs/header2.h
# executed command: cp 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/header2.h'
 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/Inputs/header2.h'
# RUN: at line 9
cp 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/module.modulemap
 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/Inputs/module.modulemap
# executed command: cp 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/module.modulemap'
 
'Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.dir/Inputs/module.modulemap'
# RUN: at line 10
sed -e 
"s|DIR|Z:/b/llvm-clang-x86_64-sie-win/build/tools/clang/test/ClangScanDeps/Output/modules-full.cpp.tmp.dir|g"
 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/modules_cdb.json
 > 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp.cdb
# executed command: sed -e 
's|DIR|Z:/b/llvm-clang-x86_64-sie-win/build/tools/clang/test/ClangScanDeps/Output/modules-full.cpp.tmp.dir|g'
 
'Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/modules_cdb.json'
# RUN: at line 11
sed -e 
"s|DIR|Z:/b/llvm-clang-x86_64-sie-win/build/tools/clang/test/ClangScanDeps/Output/modules-full.cpp.tmp.dir|g"
 
Z:\b\llvm-clang-x86_64-sie-win\llvm-project\clang\test\ClangScanDeps/Inputs/modules_cdb_clangcl.json
 > 
Z:\b\llvm-clang-x86_64-sie-win\build\tools\clang\test\ClangScanDeps\Output\modules-full.cpp.tmp_clangcl.cdb
# executed command: sed -e 
's|DIR|Z:/b/llvm-clang-x86_64-sie-win/build/tools/clang/test/ClangScanDeps/Output/modules-full.cpp.tmp.dir|g'
 

[clang] Fix print module manifest file for macos (PR #122370)

2025-01-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-aarch64-sve-vls-2stage` running on `linaro-g3-02` while building `clang` 
at step 11 "build stage 2".

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


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

```
Step 11 (build stage 2) failure: 'ninja' (failure)
...
[7958/8802] Building CXX object 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/intrinsics-library.cpp.o
[7959/8802] Building CXX object 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/characteristics.cpp.o
[7960/8802] Building CXX object 
tools/flang/lib/Parser/CMakeFiles/FortranParser.dir/Fortran-parsers.cpp.o
[7961/8802] Building CXX object 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/intrinsics.cpp.o
[7962/8802] Building CXX object 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/type.cpp.o
[7963/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/canonicalize-omp.cpp.o
[7964/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/canonicalize-do.cpp.o
[7965/8802] Building CXX object 
tools/flang/lib/Parser/CMakeFiles/FortranParser.dir/program-parsers.cpp.o
[7966/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-arithmeticif.cpp.o
[7967/8802] Building CXX object 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/tools.cpp.o
FAILED: tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/tools.cpp.o 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage1.install/bin/clang++
 -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG 
-D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/flang/lib/Evaluate
 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/lib/Evaluate
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/flang/include
 -I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/include 
-I/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/include 
-isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/../mlir/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/mlir/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/stage2/tools/clang/include
 -isystem 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/llvm/../clang/include
 -mcpu=neoverse-512tvb -msve-vector-bits=256 -mllvm 
-treat-scalable-fixed-error-as-warning=false -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic 
-Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-string-conversion 
-Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument 
-Wstring-conversion   -Wcovered-switch-default -Wno-nested-anon-types 
-O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD 
-MT tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/tools.cpp.o -MF 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/tools.cpp.o.d -o 
tools/flang/lib/Evaluate/CMakeFiles/FortranEvaluate.dir/tools.cpp.o -c 
/home/tcwg-buildbot/worker/clang-aarch64-sve-vls-2stage/llvm/flang/lib/Evaluate/tools.cpp
Killed
[7968/8802] Building CXX object 
tools/flang/lib/Lower/CMakeFiles/FortranLower.dir/Runtime.cpp.o
[7969/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-namelist.cpp.o
[7970/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-purity.cpp.o
[7971/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-return.cpp.o
[7972/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-select-type.cpp.o
[7973/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-stop.cpp.o
[7974/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-nullify.cpp.o
[7975/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-declarations.cpp.o
[7976/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/check-if-stmt.cpp.o
[7977/8802] Building CXX object 
tools/flang/lib/Semantics/CMakeFiles/FortranSemantics.dir/comput

[clang] [AST] Migrate away from PointerUnion::dyn_cast (NFC) (PR #122651)

2025-01-12 Thread Kazu Hirata via cfe-commits

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

Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //isa, cast and the llvm::dyn_cast

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect Ptr to be nonnull.


>From 9427f6765355636976ee0b67a0710e74d7312df5 Mon Sep 17 00:00:00 2001
From: Kazu Hirata 
Date: Sun, 12 Jan 2025 14:02:28 -0800
Subject: [PATCH] [AST] Migrate away from PointerUnion::dyn_cast (NFC)

Note that PointerUnion::dyn_cast has been soft deprecated in
PointerUnion.h:

  // FIXME: Replace the uses of is(), get() and dyn_cast() with
  //isa, cast and the llvm::dyn_cast

Literal migration would result in dyn_cast_if_present (see the
definition of PointerUnion::dyn_cast), but this patch uses dyn_cast
because we expect Ptr to be nonnull.
---
 clang/include/clang/AST/DeclBase.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 82932e098c86f0..77abd8b657a616 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1334,7 +1334,7 @@ class DeclListNode {
 
 reference operator*() const {
   assert(Ptr && "dereferencing end() iterator");
-  if (DeclListNode *CurNode = Ptr.dyn_cast())
+  if (DeclListNode *CurNode = dyn_cast(Ptr))
 return CurNode->D;
   return cast(Ptr);
 }
@@ -1344,7 +1344,7 @@ class DeclListNode {
 inline iterator &operator++() { // ++It
   assert(!Ptr.isNull() && "Advancing empty iterator");
 
-  if (DeclListNode *CurNode = Ptr.dyn_cast())
+  if (DeclListNode *CurNode = dyn_cast(Ptr))
 Ptr = CurNode->Rest;
   else
 Ptr = nullptr;

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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread Shafik Yaghmour via cfe-commits

https://github.com/shafik commented:

Thank you for the fix.

Please add a more detailed summary, the title feels sufficient to describe the 
problem but you should outline the solution in the summary, at least briefly. 
e.g. adding `checkMethodPointerType` which will called during  to verify ...

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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread Shafik Yaghmour via cfe-commits


@@ -96,3 +96,13 @@ namespace PR38286 {
   template struct C; // expected-note {{non-type declaration found}}
   template C::~C() {} // expected-error {{identifier 'C' after 
'~' in destructor name does not name a type}}
 }
+
+namespace GH121706 {
+struct S {
+  *S();  // expected-error {{invalid constructor declaration}}

shafik wrote:

As pointed out above, we need a lot more tests. The bug report shows several 
other cases this applies to and they should all be enumerated in the tests. 

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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread Shafik Yaghmour via cfe-commits

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


[clang] [WIP] [Modules] Delay reading type source info of the preferred_name attribute. (PR #122250)

2025-01-12 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 commented:

A special handling for `PreferredName` looks slightly add-hoc to me. What I 
thought is to delay the deserialization of `attributes` after the 
deserialization of the declaration. If this is too optimistic, I am wondering 
if we can delay reading of some sorts of attributes only, which is more generic.

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,34 @@
+// RUN: %check_clang_tidy %s performance-explicit-move-constructor %t
+
+class NotReported1 {};
+
+class NotReported2 {
+public:
+  NotReported2(NotReported2&&) = default;
+  NotReported2(const NotReported2&) = default;
+};
+
+class NotReported3 {
+public:
+  explicit NotReported3(NotReported3&&) = default;
+};
+
+class NotReported4 {
+public:
+  explicit NotReported4(NotReported4&&) = default;
+  NotReported4(const NotReported4&) = delete;
+};
+
+class NotReported5 {
+public:
+  explicit NotReported5(NotReported5&&) = delete;
+  NotReported5(const NotReported5&) = default;
+};
+
+class Reported {
+public:
+  explicit Reported(Reported&&) = default;
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: copy constructor may be called 
instead of move constructor [performance-explicit-move-constructor]
+  // CHECK-FIXES: {{^  }}Reported(Reported&&) = default;{{$}}
+  Reported(const Reported&) = default;
+};

PiotrZSL wrote:

test with inherited constructors and with template classes

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread Piotr Zegar via cfe-commits


@@ -0,0 +1,73 @@
+//===--- ExplicitMoveConstructorCheck.cpp - clang-tidy 
===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ExplicitMoveConstructorCheck.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::performance {
+
+static SourceRange findExplicitToken(const CXXConstructorDecl *Ctor,
+ const SourceManager &Source,
+ const LangOptions &LangOpts) {
+  SourceLocation CurrentLoc = Ctor->getBeginLoc();
+  SourceLocation EndLoc = Ctor->getEndLoc();
+  Token Tok;
+
+  do {
+const bool failed = Lexer::getRawToken(CurrentLoc, Tok, Source, LangOpts);
+
+if (failed)
+  return {};
+
+if (Tok.is(tok::raw_identifier) && Tok.getRawIdentifier() == "explicit")
+  return {Tok.getLocation(), Tok.getEndLoc()};
+
+CurrentLoc = Tok.getEndLoc();
+  } while (Tok.isNot(tok::eof) && CurrentLoc < EndLoc);
+
+  return {};
+}
+
+void ExplicitMoveConstructorCheck::registerMatchers(MatchFinder *Finder) {
+  Finder->addMatcher(
+  cxxRecordDecl(
+  has(cxxConstructorDecl(isMoveConstructor(), isExplicit(),

PiotrZSL wrote:

Maybe exclude implicit code, in such case it would be faster.
Also consider excluding system code.

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread Piotr Zegar via cfe-commits

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread Piotr Zegar via cfe-commits

https://github.com/PiotrZSL commented:

To be honest, best would be flag calls to copy constructors that take rvalue 
where move constructor exists. In such case it would found actual performance 
issues.

But still this kind of check is fine.

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


[clang] [Clang][MIPS] Create correct linker arguments for Windows toolchains (PR #121041)

2025-01-12 Thread Hervé Poussineau via cfe-commits

hpoussin wrote:

Ping

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


[clang] Fix print module manifest file for macos (PR #122370)

2025-01-12 Thread Chuanqi Xu via cfe-commits

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


[clang] acbd822 - Fix print module manifest file for macos (#122370)

2025-01-12 Thread via cfe-commits

Author: Bill Hoffman
Date: 2025-01-13T10:20:20+08:00
New Revision: acbd822879f7727127926c25e1b47f5017f962c5

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

LOG: Fix print module manifest file for macos (#122370)

This commit fixes -print-library-module-manifest-path on macos.
Currently, this only works on linux systems. This is because on macos
systems the library and header files are installed in a different
location. The module manifest is next to the libraries and the search
function was not looking in both places. There is also a test included.

Added: 


Modified: 
clang/lib/Driver/Driver.cpp
clang/test/Driver/modules-print-library-module-manifest-path.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 10df730744b089..9a947f32283c3a 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6398,6 +6398,11 @@ std::string Driver::GetFilePath(StringRef Name, const 
ToolChain &TC) const {
   if (auto P = SearchPaths(TC.getFilePaths()))
 return *P;
 
+  SmallString<128> R2(ResourceDir);
+  llvm::sys::path::append(R2, "..", "..", Name);
+  if (llvm::sys::fs::exists(Twine(R2)))
+return std::string(R2);
+
   return std::string(Name);
 }
 

diff  --git a/clang/test/Driver/modules-print-library-module-manifest-path.cpp 
b/clang/test/Driver/modules-print-library-module-manifest-path.cpp
index 3ba2709ad95cc8..8d17fe1549e34b 100644
--- a/clang/test/Driver/modules-print-library-module-manifest-path.cpp
+++ b/clang/test/Driver/modules-print-library-module-manifest-path.cpp
@@ -18,6 +18,28 @@
 // RUN: --target=x86_64-linux-gnu 2>&1 \
 // RUN:   | FileCheck libcxx.cpp
 
+// for macos there is a 
diff erent directory structure
+// where the library and libc++.modules.json file are in lib
+// directly but headers are in clang/ver directory which
+// is the resource directory
+// RUN: mkdir -p %t/Inputs/usr/lib/clang/20
+// RUN: touch %t/Inputs/usr/lib/libc++.so
+// RUN: touch %t/Inputs/usr/lib/libc++.modules.json
+// RUN: %clang -print-library-module-manifest-path \
+// RUN: -stdlib=libc++ \
+// RUN: -resource-dir=%t/Inputs/usr/lib/clang/20 \
+// RUN: --target=arm64-apple-darwin24.1.0 2>&1 \
+// RUN:   | FileCheck libcxx.cpp.macos
+
+// RUN: rm %t/Inputs/usr/lib/libc++.so
+// RUN: touch %t/Inputs/usr/lib/libc++.a
+// RUN: touch %t/Inputs/usr/lib/libc++.modules.json
+// RUN: %clang -print-library-module-manifest-path \
+// RUN: -stdlib=libc++ \
+// RUN: -resource-dir=%t/Inputs/usr/lib/clang/20 \
+// RUN: --target=arm64-apple-darwin24.1.0 2>&1 \
+// RUN:   | FileCheck libcxx.cpp.macos
+
 // RUN: rm %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.so
 // RUN: touch %t/Inputs/usr/lib/x86_64-linux-gnu/libc++.a
 // RUN: %clang -print-library-module-manifest-path \
@@ -40,6 +62,10 @@
 
 // CHECK: {{.*}}/Inputs/usr/lib/x86_64-linux-gnu{{/|\\}}libc++.modules.json
 
+//--- libcxx.cpp.macos
+
+// CHECK: {{.*}}libc++.modules.json
+
 //--- libcxx-no-shared-lib.cpp
 
 // Note this might find a 
diff erent path depending whether search path



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


[clang] Fix print module manifest file for macos (PR #122370)

2025-01-12 Thread Chuanqi Xu via cfe-commits

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


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


[clang] Fix print module manifest file for macos (PR #122370)

2025-01-12 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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


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


[clang] [Clang] Reapply CWG2369 "Ordering between constraints and substitution" (PR #122423)

2025-01-12 Thread Younan Zhang via cfe-commits

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


[clang-tools-extra] [clangd] Support .clangd command line modifications for C++ modules (PR #122606)

2025-01-12 Thread Chuanqi Xu via cfe-commits

https://github.com/ChuanqiXu9 commented:

Do we need to update `buildModuleFile` in 
`clang-tools-extra/clangd/ModulesBuilder.cpp` to update the commands to build 
the module interfaces?

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


[clang-tools-extra] [clangd] Support .clangd command line modifications for C++ modules (PR #122606)

2025-01-12 Thread Chuanqi Xu via cfe-commits


@@ -9,6 +9,7 @@
 
 /// FIXME: Skip testing on windows temporarily due to the different escaping
 /// code mode.
+#include "llvm/ADT/StringRef.h"

ChuanqiXu9 wrote:

Move the include after the `#ifndef`

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


[clang-tools-extra] [clangd] Support .clangd command line modifications for C++ modules (PR #122606)

2025-01-12 Thread Chuanqi Xu via cfe-commits

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


[clang] [AArch64][Clang] Add support for __arm_agnostic("sme_za_state") (PR #121788)

2025-01-12 Thread Sander de Smalen via cfe-commits

https://github.com/sdesmalen-arm updated 
https://github.com/llvm/llvm-project/pull/121788

>From 4e2166f1c19246e3fb5074da466d151070b5606c Mon Sep 17 00:00:00 2001
From: Sander de Smalen 
Date: Mon, 9 Sep 2024 15:20:26 +0100
Subject: [PATCH 1/4] [AArch64][Clang] Add support for
 __arm_agnostic("sme_za_state")

This adds support for parsing the attribute and codegen to
map it to "aarch64_za_state_agnostic" LLVM IR attribute.

This attribute is described in the Arm C Language Extensions
(ACLE) document:

  https://github.com/ARM-software/acle/blob/main/main/acle.md#__arm_agnostic
---
 clang/include/clang/AST/Type.h| 13 --
 clang/include/clang/Basic/Attr.td |  7 +++
 clang/include/clang/Basic/AttrDocs.td | 20 
 .../clang/Basic/DiagnosticSemaKinds.td|  5 ++
 clang/lib/AST/TypePrinter.cpp |  2 +
 clang/lib/CodeGen/CGCall.cpp  |  2 +
 clang/lib/Sema/SemaARM.cpp|  8 
 clang/lib/Sema/SemaType.cpp   | 46 ++-
 .../sme-intrinsics/aarch64-sme-attrs.cpp  | 24 ++
 clang/test/Sema/aarch64-sme-func-attrs.c  | 21 +
 10 files changed, 143 insertions(+), 5 deletions(-)

diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 09c98f642852fc..49c1681d84dd52 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -4593,9 +4593,14 @@ class FunctionType : public Type {
 SME_ZT0Shift = 5,
 SME_ZT0Mask = 0b111 << SME_ZT0Shift,
 
+// A bit to tell whether a function is agnostic about sme ZA state.
+SME_AgnosticZAStateShift = 8,
+SME_AgnosticZAStateMask = 1 << SME_AgnosticZAStateShift,
+
 SME_AttributeMask =
-0b111'111'11 // We can't support more than 8 bits because of
- // the bitmask in FunctionTypeExtraBitfields.
+0b1'111'111'11 // We can't support more than 16 bits because of
+   // the bitmask in FunctionTypeArmAttributes
+   // and ExtProtoInfo.
   };
 
   enum ArmStateValue : unsigned {
@@ -4620,7 +4625,7 @@ class FunctionType : public Type {
   struct alignas(void *) FunctionTypeArmAttributes {
 /// Any AArch64 SME ACLE type attributes that need to be propagated
 /// on declarations and function pointers.
-unsigned AArch64SMEAttributes : 8;
+unsigned AArch64SMEAttributes : 9;
 
 FunctionTypeArmAttributes() : AArch64SMEAttributes(SME_NormalFunction) {}
   };
@@ -5188,7 +5193,7 @@ class FunctionProtoType final
 FunctionType::ExtInfo ExtInfo;
 unsigned Variadic : 1;
 unsigned HasTrailingReturn : 1;
-unsigned AArch64SMEAttributes : 8;
+unsigned AArch64SMEAttributes : 9;
 Qualifiers TypeQuals;
 RefQualifierKind RefQualifier = RQ_None;
 ExceptionSpecInfo ExceptionSpec;
diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 5039c20d8b73be..c0632aaa516255 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2877,6 +2877,13 @@ def ArmPreserves : TypeAttr, 
TargetSpecificAttr {
   let Documentation = [ArmPreservesDocs];
 }
 
+def ArmAgnostic : TypeAttr, TargetSpecificAttr {
+  let Spellings = [RegularKeyword<"__arm_agnostic">];
+  let Args = [VariadicStringArgument<"AgnosticArgs">];
+  let Subjects = SubjectList<[HasFunctionProto], ErrorDiag>;
+  let Documentation = [ArmAgnosticDocs];
+}
+
 def ArmLocallyStreaming : InheritableAttr, TargetSpecificAttr {
   let Spellings = [RegularKeyword<"__arm_locally_streaming">];
   let Subjects = SubjectList<[Function], ErrorDiag>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index 506fe38eb882b2..70c039c2cfa4f1 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -7635,6 +7635,26 @@ The attributes ``__arm_in(S)``, ``__arm_out(S)``, 
``__arm_inout(S)`` and
   }];
 }
 
+def ArmAgnosticDocs : Documentation {
+  let Category = DocCatArmSmeAttributes;
+  let Content = [{
+The ``__arm_agnostic`` keyword applies to prototyped function types and
+specifies that the function is agnostic about the given state S and
+returns with state S unchanged if state S exists.
+
+The attribute takes string arguments to instruct the compiler which state
+the function is agnostic about.  The supported states for S are:
+
+* ``"sme_za_state"`` for any state enabled by PSTATE.ZA (including the
+  bit itself)
+
+The attributes ``__arm_agnostic("sme_za_state") cannot be used in conjunction
+with ``__arm_in(S)``, ``__arm_out(S)``, ``__arm_inout(S)`` or
+``__arm_preserves(S)`` where state S describes state enabled by PSTATE.ZA,
+such as "za" or "zt0".
+  }];
+}
+
 def ArmSmeLocallyStreamingDocs : Documentation {
   let Category = DocCatArmSmeAttributes;
   let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index d4e89

[clang] [llvm] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to support AMDGPU's generic target (PR #122629)

2025-01-12 Thread Shilei Tian via cfe-commits

https://github.com/shiltian updated 
https://github.com/llvm/llvm-project/pull/122629

>From 2fdbbac7ca1dcb5b6a0ad28f9fedabf24c634465 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Sun, 12 Jan 2025 15:58:32 -0500
Subject: [PATCH] [OffloadBundler] Rework the ctor of `OffloadTargetInfo` to
 support generic target

The current parsing of target string assumes to be in a form of
`kind-triple-targetid:feature`, such as
`hipv4-amdgcn-amd-amdhsa-gfx1030:+xnack`. Specifically, the target id does not
contain any `-`, which is not the case for generic target. Also, a generic
target may contain one or more `-`, such as `gfx10-3-generic` and
`gfx12-generic`. As a result, we can no longer depend on `rstrip` to get things
work right. This patch reworks the logic to parse the target string to make it
more robust, as well as supporting generic target.
---
 clang/docs/ClangOffloadBundler.rst|  7 ++-
 clang/lib/Driver/OffloadBundler.cpp   | 46 --
 .../Driver/clang-offload-bundler-asserts-on.c | 14 +++---
 .../clang-offload-bundler-standardize.c   | 13 +++--
 .../test/Driver/clang-offload-bundler-zlib.c  | 12 ++---
 .../test/Driver/clang-offload-bundler-zstd.c  | 12 ++---
 clang/test/Driver/clang-offload-bundler.c | 48 +--
 llvm/utils/lit/lit/llvm/config.py | 12 -
 8 files changed, 84 insertions(+), 80 deletions(-)

diff --git a/clang/docs/ClangOffloadBundler.rst 
b/clang/docs/ClangOffloadBundler.rst
index 3c241027d405ca..25214c2ea6a4e1 100644
--- a/clang/docs/ClangOffloadBundler.rst
+++ b/clang/docs/ClangOffloadBundler.rst
@@ -266,15 +266,14 @@ without differentiation based on offload kind.
 The target triple of the code object. See `Target Triple
 `_.
 
-The bundler accepts target triples with or without the optional environment
-field:
+LLVM target triples can be with or without the optional environment field:
 
 ``--``, or
 ``---``
 
 However, in order to standardize outputs for tools that consume bitcode
-bundles, bundles written by the bundler internally use only the 4-field
-target triple:
+bundles, the bundler only accepts target triples with the 4-field target
+triple:
 
 ``---``
 
diff --git a/clang/lib/Driver/OffloadBundler.cpp 
b/clang/lib/Driver/OffloadBundler.cpp
index 2d6bdff0393be5..1d5b618d0fc80d 100644
--- a/clang/lib/Driver/OffloadBundler.cpp
+++ b/clang/lib/Driver/OffloadBundler.cpp
@@ -84,31 +84,27 @@ OffloadTargetInfo::OffloadTargetInfo(const StringRef Target,
 : BundlerConfig(BC) {
 
   // TODO: Add error checking from ClangOffloadBundler.cpp
-  auto TargetFeatures = Target.split(':');
-  auto TripleOrGPU = TargetFeatures.first.rsplit('-');
-
-  if (clang::StringToOffloadArch(TripleOrGPU.second) !=
-  clang::OffloadArch::UNKNOWN) {
-auto KindTriple = TripleOrGPU.first.split('-');
-this->OffloadKind = KindTriple.first;
-
-// Enforce optional env field to standardize bundles
-llvm::Triple t = llvm::Triple(KindTriple.second);
-this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
-t.getOSName(), t.getEnvironmentName());
-
-this->TargetID = Target.substr(Target.find(TripleOrGPU.second));
-  } else {
-auto KindTriple = TargetFeatures.first.split('-');
-this->OffloadKind = KindTriple.first;
-
-// Enforce optional env field to standardize bundles
-llvm::Triple t = llvm::Triple(KindTriple.second);
-this->Triple = llvm::Triple(t.getArchName(), t.getVendorName(),
-t.getOSName(), t.getEnvironmentName());
-
+  // -[-[:target features]]
+  //  := ---
+  SmallVector Components;
+  Target.split(Components, '-', /*MaxSplit=*/5);
+  assert((Components.size() == 5 || Components.size() == 6) &&
+ "malformed target string");
+
+  StringRef TargetIdWithFeature =
+  Components.size() == 6 ? Components.back() : "";
+  StringRef TargetId = TargetIdWithFeature.split(':').first;
+  if (!TargetId.empty() &&
+  clang::StringToOffloadArch(TargetId) != clang::OffloadArch::UNKNOWN)
+this->TargetID = TargetIdWithFeature;
+  else
 this->TargetID = "";
-  }
+
+  this->OffloadKind = Components.front();
+  ArrayRef TripleSlice{&Components[1], /*length=*/4};
+  llvm::Triple T = llvm::Triple(llvm::join(TripleSlice, "-"));
+  this->Triple = llvm::Triple(T.getArchName(), T.getVendorName(), 
T.getOSName(),
+  T.getEnvironmentName());
 }
 
 bool OffloadTargetInfo::hasHostKind() const {
@@ -148,7 +144,7 @@ bool OffloadTargetInfo::operator==(const OffloadTargetInfo 
&Target) const {
 }
 
 std::string OffloadTargetInfo::str() const {
-  return Twine(OffloadKind + "-" + Triple.str() + "-" + TargetID).str();
+  return Twine(OffloadKind + "-" + Triple.normalize() + "-" + TargetID).str();
 }
 
 static StringRef getDeviceFileExtension(StringRef Device,
diff --git a/clang/test/Driver/

[clang] Fix print module manifest file for macos (PR #122370)

2025-01-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `fuchsia-x86_64-linux` 
running on `fuchsia-debian-64-us-central1-a-1` while building `clang` at step 4 
"annotate".

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


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

```
Step 4 (annotate) failure: 'python 
../llvm-zorg/zorg/buildbot/builders/annotated/fuchsia-linux.py ...' (failure)
...
[182/2768] Copying CXX header __algorithm/count.h
[183/2768] Copying CXX header __algorithm/is_heap.h
[184/2768] Copying CXX header __algorithm/is_heap_until.h
[185/2768] Copying CXX header __algorithm/is_partitioned.h
[186/2768] Copying CXX header __algorithm/is_permutation.h
[187/2768] Copying CXX header __algorithm/is_sorted.h
[188/2768] Copying CXX header __algorithm/for_each.h
[189/2768] Copying CXX header __algorithm/for_each_n.h
[190/2768] Copying CXX header __algorithm/ranges_find_if_not.h
[191/2768] Building CXX object 
libc/src/compiler/generic/CMakeFiles/libc.src.compiler.generic.__stack_chk_fail.dir/__stack_chk_fail.cpp.obj
FAILED: 
libc/src/compiler/generic/CMakeFiles/libc.src.compiler.generic.__stack_chk_fail.dir/__stack_chk_fail.cpp.obj
 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-q8at8zpg/bin/clang++ 
--target=armv8.1m.main-none-eabi -DLIBC_NAMESPACE=__llvm_libc_20_0_0_git 
-I/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc -isystem 
/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-q8at8zpg/include/armv8.1m.main-unknown-none-eabi
 --target=armv8.1m.main-none-eabi -Wno-atomic-alignment "-Dvfprintf(stream, 
format, vlist)=vprintf(format, vlist)" "-Dfprintf(stream, format, 
...)=printf(format)" -D_LIBCPP_PRINT=1 -mthumb -mfloat-abi=hard 
-march=armv8.1-m.main+mve.fp+fp.dp -mcpu=cortex-m55 -fPIC 
-fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time 
-Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter 
-Wwrite-strings -Wcast-qual -Wmissing-field-initializers -Wimplicit-fallthrough 
-Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion 
-Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections 
-fdata-sections 
-ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/build/llvm-build-q8at8zpg/runtimes/runtimes-armv8.1m.main-none-eabi-bins=../../../../llvm-project
 -ffile-prefix-map=/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/= 
-no-canonical-prefixes -Os -DNDEBUG -std=gnu++17 
--target=armv8.1m.main-none-eabi -DLIBC_QSORT_IMPL=LIBC_QSORT_HEAP_SORT 
-DLIBC_TYPES_TIME_T_IS_32_BIT -DLIBC_ADD_NULL_CHECKS 
"-DLIBC_MATH=(LIBC_MATH_SKIP_ACCURATE_PASS | LIBC_MATH_SMALL_TABLES)" -fpie 
-ffreestanding -DLIBC_FULL_BUILD -nostdlibinc -ffixed-point -fno-builtin 
-fno-exceptions -fno-lax-vector-conversions -fno-unwind-tables 
-fno-asynchronous-unwind-tables -fno-rtti -ftrivial-auto-var-init=pattern 
-fno-omit-frame-pointer -Wall -Wextra -Werror -Wconversion -Wno-sign-conversion 
-Wno-c99-extensions -Wno-gnu-imaginary-constant -Wno-pedantic 
-Wimplicit-fallthrough -Wwrite-strings -Wextra-semi -Wnewline-eof 
-Wnonportable-system-include-path -Wstrict-prototypes -Wthread-safety 
-Wglobal-constructors -DLIBC_COPT_PUBLIC_PACKAGING -MD -MT 
libc/src/compiler/generic/CMakeFiles/libc.src.compiler.generic.__stack_chk_fail.dir/__stack_chk_fail.cpp.obj
 -MF 
libc/src/compiler/generic/CMakeFiles/libc.src.compiler.generic.__stack_chk_fail.dir/__stack_chk_fail.cpp.obj.d
 -o 
libc/src/compiler/generic/CMakeFiles/libc.src.compiler.generic.__stack_chk_fail.dir/__stack_chk_fail.cpp.obj
 -c 
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/compiler/generic/__stack_chk_fail.cpp
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/compiler/generic/__stack_chk_fail.cpp:16:1:
 error: unknown type name 'uintptr_t'
   16 | uintptr_t __stack_chk_guard = static_cast(0xa9fff01234);
  | ^
/var/lib/buildbot/fuchsia-x86_64-linux/llvm-project/libc/src/compiler/generic/__stack_chk_fail.cpp:16:43:
 error: unknown type name 'uintptr_t'
   16 | uintptr_t __stack_chk_guard = static_cast(0xa9fff01234);
  |   ^
2 errors generated.
[192/2768] Copying CXX header __algorithm/ranges_find_last.h
[193/2768] Copying CXX header __algorithm/ranges_fold.h
[194/2768] Copying CXX header __algorithm/ranges_for_each.h
[195/2768] Copying CXX header __algorithm/ranges_for_each_n.h
[196/2768] Copying CXX header __algorithm/ranges_generate.h
[197/2768] Copying CXX header __algorithm/ranges_generate_n.h
[198/2768] Copying CXX header __algorithm/ranges_includes.h
[199/2768] Copying CXX header __algorithm/ranges_inplace_merge.h
[200/2768] Building CXX object 
libc/src/string/CMakeFiles/libc.src.string.strcoll.dir/strcoll.cpp.obj
[201/2768] Building CXX object 
libc/src/string/CMakeFiles/libc.src.string.memccpy.dir/memccpy.cpp.obj
[202/2768] Copying CXX header __algorithm/ranges_is_heap.h

[clang] 6f558e0 - [OpenMP] codegen support for masked combined construct masked taskloop (#121914)

2025-01-12 Thread via cfe-commits

Author: CHANDRA GHALE
Date: 2025-01-13T11:42:13+05:30
New Revision: 6f558e0e124012fd00927d6d42545649bd7e0dcd

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

LOG: [OpenMP] codegen support for masked combined construct masked taskloop 
(#121914)

Added codegen support for combined masked constructs `masked taskloop.`
Added implementation for `EmitOMPMaskedTaskLoopDirective`.

-

Co-authored-by: Chandra Ghale 

Added: 
clang/test/OpenMP/masked_taskloop_codegen.c

Modified: 
clang/lib/CodeGen/CGStmt.cpp
clang/lib/CodeGen/CGStmtOpenMP.cpp
clang/lib/CodeGen/CodeGenFunction.h

Removed: 




diff  --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index ee10e586d9250a..f9258a396b7d07 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -332,7 +332,7 @@ void CodeGenFunction::EmitStmt(const Stmt *S, 
ArrayRef Attrs) {
 EmitOMPMasterTaskLoopDirective(cast(*S));
 break;
   case Stmt::OMPMaskedTaskLoopDirectiveClass:
-llvm_unreachable("masked taskloop directive not supported yet.");
+EmitOMPMaskedTaskLoopDirective(cast(*S));
 break;
   case Stmt::OMPMasterTaskLoopSimdDirectiveClass:
 EmitOMPMasterTaskLoopSimdDirective(

diff  --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp 
b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 94daf059edba08..2b4ca65e169a6e 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -7982,6 +7982,18 @@ void CodeGenFunction::EmitOMPMasterTaskLoopDirective(
   CGM.getOpenMPRuntime().emitMasterRegion(*this, CodeGen, S.getBeginLoc());
 }
 
+void CodeGenFunction::EmitOMPMaskedTaskLoopDirective(
+const OMPMaskedTaskLoopDirective &S) {
+  auto &&CodeGen = [this, &S](CodeGenFunction &CGF, PrePostActionTy &Action) {
+Action.Enter(CGF);
+EmitOMPTaskLoopBasedDirective(S);
+  };
+  auto LPCRegion =
+  CGOpenMPRuntime::LastprivateConditionalRAII::disable(*this, S);
+  OMPLexicalScope Scope(*this, S, std::nullopt, /*EmitPreInitStmt=*/false);
+  CGM.getOpenMPRuntime().emitMaskedRegion(*this, CodeGen, S.getBeginLoc());
+}
+
 void CodeGenFunction::EmitOMPMasterTaskLoopSimdDirective(
 const OMPMasterTaskLoopSimdDirective &S) {
   auto &&CodeGen = [this, &S](CodeGenFunction &CGF, PrePostActionTy &Action) {

diff  --git a/clang/lib/CodeGen/CodeGenFunction.h 
b/clang/lib/CodeGen/CodeGenFunction.h
index 86328db345508a..311f2ae94d0463 100644
--- a/clang/lib/CodeGen/CodeGenFunction.h
+++ b/clang/lib/CodeGen/CodeGenFunction.h
@@ -3870,6 +3870,7 @@ class CodeGenFunction : public CodeGenTypeCache {
   void EmitOMPTaskLoopDirective(const OMPTaskLoopDirective &S);
   void EmitOMPTaskLoopSimdDirective(const OMPTaskLoopSimdDirective &S);
   void EmitOMPMasterTaskLoopDirective(const OMPMasterTaskLoopDirective &S);
+  void EmitOMPMaskedTaskLoopDirective(const OMPMaskedTaskLoopDirective &S);
   void
   EmitOMPMasterTaskLoopSimdDirective(const OMPMasterTaskLoopSimdDirective &S);
   void

diff  --git a/clang/test/OpenMP/masked_taskloop_codegen.c 
b/clang/test/OpenMP/masked_taskloop_codegen.c
new file mode 100644
index 00..26f54c1797bbe3
--- /dev/null
+++ b/clang/test/OpenMP/masked_taskloop_codegen.c
@@ -0,0 +1,50 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --include-generated-funcs --prefix-filecheck-ir-name _ --version 5
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fopenmp -fopenmp-version=52 
-x c -emit-llvm %s -o - | FileCheck %s
+// expected-no-diagnostics
+#define N 100
+void masked_taskloop(){
+   #pragma omp masked taskloop
+   for( int i = 0; i < N; i++)
+   ;
+
+}
+
+int main()
+{
+ masked_taskloop();
+}
+// CHECK-LABEL: define dso_local void @masked_taskloop(
+// CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[AGG_CAPTURED:%.*]] = alloca [[STRUCT_ANON:%.*]], align 1
+// CHECK-NEXT:[[TMP:%.*]] = alloca i32, align 4
+// CHECK-NEXT:[[TMP0:%.*]] = call i32 @__kmpc_global_thread_num(ptr 
@[[GLOB1:[0-9]+]])
+// CHECK-NEXT:[[TMP1:%.*]] = call i32 @__kmpc_masked(ptr @[[GLOB1]], i32 
[[TMP0]], i32 0)
+// CHECK-NEXT:[[TMP2:%.*]] = icmp ne i32 [[TMP1]], 0
+// CHECK-NEXT:br i1 [[TMP2]], label %[[OMP_IF_THEN:.*]], label 
%[[OMP_IF_END:.*]]
+// CHECK:   [[OMP_IF_THEN]]:
+// CHECK-NEXT:call void @__kmpc_taskgroup(ptr @[[GLOB1]], i32 [[TMP0]])
+// CHECK-NEXT:[[TMP3:%.*]] = call ptr @__kmpc_omp_task_alloc(ptr 
@[[GLOB1]], i32 [[TMP0]], i32 1, i64 80, i64 0, ptr @.omp_task_entry.)
+// CHECK-NEXT:[[TMP4:%.*]] = getelementptr inbounds nuw 
[[STRUCT_KMP_TASK_T_WITH_PRIVATES:%.*]], ptr [[TMP3]], i32 0, i32 0
+// CHECK-NEXT:[[TMP5:%.*]] = getelementptr inbounds nuw 
[[STRUCT_KMP_TASK_T:%.*]], ptr [[TMP4]], i32 0, i32 5
+// CHECK-N

[clang] [OpenMP] codegen support for masked combined construct masked taskloop (PR #121914)

2025-01-12 Thread CHANDRA GHALE via cfe-commits

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


[clang-tools-extra] [clang-tidy] Add `performance-explicit-move-constructor` check (PR #122599)

2025-01-12 Thread Congcong Cai via cfe-commits

HerrCai0907 wrote:

> > This check sounds a bit strange. Is this issue common in real-world 
> > projects, do we have some data? It's the first time I've heard of it. Why 
> > would people deviate from the standard signature for move constructors?
> 
> It's anecdotal, but I've encountered it in a few places in a private 
> codebase. I don't think it's a _really_ common issue, but it'd be nice to 
> have a lint warning for this.

It may happen. Some C++ newer will follow blindly follow some coding guideline 
and add explicit for all constructor with only one parameter. And it is hard to 
detect to be honest since small performance issues are always hard to detect.

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


[clang] [OpenMP] codegen support for masked combined construct masked taskloop simd (PR #121916)

2025-01-12 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder `clang-aarch64-sve-vls` 
running on `linaro-g3-01` while building `clang` at step 5 "cmake stage 1".

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


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

```
Step 5 (cmake stage 1) failure: 'cmake -G ...' (failure)
...
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.
Call Stack (most recent call first):
  CMakeLists.txt:8 (include)


command timed out: 1200 seconds without output running [b'cmake', b'-G', 
b'Ninja', b'../llvm/llvm', b'-DCMAKE_BUILD_TYPE=Release', 
b'-DLLVM_ENABLE_ASSERTIONS=True', b"-DLLVM_LIT_ARGS='-v'", 
b'-DCMAKE_INSTALL_PREFIX=../stage1.install', 
b"-DCMAKE_C_FLAGS='-mcpu=neoverse-512tvb'", 
b"-DCMAKE_CXX_FLAGS='-mcpu=neoverse-512tvb'", b'-DLLVM_ENABLE_LLD=True', 
b'-DMLIR_INCLUDE_INTEGRATION_TESTS=True', b'-DMLIR_RUN_ARM_SVE_TESTS=True', 
b'-DLLVM_ENABLE_PROJECTS=clang-tools-extra;lld;mlir;llvm;clang;flang', 
b'-DLLVM_ENABLE_RUNTIMES=compiler-rt'], attempting to kill
process killed by signal 9
program finished with exit code -1
elapsedTime=1200.237996

```



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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread Oleksandr T. via cfe-commits


@@ -10757,6 +10757,17 @@ static void checkMethodTypeQualifiers(Sema &S, 
Declarator &D, unsigned DiagID) {
   }
 }
 
+static void checkMethodPointerType(Sema &S, Declarator &D, unsigned DiagID) {
+  if (D.getNumTypeObjects() > 0) {
+DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1);
+if (Chunk.Kind == DeclaratorChunk::Pointer) {
+  SourceLocation PointerLoc = Chunk.getSourceRange().getBegin();
+  S.Diag(PointerLoc, DiagID) << Chunk.getSourceRange();
+  D.setInvalidType();
+}
+  }
+}
+

a-tarasyuk wrote:

Do you mean that having more than one chunk should, by default, be considered 
an error? I thought about that, however, I opted to use the appropriate kind 
check to ensure cases like this are handled correctly (the helper is used for 
constructors and destructors). 

```cpp
struct S {
  (~S)();
};
```




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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread Oleksandr T. via cfe-commits

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


[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)

2025-01-12 Thread via cfe-commits

https://github.com/leijurv updated 
https://github.com/llvm/llvm-project/pull/118046

>From 1caf823165b16f6701993d586df51d5cdbf0885e Mon Sep 17 00:00:00 2001
From: Leijurv 
Date: Fri, 29 Nov 2024 21:54:36 -0600
Subject: [PATCH 1/8] [clang-format] Add BreakBeforeTemplateClose option

---
 clang/docs/ClangFormatStyleOptions.rst |  21 
 clang/docs/ReleaseNotes.rst|   1 +
 clang/include/clang/Format/Format.h|  20 
 clang/lib/Format/ContinuationIndenter.cpp  |  11 ++
 clang/lib/Format/ContinuationIndenter.h|  26 ++--
 clang/lib/Format/Format.cpp|   2 +
 clang/lib/Format/TokenAnnotator.cpp|   2 +-
 clang/unittests/Format/ConfigParseTest.cpp |   1 +
 clang/unittests/Format/FormatTest.cpp  | 131 +
 9 files changed, 206 insertions(+), 9 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4be448171699ca..84ab1b0a2eff61 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -3416,6 +3416,27 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+.. _BreakBeforeTemplateClose:
+
+**BreakBeforeTemplateClose** (``Boolean``) :versionbadge:`clang-format 20` 
:ref:`¶ `
+  If ``true``, a line break will be placed before the ``>`` in a multiline
+  template declaration.
+
+  .. code-block:: c++
+
+ true:
+ template <
+ typename Foo,
+ typename Bar,
+ typename Baz
+ >
+
+ false:
+ template <
+ typename Foo,
+ typename Bar,
+ typename Baz>
+
 .. _BreakBeforeTernaryOperators:
 
 **BreakBeforeTernaryOperators** (``Boolean``) :versionbadge:`clang-format 3.7` 
:ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index e44aefa90ab386..867d4b5d8c3f18 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -976,6 +976,7 @@ clang-format
   ``Never``, and ``true`` to ``Always``.
 - Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
 - Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
+- Adds ``BreakBeforeTemplateClose`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6383934afa2c40..bffd964f6aa8aa 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -2248,6 +2248,25 @@ struct FormatStyle {
   /// \version 16
   BreakBeforeInlineASMColonStyle BreakBeforeInlineASMColon;
 
+  /// If ``true``, a line break will be placed before the ``>`` in a multiline
+  /// template declaration.
+  /// \code
+  ///true:
+  ///template <
+  ///typename Foo,
+  ///typename Bar,
+  ///typename Baz
+  ///>
+  ///
+  ///false:
+  ///template <
+  ///typename Foo,
+  ///typename Bar,
+  ///typename Baz>
+  /// \endcode
+  /// \version 20
+  bool BreakBeforeTemplateClose;
+
   /// If ``true``, ternary operators will be placed after line breaks.
   /// \code
   ///true:
@@ -5184,6 +5203,7 @@ struct FormatStyle {
BreakBeforeBraces == R.BreakBeforeBraces &&
BreakBeforeConceptDeclarations == R.BreakBeforeConceptDeclarations 
&&
BreakBeforeInlineASMColon == R.BreakBeforeInlineASMColon &&
+   BreakBeforeTemplateClose == R.BreakBeforeTemplateClose &&
BreakBeforeTernaryOperators == R.BreakBeforeTernaryOperators &&
BreakBinaryOperations == R.BreakBinaryOperations &&
BreakConstructorInitializers == R.BreakConstructorInitializers &&
diff --git a/clang/lib/Format/ContinuationIndenter.cpp 
b/clang/lib/Format/ContinuationIndenter.cpp
index aed86c1fb99551..4c783623afc535 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -406,6 +406,10 @@ bool ContinuationIndenter::mustBreak(const LineState 
&State) {
   }
   if (CurrentState.BreakBeforeClosingParen && Current.is(tok::r_paren))
 return true;
+  if (CurrentState.BreakBeforeClosingAngle &&
+  Current.ClosesTemplateDeclaration && Style.BreakBeforeTemplateClose) {
+return true;
+  }
   if (Style.Language == FormatStyle::LK_ObjC &&
   Style.ObjCBreakBeforeNestedBlockParam &&
   Current.ObjCSelectorNameParts > 1 &&
@@ -1234,6 +1238,9 @@ unsigned 
ContinuationIndenter::addTokenOnNewLine(LineState &State,
 Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent;
   }
 
+  if (PreviousNonComment && PreviousNonComment->is(tok::less))
+CurrentState.BreakBeforeClosingAngle = true;
+
   if (CurrentState.AvoidBinPacking) {
 // If we are breaking after '(', '{', '<', or this is the break after a ':'
 // to start a member initializer list in a constructor, this should not
@@ -1370,6 +1377,10 @@ unsigned ContinuationIndenter::getNewLineColumn(const 
LineState &State) {
   State.Stack.size() > 1) {
 return State.Stack[State.Stack.size() - 2].Last

[clang] [clang-format] Add BreakBeforeTemplateClose option (PR #118046)

2025-01-12 Thread via cfe-commits


@@ -2252,6 +2252,25 @@ struct FormatStyle {
   /// \version 16
   BreakBeforeInlineASMColonStyle BreakBeforeInlineASMColon;
 
+  /// If ``true``, a line break will be placed before the ``>`` in a multiline
+  /// template declaration.
+  /// \code
+  ///true:
+  ///template <
+  ///typename Foo,
+  ///typename Bar,
+  ///typename Baz
+  ///>
+  ///
+  ///false:
+  ///template <
+  ///typename Foo,
+  ///typename Bar,
+  ///typename Baz>

leijurv wrote:

I'm doing `BreakBeforeTemplateCloser` because of [your comment 
here](https://github.com/llvm/llvm-project/pull/118046#discussion_r1912369946)

I've changed it to an enum in this commit: 
https://github.com/llvm/llvm-project/pull/118046/commits/9277a685c7a0199fff20677759d663254de9189f
 👍 

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


[clang] [libcxx] [clang & libcxx] constexpr pointer tagging (DO NOT MERGE) (PR #111861)

2025-01-12 Thread Hana Dusíková via cfe-commits

hanickadot wrote:

I pushed new design, will update PR's description soon, but now I need to 
finish proposal's wording.

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


[clang] 5c0aa31 - -ftime-report: Move FrontendTimer closer to TimeTraceScope

2025-01-12 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2025-01-12T13:17:49-08:00
New Revision: 5c0aa31c3cb448065f12ede53e4dd54a9a98f650

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

LOG: -ftime-report: Move FrontendTimer closer to TimeTraceScope

... to improve consistency and make "Clang time report" cover
`FrontendAction::BeginSourceFile` and `FrontendAction::EndSourceFile`.

Added: 


Modified: 
clang/include/clang/Frontend/CompilerInstance.h
clang/lib/Frontend/CompilerInstance.cpp
clang/lib/Frontend/FrontendAction.cpp
clang/tools/driver/cc1_main.cpp

Removed: 




diff  --git a/clang/include/clang/Frontend/CompilerInstance.h 
b/clang/include/clang/Frontend/CompilerInstance.h
index 4a79b8d107171a..8b539dfc92960e 100644
--- a/clang/include/clang/Frontend/CompilerInstance.h
+++ b/clang/include/clang/Frontend/CompilerInstance.h
@@ -632,8 +632,6 @@ class CompilerInstance : public ModuleLoader {
 
   llvm::TimerGroup &getTimerGroup() const { return *timerGroup; }
 
-  bool hasFrontendTimer() const { return (bool)FrontendTimer; }
-
   llvm::Timer &getFrontendTimer() const {
 assert(FrontendTimer && "Compiler instance has no frontend timer!");
 return *FrontendTimer;

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index b00a4ac0757763..c11c857ea06061 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -1038,9 +1038,6 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) 
{
<< LLVM_VERSION_STRING << " default target "
<< llvm::sys::getDefaultTargetTriple() << "\n";
 
-  if (getCodeGenOpts().TimePasses)
-createFrontendTimer();
-
   if (getFrontendOpts().ShowStats || !getFrontendOpts().StatsFile.empty())
 llvm::EnableStatistics(false);
 

diff  --git a/clang/lib/Frontend/FrontendAction.cpp 
b/clang/lib/Frontend/FrontendAction.cpp
index 9a50e7453eb61a..9f789f093f55dc 100644
--- a/clang/lib/Frontend/FrontendAction.cpp
+++ b/clang/lib/Frontend/FrontendAction.cpp
@@ -1069,12 +1069,7 @@ bool FrontendAction::BeginSourceFile(CompilerInstance 
&CI,
 
 llvm::Error FrontendAction::Execute() {
   CompilerInstance &CI = getCompilerInstance();
-
-  if (CI.hasFrontendTimer()) {
-llvm::TimeRegion Timer(CI.getFrontendTimer());
-ExecuteAction();
-  }
-  else ExecuteAction();
+  ExecuteAction();
 
   // If we are supposed to rebuild the global module index, do so now unless
   // there were any module-build failures.

diff  --git a/clang/tools/driver/cc1_main.cpp b/clang/tools/driver/cc1_main.cpp
index d14058ff2c723d..26b5e78cfb4b58 100644
--- a/clang/tools/driver/cc1_main.cpp
+++ b/clang/tools/driver/cc1_main.cpp
@@ -283,6 +283,10 @@ int cc1_main(ArrayRef Argv, const char 
*Argv0, void *MainAddr) {
   // Execute the frontend actions.
   {
 llvm::TimeTraceScope TimeScope("ExecuteCompiler");
+bool TimePasses = Clang->getCodeGenOpts().TimePasses;
+if (TimePasses)
+  Clang->createFrontendTimer();
+llvm::TimeRegion Timer(TimePasses ? &Clang->getFrontendTimer() : nullptr);
 Success = ExecuteCompilerInvocation(Clang.get());
   }
 



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


[clang] Accept `cl`-style output arguments (`/Fo`, `-Fo`) for `--fmodule-output` (PR #121046)

2025-01-12 Thread via cfe-commits

github-actions[bot] wrote:




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



You can test this locally with the following command:


``bash
git-clang-format --diff 4f4e2abb1a5ff1225d32410fd02b732d077aa056 
ff22639d751a38e633a5b2e4fe42586d81b36499 --extensions cpp -- 
clang/lib/Driver/Driver.cpp
``





View the diff from clang-format here.


``diff
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 1bab4efc75..a59f7108c0 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6099,10 +6099,12 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
-// CL and not building a PCH. Not sure why the GNU-style driver doesn't 
need this.
-// May need to rethink.
-Arg *FinalOutput = IsCLMode() && 
!C.getArgs().hasArg(options::OPT__SLASH_Yc)
-? C.getArgs().getLastArg(options::OPT__SLASH_Fo, 
options::OPT__SLASH_Fo_COLON)
+// CL and not building a PCH. Not sure why the GNU-style driver doesn't 
need
+// this. May need to rethink.
+Arg *FinalOutput =
+IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc)
+? C.getArgs().getLastArg(options::OPT__SLASH_Fo,
+ options::OPT__SLASH_Fo_COLON)
 : C.getArgs().getLastArg(options::OPT_o);
 
 if (FinalOutput != nullptr) {

``




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


[clang] [Clang] disallow the use of asterisks preceding constructor and destructor names (PR #122621)

2025-01-12 Thread via cfe-commits


@@ -10757,6 +10757,17 @@ static void checkMethodTypeQualifiers(Sema &S, 
Declarator &D, unsigned DiagID) {
   }
 }
 
+static void checkMethodPointerType(Sema &S, Declarator &D, unsigned DiagID) {
+  if (D.getNumTypeObjects() > 0) {
+DeclaratorChunk &Chunk = D.getTypeObject(D.getNumTypeObjects() - 1);
+if (Chunk.Kind == DeclaratorChunk::Pointer) {
+  SourceLocation PointerLoc = Chunk.getSourceRange().getBegin();
+  S.Diag(PointerLoc, DiagID) << Chunk.getSourceRange();
+  D.setInvalidType();
+}
+  }
+}
+

MagentaTreehouse wrote:

See also 
https://github.com/llvm/llvm-project/issues/121706#issuecomment-2585579281

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


[clang] Accept `cl`-style output arguments (`/Fo`, `-Fo`) for `--fmodule-output` (PR #121046)

2025-01-12 Thread Sharadh Rajaraman via cfe-commits

https://github.com/sharadhr updated 
https://github.com/llvm/llvm-project/pull/121046

>From 3a84b5906330c4f6308e10c50381f06956c27e2d Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Tue, 24 Dec 2024 09:32:21 +
Subject: [PATCH 1/4] Accept /Fo and -Fo in `-fmodule-output` when running
 under CL mode

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

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 4d9492ea08f647..67b5e7268051ae 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6099,7 +6099,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
-if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o, 
options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON))
   return C.addResultFile(FinalOutput->getValue(), &JA);
   }
 

>From 1a471fe6ef2549c53b393ac407756f4a4bbc7363 Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Sun, 5 Jan 2025 14:09:24 +
Subject: [PATCH 2/4] Use `IsCLMode` to guard cl-style output argument presence

---
 clang/lib/Driver/Driver.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 67b5e7268051ae..41c30899807c52 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6099,8 +6099,15 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
-if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o, 
options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON))
+Arg *FinalOutput =
+IsCLMode()
+? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo,
+ options::OPT__SLASH_Fo_COLON)
+: C.getArgs().getLastArg(options::OPT_o);
+
+if (FinalOutput != nullptr) {
   return C.addResultFile(FinalOutput->getValue(), &JA);
+}
   }
 
   // For /P, preprocess to file named after BaseInput.

>From fe69cf4b4de805b67b877e7b30165e32a986dedc Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Thu, 9 Jan 2025 19:20:30 +
Subject: [PATCH 3/4] Test for `/Yc` and `/Fp` under CL mode

---
 clang/lib/Driver/Driver.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 41c30899807c52..32d87a4eaa59ca 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6100,7 +6100,9 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
 Arg *FinalOutput =
-IsCLMode()
+// CL and not generating a PCH: test for Fo, Fp, and Yc
+IsCLMode() && !(C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
+C.getArgs().hasArg(options::OPT__SLASH_Fp))
 ? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo,
  options::OPT__SLASH_Fo_COLON)
 : C.getArgs().getLastArg(options::OPT_o);

>From ff22639d751a38e633a5b2e4fe42586d81b36499 Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Sun, 12 Jan 2025 21:44:33 +
Subject: [PATCH 4/4] Account for /Yc when generating PCH

---
 clang/lib/Driver/Driver.cpp | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 32d87a4eaa59ca..1bab4efc75db17 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6099,12 +6099,10 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
-Arg *FinalOutput =
-// CL and not generating a PCH: test for Fo, Fp, and Yc
-IsCLMode() && !(C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
-C.getArgs().hasArg(options::OPT__SLASH_Fp))
-? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo,
- options::OPT__SLASH_Fo_COLON)
+// CL and not building a PCH. Not sure why the GNU-style driver doesn't 
need this.
+// May need to rethink.
+Arg *FinalOutput = IsCLMode() && 
!C.getArgs().hasArg(options::OPT__SLASH_Yc)
+? C.getArgs().getLastArg(options::OPT__SLASH_Fo, 
options::OPT__SLASH_Fo_COLON)
 : C.getArgs().getLastArg(options::OPT_o);
 
 if (FinalOutput != nullptr) {

_

[clang] Accept `cl`-style output arguments (`/Fo`, `-Fo`) for `--fmodule-output` (PR #121046)

2025-01-12 Thread Sharadh Rajaraman via cfe-commits

https://github.com/sharadhr updated 
https://github.com/llvm/llvm-project/pull/121046

>From 3a84b5906330c4f6308e10c50381f06956c27e2d Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Tue, 24 Dec 2024 09:32:21 +
Subject: [PATCH 1/5] Accept /Fo and -Fo in `-fmodule-output` when running
 under CL mode

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

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 4d9492ea08f647..67b5e7268051ae 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6099,7 +6099,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
-if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o))
+if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o, 
options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON))
   return C.addResultFile(FinalOutput->getValue(), &JA);
   }
 

>From 1a471fe6ef2549c53b393ac407756f4a4bbc7363 Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Sun, 5 Jan 2025 14:09:24 +
Subject: [PATCH 2/5] Use `IsCLMode` to guard cl-style output argument presence

---
 clang/lib/Driver/Driver.cpp | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 67b5e7268051ae..41c30899807c52 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6099,8 +6099,15 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
-if (Arg *FinalOutput = C.getArgs().getLastArg(options::OPT_o, 
options::OPT__SLASH_Fo, options::OPT__SLASH_Fo_COLON))
+Arg *FinalOutput =
+IsCLMode()
+? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo,
+ options::OPT__SLASH_Fo_COLON)
+: C.getArgs().getLastArg(options::OPT_o);
+
+if (FinalOutput != nullptr) {
   return C.addResultFile(FinalOutput->getValue(), &JA);
+}
   }
 
   // For /P, preprocess to file named after BaseInput.

>From fe69cf4b4de805b67b877e7b30165e32a986dedc Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Thu, 9 Jan 2025 19:20:30 +
Subject: [PATCH 3/5] Test for `/Yc` and `/Fp` under CL mode

---
 clang/lib/Driver/Driver.cpp | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 41c30899807c52..32d87a4eaa59ca 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6100,7 +6100,9 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
 Arg *FinalOutput =
-IsCLMode()
+// CL and not generating a PCH: test for Fo, Fp, and Yc
+IsCLMode() && !(C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
+C.getArgs().hasArg(options::OPT__SLASH_Fp))
 ? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo,
  options::OPT__SLASH_Fo_COLON)
 : C.getArgs().getLastArg(options::OPT_o);

>From d7b7e93fb04fc624e7ce3758bd385bdea1a388a9 Mon Sep 17 00:00:00 2001
From: Sharadh Rajaraman 
Date: Sun, 12 Jan 2025 21:44:33 +
Subject: [PATCH 4/5] Account for /Yc when generating PCH

---
 clang/lib/Driver/Driver.cpp | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 32d87a4eaa59ca..a59f7108c07602 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -6099,11 +6099,11 @@ const char *Driver::GetNamedOutputPath(Compilation &C, 
const JobAction &JA,
   llvm::PrettyStackTraceString CrashInfo("Computing output path");
   // Output to a user requested destination?
   if (AtTopLevel && !isa(JA) && !isa(JA)) {
+// CL and not building a PCH. Not sure why the GNU-style driver doesn't 
need
+// this. May need to rethink.
 Arg *FinalOutput =
-// CL and not generating a PCH: test for Fo, Fp, and Yc
-IsCLMode() && !(C.getArgs().hasArg(options::OPT__SLASH_Yc) &&
-C.getArgs().hasArg(options::OPT__SLASH_Fp))
-? C.getArgs().getLastArg(options::OPT_o, options::OPT__SLASH_Fo,
+IsCLMode() && !C.getArgs().hasArg(options::OPT__SLASH_Yc)
+? C.getArgs().getLastArg(options::OPT__SLASH_Fo,
  options::OPT__SLASH_Fo_COLON)
 : C.getArgs().getLastArg(options::OPT_o);
 

>From 1f40c12decf6faef58dc4e268dd3aac0c3c1874a Mon Sep 17 00:00:00 2001
From: Sharadh 

[clang] [flang] [lld] [Flang] Don't use FortranDecimal for runtime (PR #121997)

2025-01-12 Thread Michael Kruse via cfe-commits

https://github.com/Meinersbur updated 
https://github.com/llvm/llvm-project/pull/121997

>From a08aa48fb4955f9d16c6172580505c100076b5d4 Mon Sep 17 00:00:00 2001
From: Michael Kruse 
Date: Tue, 7 Jan 2025 17:05:39 +0100
Subject: [PATCH 1/4] Join FortranDecimal into FortranCommon

---
 clang/lib/Driver/ToolChains/CommonArgs.cpp|  3 +-
 clang/lib/Driver/ToolChains/Flang.cpp |  4 -
 flang/docs/FlangDriver.md |  5 +-
 .../binary-floating-point.h   |  8 +-
 .../flang/{Decimal => Common}/decimal.h   | 11 ++-
 flang/lib/CMakeLists.txt  |  1 -
 flang/lib/Common/CMakeLists.txt   |  2 +
 .../big-radix-floating-point.h| 12 +--
 .../{Decimal => Common}/binary-to-decimal.cpp |  4 +-
 .../{Decimal => Common}/decimal-to-binary.cpp |  6 +-
 flang/lib/Decimal/CMakeLists.txt  | 86 ---
 flang/lib/Evaluate/CMakeLists.txt |  1 -
 flang/lib/Evaluate/real.cpp   |  2 +-
 flang/runtime/CMakeLists.txt  | 14 +--
 flang/runtime/edit-input.h|  2 +-
 flang/runtime/edit-output.h   |  2 +-
 flang/runtime/environment.h   |  2 +-
 flang/runtime/format-implementation.h |  2 +-
 flang/runtime/format.h|  2 +-
 flang/test/CMakeLists.txt |  1 -
 flang/test/Driver/linker-flags.f90|  6 +-
 .../test/Driver/msvc-dependent-lib-flags.f90  |  4 -
 flang/test/Driver/nostdlib.f90|  1 -
 flang/test/Runtime/no-cpp-dep.c   |  2 +-
 flang/test/lit.cfg.py |  3 -
 flang/unittests/Decimal/CMakeLists.txt|  4 +-
 flang/unittests/Decimal/quick-sanity-test.cpp |  2 +-
 flang/unittests/Decimal/thorough-test.cpp |  2 +-
 flang/unittests/Evaluate/CMakeLists.txt   |  2 -
 lld/COFF/MinGW.cpp|  1 -
 30 files changed, 40 insertions(+), 157 deletions(-)
 rename flang/include/flang/{Decimal => Common}/binary-floating-point.h (96%)
 rename flang/include/flang/{Decimal => Common}/decimal.h (95%)
 rename flang/lib/{Decimal => Common}/big-radix-floating-point.h (97%)
 rename flang/lib/{Decimal => Common}/binary-to-decimal.cpp (99%)
 rename flang/lib/{Decimal => Common}/decimal-to-binary.cpp (99%)
 delete mode 100644 flang/lib/Decimal/CMakeLists.txt

diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp 
b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 60214c4d59cee5..9e9872975de9c2 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1317,7 +1317,7 @@ void tools::addOpenMPHostOffloadingArgs(const Compilation 
&C,
 /// Add Fortran runtime libs
 void tools::addFortranRuntimeLibs(const ToolChain &TC, const ArgList &Args,
   llvm::opt::ArgStringList &CmdArgs) {
-  // Link FortranRuntime and FortranDecimal
+  // Link FortranRuntime
   // These are handled earlier on Windows by telling the frontend driver to
   // add the correct libraries to link against as dependents in the object
   // file.
@@ -1334,7 +1334,6 @@ void tools::addFortranRuntimeLibs(const ToolChain &TC, 
const ArgList &Args,
 addAsNeededOption(TC, Args, CmdArgs, /*as_needed=*/false);
 }
 CmdArgs.push_back("-lFortranRuntime");
-CmdArgs.push_back("-lFortranDecimal");
 addArchSpecificRPath(TC, Args, CmdArgs);
   }
 
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 7034e5b475c1d3..749af4ada9a696 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -357,21 +357,18 @@ static void processVSRuntimeLibrary(const ToolChain &TC, 
const ArgList &Args,
 CmdArgs.push_back("-D_MT");
 CmdArgs.push_back("--dependent-lib=libcmt");
 CmdArgs.push_back("--dependent-lib=FortranRuntime.static.lib");
-CmdArgs.push_back("--dependent-lib=FortranDecimal.static.lib");
 break;
   case options::OPT__SLASH_MTd:
 CmdArgs.push_back("-D_MT");
 CmdArgs.push_back("-D_DEBUG");
 CmdArgs.push_back("--dependent-lib=libcmtd");
 CmdArgs.push_back("--dependent-lib=FortranRuntime.static_dbg.lib");
-CmdArgs.push_back("--dependent-lib=FortranDecimal.static_dbg.lib");
 break;
   case options::OPT__SLASH_MD:
 CmdArgs.push_back("-D_MT");
 CmdArgs.push_back("-D_DLL");
 CmdArgs.push_back("--dependent-lib=msvcrt");
 CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic.lib");
-CmdArgs.push_back("--dependent-lib=FortranDecimal.dynamic.lib");
 break;
   case options::OPT__SLASH_MDd:
 CmdArgs.push_back("-D_MT");
@@ -379,7 +376,6 @@ static void processVSRuntimeLibrary(const ToolChain &TC, 
const ArgList &Args,
 CmdArgs.push_back("-D_DLL");
 CmdArgs.push_back("--dependent-lib=msvcrtd");
 CmdArgs.push_back("--dependent-lib=FortranRuntime.dynamic_dbg.lib");
-CmdArgs.push_back("--dependent-lib=FortranD

  1   2   >