[clang] [llvm] [OpenEmbedded] Fix include and lib paths for multilib targets (PR #121302)

2024-12-29 Thread Mike Crowe via cfe-commits

mikecrowe wrote:

This works, but I'm not sure that it's the best solution. I could teach 
`parseVendor` to match a prefix of `oeml` rather than hard-coding the two 
specific multilib types.

https://github.com/llvm/llvm-project/pull/121302
___
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 bugprone-move-shared-pointer-contents check. (PR #67467)

2024-12-29 Thread Denis Mikhailov via cfe-commits

denzor200 wrote:

Suppose this check should be silent for a shared_ptr with `use_count() == 1`. 
Is it possible to change implementation in order to following this way?

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


[clang] [llvm] [OpenEmbedded] Fix include and lib paths for multilib targets (PR #121302)

2024-12-29 Thread Mike Crowe via cfe-commits

https://github.com/mikecrowe created 
https://github.com/llvm/llvm-project/pull/121302

The fix in e9ddc44a604318739a27249d267aa7267d13d93b wasn't enough for multilib 
targets since they use a custom vendor that contains the multilib variant.  
There are two common multilib variants: lib32 and libx32, so let's support both.

>From 8e11693fc2fd17c35b0ea7ec885c8c815e61173d Mon Sep 17 00:00:00 2001
From: Mike Crowe 
Date: Sun, 29 Dec 2024 17:25:20 +
Subject: [PATCH] [OpenEmbedded] Fix include and lib paths for multilib targets

The fix in e9ddc44a604318739a27249d267aa7267d13d93b wasn't enough for
multilib targets since they use a custom vendor that contains the
multilib variant.  There are two common multilib variants: lib32 and
libx32, so let's support both.
---
 .../usr/include/c++/9.5.0/backward/.keep  |  0
 .../9.5.0/crtbegin.o  |  0
 .../9.5.0/crtend.o|  0
 .../usr/lib/crt1.o|  0
 .../usr/lib/crti.o|  0
 .../usr/lib/crtn.o|  0
 .../usr/include/c++/14.2.0/backward/.keep |  0
 .../usr/libx32/crt1.o |  0
 .../usr/libx32/crti.o |  0
 .../usr/libx32/crtn.o |  0
 .../14.2.0/crtbegin.o |  0
 .../14.2.0/crtend.o   |  0
 clang/test/Driver/linux-header-search.cpp | 22 
 clang/test/Driver/linux-ld.c  | 36 +++
 llvm/lib/TargetParser/Triple.cpp  |  2 ++
 llvm/unittests/TargetParser/TripleTest.cpp| 12 +++
 16 files changed, 72 insertions(+)
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crt1.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crti.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crtn.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtend.o

diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep
 
b/clang/test/Driver/Inputs/openembedded_x86_64_multi

[clang] [llvm] [OpenEmbedded] Fix include and lib paths for multilib targets (PR #121302)

2024-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Mike Crowe (mikecrowe)


Changes

The fix in e9ddc44a604318739a27249d267aa7267d13d93b wasn't enough for multilib 
targets since they use a custom vendor that contains the multilib variant.  
There are two common multilib variants: lib32 and libx32, so let's support both.

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


16 Files Affected:

- (added) 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crt1.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crti.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crtn.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtbegin.o
 () 
- (added) 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtend.o
 () 
- (modified) clang/test/Driver/linux-header-search.cpp (+22) 
- (modified) clang/test/Driver/linux-ld.c (+36) 
- (modified) llvm/lib/TargetParser/Triple.cpp (+2) 
- (modified) llvm/unittests/TargetParser/TripleTest.cpp (+12) 


``diff
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep
 
b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crt1.o
 
b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crt1.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crti.o
 
b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crti.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crtn.o
 
b/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crtn.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtbegin.o
 
b/clang/test/Driver/Inputs/openembedded_x86_64_multi

[clang] [clang-format] Add VariableTemplates option (PR #121318)

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

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


[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)

2024-12-29 Thread Galen Elias via cfe-commits


@@ -4504,6 +4504,16 @@ TEST_F(FormatTest, FormatsCompactNamespaces) {
"} // namespace bb\n"
"} // namespace aa",
Style);
+
+  verifyFormat("namespace a { namespace b { namespace c {\n"
+   "}}} // namespace a::b::c",
+   Style);
+
+  verifyFormat("namespace a { namespace b {\n"
+   "namespace cc {\n"
+   "}}} // namespace a::b::cc",

galenelias wrote:

I'll defer to your judgement, but I personally think it is helpful to test each 
side of these edge cases around line wrapping.  Having a test to verify things 
don't get wrapped at 'X' columns, but then having tests cases which are like 
X/2 long doesn't really validate the precision of the width calculations, as 
evidenced by this bug, and means we might be wrapping too aggressively, and 
won't catch that via any existing tests.  If we only verify lines significantly 
shorter or longer than the ColumnLimit then we it is easy for mistakes in the 
logic to sneak through.

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


[clang] [diagtool] Make the BuiltinDiagnosticsByID table sorted (PR #120321)

2024-12-29 Thread Karl-Johan Karlsson via cfe-commits


@@ -23,28 +23,29 @@ llvm::ArrayRef 
diagtool::getBuiltinDiagnosticsByName() {
   return llvm::ArrayRef(BuiltinDiagnosticsByName);
 }
 
-
 // FIXME: Is it worth having two tables, especially when this one can get
 // out of sync easily?
+// clang-format off
 static const DiagnosticRecord BuiltinDiagnosticsByID[] = {
 #define DIAG(ENUM, CLASS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR,  
\
  SHOWINSYSHEADER, SHOWINSYSMACRO, DEFER, CATEGORY) 
\
   {#ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t)},
 #include "clang/Basic/DiagnosticCommonKinds.inc"
-#include "clang/Basic/DiagnosticCrossTUKinds.inc"
 #include "clang/Basic/DiagnosticDriverKinds.inc"
 #include "clang/Basic/DiagnosticFrontendKinds.inc"
 #include "clang/Basic/DiagnosticSerializationKinds.inc"
 #include "clang/Basic/DiagnosticLexKinds.inc"
 #include "clang/Basic/DiagnosticParseKinds.inc"
 #include "clang/Basic/DiagnosticASTKinds.inc"
 #include "clang/Basic/DiagnosticCommentKinds.inc"
+#include "clang/Basic/DiagnosticCrossTUKinds.inc"

karka228 wrote:

Verify the changed include order by adding an assert in getDiagnosticForID 
below:
```
  // The requirement for lower_bound to produce a valid result it is
  // enough if the BuiltinDiagnosticsByID is partitioned (by DiagID),
  // but as we want this function to work for all possible values of
  // DiagID sent in as argument it is better to right away check if
  // BuiltinDiagnosticsByID is sorted.
  assert(llvm::is_sorted(BuiltinDiagnosticsByID, orderByID) &&
 "IDs in BuiltinDiagnosticsByID must be sorted.");
```

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


[clang] [diagtool] Make the BuiltinDiagnosticsByID table sorted (PR #120321)

2024-12-29 Thread Karl-Johan Karlsson via cfe-commits


@@ -23,28 +23,29 @@ llvm::ArrayRef 
diagtool::getBuiltinDiagnosticsByName() {
   return llvm::ArrayRef(BuiltinDiagnosticsByName);
 }
 
-
 // FIXME: Is it worth having two tables, especially when this one can get
 // out of sync easily?
+// clang-format off

karka228 wrote:

Add a comment about why we turn off clang-format:
```
// Turn off clang-format, as the order of the includes are important
// to make sure the table is sorted.
```

https://github.com/llvm/llvm-project/pull/120321
___
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 bugprone-reset-call check (PR #121291)

2024-12-29 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor updated 
https://github.com/llvm/llvm-project/pull/121291

>From 37dce6a7ed0cca2e9819c24f4d176c43e3c9f2ac Mon Sep 17 00:00:00 2001
From: Victor Baranov 
Date: Sun, 29 Dec 2024 15:32:22 +0300
Subject: [PATCH 1/3] [clang-tidy] Add bugprone-reset-call check

---
 .../bugprone/BugproneTidyModule.cpp   |   2 +
 .../clang-tidy/bugprone/CMakeLists.txt|   1 +
 .../clang-tidy/bugprone/ResetCallCheck.cpp| 133 +++
 .../clang-tidy/bugprone/ResetCallCheck.h  |  34 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../clang-tidy/checks/bugprone/reset-call.rst |  33 +++
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../checkers/bugprone/reset-call.cpp  | 215 ++
 8 files changed, 425 insertions(+)
 create mode 100644 clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp
 create mode 100644 clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/reset-call.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/reset-call.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 33ac65e715ce81..645958e47e22a5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -57,6 +57,7 @@
 #include "PosixReturnCheck.h"
 #include "RedundantBranchConditionCheck.h"
 #include "ReservedIdentifierCheck.h"
+#include "ResetCallCheck.h"
 #include "ReturnConstRefFromParameterCheck.h"
 #include "SharedPtrArrayMismatchCheck.h"
 #include "SignalHandlerCheck.h"
@@ -144,6 +145,7 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck("bugprone-reset-call");
 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 13adad7c3dadbd..17ab5b27ec5550 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -52,6 +52,7 @@ add_clang_library(clangTidyBugproneModule STATIC
   PosixReturnCheck.cpp
   RedundantBranchConditionCheck.cpp
   ReservedIdentifierCheck.cpp
+  ResetCallCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SharedPtrArrayMismatchCheck.cpp
   SignalHandlerCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp
new file mode 100644
index 00..305ac8d51adf3e
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp
@@ -0,0 +1,133 @@
+//===--- ResetCallCheck.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 "ResetCallCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+
+AST_MATCHER_P(CallExpr, everyArgumentMatches,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  if (Node.getNumArgs() == 0)
+return true;
+
+  for (const auto *Arg : Node.arguments()) {
+if (!InnerMatcher.matches(*Arg, Finder, Builder))
+  return false;
+  }
+  return true;
+}
+
+AST_MATCHER(CXXMethodDecl, hasOnlyDefaultArgs) {
+  if (Node.param_empty())
+return true;
+
+  for (const auto *Param : Node.parameters()) {
+if (!Param->hasDefaultArg())
+  return false;
+  }
+  return true;
+}
+
+} // namespace
+
+void ResetCallCheck::registerMatchers(MatchFinder *Finder) {
+  const auto IsSmartptr = hasAnyName("::std::unique_ptr", "::std::shared_ptr");
+
+  const auto ResetMethod =
+  cxxMethodDecl(hasName("reset"), hasOnlyDefaultArgs());
+
+  const auto TypeWithReset =
+  anyOf(cxxRecordDecl(hasMethod(ResetMethod)),
+classTemplateSpecializationDecl(
+hasSpecializedTemplate(classTemplateDecl(has(ResetMethod);
+
+  const auto SmartptrWithBugproneReset = classTemplateSpecializationDecl(
+  IsSmartptr,
+  hasTemplateArgument(
+  0, templateArgument(refersToType(hasUnqualifiedDesugaredType(
+ recordType(hasDeclaration(TypeWithReset)));
+
+  // Find a.reset() calls
+  Finder->addMatcher(
+  cxxMemberCallExpr(callee(memberExpr(member(hasName("reset",
+ 

[clang-tools-extra] [clang-tidy] Add bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-29 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor edited 
https://github.com/llvm/llvm-project/pull/121291
___
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 bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-29 Thread Baranov Victor via cfe-commits


@@ -0,0 +1,33 @@
+.. title:: clang-tidy - bugprone-reset-call
+
+bugprone-reset-call
+===
+
+Finds calls to ``reset()`` method on smart pointers where the pointee type

vbvictor wrote:

Done, also removed parentheses in ``reset`` to follow general style

https://github.com/llvm/llvm-project/pull/121291
___
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 bugprone-smartptr-reset-ambiguous-call check (PR #121291)

2024-12-29 Thread Baranov Victor via cfe-commits

vbvictor wrote:

> 1. Consider TK_IgnoreUnlessSpelledInSource, may simplify matchers
> 2. Name is too generic, consider:
> 
> * bugprone-smartptr-reset-pointee-reset
> * bugprone-smartptr-reset-call
> * bugprone-smartptr-pointee-reset
> * bugprone-smartptr-reset-ambiguous-call (my prefered)
> 
> Or any simillar.

1. Could not find a way to use TK_IgnoreUnlessSpelledInSource because code in 
function
`template 
void TemplatePositiveTest() {}`
is implicitly instantiated for different template types, so it is being ignored 
by matchers with TK_IgnoreUnlessSpelledInSource.
2. Renamed check to bugprone-smartptr-reset-ambiguous-call.


https://github.com/llvm/llvm-project/pull/121291
___
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 depercation warning for non-whitelisted global options (PR #121057)

2024-12-29 Thread Congcong Cai via cfe-commits

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

>From 98d65a0b9a1189ce73d97d76527b458f93f17b43 Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Tue, 24 Dec 2024 23:32:02 +0800
Subject: [PATCH 1/4] [clang-tidy] add depercation warning for non-whitelisted
 global options

---
 .../clang-tidy/ClangTidyCheck.cpp | 32 ---
 .../checkers/modernize/use-std-format-fmt.cpp |  2 +-
 .../deprecation-global-option.cpp |  3 ++
 3 files changed, 25 insertions(+), 12 deletions(-)
 create mode 100644 
clang-tools-extra/test/clang-tidy/infrastructure/deprecation-global-option.cpp

diff --git a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
index 6028bb2258136b..5161ffeedf70df 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp
@@ -7,11 +7,11 @@
 
//===--===//
 
 #include "ClangTidyCheck.h"
-#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/Error.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/Support/YAMLParser.h"
 #include 
+#include 
 
 namespace clang::tidy {
 
@@ -62,16 +62,29 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const 
{
   return std::nullopt;
 }
 
+static const llvm::StringSet<> DeprecatedGlobalOptions{
+"StrictMode",
+"IgnoreMacros",
+};
+
 static ClangTidyOptions::OptionMap::const_iterator
 findPriorityOption(const ClangTidyOptions::OptionMap &Options,
StringRef NamePrefix, StringRef LocalName,
-   llvm::StringSet<> *Collector) {
+   ClangTidyContext *Context) {
+  llvm::StringSet<> *Collector = Context->getOptionsCollector();
   if (Collector) {
 Collector->insert((NamePrefix + LocalName).str());
 Collector->insert(LocalName);
   }
   auto IterLocal = Options.find((NamePrefix + LocalName).str());
   auto IterGlobal = Options.find(LocalName);
+  // FIXME: temporary solution for deprecation warnings, should be removed
+  // after 22.x.
+  if (IterGlobal != Options.end() &&
+  DeprecatedGlobalOptions.contains(LocalName))
+Context->configurationDiag(
+"deprecation global option '%0', please use '%1%0'.")
+<< LocalName << NamePrefix;
   if (IterLocal == Options.end())
 return IterGlobal;
   if (IterGlobal == Options.end())
@@ -83,8 +96,7 @@ findPriorityOption(const ClangTidyOptions::OptionMap &Options,
 
 std::optional
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const {
-  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName,
- Context->getOptionsCollector());
+  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
   if (Iter != CheckOptions.end())
 return StringRef(Iter->getValue().Value);
   return std::nullopt;
@@ -117,8 +129,7 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) 
const {
 template <>
 std::optional
 ClangTidyCheck::OptionsView::getLocalOrGlobal(StringRef LocalName) const 
{
-  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName,
- Context->getOptionsCollector());
+  auto Iter = findPriorityOption(CheckOptions, NamePrefix, LocalName, Context);
   if (Iter != CheckOptions.end()) {
 if (auto Result = getAsBool(Iter->getValue().Value, Iter->getKey()))
   return Result;
@@ -157,10 +168,9 @@ std::optional 
ClangTidyCheck::OptionsView::getEnumInt(
 bool IgnoreCase) const {
   if (!CheckGlobal && Context->getOptionsCollector())
 Context->getOptionsCollector()->insert((NamePrefix + LocalName).str());
-  auto Iter = CheckGlobal
-  ? findPriorityOption(CheckOptions, NamePrefix, LocalName,
-   Context->getOptionsCollector())
-  : CheckOptions.find((NamePrefix + LocalName).str());
+  auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix,
+   LocalName, Context)
+  : CheckOptions.find((NamePrefix + LocalName).str());
   if (Iter == CheckOptions.end())
 return std::nullopt;
 
diff --git 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
index 1eaf18ac119966..71c8af190467cf 100644
--- 
a/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
+++ 
b/clang-tools-extra/test/clang-tidy/checkers/modernize/use-std-format-fmt.cpp
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-use-std-format %t -- \
 // RUN:   -config="{CheckOptions: { \
-// RUN:  StrictMode: true, \
+// RUN:  modernize-use-std-format.StrictMode: true, \
 // RUN:  modernize-use-std-format.StrFormatLikeFunctions: 
'fmt::sprintf', \
 // RUN: 

[clang-tools-extra] [clang-tidy] bugprone-unhandled-self-assignment: fix smart pointer check against std::unique_ptr type (PR #121266)

2024-12-29 Thread Congcong Cai via cfe-commits

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

LGTM

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


[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121313)

2024-12-29 Thread Nathan Ridge via cfe-commits

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

Fixes https://github.com/clangd/clangd/issues/2154

>From 8238ad159c0b8123c03d953d18340147c72372e9 Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Sun, 6 Oct 2024 00:41:48 -0400
Subject: [PATCH] [clangd] Add a unit test suite for HeuristicResolver

Fixes https://github.com/clangd/clangd/issues/2154
---
 clang-tools-extra/clangd/HeuristicResolver.h  |   5 +-
 .../clangd/unittests/CMakeLists.txt   |   1 +
 .../unittests/HeuristicResolverTests.cpp  | 521 ++
 3 files changed, 525 insertions(+), 2 deletions(-)
 create mode 100644 
clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp

diff --git a/clang-tools-extra/clangd/HeuristicResolver.h 
b/clang-tools-extra/clangd/HeuristicResolver.h
index dcc063bbc4adc0..c130e0677e86dd 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.h
+++ b/clang-tools-extra/clangd/HeuristicResolver.h
@@ -26,13 +26,14 @@ class UnresolvedUsingValueDecl;
 
 namespace clangd {
 
-// This class heuristic resolution of declarations and types in template code.
+// This class handles heuristic resolution of declarations and types in 
template
+// code.
 //
 // As a compiler, clang only needs to perform certain types of processing on
 // template code (such as resolving dependent names to declarations, or
 // resolving the type of a dependent expression) after instantiation. Indeed,
 // C++ language features such as template specialization mean such resolution
-// cannot be done accurately before instantiation
+// cannot be done accurately before instantiation.
 //
 // However, template code is written and read in uninstantiated form, and 
clangd
 // would like to provide editor features like go-to-definition in template code
diff --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index dffdcd5d014ca9..8dba8088908d5e 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -64,6 +64,7 @@ add_unittest(ClangdUnitTests ClangdTests
   GlobalCompilationDatabaseTests.cpp
   HeadersTests.cpp
   HeaderSourceSwitchTests.cpp
+  HeuristicResolverTests.cpp
   HoverTests.cpp
   IncludeCleanerTests.cpp
   IndexActionTests.cpp
diff --git a/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp 
b/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp
new file mode 100644
index 00..5665fb2519267f
--- /dev/null
+++ b/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp
@@ -0,0 +1,521 @@
+//===-- HeuristicResolverTests.cpp --*- 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
+//
+//===--===//
+#include "HeuristicResolver.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock-matchers.h"
+#include "gtest/gtest.h"
+
+using namespace clang::ast_matchers;
+using clang::clangd::HeuristicResolver;
+using testing::ElementsAre;
+
+namespace clang {
+namespace {
+
+// Helper for matching a sequence of elements with a variadic list of matchers.
+// Usage: `ElementsAre(matchAdapter(Vs, MatchFunction)...)`, where `Vs...` is
+//a variadic list of matchers.
+// For each `V` in `Vs`, this will match the corresponding element `E` if
+// `MatchFunction(V, E)` is true.
+MATCHER_P2(matchAdapter, MatcherForElement, MatchFunction, "matchAdapter") {
+  return MatchFunction(MatcherForElement, arg);
+}
+
+template 
+using ResolveFnT = std::function(
+const HeuristicResolver *, const InputNode *)>;
+
+// Test heuristic resolution on `Code` using the resolution procedure
+// `ResolveFn`, which takes a `HeuristicResolver` and an input AST node of type
+// `InputNode` and returns a `std::vector`.
+// `InputMatcher` should be an AST matcher that matches a single node to pass 
as
+// input to `ResolveFn`, bound to the ID "input". `OutputMatchers` should be 
AST
+// matchers that each match a single node, bound to the ID "output".
+template 
+void expectResolution(llvm::StringRef Code, ResolveFnT ResolveFn,
+  const InputMatcher &IM, const OutputMatchers &...OMS) {
+  auto TU = tooling::buildASTFromCodeWithArgs(Code, {"-std=c++20"});
+  auto &Ctx = TU->getASTContext();
+  auto InputMatches = match(IM, Ctx);
+  ASSERT_EQ(1u, InputMatches.size());
+  const auto *Input = InputMatches[0].template getNodeAs("input");
+  ASSERT_TRUE(Input);
+
+  auto OutputNodeMatches = [&](auto &OutputMatcher, auto &Actual) {
+auto OutputMatches = match(OutputMatcher, Ctx);
+if (OutputMatches.size() != 1u)
+  return false;
+const auto *ExpectedOutput =
+

[clang] [Analyzer][CFG] Correctly handle rebuilt default arg and default init expression (PR #117437)

2024-12-29 Thread via cfe-commits

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

>From f875a02ca829f173cb2753691556829a24b8a4aa Mon Sep 17 00:00:00 2001
From: yronglin 
Date: Fri, 22 Nov 2024 21:06:58 +0800
Subject: [PATCH 1/2] [Analyzer][CFG] Correctly handle rebuilt default arg and
 default init expression

Signed-off-by: yronglin 
---
 clang/include/clang/AST/ExprCXX.h | 33 +++
 clang/include/clang/AST/Stmt.h| 14 -
 clang/lib/AST/ASTImporter.cpp |  7 ++-
 clang/lib/AST/ExprCXX.cpp | 44 ---
 clang/lib/AST/ParentMap.cpp   | 17 ++
 clang/lib/Analysis/CFG.cpp| 50 ++---
 clang/lib/Analysis/ReachableCode.cpp  | 35 ++--
 clang/lib/Sema/SemaExpr.cpp   |  9 ++-
 clang/lib/Sema/TreeTransform.h| 10 ++--
 clang/lib/Serialization/ASTReaderStmt.cpp |  8 ++-
 clang/lib/Serialization/ASTWriterStmt.cpp |  2 +
 clang/lib/StaticAnalyzer/Core/ExprEngine.cpp  | 56 +++
 .../Analysis/lifetime-extended-regions.cpp|  7 +--
 clang/test/SemaCXX/warn-unreachable.cpp   | 39 +
 14 files changed, 235 insertions(+), 96 deletions(-)

diff --git a/clang/include/clang/AST/ExprCXX.h 
b/clang/include/clang/AST/ExprCXX.h
index 4cec89c979f775..30915a14946403 100644
--- a/clang/include/clang/AST/ExprCXX.h
+++ b/clang/include/clang/AST/ExprCXX.h
@@ -1277,7 +1277,8 @@ class CXXDefaultArgExpr final
   DeclContext *UsedContext;
 
   CXXDefaultArgExpr(StmtClass SC, SourceLocation Loc, ParmVarDecl *Param,
-Expr *RewrittenExpr, DeclContext *UsedContext)
+DeclContext *UsedContext, Expr *RewrittenExpr,
+bool HasRebuiltInit)
   : Expr(SC,
  Param->hasUnparsedDefaultArg()
  ? Param->getType().getNonReferenceType()
@@ -1287,25 +1288,28 @@ class CXXDefaultArgExpr final
 Param(Param), UsedContext(UsedContext) {
 CXXDefaultArgExprBits.Loc = Loc;
 CXXDefaultArgExprBits.HasRewrittenInit = RewrittenExpr != nullptr;
+CXXDefaultArgExprBits.HasRebuiltInit = HasRebuiltInit;
 if (RewrittenExpr)
   *getTrailingObjects() = RewrittenExpr;
 setDependence(computeDependence(this));
   }
 
-  CXXDefaultArgExpr(EmptyShell Empty, bool HasRewrittenInit)
+  CXXDefaultArgExpr(EmptyShell Empty, bool HasRewrittenInit,
+bool HasRebuiltInit)
   : Expr(CXXDefaultArgExprClass, Empty) {
 CXXDefaultArgExprBits.HasRewrittenInit = HasRewrittenInit;
+CXXDefaultArgExprBits.HasRebuiltInit = HasRebuiltInit;
   }
 
 public:
-  static CXXDefaultArgExpr *CreateEmpty(const ASTContext &C,
-bool HasRewrittenInit);
+  static CXXDefaultArgExpr *
+  CreateEmpty(const ASTContext &C, bool HasRewrittenInit, bool HasRebuiltInit);
 
   // \p Param is the parameter whose default argument is used by this
   // expression.
   static CXXDefaultArgExpr *Create(const ASTContext &C, SourceLocation Loc,
-   ParmVarDecl *Param, Expr *RewrittenExpr,
-   DeclContext *UsedContext);
+   ParmVarDecl *Param, DeclContext 
*UsedContext,
+   Expr *RewrittenExpr, bool HasRebuiltInit);
   // Retrieve the parameter that the argument was created from.
   const ParmVarDecl *getParam() const { return Param; }
   ParmVarDecl *getParam() { return Param; }
@@ -1314,6 +1318,8 @@ class CXXDefaultArgExpr final
 return CXXDefaultArgExprBits.HasRewrittenInit;
   }
 
+  bool hasRebuiltInit() const { return CXXDefaultArgExprBits.HasRebuiltInit; }
+
   // Retrieve the argument to the function call.
   Expr *getExpr();
   const Expr *getExpr() const {
@@ -1385,26 +1391,31 @@ class CXXDefaultInitExpr final
 
   CXXDefaultInitExpr(const ASTContext &Ctx, SourceLocation Loc,
  FieldDecl *Field, QualType Ty, DeclContext *UsedContext,
- Expr *RewrittenInitExpr);
+ Expr *RewrittenInitExpr, bool HasRebuiltInit);
 
-  CXXDefaultInitExpr(EmptyShell Empty, bool HasRewrittenInit)
+  CXXDefaultInitExpr(EmptyShell Empty, bool HasRewrittenInit,
+ bool HasRebuiltInit)
   : Expr(CXXDefaultInitExprClass, Empty) {
 CXXDefaultInitExprBits.HasRewrittenInit = HasRewrittenInit;
+CXXDefaultInitExprBits.HasRebuiltInit = HasRebuiltInit;
   }
 
 public:
-  static CXXDefaultInitExpr *CreateEmpty(const ASTContext &C,
- bool HasRewrittenInit);
+  static CXXDefaultInitExpr *
+  CreateEmpty(const ASTContext &C, bool HasRewrittenInit, bool HasRebuiltInit);
   /// \p Field is the non-static data member whose default initializer is used
   /// by this expression.
   static CXXDefaultInitExpr *Create(const ASTContext &Ctx, SourceLocation Loc,
 FieldDecl 

[clang] [Analyzer][CFG] Correctly handle rebuilt default arg and default init expression (PR #117437)

2024-12-29 Thread via cfe-commits


@@ -850,11 +854,17 @@ class alignas(void *) Stmt {
 LLVM_PREFERRED_TYPE(ExprBitfields)
 unsigned : NumExprBits;
 
-/// Whether this CXXDefaultInitExprBitfields rewrote its argument and 
stores
-/// a copy.
+/// Whether this CXXDefaultInitExpr rewrote its argument and stores
+/// a copy, unlike HasRebuiltInit, when this flag is true, the argument may
+/// be partial rebuilt.

yronglin wrote:

Fixed

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


[clang] [llvm] [ARM] Save floating point registers and status registers with save_fp function attribute (PR #89654)

2024-12-29 Thread Benson Chu via cfe-commits

https://github.com/pestctrl updated 
https://github.com/llvm/llvm-project/pull/89654

>From a935c458c71fc8186f52d6eeea220ee142cf1d6d Mon Sep 17 00:00:00 2001
From: Jake Vossen 
Date: Wed, 30 Jun 2021 15:13:13 -0500
Subject: [PATCH 1/4] [ARM] Save floating point registers with save_fp function
 attribute

[ARM] and interrupt_save_fp attribute

interupt_save_fp update name; fix bugs

[ARM] fix typos and register class name

used better push / pop instructions

change epilog emitting order

WIP with FPSCR

save just d regs

cleaned up docs and ARMRegisterInfo td

change m3 to m4

fix reg tests

Minor format changes on top of Jake Vossen's support for
interrupt_save_fp function attribute which preserves VFP D
registers at the moment. FPSCR and FPEXC registers to follow.
---
 clang/include/clang/Basic/Attr.td |  16 ++
 clang/include/clang/Basic/AttrDocs.td |  14 ++
 .../clang/Basic/DiagnosticSemaKinds.td|   8 +-
 clang/include/clang/Sema/SemaARM.h|   1 +
 clang/lib/CodeGen/Targets/ARM.cpp |   6 +
 clang/lib/Sema/SemaARM.cpp|  31 +++-
 clang/lib/Sema/SemaDeclAttr.cpp   |   3 +
 .../test/CodeGen/arm-interrupt-save-fp-attr.c |  39 
 clang/test/Sema/arm-interrupt-attr.c  |   2 +-
 clang/test/Sema/arm-interrupt-save-fp-attr.c  |  26 +++
 llvm/lib/Target/ARM/ARMBaseRegisterInfo.cpp   |  34 +++-
 llvm/lib/Target/ARM/ARMCallingConv.td |  28 +++
 .../CodeGen/ARM/interrupt-save-fp-attr.ll | 171 ++
 13 files changed, 369 insertions(+), 10 deletions(-)
 create mode 100644 clang/test/CodeGen/arm-interrupt-save-fp-attr.c
 create mode 100644 clang/test/Sema/arm-interrupt-save-fp-attr.c
 create mode 100644 llvm/test/CodeGen/ARM/interrupt-save-fp-attr.ll

diff --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 52ad72eb608c319..ae773086a1674f3 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -984,6 +984,22 @@ def ARMInterrupt : InheritableAttr, 
TargetSpecificAttr {
   let Documentation = [ARMInterruptDocs];
 }
 
+def ARMInterruptSaveFP : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [GNU<"interrupt_save_fp">];
+  let Args = [EnumArgument<"Interrupt", "InterruptType", /*is_string=*/true,
+   ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", ""],
+   ["IRQ", "FIQ", "SWI", "ABORT", "UNDEF", "Generic"],
+   1>];
+  let HasCustomParsing = 0;
+  let Documentation = [ARMInterruptSaveFPDocs];
+}
+
+def ARMSaveFP : InheritableAttr, TargetSpecificAttr {
+  let Spellings = [];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [InternalOnly];
+}
+
 def AVRInterrupt : InheritableAttr, TargetSpecificAttr {
   let Spellings = [GCC<"interrupt">];
   let Subjects = SubjectList<[Function]>;
diff --git a/clang/include/clang/Basic/AttrDocs.td 
b/clang/include/clang/Basic/AttrDocs.td
index fdad4c9a3ea1910..fe265402895bc36 100644
--- a/clang/include/clang/Basic/AttrDocs.td
+++ b/clang/include/clang/Basic/AttrDocs.td
@@ -2484,6 +2484,20 @@ The semantics are as follows:
   }];
 }
 
+def ARMInterruptSaveFPDocs : Documentation {
+let Category = DocCatFunction;
+  let Heading = "interrupt_save_fp (ARM)";
+  let Content = [{
+Clang supports the GNU style ``__attribute__((interrupt_save_fp("TYPE")))``
+on ARM targets. This attribute behaves the same way as the ARM interrupt
+attribute, except the general purpose floating point registers are also saved. 
+If the FPEXC or FPSCR are needed, that state must be saved manually. Note, 
even 
+on M-class CPUs, where the floating point context can be automatically saved 
+depending on the FPCCR, the general purpose floating point registers will be 
+saved.
+  }];
+}
+
 def BPFPreserveAccessIndexDocs : Documentation {
   let Category = DocCatFunction;
   let Content = [{
diff --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 330ae045616abaf..58a932ca6f13314 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -346,8 +346,14 @@ def warn_anyx86_excessive_regsave : Warning<
   InGroup>;
 def warn_arm_interrupt_vfp_clobber : Warning<
   "interrupt service routine with vfp enabled may clobber the "
-  "interruptee's vfp state">,
+  "interruptee's vfp state; "
+  "consider using the `interrupt_save_fp` attribute to prevent this behavior">,
   InGroup>;
+def warn_arm_interrupt_save_fp_without_vfp_unit : Warning<
+   "`interrupt_save_fp` only applies to targets that have a VFP unit enabled "
+   "for this compilation; this will be treated as a regular `interrupt` "
+   "attribute">,
+   InGroup>;
 def err_arm_interrupt_called : Error<
   "interrupt service routine cannot be called directly">;
 def warn_interrupt_attribute_invalid : Warning<
diff --git a/clang/include/clang/Sema/SemaARM.h 
b/clang/include/cl

[clang] [Clang] Diagnose unexpanded packs for NTTP type constraints (PR #121296)

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

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

Otherwise, the invalid unexpanded type would be passed to getAutoType and lead 
to a crash.

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

>From 102e031cae56c130f48f08bcb316b6f451facf49 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 29 Dec 2024 23:13:52 +0800
Subject: [PATCH] [Clang] Diagnose unexpanded packs for NTTP type constraints

---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/lib/Sema/SemaTemplate.cpp | 12 +--
 clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 43 +
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b984ecaefecaf..78ae4c8cab3a9e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -885,6 +885,7 @@ Bug Fixes to C++ Support
 - Fixed recognition of ``std::initializer_list`` when it's surrounded with 
``extern "C++"`` and exported
   out of a module (which is the case e.g. in MSVC's implementation of ``std`` 
module). (#GH118218)
 - Fixed a pack expansion issue in checking unexpanded parameter sizes. 
(#GH17042)
+- Clang now identifies unexpanded parameter packs within the type constraint 
on a non-type template parameter. (#GH88866)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 5e7a3c8484c88f..eac184d468ce9a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1530,9 +1530,17 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, 
Declarator &D,
   Param->setAccess(AS_public);
 
   if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc())
-if (TL.isConstrained())
-  if (AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
+if (TL.isConstrained()) {
+  if (const ASTTemplateArgumentListInfo *ArgumentList =
+  TL.getConceptReference()->getTemplateArgsAsWritten())
+for (const TemplateArgumentLoc &Loc : ArgumentList->arguments()) {
+  Invalid |= DiagnoseUnexpandedParameterPack(
+  Loc, UnexpandedParameterPackContext::UPPC_TypeConstraint);
+}
+  if (!Invalid &&
+  AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
 Invalid = true;
+}
 
   if (Invalid)
 Param->setInvalidDecl();
diff --git a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp 
b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
index 0674135aac483f..00236a8a839135 100644
--- a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
+++ b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
@@ -305,3 +305,46 @@ 
static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like,
 0>::type, long));
 
 }
+
+namespace GH88866 {
+
+template  struct index_by;
+
+template 
+concept InitFunc = true;
+
+namespace Invalid {
+
+template  auto... init>
+struct LazyLitMatrix;
+
+template <
+typename...Indices,
+InitFunc> auto... init
+// expected-error@-1 {{type constraint contains unexpanded parameter pack 
'Indices'}}
+>
+struct LazyLitMatrix, init...> {
+};
+
+static_assert(
+!__is_same(LazyLitMatrix, 42, 43>, 
LazyLitMatrix, 42, 43>));
+// expected-error@-1 {{static assertion failed}}
+}
+
+namespace Valid {
+
+template  auto... init>
+struct LazyLitMatrix;
+
+template <
+typename...Indices,
+InitFunc> auto... init
+>
+struct LazyLitMatrix, init...> {
+};
+
+static_assert(__is_same(LazyLitMatrix, 42, 43>, 
+LazyLitMatrix, 42, 43>));
+}
+
+}

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


[clang] [Clang] Diagnose unexpanded packs for NTTP type constraints (PR #121296)

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

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

>From 102e031cae56c130f48f08bcb316b6f451facf49 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 29 Dec 2024 23:13:52 +0800
Subject: [PATCH] [Clang] Diagnose unexpanded packs for NTTP type constraints

---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/lib/Sema/SemaTemplate.cpp | 12 +--
 clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 43 +
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b984ecaefecaf..78ae4c8cab3a9e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -885,6 +885,7 @@ Bug Fixes to C++ Support
 - Fixed recognition of ``std::initializer_list`` when it's surrounded with 
``extern "C++"`` and exported
   out of a module (which is the case e.g. in MSVC's implementation of ``std`` 
module). (#GH118218)
 - Fixed a pack expansion issue in checking unexpanded parameter sizes. 
(#GH17042)
+- Clang now identifies unexpanded parameter packs within the type constraint 
on a non-type template parameter. (#GH88866)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 5e7a3c8484c88f..eac184d468ce9a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1530,9 +1530,17 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, 
Declarator &D,
   Param->setAccess(AS_public);
 
   if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc())
-if (TL.isConstrained())
-  if (AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
+if (TL.isConstrained()) {
+  if (const ASTTemplateArgumentListInfo *ArgumentList =
+  TL.getConceptReference()->getTemplateArgsAsWritten())
+for (const TemplateArgumentLoc &Loc : ArgumentList->arguments()) {
+  Invalid |= DiagnoseUnexpandedParameterPack(
+  Loc, UnexpandedParameterPackContext::UPPC_TypeConstraint);
+}
+  if (!Invalid &&
+  AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
 Invalid = true;
+}
 
   if (Invalid)
 Param->setInvalidDecl();
diff --git a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp 
b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
index 0674135aac483f..00236a8a839135 100644
--- a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
+++ b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
@@ -305,3 +305,46 @@ 
static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like,
 0>::type, long));
 
 }
+
+namespace GH88866 {
+
+template  struct index_by;
+
+template 
+concept InitFunc = true;
+
+namespace Invalid {
+
+template  auto... init>
+struct LazyLitMatrix;
+
+template <
+typename...Indices,
+InitFunc> auto... init
+// expected-error@-1 {{type constraint contains unexpanded parameter pack 
'Indices'}}
+>
+struct LazyLitMatrix, init...> {
+};
+
+static_assert(
+!__is_same(LazyLitMatrix, 42, 43>, 
LazyLitMatrix, 42, 43>));
+// expected-error@-1 {{static assertion failed}}
+}
+
+namespace Valid {
+
+template  auto... init>
+struct LazyLitMatrix;
+
+template <
+typename...Indices,
+InitFunc> auto... init
+>
+struct LazyLitMatrix, init...> {
+};
+
+static_assert(__is_same(LazyLitMatrix, 42, 43>, 
+LazyLitMatrix, 42, 43>));
+}
+
+}

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


[clang] [Clang] Diagnose unexpanded packs for NTTP type constraints (PR #121296)

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

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

>From 102e031cae56c130f48f08bcb316b6f451facf49 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 29 Dec 2024 23:13:52 +0800
Subject: [PATCH 1/2] [Clang] Diagnose unexpanded packs for NTTP type
 constraints

---
 clang/docs/ReleaseNotes.rst |  1 +
 clang/lib/Sema/SemaTemplate.cpp | 12 +--
 clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 43 +
 3 files changed, 54 insertions(+), 2 deletions(-)

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8b984ecaefecaf..78ae4c8cab3a9e 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -885,6 +885,7 @@ Bug Fixes to C++ Support
 - Fixed recognition of ``std::initializer_list`` when it's surrounded with 
``extern "C++"`` and exported
   out of a module (which is the case e.g. in MSVC's implementation of ``std`` 
module). (#GH118218)
 - Fixed a pack expansion issue in checking unexpanded parameter sizes. 
(#GH17042)
+- Clang now identifies unexpanded parameter packs within the type constraint 
on a non-type template parameter. (#GH88866)
 
 Bug Fixes to AST Handling
 ^
diff --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 5e7a3c8484c88f..eac184d468ce9a 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -1530,9 +1530,17 @@ NamedDecl *Sema::ActOnNonTypeTemplateParameter(Scope *S, 
Declarator &D,
   Param->setAccess(AS_public);
 
   if (AutoTypeLoc TL = TInfo->getTypeLoc().getContainedAutoTypeLoc())
-if (TL.isConstrained())
-  if (AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
+if (TL.isConstrained()) {
+  if (const ASTTemplateArgumentListInfo *ArgumentList =
+  TL.getConceptReference()->getTemplateArgsAsWritten())
+for (const TemplateArgumentLoc &Loc : ArgumentList->arguments()) {
+  Invalid |= DiagnoseUnexpandedParameterPack(
+  Loc, UnexpandedParameterPackContext::UPPC_TypeConstraint);
+}
+  if (!Invalid &&
+  AttachTypeConstraint(TL, Param, Param, D.getEllipsisLoc()))
 Invalid = true;
+}
 
   if (Invalid)
 Param->setInvalidDecl();
diff --git a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp 
b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
index 0674135aac483f..00236a8a839135 100644
--- a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
+++ b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
@@ -305,3 +305,46 @@ 
static_assert(__is_same_as(_Three_way_comparison_result_with_tuple_like,
 0>::type, long));
 
 }
+
+namespace GH88866 {
+
+template  struct index_by;
+
+template 
+concept InitFunc = true;
+
+namespace Invalid {
+
+template  auto... init>
+struct LazyLitMatrix;
+
+template <
+typename...Indices,
+InitFunc> auto... init
+// expected-error@-1 {{type constraint contains unexpanded parameter pack 
'Indices'}}
+>
+struct LazyLitMatrix, init...> {
+};
+
+static_assert(
+!__is_same(LazyLitMatrix, 42, 43>, 
LazyLitMatrix, 42, 43>));
+// expected-error@-1 {{static assertion failed}}
+}
+
+namespace Valid {
+
+template  auto... init>
+struct LazyLitMatrix;
+
+template <
+typename...Indices,
+InitFunc> auto... init
+>
+struct LazyLitMatrix, init...> {
+};
+
+static_assert(__is_same(LazyLitMatrix, 42, 43>, 
+LazyLitMatrix, 42, 43>));
+}
+
+}

>From 111d1002e081322fdb5f3fa8e94b15b99817b3b9 Mon Sep 17 00:00:00 2001
From: Younan Zhang 
Date: Sun, 29 Dec 2024 23:30:57 +0800
Subject: [PATCH 2/2] Simplify the test

---
 clang/test/SemaCXX/cxx2c-fold-exprs.cpp | 9 -
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp 
b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
index 00236a8a839135..509922c0a8f4fe 100644
--- a/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
+++ b/clang/test/SemaCXX/cxx2c-fold-exprs.cpp
@@ -326,9 +326,8 @@ template <
 struct LazyLitMatrix, init...> {
 };
 
-static_assert(
-!__is_same(LazyLitMatrix, 42, 43>, 
LazyLitMatrix, 42, 43>));
-// expected-error@-1 {{static assertion failed}}
+using T = LazyLitMatrix, 42, 43>;
+
 }
 
 namespace Valid {
@@ -343,8 +342,8 @@ template <
 struct LazyLitMatrix, init...> {
 };
 
-static_assert(__is_same(LazyLitMatrix, 42, 43>, 
-LazyLitMatrix, 42, 43>));
+using T = LazyLitMatrix, 42, 43>;
+
 }
 
 }

___
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 bugprone-reset-call check (PR #121291)

2024-12-29 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor edited 
https://github.com/llvm/llvm-project/pull/121291
___
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 bugprone-reset-call check (PR #121291)

2024-12-29 Thread via cfe-commits


@@ -0,0 +1,33 @@
+.. title:: clang-tidy - bugprone-reset-call
+
+bugprone-reset-call
+===
+
+Finds calls to ``reset()`` method on smart pointers where the pointee type

EugeneZelenko wrote:

Please make this statement same as statement in Release Notes.

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


[clang] [Clang][Sema] Expose static inline functions from GMF (PR #104701)

2024-12-29 Thread Jan Kokemüller via cfe-commits

https://github.com/jiixyj updated 
https://github.com/llvm/llvm-project/pull/104701

From feaf6512fc6323ad0c3d5082c06e610504f0a527 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jan=20Kokem=C3=BCller?= 
Date: Sun, 18 Aug 2024 13:45:43 +0200
Subject: [PATCH 1/5] Expose static inline function from GMF

They should be exposed even when two-phase name lookup and ADL are
involved.
---
 clang/lib/Sema/SemaOverload.cpp   | 23 +--
 .../expose-static-inline-from-gmf-1.cppm  | 37 +
 .../expose-static-inline-from-gmf-2.cppm  | 22 ++
 .../expose-static-inline-from-gmf-3.cppm  | 24 +++
 .../expose-static-inline-from-gmf-4.cppm  | 40 +++
 .../expose-static-inline-from-gmf-5.cppm  | 26 
 6 files changed, 168 insertions(+), 4 deletions(-)
 create mode 100644 clang/test/Modules/expose-static-inline-from-gmf-1.cppm
 create mode 100644 clang/test/Modules/expose-static-inline-from-gmf-2.cppm
 create mode 100644 clang/test/Modules/expose-static-inline-from-gmf-3.cppm
 create mode 100644 clang/test/Modules/expose-static-inline-from-gmf-4.cppm
 create mode 100644 clang/test/Modules/expose-static-inline-from-gmf-5.cppm

diff --git a/clang/lib/Sema/SemaOverload.cpp b/clang/lib/Sema/SemaOverload.cpp
index 52f640eb96b73b..ca070d0e22d472 100644
--- a/clang/lib/Sema/SemaOverload.cpp
+++ b/clang/lib/Sema/SemaOverload.cpp
@@ -6926,11 +6926,26 @@ void Sema::AddOverloadCandidate(
 /// have linkage. So that all entities of the same should share one
 /// linkage. But in clang, different entities of the same could have
 /// different linkage.
-NamedDecl *ND = Function;
-if (auto *SpecInfo = Function->getTemplateSpecializationInfo())
+const NamedDecl *ND = Function;
+bool IsImplicitlyInstantiated = false;
+if (auto *SpecInfo = Function->getTemplateSpecializationInfo()) {
   ND = SpecInfo->getTemplate();
-
-if (ND->getFormalLinkage() == Linkage::Internal) {
+  IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
+ TSK_ImplicitInstantiation;
+}
+
+/// Don't remove inline functions with internal linkage from the overload
+/// set if they are declared in a GMF.
+/// The global module is meant to be a transition mechanism for C and C++
+/// headers.
+/// Inline functions with internal linkage are a common pattern in headers
+/// to avoid ODR issues.
+const bool IsInlineFunctionInGMF =
+  Function->getOwningModule() &&
+  Function->getOwningModule()->isGlobalModule() &&
+  (IsImplicitlyInstantiated || Function->isInlined());
+
+if (ND->getFormalLinkage() == Linkage::Internal && !IsInlineFunctionInGMF) 
{
   Candidate.Viable = false;
   Candidate.FailureKind = ovl_fail_module_mismatched;
   return;
diff --git a/clang/test/Modules/expose-static-inline-from-gmf-1.cppm 
b/clang/test/Modules/expose-static-inline-from-gmf-1.cppm
new file mode 100644
index 00..4de9b583dac8da
--- /dev/null
+++ b/clang/test/Modules/expose-static-inline-from-gmf-1.cppm
@@ -0,0 +1,37 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm \
+// RUN:   -DTEST_INLINE
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only 
-Xclang -verify \
+// RUN:   -DTEST_INLINE
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only 
-Xclang -verify
+
+//--- a.h
+#ifdef TEST_INLINE
+#define INLINE inline
+#else
+#define INLINE
+#endif
+static INLINE void func(long) {}
+template  void a() { func(T{}); }
+
+//--- a.cppm
+module;
+#include "a.h"
+export module a;
+export using ::a;
+
+//--- test.cc
+import a;
+auto m = (a(), 0);
+
+#ifdef TEST_INLINE
+// expected-no-diagnostics
+#else
+// expected-error@a.h:7 {{no matching function for call to 'func'}}
+// expected-n...@test.cc:2 {{in instantiation of function template 
specialization 'a' requested here}}
+#endif
diff --git a/clang/test/Modules/expose-static-inline-from-gmf-2.cppm 
b/clang/test/Modules/expose-static-inline-from-gmf-2.cppm
new file mode 100644
index 00..c89b613f5074b1
--- /dev/null
+++ b/clang/test/Modules/expose-static-inline-from-gmf-2.cppm
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang -std=c++20 %t/a.cppm --precompile -o %t/a.pcm
+// RUN: %clang -std=c++20 %t/test.cc -fprebuilt-module-path=%t -fsyntax-only 
-Xclang -verify
+
+//--- a.h
+template  static inline void func() {}
+template  void a() { func(); }
+
+//--- a.cppm
+module;
+#include "a.h"
+export module a;
+export using ::a;
+
+//--- test.cc
+import a;
+auto m = (a(), 0);
+
+// expected-no-diagnostics
diff --git a/clang/test/Modules/expose-static-inline-from-gmf-3.cppm 
b/clang/test/Modules/expose-static-inline-from-gmf-3.cppm
new file mode 1006

[clang-tools-extra] [clang-tidy] Add bugprone-reset-call check (PR #121291)

2024-12-29 Thread Baranov Victor via cfe-commits

https://github.com/vbvictor created 
https://github.com/llvm/llvm-project/pull/121291

Add new clang-tidy check that finds potentially erroneous calls to ``reset()`` 
method on smart pointers when
the pointee type also has a ``reset()`` method.

It's easy to make typo and delete object because the difference between ``.`` 
and ``->`` is really small.

Sometimes IDE's autocomplete will change ``->`` to ``.`` automatically. For 
example, developer wrote ``ptr->res`` but after _Tab_ it became ``ptr.reset()``.

Small example:
```cpp
struct Resettable {
  void reset() { /* Own reset logic */ }
};

auto ptr = std::make_unique();

ptr->reset();  // Calls underlying reset method
ptr.reset();   // Makes the pointer null

// After Fix-its
(*ptr).reset();  // Clearly calls underlying reset method
ptr = nullptr;   // Clearly makes the pointer null
```

>From 37dce6a7ed0cca2e9819c24f4d176c43e3c9f2ac Mon Sep 17 00:00:00 2001
From: Victor Baranov 
Date: Sun, 29 Dec 2024 15:32:22 +0300
Subject: [PATCH] [clang-tidy] Add bugprone-reset-call check

---
 .../bugprone/BugproneTidyModule.cpp   |   2 +
 .../clang-tidy/bugprone/CMakeLists.txt|   1 +
 .../clang-tidy/bugprone/ResetCallCheck.cpp| 133 +++
 .../clang-tidy/bugprone/ResetCallCheck.h  |  34 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |   6 +
 .../clang-tidy/checks/bugprone/reset-call.rst |  33 +++
 .../docs/clang-tidy/checks/list.rst   |   1 +
 .../checkers/bugprone/reset-call.cpp  | 215 ++
 8 files changed, 425 insertions(+)
 create mode 100644 clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp
 create mode 100644 clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.h
 create mode 100644 
clang-tools-extra/docs/clang-tidy/checks/bugprone/reset-call.rst
 create mode 100644 
clang-tools-extra/test/clang-tidy/checkers/bugprone/reset-call.cpp

diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 33ac65e715ce81..645958e47e22a5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -57,6 +57,7 @@
 #include "PosixReturnCheck.h"
 #include "RedundantBranchConditionCheck.h"
 #include "ReservedIdentifierCheck.h"
+#include "ResetCallCheck.h"
 #include "ReturnConstRefFromParameterCheck.h"
 #include "SharedPtrArrayMismatchCheck.h"
 #include "SignalHandlerCheck.h"
@@ -144,6 +145,7 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck("bugprone-reset-call");
 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 13adad7c3dadbd..17ab5b27ec5550 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -52,6 +52,7 @@ add_clang_library(clangTidyBugproneModule STATIC
   PosixReturnCheck.cpp
   RedundantBranchConditionCheck.cpp
   ReservedIdentifierCheck.cpp
+  ResetCallCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SharedPtrArrayMismatchCheck.cpp
   SignalHandlerCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp
new file mode 100644
index 00..305ac8d51adf3e
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp
@@ -0,0 +1,133 @@
+//===--- ResetCallCheck.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 "ResetCallCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+
+AST_MATCHER_P(CallExpr, everyArgumentMatches,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  if (Node.getNumArgs() == 0)
+return true;
+
+  for (const auto *Arg : Node.arguments()) {
+if (!InnerMatcher.matches(*Arg, Finder, Builder))
+  return false;
+  }
+  return true;
+}
+
+AST_MATCHER(CXXMethodDecl, hasOnlyDefaultArgs) {
+  if (Node.param_empty())
+return true;
+
+  for (const auto *Param : Node.parameters()) {
+if (!Param->hasDefaultArg())
+  return false;
+  }
+  return true;
+}
+
+} // namespace
+
+void ResetCallCheck::registerMatchers(MatchFinder *Finder) {
+  const auto IsSmartptr 

[clang-tools-extra] [clang-tidy] Add bugprone-reset-call check (PR #121291)

2024-12-29 Thread via cfe-commits

github-actions[bot] wrote:



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

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

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

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

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

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

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

https://github.com/llvm/llvm-project/pull/121291
___
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 bugprone-reset-call check (PR #121291)

2024-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Baranov Victor (vbvictor)


Changes

Add new clang-tidy check that finds potentially erroneous calls to ``reset()`` 
method on smart pointers when
the pointee type also has a ``reset()`` method.

It's easy to make typo and delete object because the difference between ``.`` 
and ``->`` is really small.

Sometimes IDE's autocomplete will change ``->`` to ``.`` automatically. For 
example, developer wrote ``ptr->res`` but after _Tab_ it became 
``ptr.reset()``.

Small example:
```cpp
struct Resettable {
  void reset() { /* Own reset logic */ }
};

auto ptr = std::make_unique();

ptr->reset();  // Calls underlying reset method
ptr.reset();   // Makes the pointer null

// After Fix-its
(*ptr).reset();  // Clearly calls underlying reset method
ptr = nullptr;   // Clearly makes the pointer null
```

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


8 Files Affected:

- (modified) clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp (+2) 
- (modified) clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt (+1) 
- (added) clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp (+133) 
- (added) clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.h (+34) 
- (modified) clang-tools-extra/docs/ReleaseNotes.rst (+6) 
- (added) clang-tools-extra/docs/clang-tidy/checks/bugprone/reset-call.rst 
(+33) 
- (modified) clang-tools-extra/docs/clang-tidy/checks/list.rst (+1) 
- (added) clang-tools-extra/test/clang-tidy/checkers/bugprone/reset-call.cpp 
(+215) 


``diff
diff --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 33ac65e715ce81..645958e47e22a5 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -57,6 +57,7 @@
 #include "PosixReturnCheck.h"
 #include "RedundantBranchConditionCheck.h"
 #include "ReservedIdentifierCheck.h"
+#include "ResetCallCheck.h"
 #include "ReturnConstRefFromParameterCheck.h"
 #include "SharedPtrArrayMismatchCheck.h"
 #include "SignalHandlerCheck.h"
@@ -144,6 +145,7 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-inaccurate-erase");
 CheckFactories.registerCheck(
 "bugprone-incorrect-enable-if");
+CheckFactories.registerCheck("bugprone-reset-call");
 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 13adad7c3dadbd..17ab5b27ec5550 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -52,6 +52,7 @@ add_clang_library(clangTidyBugproneModule STATIC
   PosixReturnCheck.cpp
   RedundantBranchConditionCheck.cpp
   ReservedIdentifierCheck.cpp
+  ResetCallCheck.cpp
   ReturnConstRefFromParameterCheck.cpp
   SharedPtrArrayMismatchCheck.cpp
   SignalHandlerCheck.cpp
diff --git a/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp 
b/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp
new file mode 100644
index 00..305ac8d51adf3e
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/bugprone/ResetCallCheck.cpp
@@ -0,0 +1,133 @@
+//===--- ResetCallCheck.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 "ResetCallCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Lex/Lexer.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang::tidy::bugprone {
+
+namespace {
+
+AST_MATCHER_P(CallExpr, everyArgumentMatches,
+  ast_matchers::internal::Matcher, InnerMatcher) {
+  if (Node.getNumArgs() == 0)
+return true;
+
+  for (const auto *Arg : Node.arguments()) {
+if (!InnerMatcher.matches(*Arg, Finder, Builder))
+  return false;
+  }
+  return true;
+}
+
+AST_MATCHER(CXXMethodDecl, hasOnlyDefaultArgs) {
+  if (Node.param_empty())
+return true;
+
+  for (const auto *Param : Node.parameters()) {
+if (!Param->hasDefaultArg())
+  return false;
+  }
+  return true;
+}
+
+} // namespace
+
+void ResetCallCheck::registerMatchers(MatchFinder *Finder) {
+  const auto IsSmartptr = hasAnyName("::std::unique_ptr", "::std::shared_ptr");
+
+  const auto ResetMethod =
+  cxxMethodDecl(hasName("reset"), hasOnlyDefaultArgs());
+
+  const auto TypeWithReset =
+  anyOf(cxxRecordDecl(hasMethod(ResetMethod)),
+classTemplateSpecializationDecl(
+has

[clang-tools-extra] [clang-tidy] Add bugprone-reset-call check (PR #121291)

2024-12-29 Thread Baranov Victor via cfe-commits

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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcicli (Conditional Load Immediate) extension (PR #121292)

2024-12-29 Thread Sudharsan Veeravalli via cfe-commits

https://github.com/svs-quic created 
https://github.com/llvm/llvm-project/pull/121292

This extension adds 12 instructions that conditionally load an immediate value.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

>From 44b470c5798d5e160b1d3159a936b5e1737482b3 Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Sun, 29 Dec 2024 18:28:52 +0530
Subject: [PATCH] [RISCV] Add Qualcomm uC Xqcicli (Conditional Load Immediate)
 extension

This extension adds 12 instructions that conditionally load an immediate value.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.
---
 .../Driver/print-supported-extensions-riscv.c |   1 +
 llvm/docs/RISCVUsage.rst  |   3 +
 llvm/docs/ReleaseNotes.md |   2 +
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |   3 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|   8 +
 llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td   |  28 +++
 llvm/lib/TargetParser/RISCVISAInfo.cpp|   3 +-
 llvm/test/CodeGen/RISCV/attributes.ll |   2 +
 llvm/test/MC/RISCV/xqcicli-invalid.s  | 232 ++
 llvm/test/MC/RISCV/xqcicli-valid.s|  59 +
 .../TargetParser/RISCVISAInfoTest.cpp |   4 +-
 11 files changed, 343 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/MC/RISCV/xqcicli-invalid.s
 create mode 100644 llvm/test/MC/RISCV/xqcicli-valid.s

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 8e46690cce5a63..395501eb85ccc3 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -190,6 +190,7 @@
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqcia0.2   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
 // CHECK-NEXT: xqciac   0.2   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
+// CHECK-NEXT: xqcicli  0.2   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
 // CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
 // CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 22600f5720553e..eaaad6c5168189 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -432,6 +432,9 @@ The current vendor extensions supported are:
 ``experimental-Xqciac``
   LLVM implements `version 0.2 of the Qualcomm uC Load-Store Address 
Calculation extension specification 
`__ by Qualcomm.  All 
instructions are prefixed with `qc.` as described in the specification. These 
instructions are only available for riscv32.
 
+``experimental-Xqcicli``
+  LLVM implements `version 0.2 of the Qualcomm uC Conditional Load Immediate 
extension specification 
`__ by Qualcomm.  All 
instructions are prefixed with `qc.` as described in the specification. These 
instructions are only available for riscv32.
+
 ``experimental-Xqcics``
   LLVM implements `version 0.2 of the Qualcomm uC Conditional Select extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 99a93b0467602d..be62a7e8696b4c 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -230,6 +230,8 @@ Changes to the RISC-V Backend
   extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcilsm` (Load 
Store Multiple)
   extension.
+* Adds experimental assembler support for the Qualcomm uC 'Xqcicli` 
(Conditional Load Immediate)
+  extension.
 
 Changes to the WebAssembly Backend
 --
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index 57443d3f38e3cb..30122831767f61 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -695,6 +695,9 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst 
&MI, uint64_t &Size,
   TRY_TO_DECODE_FEATURE(
   RISCV::FeatureVendorXqciac, DecoderTableXqciac32,
   "Qualcomm uC Load-Store Address Calculation custom opcode table");
+  TRY_TO_DECODE_FEATURE(
+  RISCV::FeatureVendorXqcicli, Deco

[clang] [llvm] [RISCV] Add Qualcomm uC Xqcicli (Conditional Load Immediate) extension (PR #121292)

2024-12-29 Thread via cfe-commits

llvmbot wrote:



@llvm/pr-subscribers-mc

@llvm/pr-subscribers-clang-driver

Author: Sudharsan Veeravalli (svs-quic)


Changes

This extension adds 12 instructions that conditionally load an immediate value.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.

---

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


11 Files Affected:

- (modified) clang/test/Driver/print-supported-extensions-riscv.c (+1) 
- (modified) llvm/docs/RISCVUsage.rst (+3) 
- (modified) llvm/docs/ReleaseNotes.md (+2) 
- (modified) llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp (+3) 
- (modified) llvm/lib/Target/RISCV/RISCVFeatures.td (+8) 
- (modified) llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td (+28) 
- (modified) llvm/lib/TargetParser/RISCVISAInfo.cpp (+2-1) 
- (modified) llvm/test/CodeGen/RISCV/attributes.ll (+2) 
- (added) llvm/test/MC/RISCV/xqcicli-invalid.s (+232) 
- (added) llvm/test/MC/RISCV/xqcicli-valid.s (+59) 
- (modified) llvm/unittests/TargetParser/RISCVISAInfoTest.cpp (+3-1) 


``diff
diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 8e46690cce5a63..395501eb85ccc3 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -190,6 +190,7 @@
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqcia0.2   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
 // CHECK-NEXT: xqciac   0.2   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
+// CHECK-NEXT: xqcicli  0.2   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
 // CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
 // CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 22600f5720553e..eaaad6c5168189 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -432,6 +432,9 @@ The current vendor extensions supported are:
 ``experimental-Xqciac``
   LLVM implements `version 0.2 of the Qualcomm uC Load-Store Address 
Calculation extension specification 
`__ by Qualcomm.  All 
instructions are prefixed with `qc.` as described in the specification. These 
instructions are only available for riscv32.
 
+``experimental-Xqcicli``
+  LLVM implements `version 0.2 of the Qualcomm uC Conditional Load Immediate 
extension specification 
`__ by Qualcomm.  All 
instructions are prefixed with `qc.` as described in the specification. These 
instructions are only available for riscv32.
+
 ``experimental-Xqcics``
   LLVM implements `version 0.2 of the Qualcomm uC Conditional Select extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 99a93b0467602d..be62a7e8696b4c 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -230,6 +230,8 @@ Changes to the RISC-V Backend
   extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcilsm` (Load 
Store Multiple)
   extension.
+* Adds experimental assembler support for the Qualcomm uC 'Xqcicli` 
(Conditional Load Immediate)
+  extension.
 
 Changes to the WebAssembly Backend
 --
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index 57443d3f38e3cb..30122831767f61 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -695,6 +695,9 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst 
&MI, uint64_t &Size,
   TRY_TO_DECODE_FEATURE(
   RISCV::FeatureVendorXqciac, DecoderTableXqciac32,
   "Qualcomm uC Load-Store Address Calculation custom opcode table");
+  TRY_TO_DECODE_FEATURE(
+  RISCV::FeatureVendorXqcicli, DecoderTableXqcicli32,
+  "Qualcomm uC Conditional Load Immediate custom opcode table");
   TRY_TO_DECODE(true, DecoderTable32, "RISCV32 table");
 
   return MCDisassembler::Fail;
diff --git a/llvm/lib/Target/RISCV/RISCVFeatures.td 
b/llvm/lib/Target/RISCV/RISCVFeatures.td
index 916b140c5bde75..3885b95a8937a8 100644
--- a/llvm/lib/Target/RISCV/RISCVFeatures.td
+++ b/llvm/lib/Targe

[clang-tools-extra] e45e091 - [clang-tidy] swap cppcoreguidelines-narrowing-conversions and bugprone-narrowing-conversions (#120245)

2024-12-29 Thread via cfe-commits

Author: Congcong Cai
Date: 2024-12-29T19:22:25+08:00
New Revision: e45e091b90896023584b303539bd8ae16d8932b3

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

LOG: [clang-tidy] swap cppcoreguidelines-narrowing-conversions and 
bugprone-narrowing-conversions (#120245)

According to #116591.
> Coding guidelines should "cherry-pick" (and posddsibly
configure/harden/make more strict) base checks.
We should move narrowing conversion to bugprone and keep alias in
cppcoreguidelines

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

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-bitfields.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-equivalentbitwidth-option.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-ignoreconversionfromtypes-option.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-intemplates-option.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-long-is-32bits.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-narrowingfloatingpoint-option.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-narrowinginteger-option.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-narrowingintegertofloatingpoint-option.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-pedanticmode-option.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions-unsigned-char.cpp

clang-tools-extra/test/clang-tidy/checkers/bugprone/narrowing-conversions.cpp

Modified: 
clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone/narrowing-conversions.rst

clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/narrowing-conversions.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.cpp
clang-tools-extra/clang-tidy/cppcoreguidelines/NarrowingConversionsCheck.h

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-bitfields.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-equivalentbitwidth-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-intemplates-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-long-is-32bits.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-narrowingfloatingpoint-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-narrowinginteger-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-narrowingintegertofloatingpoint-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-pedanticmode-option.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-unsigned-char.cpp

clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions.cpp



diff  --git a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp 
b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
index 33ac65e715ce81..b27616f3dcc658 100644
--- a/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
@@ -9,7 +9,6 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
-#include "../cppcoreguidelines/NarrowingConversionsCheck.h"
 #include "ArgumentCommentCheck.h"
 #include "AssertSideEffectCheck.h"
 #include "AssignmentInIfConditionCheck.h"
@@ -47,6 +46,7 @@
 #include "MultiLevelImplicitPointerConversionCheck.h"
 #include "MultipleNewInOneExpressionCheck.h"
 #include "MultipleStatementMacroCheck.h"
+#include "NarrowingConversionsCheck.h"
 #include "NoEscapeCheck.h"
 #include "NonZeroEnumToBoolConversionCheck.h"
 #include "NondeterministicPointerIterationOrderCheck.h"
@@ -183,7 +183,7 @@ class BugproneModule : public ClangTidyModule {
 "bugprone-pointer-

[clang-tools-extra] [clang-tidy] swap cppcoreguidelines-narrowing-conversions and bugprone-narrowing-conversions (PR #120245)

2024-12-29 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clang-tidy] swap cppcoreguidelines-narrowing-conversions and bugprone-narrowing-conversions (PR #120245)

2024-12-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-ppc64le-linux-multistage` running on `ppc64le-clang-multistage-test` 
while building `clang-tools-extra` at step 4 "build stage 1".

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


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

```
Step 4 (build stage 1) failure: 'ninja' (failure)
...
[5643/6211] Creating library symlink lib/libclangTidyReadabilityModule.so
[5644/6211] Linking CXX shared library lib/libclangTidyLLVMModule.so.20.0git
[5645/6211] Creating library symlink lib/libclangTidyLLVMModule.so
[5646/6211] Linking CXX shared library lib/libclangTidyGoogleModule.so.20.0git
[5647/6211] Creating library symlink lib/libclangTidyGoogleModule.so
[5648/6211] Linking CXX shared library lib/libclangTidyFuchsiaModule.so.20.0git
[5649/6211] Creating library symlink lib/libclangTidyFuchsiaModule.so
[5650/6211] Linking CXX shared library 
lib/libclangTidyModernizeModule.so.20.0git
[5651/6211] Creating library symlink lib/libclangTidyModernizeModule.so
[5652/6211] Linking CXX shared library 
lib/libclangTidyCppCoreGuidelinesModule.so.20.0git
FAILED: lib/libclangTidyCppCoreGuidelinesModule.so.20.0git 
: && /usr/lib64/ccache/c++ -fPIC -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-uninitialized -Wno-nonnull -Wno-class-memaccess -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wno-comment -Wno-misleading-indentation 
-fdiagnostics-color -ffunction-sections -fdata-sections -fno-common 
-Woverloaded-virtual -fno-strict-aliasing -O3 -DNDEBUG  -Wl,-z,defs 
-Wl,-z,nodelete   
-Wl,-rpath-link,/home/buildbots/llvm-external-buildbots/workers/ppc64le-clang-multistage-test/clang-ppc64le-multistage/stage1/./lib
  -Wl,--gc-sections -shared 
-Wl,-soname,libclangTidyCppCoreGuidelinesModule.so.20.0git -o 
lib/libclangTidyCppCoreGuidelinesModule.so.20.0git 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/AvoidCapturingLambdaCoroutinesCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/AvoidConstOrRefDataMembersCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/AvoidDoWhileCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/AvoidGotoCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/AvoidNonConstGlobalVariablesCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/AvoidReferenceCoroutineParametersCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/CppCoreGuidelinesTidyModule.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/InitVariablesCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/InterfacesGlobalInitCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/MacroUsageCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/MisleadingCaptureDefaultByValueCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/MissingStdForwardCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/NoMallocCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/NoSuspendWithLockCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/OwningMemoryCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/PreferMemberInitializerCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/ProBoundsArrayToPointerDecayCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/ProBoundsConstantArrayIndexCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/ProBoundsPointerArithmeticCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/ProTypeConstCastCheck.cpp.o
 
tools/clang/tools/extra/clang-tidy/cppcoreguidelines/CMakeFiles/obj.clangTidyCppCoreGuidelinesModule.dir/ProTypeCst

[clang-tools-extra] [clang-tidy] swap cppcoreguidelines-narrowing-conversions and bugprone-narrowing-conversions (PR #120245)

2024-12-29 Thread LLVM Continuous Integration via cfe-commits

llvm-ci wrote:

LLVM Buildbot has detected a new failure on builder 
`clang-cmake-x86_64-avx512-win` running on `avx512-intel64-win` while building 
`clang-tools-extra` at step 4 "cmake stage 1".

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


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

```
Step 4 (cmake stage 1) failure: 'cmake -G ...' (failure)
'cmake' is not recognized as an internal or external command,
operable program or batch file.

```



https://github.com/llvm/llvm-project/pull/120245
___
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 an option to exclude files not present in the compile database (PR #120348)

2024-12-29 Thread via cfe-commits

https://github.com/wonbinbk updated 
https://github.com/llvm/llvm-project/pull/120348

>From 062cecdcec24a807bd4bab5985a6ad339de3cfe6 Mon Sep 17 00:00:00 2001
From: wonbinbk 
Date: Wed, 18 Dec 2024 15:33:55 +1300
Subject: [PATCH 1/2] [clang-tidy] Add an option to exclude files not present
 in the compilation database

A change list may include files that are not part of the compilation
database, which can cause clang-tidy to fail (e.g., due to missing
included headers). To prevent false negatives, we should allow to skip
processing these files.
---
 .../clang-tidy/tool/clang-tidy-diff.py| 29 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 ++
 2 files changed, 32 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 62cb4297c50f75..a1d3598422bf24 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -35,6 +35,7 @@
 import tempfile
 import threading
 import traceback
+from pathlib import Path
 
 try:
 import yaml
@@ -124,6 +125,21 @@ def merge_replacement_files(tmpdir, mergefile):
 open(mergefile, "w").close()
 
 
+def get_compiling_files(args):
+""" Read a compile_commands.json database and return a set of file paths 
"""
+current_dir = Path.cwd()
+compile_commands_json = (current_dir / args.build_path) if args.build_path 
else current_dir
+compile_commands_json = (compile_commands_json / "compile_commands.json")
+files = set()
+with open(compile_commands_json) as db_file:
+db_json = json.load(db_file)
+for entry in db_json:
+if "file" not in entry:
+continue
+files.add(Path(entry["file"]))
+return files
+
+
 def main():
 parser = argparse.ArgumentParser(
 description="Run clang-tidy against changed files, and "
@@ -234,6 +250,13 @@ def main():
 action="store_true",
 help="Allow empty enabled checks.",
 )
+parser.add_argument(
+"-only-check-in-db",
+dest="skip_non_compiling",
+default=False,
+action="store_true",
+help="Only check files in the compilation database",
+)
 
 clang_tidy_args = []
 argv = sys.argv[1:]
@@ -243,6 +266,8 @@ def main():
 
 args = parser.parse_args(argv)
 
+compiling_files = get_compiling_files(args) if args.skip_non_compiling 
else None
+
 # Extract changed lines for each file.
 filename = None
 lines_by_file = {}
@@ -260,6 +285,10 @@ def main():
 if not re.match("^%s$" % args.iregex, filename, re.IGNORECASE):
 continue
 
+# Skip any files not in the compiling list
+if compiling_files is not None and (Path.cwd() / filename) not in 
compiling_files:
+continue
+
 match = re.search(r"^@@.*\+(\d+)(,(\d+))?", line)
 if match:
 start_line = int(match.group(1))
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index fabd0cc78ac645..dc2d5871148b35 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -115,6 +115,9 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Improved :program:`clang-tidy-diff.py` script. Add an option to exclude files
+  not present in the compilation database to avoid false negative results.
+
 - Improved :program:`clang-tidy` by accepting parameters file in command line.
 
 - Removed :program:`clang-tidy`'s global options for most of checks. All 
options

>From d95df90ab3ea7f8ec4280d6a7a35f3f2aa926f84 Mon Sep 17 00:00:00 2001
From: wonbinbk 
Date: Tue, 24 Dec 2024 09:54:05 +1300
Subject: [PATCH 2/2] [clang-tidy] Use raw string for regex pattern

---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index a1d3598422bf24..2cb1cc4598073b 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -272,7 +272,7 @@ def main():
 filename = None
 lines_by_file = {}
 for line in sys.stdin:
-match = re.search('^\\+\\+\\+\\ "?(.*?/){%s}([^ \t\n"]*)' % args.p, 
line)
+match = re.search(r'^\+\+\+\ "?(.*?/){%s}([^ \t\n"]*)' % args.p, line)
 if match:
 filename = match.group(2)
 if filename is None:

___
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 an option to exclude files not present in the compile database (PR #120348)

2024-12-29 Thread via cfe-commits

wonbinbk wrote:

Rebased.

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Amr Hesham via cfe-commits


@@ -2536,6 +2536,15 @@ Node Matchers
   matches "decltype(i + j)"
 
 
+MatcherStmt>dependentNameTypeMatcherDependentNameType>...

AmrDeveloper wrote:

Thank you, Done

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Amr Hesham via cfe-commits


@@ -1912,6 +1912,21 @@ TEST_P(ASTMatchersTest, 
DeducedTemplateSpecializationType) {
   deducedTemplateSpecializationType()));
 }
 
+TEST_P(ASTMatchersTest, DependentNameType) {
+  if (!GetParam().isCXX()) {
+// FIXME: Add a test for `dependentNameType()` that does not depend on C++.

AmrDeveloper wrote:

Done

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


[clang-tools-extra] b34ed25 - [clang-tidy][NFC] add link libs for bugprone module

2024-12-29 Thread Congcong Cai via cfe-commits

Author: Congcong Cai
Date: 2024-12-29T19:51:55+08:00
New Revision: b34ed25dd5c74abcb46872cbaab34b91e27a0bda

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

LOG: [clang-tidy][NFC] add link libs for bugprone module

Fixed bug issue introduced in #120245

Added: 


Modified: 
clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
index 73ab22381631c8..8bd5646c5fe05a 100644
--- a/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
@@ -96,7 +96,6 @@ add_clang_library(clangTidyBugproneModule STATIC
 
   LINK_LIBS
   clangTidy
-  clangTidyCppCoreGuidelinesModule
   clangTidyUtils
 
   DEPENDS

diff  --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
index 1f4107c0b35e70..b023f76a25432d 100644
--- a/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
@@ -37,6 +37,7 @@ add_clang_library(clangTidyCppCoreGuidelinesModule STATIC
 
   LINK_LIBS
   clangTidy
+  clangTidyBugproneModule
   clangTidyMiscModule
   clangTidyModernizeModule
   clangTidyPerformanceModule



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


[clang] [Clang][Sema] Expose static inline functions from GMF (PR #104701)

2024-12-29 Thread Jan Kokemüller via cfe-commits


@@ -6926,11 +6926,26 @@ void Sema::AddOverloadCandidate(
 /// have linkage. So that all entities of the same should share one
 /// linkage. But in clang, different entities of the same could have
 /// different linkage.
-NamedDecl *ND = Function;
-if (auto *SpecInfo = Function->getTemplateSpecializationInfo())
+const NamedDecl *ND = Function;
+bool IsImplicitlyInstantiated = false;
+if (auto *SpecInfo = Function->getTemplateSpecializationInfo()) {
   ND = SpecInfo->getTemplate();
-
-if (ND->getFormalLinkage() == Linkage::Internal) {
+  IsImplicitlyInstantiated = SpecInfo->getTemplateSpecializationKind() ==
+ TSK_ImplicitInstantiation;
+}
+
+/// Don't remove inline functions with internal linkage from the overload
+/// set if they are declared in a GMF.
+/// The global module is meant to be a transition mechanism for C and C++
+/// headers.
+/// Inline functions with internal linkage are a common pattern in headers
+/// to avoid ODR issues.

jiixyj wrote:

Sorry for the delay! I have now updated the comment to include the fact that 
this fix/workaround violates [basic.link]p17, strictly speaking. I've also 
merged the main branch. On my machine, the (new) tests in 
`./tools/clang/test/Modules` still pass. Does this work for you? Thanks again 
for the review!

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Amr Hesham via cfe-commits

https://github.com/AmrDeveloper updated 
https://github.com/llvm/llvm-project/pull/121263

>From bdbd11db849506c4d99036dd674f03d1eda815cc Mon Sep 17 00:00:00 2001
From: AmrDeveloper 
Date: Sat, 28 Dec 2024 13:23:33 +0100
Subject: [PATCH 1/3] [Clang][ASTMatcher] Add `dependentNameType` Matcher

---
 clang/docs/LibASTMatchersReference.html   |  9 +
 clang/docs/ReleaseNotes.rst   |  2 ++
 clang/include/clang/ASTMatchers/ASTMatchers.h | 10 ++
 clang/lib/ASTMatchers/ASTMatchersInternal.cpp |  1 +
 clang/lib/ASTMatchers/Dynamic/Registry.cpp|  1 +
 clang/unittests/AST/ASTImporterTest.cpp   |  3 ---
 .../unittests/ASTMatchers/ASTMatchersNodeTest.cpp | 15 +++
 7 files changed, 38 insertions(+), 3 deletions(-)

diff --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index ddc99020604c94..69fd43b2114723 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2536,6 +2536,15 @@ Node Matchers
   matches "decltype(i + j)"
 
 
+MatcherStmt>dependentNameTypeMatcherDependentNameType>...
+Matches dependent 
name type.
+
+Example matches T::type
+
+  template  struct declToImport {
+typedef typename T::type dependent_name;
+  };
+
 
 MatcherType>deducedTemplateSpecializationTypeMatcherDeducedTemplateSpecializationType>...
 Matches C++17 deduced template 
specialization types, e.g. deduced class
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 983c1da20ed4c8..7446aaf57a02dc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1110,6 +1110,8 @@ AST Matchers
 
 - Add ``dependentScopeDeclRefExpr`` matcher to match expressions that refer to 
dependent scope declarations.
 
+- Add ``dependentNameType`` matcher to match dependent name type.
+
 clang-format
 
 
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 22e2546ab81e0a..b27914306b8270 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7711,6 +7711,16 @@ AST_MATCHER_P(DecayedType, hasDecayedType, 
internal::Matcher,
   return InnerType.matches(Node.getDecayedType(), Finder, Builder);
 }
 
+/// Matches dependent name type
+///
+/// Example matches  T::type
+/// \code
+///  template  struct declToImport {
+///typedef typename T::type dependent_name;
+///  };
+/// \endcode
+extern const AstTypeMatcher dependentNameType;
+
 /// Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 8c744eebbdfb50..a47633bf4bae24 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -1108,6 +1108,7 @@ const AstTypeMatcher 
substTemplateTypeParmType;
 const AstTypeMatcher templateTypeParmType;
 const AstTypeMatcher injectedClassNameType;
 const AstTypeMatcher decayedType;
+const AstTypeMatcher dependentNameType;
 AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasElementType,
  AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,
  ComplexType));
diff --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 685d626d2978bf..674129aee59241 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -218,6 +218,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(cxxTryStmt);
   REGISTER_MATCHER(cxxUnresolvedConstructExpr);
   REGISTER_MATCHER(decayedType);
+  REGISTER_MATCHER(dependentNameType);
   REGISTER_MATCHER(decl);
   REGISTER_MATCHER(decompositionDecl);
   REGISTER_MATCHER(declCountIs);
diff --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index ec062a5cc953b8..ee1d896f1ca6dc 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3196,9 +3196,6 @@ TEST_P(ImportExpr, DependentScopeDeclRefExpr) {
  has(callExpr(has(dependentScopeDeclRefExpr());
 }
 
-const internal::VariadicDynCastAllOfMatcher
-dependentNameType;
-
 TEST_P(ImportExpr, DependentNameType) {
   MatchVerifier Verifier;
   testImport("template  struct declToImport {"
diff --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index a3baad367a27b1..6dfa3d9c0992f0 100644
--- a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ b/clang/unitt

[clang-tools-extra] [clang-tidy] Add bugprone-reset-call check (PR #121291)

2024-12-29 Thread Piotr Zegar via cfe-commits

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

1. Consider TK_IgnoreUnlessSpelledInSource, may simplify matchers
2. Name is too generic, consider:
 - bugprone-smartptr-reset-pointee-reset
 - bugprone-smartptr-reset-call
 - bugprone-smartptr-pointee-reset
 - bugprone-smartptr-reset-ambiguous-call (my prefered)

Or any simillar.

https://github.com/llvm/llvm-project/pull/121291
___
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 depercation warning for non-whitelisted global options (PR #121057)

2024-12-29 Thread Carlos Galvez via cfe-commits


@@ -62,16 +62,29 @@ ClangTidyCheck::OptionsView::get(StringRef LocalName) const 
{
   return std::nullopt;
 }
 
+static const llvm::StringSet<> DeprecatedGlobalOptions{
+"StrictMode",
+"IgnoreMacros",
+};
+
 static ClangTidyOptions::OptionMap::const_iterator
 findPriorityOption(const ClangTidyOptions::OptionMap &Options,
StringRef NamePrefix, StringRef LocalName,
-   llvm::StringSet<> *Collector) {
+   ClangTidyContext *Context) {
+  llvm::StringSet<> *Collector = Context->getOptionsCollector();
   if (Collector) {
 Collector->insert((NamePrefix + LocalName).str());
 Collector->insert(LocalName);
   }
   auto IterLocal = Options.find((NamePrefix + LocalName).str());
   auto IterGlobal = Options.find(LocalName);
+  // FIXME: temporary solution for deprecation warnings, should be removed

carlosgalvezp wrote:

After this is merged, please create an issue on github to track this removal 
work for release 22.x

https://github.com/llvm/llvm-project/pull/121057
___
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 depercation warning for non-whitelisted global options (PR #121057)

2024-12-29 Thread Carlos Galvez via cfe-commits

https://github.com/carlosgalvezp commented:

I believe we should document this deprecation in the Release Notes.

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


[clang] [Clang] Remove 3-element vector load and store special handling (PR #104661)

2024-12-29 Thread Shilei Tian via cfe-commits

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

>From 9dfb68ddc02bb70b3c9ff9d5aeedabbc2feed258 Mon Sep 17 00:00:00 2001
From: Shilei Tian 
Date: Tue, 17 Dec 2024 23:50:06 -0500
Subject: [PATCH] [Clang] Remove 3-element vector load and store special
 handling

Clang uses a long-time special handling of the case where  3 element vector 
loads
and stores are performed as 4 element, and then a shufflevector is used to 
extract
the used elements. Odd sized vector codegen should now work reasonably well.

This patch removes this special handling, as well as the compiler argument
`-fpreserve-vec3-type`.
---
 clang/include/clang/Basic/CodeGenOptions.def  |  3 -
 clang/include/clang/Basic/LangOptions.def |  2 +
 clang/include/clang/Driver/Options.td |  4 -
 clang/lib/Basic/LangOptions.cpp   |  2 +
 clang/lib/CodeGen/ABIInfo.cpp |  8 ++
 clang/lib/CodeGen/ABIInfo.h   |  7 ++
 clang/lib/CodeGen/CGExpr.cpp  | 48 ++--
 clang/lib/CodeGen/Targets/AMDGPU.cpp  |  6 ++
 .../test/CodeGenCXX/matrix-vector-bit-int.cpp | 32 
 clang/test/CodeGenOpenCL/amdgpu-alignment.cl  | 28 +++
 clang/test/CodeGenOpenCL/preserve_vec3.cl | 77 ---
 11 files changed, 78 insertions(+), 139 deletions(-)
 delete mode 100644 clang/test/CodeGenOpenCL/preserve_vec3.cl

diff --git a/clang/include/clang/Basic/CodeGenOptions.def 
b/clang/include/clang/Basic/CodeGenOptions.def
index 0f4ed13d5f3d8c..1ab8c7fb4d3c33 100644
--- a/clang/include/clang/Basic/CodeGenOptions.def
+++ b/clang/include/clang/Basic/CodeGenOptions.def
@@ -413,9 +413,6 @@ CODEGENOPT(StrictReturn, 1, 1)
 /// Whether emit pseudo probes for sample pgo profile collection.
 CODEGENOPT(PseudoProbeForProfiling, 1, 0)
 
-/// Whether 3-component vector type is preserved.
-CODEGENOPT(PreserveVec3Type, 1, 0)
-
 CODEGENOPT(NoPLT, 1, 0)
 
 /// Whether to emit all vtables
diff --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 3b833240e5b68c..a980be853d53e6 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -532,6 +532,8 @@ BENIGN_LANGOPT(CheckConstexprFunctionBodies, 1, 1,
 
 LANGOPT(BoundsSafety, 1, 0, "Bounds safety extension for C")
 
+LANGOPT(PreserveVec3Type, 1, 0, "Preserve 3-component vector type")
+
 #undef LANGOPT
 #undef COMPATIBLE_LANGOPT
 #undef BENIGN_LANGOPT
diff --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index d922709db17786..38d8a255fedec4 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -8215,10 +8215,6 @@ def fhlsl_strict_availability : Flag<["-"], 
"fhlsl-strict-availability">,
   Group,
   MarshallingInfoFlag>;
 
-def fpreserve_vec3_type : Flag<["-"], "fpreserve-vec3-type">,
-  HelpText<"Preserve 3-component vector type">,
-  MarshallingInfoFlag>,
-  ImpliedByAnyOf<[hlsl.KeyPath]>;
 def fwchar_type_EQ : Joined<["-"], "fwchar-type=">,
   HelpText<"Select underlying type for wchar_t">,
   Values<"char,short,int">,
diff --git a/clang/lib/Basic/LangOptions.cpp b/clang/lib/Basic/LangOptions.cpp
index 94caf6a3897bc1..e3037ec819add2 100644
--- a/clang/lib/Basic/LangOptions.cpp
+++ b/clang/lib/Basic/LangOptions.cpp
@@ -208,6 +208,8 @@ void LangOptions::setLangDefaults(LangOptions &Opts, 
Language Lang,
 
   // OpenCL and HLSL have half keyword
   Opts.Half = Opts.OpenCL || Opts.HLSL;
+
+  Opts.PreserveVec3Type = Opts.HLSL;
 }
 
 FPOptions FPOptions::defaultWithoutTrailingStorage(const LangOptions &LO) {
diff --git a/clang/lib/CodeGen/ABIInfo.cpp b/clang/lib/CodeGen/ABIInfo.cpp
index 8e76cf15b642c6..3d6c793d2b6759 100644
--- a/clang/lib/CodeGen/ABIInfo.cpp
+++ b/clang/lib/CodeGen/ABIInfo.cpp
@@ -236,6 +236,14 @@ void ABIInfo::appendAttributeMangling(StringRef AttrStr,
   }
 }
 
+llvm::FixedVectorType *
+ABIInfo::getOptimalVectorType(llvm::FixedVectorType *T,
+  const LangOptions &Opt) const {
+  if (T->getNumElements() == 3 && !Opt.PreserveVec3Type)
+return llvm::FixedVectorType::get(T->getElementType(), 4);
+  return T;
+}
+
 // Pin the vtable to this file.
 SwiftABIInfo::~SwiftABIInfo() = default;
 
diff --git a/clang/lib/CodeGen/ABIInfo.h b/clang/lib/CodeGen/ABIInfo.h
index b8a8de57e5b971..13842fe43eb65f 100644
--- a/clang/lib/CodeGen/ABIInfo.h
+++ b/clang/lib/CodeGen/ABIInfo.h
@@ -20,6 +20,7 @@ class Value;
 class LLVMContext;
 class DataLayout;
 class Type;
+class FixedVectorType;
 } // namespace llvm
 
 namespace clang {
@@ -123,6 +124,12 @@ class ABIInfo {
raw_ostream &Out) const;
   virtual void appendAttributeMangling(StringRef AttrStr,
raw_ostream &Out) const;
+
+  /// Returns the optimal vector type based on the given vector type. For
+  /// example, on certain targets, a vector with 3 elements might be promoted 
to
+

[clang] 49331ab - [NFC][Clang] Auto generate check lines for `clang/test/CodeGenCXX/matrix-vector-bit-int.cpp`

2024-12-29 Thread Shilei Tian via cfe-commits

Author: Shilei Tian
Date: 2024-12-29T22:28:14-05:00
New Revision: 49331ab0b9a41f925153fe03cd7e0d4a33b7c3d4

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

LOG: [NFC][Clang] Auto generate check lines for 
`clang/test/CodeGenCXX/matrix-vector-bit-int.cpp`

Added: 


Modified: 
clang/test/CodeGenCXX/matrix-vector-bit-int.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/matrix-vector-bit-int.cpp 
b/clang/test/CodeGenCXX/matrix-vector-bit-int.cpp
index 040615f4170855..ffbce9ff8d6f4c 100644
--- a/clang/test/CodeGenCXX/matrix-vector-bit-int.cpp
+++ b/clang/test/CodeGenCXX/matrix-vector-bit-int.cpp
@@ -1,3 +1,4 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py 
UTC_ARGS: --version 5
 // RUN: %clang_cc1 -fenable-matrix %s -emit-llvm -triple x86_64-unknown-linux 
-disable-llvm-passes -o - -std=c++11 | FileCheck %s
 
 using i8x3 = _BitInt(8) __attribute__((ext_vector_type(3)));
@@ -7,92 +8,104 @@ using i32x3x3 = _BitInt(32) __attribute__((matrix_type(3, 
3)));
 using i512x3 = _BitInt(512) __attribute__((ext_vector_type(3)));
 using i512x3x3 = _BitInt(512) __attribute__((matrix_type(3, 3)));
 
-// CHECK-LABEL: define dso_local i32 @_Z2v1Dv3_DB8_(i32 %a.coerce)
+// CHECK-LABEL: define dso_local i32 @_Z2v1Dv3_DB8_(
+// CHECK-SAME: i32 [[A_COERCE:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[RETVAL:%.*]] = alloca <3 x i8>, align 4
+// CHECK-NEXT:[[A:%.*]] = alloca <3 x i8>, align 4
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <3 x i8>, align 4
+// CHECK-NEXT:store i32 [[A_COERCE]], ptr [[A]], align 4
+// CHECK-NEXT:[[LOADVEC4:%.*]] = load <4 x i8>, ptr [[A]], align 4
+// CHECK-NEXT:[[A1:%.*]] = shufflevector <4 x i8> [[LOADVEC4]], <4 x i8> 
poison, <3 x i32> 
+// CHECK-NEXT:[[EXTRACTVEC:%.*]] = shufflevector <3 x i8> [[A1]], <3 x i8> 
poison, <4 x i32> 
+// CHECK-NEXT:store <4 x i8> [[EXTRACTVEC]], ptr [[A_ADDR]], align 4
+// CHECK-NEXT:[[LOADVEC42:%.*]] = load <4 x i8>, ptr [[A_ADDR]], align 4
+// CHECK-NEXT:[[EXTRACTVEC3:%.*]] = shufflevector <4 x i8> [[LOADVEC42]], 
<4 x i8> poison, <3 x i32> 
+// CHECK-NEXT:[[LOADVEC44:%.*]] = load <4 x i8>, ptr [[A_ADDR]], align 4
+// CHECK-NEXT:[[EXTRACTVEC5:%.*]] = shufflevector <4 x i8> [[LOADVEC44]], 
<4 x i8> poison, <3 x i32> 
+// CHECK-NEXT:[[ADD:%.*]] = add <3 x i8> [[EXTRACTVEC3]], [[EXTRACTVEC5]]
+// CHECK-NEXT:store <3 x i8> [[ADD]], ptr [[RETVAL]], align 4
+// CHECK-NEXT:[[TMP0:%.*]] = load i32, ptr [[RETVAL]], align 4
+// CHECK-NEXT:ret i32 [[TMP0]]
+//
 i8x3 v1(i8x3 a) {
-  // CHECK-NEXT: entry:
-  // CHECK-NEXT:   %retval = alloca <3 x i8>, align 4
-  // CHECK-NEXT:   %a = alloca <3 x i8>, align 4
-  // CHECK-NEXT:   %a.addr = alloca <3 x i8>, align 4
-  // CHECK-NEXT:   store i32 %a.coerce, ptr %a, align 4
-  // CHECK-NEXT:   %loadVec4 = load <4 x i8>, ptr %a, align 4
-  // CHECK-NEXT:   %a1 = shufflevector <4 x i8> %loadVec4, <4 x i8> poison, <3 
x i32> 
-  // CHECK-NEXT:   %extractVec = shufflevector <3 x i8> %a1, <3 x i8> poison, 
<4 x i32> 
-  // CHECK-NEXT:   store <4 x i8> %extractVec, ptr %a.addr, align 4
-  // CHECK-NEXT:   %loadVec42 = load <4 x i8>, ptr %a.addr, align 4
-  // CHECK-NEXT:   %extractVec3 = shufflevector <4 x i8> %loadVec42, <4 x i8> 
poison, <3 x i32> 
-  // CHECK-NEXT:   %loadVec44 = load <4 x i8>, ptr %a.addr, align 4
-  // CHECK-NEXT:   %extractVec5 = shufflevector <4 x i8> %loadVec44, <4 x i8> 
poison, <3 x i32> 
-  // CHECK-NEXT:   %add = add <3 x i8> %extractVec3, %extractVec5
-  // CHECK-NEXT:   store <3 x i8> %add, ptr %retval, align 4
-  // CHECK-NEXT:   %0 = load i32, ptr %retval, align 4
-  // CHECK-NEXT:   ret i32 %0
   return a + a;
 }
 
-// CHECK-LABEL: define dso_local noundef <3 x i32> @_Z2v2Dv3_DB32_(<3 x i32> 
noundef %a)
+// CHECK-LABEL: define dso_local noundef <3 x i32> @_Z2v2Dv3_DB32_(
+// CHECK-SAME: <3 x i32> noundef [[A:%.*]]) #[[ATTR1:[0-9]+]] {
+// CHECK-NEXT:  [[ENTRY:.*:]]
+// CHECK-NEXT:[[A_ADDR:%.*]] = alloca <3 x i32>, align 16
+// CHECK-NEXT:[[EXTRACTVEC:%.*]] = shufflevector <3 x i32> [[A]], <3 x 
i32> poison, <4 x i32> 
+// CHECK-NEXT:store <4 x i32> [[EXTRACTVEC]], ptr [[A_ADDR]], align 16
+// CHECK-NEXT:[[LOADVEC4:%.*]] = load <4 x i32>, ptr [[A_ADDR]], align 16
+// CHECK-NEXT:[[EXTRACTVEC1:%.*]] = shufflevector <4 x i32> [[LOADVEC4]], 
<4 x i32> poison, <3 x i32> 
+// CHECK-NEXT:[[LOADVEC42:%.*]] = load <4 x i32>, ptr [[A_ADDR]], align 16
+// CHECK-NEXT:[[EXTRACTVEC3:%.*]] = shufflevector <4 x i32> [[LOADVEC42]], 
<4 x i32> poison, <3 x i32> 
+// CHECK-NEXT:[[ADD:%.*]] = add <3 x i32> [[EXTRACTVEC1]], [[EXTRACTVEC3]]
+// CHECK-NEXT:ret <3 x i32> [[ADD]]
+//
 i32x3 v2(i32x3 a) {
-  // CHECK-NEXT: entry:
-  // CHECK-NE

[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121313)

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

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

LGTM, feel free to merge unless you prefer additional input from other 
maintainers.

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


[clang] [llvm] [OpenEmbedded] Fix include and lib paths for multilib targets (PR #121302)

2024-12-29 Thread Mike Crowe via cfe-commits

https://github.com/mikecrowe updated 
https://github.com/llvm/llvm-project/pull/121302

>From e376b821928b6de9f9ba45efad159341e2e242e6 Mon Sep 17 00:00:00 2001
From: Mike Crowe 
Date: Sun, 29 Dec 2024 17:25:20 +
Subject: [PATCH] [OpenEmbedded] Fix include and lib paths for multilib targets

The fix in e9ddc44a604318739a27249d267aa7267d13d93b wasn't enough for
multilib targets since they use a custom vendor that contains the
multilib variant.  There are two common multilib variants: lib32 and
libx32, so let's support both.
---
 clang/docs/ReleaseNotes.rst   |  2 ++
 .../usr/include/c++/9.5.0/backward/.keep  |  0
 .../9.5.0/crtbegin.o  |  0
 .../9.5.0/crtend.o|  0
 .../usr/lib/crt1.o|  0
 .../usr/lib/crti.o|  0
 .../usr/lib/crtn.o|  0
 .../usr/include/c++/14.2.0/backward/.keep |  0
 .../usr/libx32/crt1.o |  0
 .../usr/libx32/crti.o |  0
 .../usr/libx32/crtn.o |  0
 .../14.2.0/crtbegin.o |  0
 .../14.2.0/crtend.o   |  0
 clang/test/Driver/linux-header-search.cpp | 22 
 clang/test/Driver/linux-ld.c  | 36 +++
 llvm/lib/TargetParser/Triple.cpp  |  2 ++
 llvm/unittests/TargetParser/TripleTest.cpp| 12 +++
 17 files changed, 74 insertions(+)
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crtn.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/include/c++/14.2.0/backward/.keep
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crt1.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crti.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/crtn.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtbegin.o
 create mode 100644 
clang/test/Driver/Inputs/openembedded_x86_64_multilib_libx32_linux_tree/usr/libx32/x86_64-oemllibx32-linux-gnux32/14.2.0/crtend.o

diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 983c1da20ed4c8..23e0c36e6d2961 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -759,6 +759,8 @@ Bug Fixes in This Version
 - No longer return ``false`` for ``noexcept`` expressions involving a
   ``delete`` which resolves to a destroying delete but the type of the object
   being deleted has a potentially throwing destructor (#GH118660).
+- OpenEmbedded multilib oemllib32 and oemllibx32 are now recognised in
+  target triples.
 
 Bug Fixes to Compiler Builtins
 ^^
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/include/c++/9.5.0/backward/.keep
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtbegin.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/arm-oemllib32-linux-gnueabi/9.5.0/crtend.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crt1.o
new file mode 100644
index 00..e69de29bb2d1d6
diff --git 
a/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
 
b/clang/test/Driver/Inputs/openembedded_arm_multilib_lib32_linux_tree/usr/lib/crti.o
new file mode 100644
index 00..e69de29bb2d1d6

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

2024-12-29 Thread via cfe-commits

goldsteinn wrote:

ping @ideasman42 

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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcicli (Conditional Load Immediate) extension (PR #121292)

2024-12-29 Thread Craig Topper via cfe-commits


@@ -243,6 +253,24 @@ let Predicates = [HasVendorXqcilsm, IsRV32], 
DecoderNamespace = "Xqcilsm" in {
 def QC_LWMI : QCILoadMultiple<0b01, uimm5nonzero, "qc.lwmi">;
 } // Predicates = [HasVendorXqcilsm, IsRV32], DecoderNamespace = "Xqcilsm"
 
+let Predicates = [HasVendorXqcicli, IsRV32], DecoderNamespace = "Xqcicli" in {
+let hasSideEffects = 0, mayLoad = 0, mayStore = 0 in {

topperc wrote:

Can we put the `hasSideEffects = 0, mayLoad = 0, mayStore = 0` on the `QCILICC` 
class? Like was done for `QCIStoreMultiple`, `QCISELECTIICC`, etc?

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


[clang-tools-extra] [clang-tidy] bugprone-unhandled-self-assignment: fix smart pointer check against std::unique_ptr type (PR #121266)

2024-12-29 Thread Congcong Cai via cfe-commits

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


[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121313)

2024-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: Nathan Ridge (HighCommander4)


Changes

Fixes https://github.com/clangd/clangd/issues/2154

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


3 Files Affected:

- (modified) clang-tools-extra/clangd/HeuristicResolver.h (+3-2) 
- (modified) clang-tools-extra/clangd/unittests/CMakeLists.txt (+1) 
- (added) clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp (+521) 


``diff
diff --git a/clang-tools-extra/clangd/HeuristicResolver.h 
b/clang-tools-extra/clangd/HeuristicResolver.h
index dcc063bbc4adc0..c130e0677e86dd 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.h
+++ b/clang-tools-extra/clangd/HeuristicResolver.h
@@ -26,13 +26,14 @@ class UnresolvedUsingValueDecl;
 
 namespace clangd {
 
-// This class heuristic resolution of declarations and types in template code.
+// This class handles heuristic resolution of declarations and types in 
template
+// code.
 //
 // As a compiler, clang only needs to perform certain types of processing on
 // template code (such as resolving dependent names to declarations, or
 // resolving the type of a dependent expression) after instantiation. Indeed,
 // C++ language features such as template specialization mean such resolution
-// cannot be done accurately before instantiation
+// cannot be done accurately before instantiation.
 //
 // However, template code is written and read in uninstantiated form, and 
clangd
 // would like to provide editor features like go-to-definition in template code
diff --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index dffdcd5d014ca9..8dba8088908d5e 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -64,6 +64,7 @@ add_unittest(ClangdUnitTests ClangdTests
   GlobalCompilationDatabaseTests.cpp
   HeadersTests.cpp
   HeaderSourceSwitchTests.cpp
+  HeuristicResolverTests.cpp
   HoverTests.cpp
   IncludeCleanerTests.cpp
   IndexActionTests.cpp
diff --git a/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp 
b/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp
new file mode 100644
index 00..5665fb2519267f
--- /dev/null
+++ b/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp
@@ -0,0 +1,521 @@
+//===-- HeuristicResolverTests.cpp --*- 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
+//
+//===--===//
+#include "HeuristicResolver.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock-matchers.h"
+#include "gtest/gtest.h"
+
+using namespace clang::ast_matchers;
+using clang::clangd::HeuristicResolver;
+using testing::ElementsAre;
+
+namespace clang {
+namespace {
+
+// Helper for matching a sequence of elements with a variadic list of matchers.
+// Usage: `ElementsAre(matchAdapter(Vs, MatchFunction)...)`, where `Vs...` is
+//a variadic list of matchers.
+// For each `V` in `Vs`, this will match the corresponding element `E` if
+// `MatchFunction(V, E)` is true.
+MATCHER_P2(matchAdapter, MatcherForElement, MatchFunction, "matchAdapter") {
+  return MatchFunction(MatcherForElement, arg);
+}
+
+template 
+using ResolveFnT = std::function(
+const HeuristicResolver *, const InputNode *)>;
+
+// Test heuristic resolution on `Code` using the resolution procedure
+// `ResolveFn`, which takes a `HeuristicResolver` and an input AST node of type
+// `InputNode` and returns a `std::vector`.
+// `InputMatcher` should be an AST matcher that matches a single node to pass 
as
+// input to `ResolveFn`, bound to the ID "input". `OutputMatchers` should be 
AST
+// matchers that each match a single node, bound to the ID "output".
+template 
+void expectResolution(llvm::StringRef Code, ResolveFnT ResolveFn,
+  const InputMatcher &IM, const OutputMatchers &...OMS) {
+  auto TU = tooling::buildASTFromCodeWithArgs(Code, {"-std=c++20"});
+  auto &Ctx = TU->getASTContext();
+  auto InputMatches = match(IM, Ctx);
+  ASSERT_EQ(1u, InputMatches.size());
+  const auto *Input = InputMatches[0].template getNodeAs("input");
+  ASSERT_TRUE(Input);
+
+  auto OutputNodeMatches = [&](auto &OutputMatcher, auto &Actual) {
+auto OutputMatches = match(OutputMatcher, Ctx);
+if (OutputMatches.size() != 1u)
+  return false;
+const auto *ExpectedOutput =
+OutputMatches[0].template getNodeAs("output");
+if (!ExpectedOutput)
+  return false;
+return ExpectedOutput == Actual;
+  };
+
+  HeuristicResolver H(Ctx);
+  auto Results = ResolveFn(&H, Input);
+  EXPECT_THAT(Results, ElementsAre(mat

[clang-tools-extra] [clang-tidy][doc] mention smart ptr in bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField option (PR #121316)

2024-12-29 Thread Congcong Cai via cfe-commits

https://github.com/HerrCai0907 created 
https://github.com/llvm/llvm-project/pull/121316

None

>From 4cbe19c9acedd68dccc4f7211b1d2f8e93e1492c Mon Sep 17 00:00:00 2001
From: Congcong Cai 
Date: Mon, 30 Dec 2024 11:06:59 +0800
Subject: [PATCH] [clang-tidy][doc] mention smart ptr in
 bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField option

---
 .../checks/bugprone/unhandled-self-assignment.rst   | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
index dee139861c8cfe..d3cdd5a12fdca3 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
@@ -120,5 +120,7 @@ temporary object into ``this`` (needs a move assignment 
operator):
 
 .. option:: WarnOnlyIfThisHasSuspiciousField
 
-  When `true`, the check will warn only if the container class of the copy 
assignment operator
-  has any suspicious fields (pointer or C array). This option is set to `true` 
by default.
+  When `true`, the check will warn only if the container class of the copy
+  assignment operator has any suspicious fields (pointer, C array and C++ smart
+  pointer).
+  This option is set to `true` by default.

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


[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121313)

2024-12-29 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] [clang-tidy][doc] mention smart ptr in bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField option (PR #121316)

2024-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Congcong Cai (HerrCai0907)


Changes



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


1 Files Affected:

- (modified) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst 
(+4-2) 


``diff
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
index dee139861c8cfe..d3cdd5a12fdca3 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
@@ -120,5 +120,7 @@ temporary object into ``this`` (needs a move assignment 
operator):
 
 .. option:: WarnOnlyIfThisHasSuspiciousField
 
-  When `true`, the check will warn only if the container class of the copy 
assignment operator
-  has any suspicious fields (pointer or C array). This option is set to `true` 
by default.
+  When `true`, the check will warn only if the container class of the copy
+  assignment operator has any suspicious fields (pointer, C array and C++ smart
+  pointer).
+  This option is set to `true` by default.

``




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


[clang-tools-extra] [clang-tidy][doc] mention smart ptr in bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField option (PR #121316)

2024-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tidy

Author: Congcong Cai (HerrCai0907)


Changes



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


1 Files Affected:

- (modified) 
clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst 
(+4-2) 


``diff
diff --git 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
index dee139861c8cfe..d3cdd5a12fdca3 100644
--- 
a/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
+++ 
b/clang-tools-extra/docs/clang-tidy/checks/bugprone/unhandled-self-assignment.rst
@@ -120,5 +120,7 @@ temporary object into ``this`` (needs a move assignment 
operator):
 
 .. option:: WarnOnlyIfThisHasSuspiciousField
 
-  When `true`, the check will warn only if the container class of the copy 
assignment operator
-  has any suspicious fields (pointer or C array). This option is set to `true` 
by default.
+  When `true`, the check will warn only if the container class of the copy
+  assignment operator has any suspicious fields (pointer, C array and C++ smart
+  pointer).
+  This option is set to `true` by default.

``




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


[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121246)

2024-12-29 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

Resubmitted as https://github.com/llvm/llvm-project/pull/121313 in a user 
branch of this repo, so that I can stack dependent PRs on top of this.

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


[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121246)

2024-12-29 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] [clang-tidy] Mention std::forward_list in container-size-empty doc (PR #120701)

2024-12-29 Thread Congcong Cai via cfe-commits

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


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


[clang] [llvm] [RISCV] Add Qualcomm uC Xqcicli (Conditional Load Immediate) extension (PR #121292)

2024-12-29 Thread Sudharsan Veeravalli via cfe-commits

https://github.com/svs-quic updated 
https://github.com/llvm/llvm-project/pull/121292

>From 44b470c5798d5e160b1d3159a936b5e1737482b3 Mon Sep 17 00:00:00 2001
From: Sudharsan Veeravalli 
Date: Sun, 29 Dec 2024 18:28:52 +0530
Subject: [PATCH 1/2] [RISCV] Add Qualcomm uC Xqcicli (Conditional Load
 Immediate) extension

This extension adds 12 instructions that conditionally load an immediate value.

The current spec can be found at:
https://github.com/quic/riscv-unified-db/releases/latest

This patch adds assembler only support.
---
 .../Driver/print-supported-extensions-riscv.c |   1 +
 llvm/docs/RISCVUsage.rst  |   3 +
 llvm/docs/ReleaseNotes.md |   2 +
 .../RISCV/Disassembler/RISCVDisassembler.cpp  |   3 +
 llvm/lib/Target/RISCV/RISCVFeatures.td|   8 +
 llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td   |  28 +++
 llvm/lib/TargetParser/RISCVISAInfo.cpp|   3 +-
 llvm/test/CodeGen/RISCV/attributes.ll |   2 +
 llvm/test/MC/RISCV/xqcicli-invalid.s  | 232 ++
 llvm/test/MC/RISCV/xqcicli-valid.s|  59 +
 .../TargetParser/RISCVISAInfoTest.cpp |   4 +-
 11 files changed, 343 insertions(+), 2 deletions(-)
 create mode 100644 llvm/test/MC/RISCV/xqcicli-invalid.s
 create mode 100644 llvm/test/MC/RISCV/xqcicli-valid.s

diff --git a/clang/test/Driver/print-supported-extensions-riscv.c 
b/clang/test/Driver/print-supported-extensions-riscv.c
index 8e46690cce5a63..395501eb85ccc3 100644
--- a/clang/test/Driver/print-supported-extensions-riscv.c
+++ b/clang/test/Driver/print-supported-extensions-riscv.c
@@ -190,6 +190,7 @@
 // CHECK-NEXT: svukte   0.3   'Svukte' 
(Address-Independent Latency of User-Mode Faults to Supervisor Addresses)
 // CHECK-NEXT: xqcia0.2   'Xqcia' (Qualcomm uC 
Arithmetic Extension)
 // CHECK-NEXT: xqciac   0.2   'Xqciac' (Qualcomm uC 
Load-Store Address Calculation Extension)
+// CHECK-NEXT: xqcicli  0.2   'Xqcicli' (Qualcomm uC 
Conditional Load Immediate Extension)
 // CHECK-NEXT: xqcics   0.2   'Xqcics' (Qualcomm uC 
Conditional Select Extension)
 // CHECK-NEXT: xqcicsr  0.2   'Xqcicsr' (Qualcomm uC CSR 
Extension)
 // CHECK-NEXT: xqcilsm  0.2   'Xqcilsm' (Qualcomm uC Load 
Store Multiple Extension)
diff --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 22600f5720553e..eaaad6c5168189 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -432,6 +432,9 @@ The current vendor extensions supported are:
 ``experimental-Xqciac``
   LLVM implements `version 0.2 of the Qualcomm uC Load-Store Address 
Calculation extension specification 
`__ by Qualcomm.  All 
instructions are prefixed with `qc.` as described in the specification. These 
instructions are only available for riscv32.
 
+``experimental-Xqcicli``
+  LLVM implements `version 0.2 of the Qualcomm uC Conditional Load Immediate 
extension specification 
`__ by Qualcomm.  All 
instructions are prefixed with `qc.` as described in the specification. These 
instructions are only available for riscv32.
+
 ``experimental-Xqcics``
   LLVM implements `version 0.2 of the Qualcomm uC Conditional Select extension 
specification `__ by 
Qualcomm.  All instructions are prefixed with `qc.` as described in the 
specification. These instructions are only available for riscv32.
 
diff --git a/llvm/docs/ReleaseNotes.md b/llvm/docs/ReleaseNotes.md
index 99a93b0467602d..be62a7e8696b4c 100644
--- a/llvm/docs/ReleaseNotes.md
+++ b/llvm/docs/ReleaseNotes.md
@@ -230,6 +230,8 @@ Changes to the RISC-V Backend
   extension.
 * Adds experimental assembler support for the Qualcomm uC 'Xqcilsm` (Load 
Store Multiple)
   extension.
+* Adds experimental assembler support for the Qualcomm uC 'Xqcicli` 
(Conditional Load Immediate)
+  extension.
 
 Changes to the WebAssembly Backend
 --
diff --git a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp 
b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
index 57443d3f38e3cb..30122831767f61 100644
--- a/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
+++ b/llvm/lib/Target/RISCV/Disassembler/RISCVDisassembler.cpp
@@ -695,6 +695,9 @@ DecodeStatus RISCVDisassembler::getInstruction32(MCInst 
&MI, uint64_t &Size,
   TRY_TO_DECODE_FEATURE(
   RISCV::FeatureVendorXqciac, DecoderTableXqciac32,
   "Qualcomm uC Load-Store Address Calculation custom opcode table");
+  TRY_TO_DECODE_FEATURE(
+  RISCV::FeatureVendorXqcicli, DecoderTableXqcicli32,
+  "Qualcomm uC Conditional Load Immediate custom opcode table");
   TRY_TO_DECODE(true, DecoderTable32, "RISCV32 table");
 
   return MCDisassembler::Fail;
diff --git a/llvm/lib/Target/R

[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)

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

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


[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)

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

https://github.com/owenca commented:

Also, additional cleanup of `tryMergeNamespace()`:
```cpp
 if (Limit == 0)
   return 0;
-if (I[1]->InPPDirective != (*I)->InPPDirective ||
-(I[1]->InPPDirective && I[1]->First->HasUnescapedNewline)) {
+
+assert(I[1]);
+const auto &L1 = *I[1];
+if (L1.InPPDirective != (*I)->InPPDirective ||
+(L1.InPPDirective && L1.First->HasUnescapedNewline)) {
   return 0;
 }
-if (I + 2 == E || I[2]->Type == LT_Invalid)
+
+if (std::distance(I, E) <= 2)
+  return 0;
+
+assert(I[2]);
+const auto &L2 = *I[2];
+if (L2.Type == LT_Invalid)
   return 0;
 
 Limit = limitConsideringMacros(I + 1, E, Limit);
@@ -645,13 +654,13 @@ private:
 
 // Check if it's a namespace inside a namespace, and call recursively if 
so.
 // '3' is the sizes of the whitespace and closing brace for " _inner_ }".
-if (I[1]->First->is(tok::kw_namespace)) {
-  if (I[1]->Last->is(tok::comment) || !Style.CompactNamespaces)
+if (L1.First->is(tok::kw_namespace)) {
+  if (L1.Last->is(tok::comment) || !Style.CompactNamespaces)
 return 0;
 
-  assert(Limit >= I[1]->Last->TotalLength + 3);
-  const unsigned InnerLimit = Limit - I[1]->Last->TotalLength - 3;
-  const unsigned MergedLines = tryMergeNamespace(I + 1, E, InnerLimit);
+  assert(Limit >= L1.Last->TotalLength + 3);
+  const auto InnerLimit = Limit - L1.Last->TotalLength - 3;
+  const auto MergedLines = tryMergeNamespace(I + 1, E, InnerLimit);
   if (MergedLines == 0)
 return 0;
   const auto N = MergedLines + 2;
@@ -672,11 +681,11 @@ private:
 // line.
 
 // The line which is in the namespace should end with semicolon.
-if (I[1]->Last->isNot(tok::semi))
+if (L1.Last->isNot(tok::semi))
   return 0;
 
 // Last, check that the third line starts with a closing brace.
-if (I[2]->First->isNot(tok::r_brace) || I[2]->First->MustBreakBefore)
+if (L2.First->isNot(tok::r_brace) || L2.First->MustBreakBefore)
   return 0;
```
Use more descriptive names instead of `L1` and `L2` if you like.

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


[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)

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


@@ -4504,6 +4504,16 @@ TEST_F(FormatTest, FormatsCompactNamespaces) {
"} // namespace bb\n"
"} // namespace aa",
Style);
+
+  verifyFormat("namespace a { namespace b { namespace c {\n"
+   "}}} // namespace a::b::c",
+   Style);
+
+  verifyFormat("namespace a { namespace b {\n"
+   "namespace cc {\n"
+   "}}} // namespace a::b::cc",

owenca wrote:

```suggestion
  verifyFormat("namespace a { namespace b {\n"
   "namespace c {\n"
   "}}} // namespace a::b::c",
```
The test case on lines 4508-4509 (with `ColumnLimit: 41`) is the current 
behavior and can be deleted.

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


[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)

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


@@ -4484,7 +4484,7 @@ TEST_F(FormatTest, FormatsCompactNamespaces) {
"} // namespace A",
Style);
 
-  Style.ColumnLimit = 40;
+  Style.ColumnLimit = 41;

owenca wrote:

```suggestion
  Style.ColumnLimit = 40;
```
See below.

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


[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)

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


@@ -916,6 +983,21 @@ class LineJoiner {
 return 1 + I[1]->Last->TotalLength + 1 + I[2]->Last->TotalLength <= Limit;
   }
 
+  bool nextNLinesFitInto(SmallVectorImpl::const_iterator I,
+ SmallVectorImpl::const_iterator E,
+ unsigned Limit) {
+unsigned JoinedLength = 0;
+for (auto J = I + 1; J != E; ++J) {

owenca wrote:

```suggestion
for (const auto *J = I + 1; J != E; ++J) {
```

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


[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Nathan Ridge via cfe-commits

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

LGTM, thanks!

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


[clang] 6230f1b - [Clang][ASTMatcher] Add `dependentNameType` AST matcher (#121263)

2024-12-29 Thread via cfe-commits

Author: Amr Hesham
Date: 2024-12-29T19:27:10-05:00
New Revision: 6230f1ba945a1bc795a34cd438c6df3b987f359f

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

LOG: [Clang][ASTMatcher] Add `dependentNameType` AST matcher (#121263)

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

Added: 


Modified: 
clang/docs/LibASTMatchersReference.html
clang/docs/ReleaseNotes.rst
clang/include/clang/ASTMatchers/ASTMatchers.h
clang/lib/ASTMatchers/ASTMatchersInternal.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/unittests/AST/ASTImporterTest.cpp
clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Removed: 




diff  --git a/clang/docs/LibASTMatchersReference.html 
b/clang/docs/LibASTMatchersReference.html
index ddc99020604c94..8564f2650d205f 100644
--- a/clang/docs/LibASTMatchersReference.html
+++ b/clang/docs/LibASTMatchersReference.html
@@ -2536,6 +2536,15 @@ Node Matchers
   matches "decltype(i + j)"
 
 
+MatcherType>dependentNameTypeMatcherDependentNameType>...
+Matches a 
dependent name type.
+
+Example matches T::type
+
+  template  struct declToImport {
+typedef typename T::type dependent_name;
+  };
+
 
 MatcherType>deducedTemplateSpecializationTypeMatcherDeducedTemplateSpecializationType>...
 Matches C++17 deduced template 
specialization types, e.g. deduced class

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 983c1da20ed4c8..210ccc16eeb4fc 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1110,6 +1110,8 @@ AST Matchers
 
 - Add ``dependentScopeDeclRefExpr`` matcher to match expressions that refer to 
dependent scope declarations.
 
+- Add ``dependentNameType`` matcher to match a dependent name type.
+
 clang-format
 
 

diff  --git a/clang/include/clang/ASTMatchers/ASTMatchers.h 
b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 22e2546ab81e0a..9a046714068a51 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -7711,6 +7711,16 @@ AST_MATCHER_P(DecayedType, hasDecayedType, 
internal::Matcher,
   return InnerType.matches(Node.getDecayedType(), Finder, Builder);
 }
 
+/// Matches a dependent name type
+///
+/// Example matches  T::type
+/// \code
+///  template  struct declToImport {
+///typedef typename T::type dependent_name;
+///  };
+/// \endcode
+extern const AstTypeMatcher dependentNameType;
+
 /// Matches declarations whose declaration context, interpreted as a
 /// Decl, matches \c InnerMatcher.
 ///

diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 8c744eebbdfb50..a47633bf4bae24 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -1108,6 +1108,7 @@ const AstTypeMatcher 
substTemplateTypeParmType;
 const AstTypeMatcher templateTypeParmType;
 const AstTypeMatcher injectedClassNameType;
 const AstTypeMatcher decayedType;
+const AstTypeMatcher dependentNameType;
 AST_TYPELOC_TRAVERSE_MATCHER_DEF(hasElementType,
  AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,
  ComplexType));

diff  --git a/clang/lib/ASTMatchers/Dynamic/Registry.cpp 
b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
index 685d626d2978bf..bfdee412c53281 100644
--- a/clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -222,6 +222,7 @@ RegistryMaps::RegistryMaps() {
   REGISTER_MATCHER(decompositionDecl);
   REGISTER_MATCHER(declCountIs);
   REGISTER_MATCHER(declRefExpr);
+  REGISTER_MATCHER(dependentNameType);
   REGISTER_MATCHER(dependentScopeDeclRefExpr);
   REGISTER_MATCHER(declStmt);
   REGISTER_MATCHER(declaratorDecl);

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index ec062a5cc953b8..ee1d896f1ca6dc 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -3196,9 +3196,6 @@ TEST_P(ImportExpr, DependentScopeDeclRefExpr) {
  has(callExpr(has(dependentScopeDeclRefExpr());
 }
 
-const internal::VariadicDynCastAllOfMatcher
-dependentNameType;
-
 TEST_P(ImportExpr, DependentNameType) {
   MatchVerifier Verifier;
   testImport("template  struct declToImport {"

diff  --git a/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp 
b/clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
index a3ba

[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Nathan Ridge via cfe-commits

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


[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121246)

2024-12-29 Thread Nathan Ridge via cfe-commits

https://github.com/HighCommander4 updated 
https://github.com/llvm/llvm-project/pull/121246

>From 8238ad159c0b8123c03d953d18340147c72372e9 Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Sun, 6 Oct 2024 00:41:48 -0400
Subject: [PATCH] [clangd] Add a unit test suite for HeuristicResolver

Fixes https://github.com/clangd/clangd/issues/2154
---
 clang-tools-extra/clangd/HeuristicResolver.h  |   5 +-
 .../clangd/unittests/CMakeLists.txt   |   1 +
 .../unittests/HeuristicResolverTests.cpp  | 521 ++
 3 files changed, 525 insertions(+), 2 deletions(-)
 create mode 100644 
clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp

diff --git a/clang-tools-extra/clangd/HeuristicResolver.h 
b/clang-tools-extra/clangd/HeuristicResolver.h
index dcc063bbc4adc0..c130e0677e86dd 100644
--- a/clang-tools-extra/clangd/HeuristicResolver.h
+++ b/clang-tools-extra/clangd/HeuristicResolver.h
@@ -26,13 +26,14 @@ class UnresolvedUsingValueDecl;
 
 namespace clangd {
 
-// This class heuristic resolution of declarations and types in template code.
+// This class handles heuristic resolution of declarations and types in 
template
+// code.
 //
 // As a compiler, clang only needs to perform certain types of processing on
 // template code (such as resolving dependent names to declarations, or
 // resolving the type of a dependent expression) after instantiation. Indeed,
 // C++ language features such as template specialization mean such resolution
-// cannot be done accurately before instantiation
+// cannot be done accurately before instantiation.
 //
 // However, template code is written and read in uninstantiated form, and 
clangd
 // would like to provide editor features like go-to-definition in template code
diff --git a/clang-tools-extra/clangd/unittests/CMakeLists.txt 
b/clang-tools-extra/clangd/unittests/CMakeLists.txt
index dffdcd5d014ca9..8dba8088908d5e 100644
--- a/clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ b/clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -64,6 +64,7 @@ add_unittest(ClangdUnitTests ClangdTests
   GlobalCompilationDatabaseTests.cpp
   HeadersTests.cpp
   HeaderSourceSwitchTests.cpp
+  HeuristicResolverTests.cpp
   HoverTests.cpp
   IncludeCleanerTests.cpp
   IndexActionTests.cpp
diff --git a/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp 
b/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp
new file mode 100644
index 00..5665fb2519267f
--- /dev/null
+++ b/clang-tools-extra/clangd/unittests/HeuristicResolverTests.cpp
@@ -0,0 +1,521 @@
+//===-- HeuristicResolverTests.cpp --*- 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
+//
+//===--===//
+#include "HeuristicResolver.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Tooling.h"
+#include "gmock/gmock-matchers.h"
+#include "gtest/gtest.h"
+
+using namespace clang::ast_matchers;
+using clang::clangd::HeuristicResolver;
+using testing::ElementsAre;
+
+namespace clang {
+namespace {
+
+// Helper for matching a sequence of elements with a variadic list of matchers.
+// Usage: `ElementsAre(matchAdapter(Vs, MatchFunction)...)`, where `Vs...` is
+//a variadic list of matchers.
+// For each `V` in `Vs`, this will match the corresponding element `E` if
+// `MatchFunction(V, E)` is true.
+MATCHER_P2(matchAdapter, MatcherForElement, MatchFunction, "matchAdapter") {
+  return MatchFunction(MatcherForElement, arg);
+}
+
+template 
+using ResolveFnT = std::function(
+const HeuristicResolver *, const InputNode *)>;
+
+// Test heuristic resolution on `Code` using the resolution procedure
+// `ResolveFn`, which takes a `HeuristicResolver` and an input AST node of type
+// `InputNode` and returns a `std::vector`.
+// `InputMatcher` should be an AST matcher that matches a single node to pass 
as
+// input to `ResolveFn`, bound to the ID "input". `OutputMatchers` should be 
AST
+// matchers that each match a single node, bound to the ID "output".
+template 
+void expectResolution(llvm::StringRef Code, ResolveFnT ResolveFn,
+  const InputMatcher &IM, const OutputMatchers &...OMS) {
+  auto TU = tooling::buildASTFromCodeWithArgs(Code, {"-std=c++20"});
+  auto &Ctx = TU->getASTContext();
+  auto InputMatches = match(IM, Ctx);
+  ASSERT_EQ(1u, InputMatches.size());
+  const auto *Input = InputMatches[0].template getNodeAs("input");
+  ASSERT_TRUE(Input);
+
+  auto OutputNodeMatches = [&](auto &OutputMatcher, auto &Actual) {
+auto OutputMatches = match(OutputMatcher, Ctx);
+if (OutputMatches.size() != 1u)
+  return false;
+const auto *ExpectedOutput =
+OutputMatches[0].template getNodeAs("output");
+

[clang-tools-extra] [clangd] Add a unit test suite for HeuristicResolver (PR #121246)

2024-12-29 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

Updated to take advantage of the new `dependentNameType()` matcher added in 
https://github.com/llvm/llvm-project/pull/121263.

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


[clang-tools-extra] [clangd] Remove clangd's HasValue GMock matcher (PR #121309)

2024-12-29 Thread Nathan Ridge via cfe-commits

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

An equivalent matcher under the name Optional has since been added upstream to 
GMock.

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

>From 112d20354add8679fc62e66de4428c947b295e96 Mon Sep 17 00:00:00 2001
From: Nathan Ridge 
Date: Sun, 29 Dec 2024 02:25:10 -0500
Subject: [PATCH] [clangd] Remove clangd's HasValue GMock matcher

An equivalent matcher under the name Optional has since been added
upstream to GMock.

Fixes https://github.com/llvm/llvm-project/issues/121308
---
 clang-tools-extra/clangd/unittests/Matchers.h | 68 ---
 .../clangd/unittests/TypeHierarchyTests.cpp   | 11 +--
 2 files changed, 6 insertions(+), 73 deletions(-)

diff --git a/clang-tools-extra/clangd/unittests/Matchers.h 
b/clang-tools-extra/clangd/unittests/Matchers.h
index 0fbd93b2e68825..17d18dd9b85b65 100644
--- a/clang-tools-extra/clangd/unittests/Matchers.h
+++ b/clang-tools-extra/clangd/unittests/Matchers.h
@@ -127,74 +127,6 @@ PolySubsequenceMatcher HasSubsequence(Args &&... 
M) {
 llvm::consumeError(ComputedValue.takeError()); 
\
   } while (false)
 
-// Implements the HasValue(m) matcher for matching an Optional whose
-// value matches matcher m.
-template  class OptionalMatcher {
-public:
-  explicit OptionalMatcher(const InnerMatcher &matcher) : matcher_(matcher) {}
-  OptionalMatcher(const OptionalMatcher&) = default;
-  OptionalMatcher &operator=(const OptionalMatcher&) = delete;
-
-  // This type conversion operator template allows Optional(m) to be
-  // used as a matcher for any Optional type whose value type is
-  // compatible with the inner matcher.
-  //
-  // The reason we do this instead of relying on
-  // MakePolymorphicMatcher() is that the latter is not flexible
-  // enough for implementing the DescribeTo() method of Optional().
-  template  operator Matcher() const {
-return MakeMatcher(new Impl(matcher_));
-  }
-
-private:
-  // The monomorphic implementation that works for a particular optional type.
-  template 
-  class Impl : public ::testing::MatcherInterface {
-  public:
-using Value = typename std::remove_const<
-typename std::remove_reference::type>::type::value_type;
-
-explicit Impl(const InnerMatcher &matcher)
-: matcher_(::testing::MatcherCast(matcher)) {}
-
-Impl(const Impl&) = default;
-Impl &operator=(const Impl&) = delete;
-
-virtual void DescribeTo(::std::ostream *os) const {
-  *os << "has a value that ";
-  matcher_.DescribeTo(os);
-}
-
-virtual void DescribeNegationTo(::std::ostream *os) const {
-  *os << "does not have a value that ";
-  matcher_.DescribeTo(os);
-}
-
-virtual bool
-MatchAndExplain(Optional optional,
-::testing::MatchResultListener *listener) const {
-  if (!optional)
-return false;
-
-  *listener << "which has a value ";
-  return MatchPrintAndExplain(*optional, matcher_, listener);
-}
-
-  private:
-const Matcher matcher_;
-  };
-
-  const InnerMatcher matcher_;
-};
-
-// Creates a matcher that matches an Optional that has a value
-// that matches inner_matcher.
-template 
-inline OptionalMatcher
-HasValue(const InnerMatcher &inner_matcher) {
-  return OptionalMatcher(inner_matcher);
-}
-
 } // namespace clangd
 } // namespace clang
 #endif
diff --git a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp 
b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
index 15158d8a45ca8b..406a842f5a0081 100644
--- a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -28,6 +28,7 @@ using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::Optional;
 using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
 
@@ -38,12 +39,12 @@ MATCHER_P(selectionRangeIs, R, "") { return 
arg.selectionRange == R; }
 template 
 ::testing::Matcher parents(ParentMatchers... ParentsM) {
   return Field(&TypeHierarchyItem::parents,
-   HasValue(UnorderedElementsAre(ParentsM...)));
+   Optional(UnorderedElementsAre(ParentsM...)));
 }
 template 
 ::testing::Matcher children(ChildMatchers... ChildrenM) {
   return Field(&TypeHierarchyItem::children,
-   HasValue(UnorderedElementsAre(ChildrenM...)));
+   Optional(UnorderedElementsAre(ChildrenM...)));
 }
 // Note: "not resolved" is different from "resolved but empty"!
 MATCHER(parentsNotResolved, "") { return !arg.parents; }
@@ -790,7 +791,7 @@ struct Child : Parent1, Parent2 {};
   Children,
   UnorderedElementsAre(
   AllOf(withName("Child"),
-withResolveParents(HasValue(UnorderedElementsAre(withResolveID(
+withResolveParents(Optional(UnorderedElementsAre(withResolveID(
 getSymbolID(&findDecl(AST, "Parent1"

[clang] [Clang][ASTMatcher] Add `dependentNameType` Matcher (PR #121263)

2024-12-29 Thread Nathan Ridge via cfe-commits

HighCommander4 wrote:

@AmrDeveloper if you're not tired of these yet, I have one final one: 
https://github.com/llvm/llvm-project/issues/121307

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


[clang-tools-extra] [clangd] Remove clangd's HasValue GMock matcher (PR #121309)

2024-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-tools-extra

Author: Nathan Ridge (HighCommander4)


Changes

An equivalent matcher under the name Optional has since been added upstream to 
GMock.

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

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


2 Files Affected:

- (modified) clang-tools-extra/clangd/unittests/Matchers.h (-68) 
- (modified) clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp (+6-5) 


``diff
diff --git a/clang-tools-extra/clangd/unittests/Matchers.h 
b/clang-tools-extra/clangd/unittests/Matchers.h
index 0fbd93b2e68825..17d18dd9b85b65 100644
--- a/clang-tools-extra/clangd/unittests/Matchers.h
+++ b/clang-tools-extra/clangd/unittests/Matchers.h
@@ -127,74 +127,6 @@ PolySubsequenceMatcher HasSubsequence(Args &&... 
M) {
 llvm::consumeError(ComputedValue.takeError()); 
\
   } while (false)
 
-// Implements the HasValue(m) matcher for matching an Optional whose
-// value matches matcher m.
-template  class OptionalMatcher {
-public:
-  explicit OptionalMatcher(const InnerMatcher &matcher) : matcher_(matcher) {}
-  OptionalMatcher(const OptionalMatcher&) = default;
-  OptionalMatcher &operator=(const OptionalMatcher&) = delete;
-
-  // This type conversion operator template allows Optional(m) to be
-  // used as a matcher for any Optional type whose value type is
-  // compatible with the inner matcher.
-  //
-  // The reason we do this instead of relying on
-  // MakePolymorphicMatcher() is that the latter is not flexible
-  // enough for implementing the DescribeTo() method of Optional().
-  template  operator Matcher() const {
-return MakeMatcher(new Impl(matcher_));
-  }
-
-private:
-  // The monomorphic implementation that works for a particular optional type.
-  template 
-  class Impl : public ::testing::MatcherInterface {
-  public:
-using Value = typename std::remove_const<
-typename std::remove_reference::type>::type::value_type;
-
-explicit Impl(const InnerMatcher &matcher)
-: matcher_(::testing::MatcherCast(matcher)) {}
-
-Impl(const Impl&) = default;
-Impl &operator=(const Impl&) = delete;
-
-virtual void DescribeTo(::std::ostream *os) const {
-  *os << "has a value that ";
-  matcher_.DescribeTo(os);
-}
-
-virtual void DescribeNegationTo(::std::ostream *os) const {
-  *os << "does not have a value that ";
-  matcher_.DescribeTo(os);
-}
-
-virtual bool
-MatchAndExplain(Optional optional,
-::testing::MatchResultListener *listener) const {
-  if (!optional)
-return false;
-
-  *listener << "which has a value ";
-  return MatchPrintAndExplain(*optional, matcher_, listener);
-}
-
-  private:
-const Matcher matcher_;
-  };
-
-  const InnerMatcher matcher_;
-};
-
-// Creates a matcher that matches an Optional that has a value
-// that matches inner_matcher.
-template 
-inline OptionalMatcher
-HasValue(const InnerMatcher &inner_matcher) {
-  return OptionalMatcher(inner_matcher);
-}
-
 } // namespace clangd
 } // namespace clang
 #endif
diff --git a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp 
b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
index 15158d8a45ca8b..406a842f5a0081 100644
--- a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -28,6 +28,7 @@ using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::Optional;
 using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
 
@@ -38,12 +39,12 @@ MATCHER_P(selectionRangeIs, R, "") { return 
arg.selectionRange == R; }
 template 
 ::testing::Matcher parents(ParentMatchers... ParentsM) {
   return Field(&TypeHierarchyItem::parents,
-   HasValue(UnorderedElementsAre(ParentsM...)));
+   Optional(UnorderedElementsAre(ParentsM...)));
 }
 template 
 ::testing::Matcher children(ChildMatchers... ChildrenM) {
   return Field(&TypeHierarchyItem::children,
-   HasValue(UnorderedElementsAre(ChildrenM...)));
+   Optional(UnorderedElementsAre(ChildrenM...)));
 }
 // Note: "not resolved" is different from "resolved but empty"!
 MATCHER(parentsNotResolved, "") { return !arg.parents; }
@@ -790,7 +791,7 @@ struct Child : Parent1, Parent2 {};
   Children,
   UnorderedElementsAre(
   AllOf(withName("Child"),
-withResolveParents(HasValue(UnorderedElementsAre(withResolveID(
+withResolveParents(Optional(UnorderedElementsAre(withResolveID(
 getSymbolID(&findDecl(AST, "Parent1")).str(;
 }
 
@@ -810,9 +811,9 @@ struct Chil^d : Parent {};
   ASSERT_THAT(Result, SizeIs(1));
   auto Parents = superTypes(Result.front(), Index.get());
 
-  EXPECT_THAT(Parents, HasValue(UnorderedElementsAre(
+  EXPECT_THAT(Parents, Optional(Unor

[clang-tools-extra] [clangd] Remove clangd's HasValue GMock matcher (PR #121309)

2024-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clangd

Author: Nathan Ridge (HighCommander4)


Changes

An equivalent matcher under the name Optional has since been added upstream to 
GMock.

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

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


2 Files Affected:

- (modified) clang-tools-extra/clangd/unittests/Matchers.h (-68) 
- (modified) clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp (+6-5) 


``diff
diff --git a/clang-tools-extra/clangd/unittests/Matchers.h 
b/clang-tools-extra/clangd/unittests/Matchers.h
index 0fbd93b2e68825..17d18dd9b85b65 100644
--- a/clang-tools-extra/clangd/unittests/Matchers.h
+++ b/clang-tools-extra/clangd/unittests/Matchers.h
@@ -127,74 +127,6 @@ PolySubsequenceMatcher HasSubsequence(Args &&... 
M) {
 llvm::consumeError(ComputedValue.takeError()); 
\
   } while (false)
 
-// Implements the HasValue(m) matcher for matching an Optional whose
-// value matches matcher m.
-template  class OptionalMatcher {
-public:
-  explicit OptionalMatcher(const InnerMatcher &matcher) : matcher_(matcher) {}
-  OptionalMatcher(const OptionalMatcher&) = default;
-  OptionalMatcher &operator=(const OptionalMatcher&) = delete;
-
-  // This type conversion operator template allows Optional(m) to be
-  // used as a matcher for any Optional type whose value type is
-  // compatible with the inner matcher.
-  //
-  // The reason we do this instead of relying on
-  // MakePolymorphicMatcher() is that the latter is not flexible
-  // enough for implementing the DescribeTo() method of Optional().
-  template  operator Matcher() const {
-return MakeMatcher(new Impl(matcher_));
-  }
-
-private:
-  // The monomorphic implementation that works for a particular optional type.
-  template 
-  class Impl : public ::testing::MatcherInterface {
-  public:
-using Value = typename std::remove_const<
-typename std::remove_reference::type>::type::value_type;
-
-explicit Impl(const InnerMatcher &matcher)
-: matcher_(::testing::MatcherCast(matcher)) {}
-
-Impl(const Impl&) = default;
-Impl &operator=(const Impl&) = delete;
-
-virtual void DescribeTo(::std::ostream *os) const {
-  *os << "has a value that ";
-  matcher_.DescribeTo(os);
-}
-
-virtual void DescribeNegationTo(::std::ostream *os) const {
-  *os << "does not have a value that ";
-  matcher_.DescribeTo(os);
-}
-
-virtual bool
-MatchAndExplain(Optional optional,
-::testing::MatchResultListener *listener) const {
-  if (!optional)
-return false;
-
-  *listener << "which has a value ";
-  return MatchPrintAndExplain(*optional, matcher_, listener);
-}
-
-  private:
-const Matcher matcher_;
-  };
-
-  const InnerMatcher matcher_;
-};
-
-// Creates a matcher that matches an Optional that has a value
-// that matches inner_matcher.
-template 
-inline OptionalMatcher
-HasValue(const InnerMatcher &inner_matcher) {
-  return OptionalMatcher(inner_matcher);
-}
-
 } // namespace clangd
 } // namespace clang
 #endif
diff --git a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp 
b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
index 15158d8a45ca8b..406a842f5a0081 100644
--- a/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TypeHierarchyTests.cpp
@@ -28,6 +28,7 @@ using ::testing::ElementsAre;
 using ::testing::Field;
 using ::testing::IsEmpty;
 using ::testing::Matcher;
+using ::testing::Optional;
 using ::testing::SizeIs;
 using ::testing::UnorderedElementsAre;
 
@@ -38,12 +39,12 @@ MATCHER_P(selectionRangeIs, R, "") { return 
arg.selectionRange == R; }
 template 
 ::testing::Matcher parents(ParentMatchers... ParentsM) {
   return Field(&TypeHierarchyItem::parents,
-   HasValue(UnorderedElementsAre(ParentsM...)));
+   Optional(UnorderedElementsAre(ParentsM...)));
 }
 template 
 ::testing::Matcher children(ChildMatchers... ChildrenM) {
   return Field(&TypeHierarchyItem::children,
-   HasValue(UnorderedElementsAre(ChildrenM...)));
+   Optional(UnorderedElementsAre(ChildrenM...)));
 }
 // Note: "not resolved" is different from "resolved but empty"!
 MATCHER(parentsNotResolved, "") { return !arg.parents; }
@@ -790,7 +791,7 @@ struct Child : Parent1, Parent2 {};
   Children,
   UnorderedElementsAre(
   AllOf(withName("Child"),
-withResolveParents(HasValue(UnorderedElementsAre(withResolveID(
+withResolveParents(Optional(UnorderedElementsAre(withResolveID(
 getSymbolID(&findDecl(AST, "Parent1")).str(;
 }
 
@@ -810,9 +811,9 @@ struct Chil^d : Parent {};
   ASSERT_THAT(Result, SizeIs(1));
   auto Parents = superTypes(Result.front(), Index.get());
 
-  EXPECT_THAT(Parents, HasValue(UnorderedElementsAre(
+  EXPECT_THAT(Parents, Optional(UnorderedElemen

[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)

2024-12-29 Thread Galen Elias via cfe-commits

https://github.com/galenelias updated 
https://github.com/llvm/llvm-project/pull/105597

>From 93eb3d89652607173f4f68fce7dcc5b2bd33f266 Mon Sep 17 00:00:00 2001
From: Galen Elias 
Date: Wed, 21 Aug 2024 16:33:42 -0700
Subject: [PATCH 01/16] clang-format: Add "AllowShortNamespacesOnASingleLine"
 option

This addresses: https://github.com/llvm/llvm-project/issues/101363
which is a resurrection of a previously opened but never completed
review: https://reviews.llvm.org/D11851

The feature is to allow code like the following not to be broken across
multiple lines:

```
namespace foo { class bar; }
namespace foo { namespace bar { class baz; } }
```

Code like this is commonly used for forward declarations, which are
ideally kept compact. This is also apparently the format that
include-what-you-use will insert for forward declarations.
---
 clang/include/clang/Format/Format.h |   5 +
 clang/lib/Format/Format.cpp |   3 +
 clang/lib/Format/UnwrappedLineFormatter.cpp |  82 ++
 clang/unittests/Format/FormatTest.cpp   | 112 
 4 files changed, 202 insertions(+)

diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6383934afa2c40..26cd673685942e 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -988,6 +988,11 @@ struct FormatStyle {
   /// \version 3.7
   bool AllowShortLoopsOnASingleLine;
 
+  /// If ``true``, ``namespace a { class b; }`` can be put on a single a single
+  /// line.
+  /// \version 19
+  bool AllowShortNamespacesOnASingleLine;
+
   /// Different ways to break after the function definition return type.
   /// This option is **deprecated** and is retained for backwards 
compatibility.
   enum DefinitionReturnTypeBreakingStyle : int8_t {
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 95129a8fe9240c..8f44e9f00212cf 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -975,6 +975,8 @@ template <> struct MappingTraits {
Style.AllowShortLambdasOnASingleLine);
 IO.mapOptional("AllowShortLoopsOnASingleLine",
Style.AllowShortLoopsOnASingleLine);
+IO.mapOptional("AllowShortNamespacesOnASingleLine",
+   Style.AllowShortNamespacesOnASingleLine);
 IO.mapOptional("AlwaysBreakAfterDefinitionReturnType",
Style.AlwaysBreakAfterDefinitionReturnType);
 IO.mapOptional("AlwaysBreakBeforeMultilineStrings",
@@ -1480,6 +1482,7 @@ FormatStyle getLLVMStyle(FormatStyle::LanguageKind 
Language) {
   LLVMStyle.AllowShortIfStatementsOnASingleLine = FormatStyle::SIS_Never;
   LLVMStyle.AllowShortLambdasOnASingleLine = FormatStyle::SLS_All;
   LLVMStyle.AllowShortLoopsOnASingleLine = false;
+  LLVMStyle.AllowShortNamespacesOnASingleLine = false;
   LLVMStyle.AlwaysBreakAfterDefinitionReturnType = FormatStyle::DRTBS_None;
   LLVMStyle.AlwaysBreakBeforeMultilineStrings = false;
   LLVMStyle.AttributeMacros.push_back("__capability");
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 1804c1437fd41d..971eac1978bb71 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -420,6 +420,15 @@ class LineJoiner {
 TheLine->First != LastNonComment) {
   return MergeShortFunctions ? tryMergeSimpleBlock(I, E, Limit) : 0;
 }
+
+if (TheLine->Last->is(tok::l_brace)) {
+  if (Style.AllowShortNamespacesOnASingleLine &&
+  TheLine->First->is(tok::kw_namespace)) {
+if (unsigned result = tryMergeNamespace(I, E, Limit))
+  return result;
+  }
+}
+
 // Try to merge a control statement block with left brace unwrapped.
 if (TheLine->Last->is(tok::l_brace) && FirstNonComment != TheLine->Last &&
 FirstNonComment->isOneOf(tok::kw_if, tok::kw_while, tok::kw_for,
@@ -616,6 +625,62 @@ class LineJoiner {
 return 1;
   }
 
+  unsigned tryMergeNamespace(SmallVectorImpl::const_iterator 
I,
+ SmallVectorImpl::const_iterator 
E,
+ unsigned Limit) {
+if (Limit == 0)
+  return 0;
+if (I[1]->InPPDirective != (*I)->InPPDirective ||
+(I[1]->InPPDirective && I[1]->First->HasUnescapedNewline)) {
+  return 0;
+}
+if (I + 2 == E || I[2]->Type == LT_Invalid)
+  return 0;
+
+Limit = limitConsideringMacros(I + 1, E, Limit);
+
+if (!nextTwoLinesFitInto(I, Limit))
+  return 0;
+
+// Check if it's a namespace inside a namespace, and call recursively if so
+// '3' is the sizes of the whitespace and closing brace for " _inner_ }"
+if (I[1]->First->is(tok::kw_namespace)) {
+  if (I[1]->Last->is(TT_LineComment))
+return 0;
+
+  unsigned inner_limit = Limit - I[1]->Last->TotalLength - 3;
+  unsigned inner_result = tryMergeNamespace(I + 1, E, inner_limit);
+  if (!inner_result)
+  

[clang] [clang-format] Add `AllowShortNamespacesOnASingleLine` option (PR #105597)

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


@@ -4504,6 +4504,16 @@ TEST_F(FormatTest, FormatsCompactNamespaces) {
"} // namespace bb\n"
"} // namespace aa",
Style);
+
+  verifyFormat("namespace a { namespace b { namespace c {\n"
+   "}}} // namespace a::b::c",
+   Style);
+
+  verifyFormat("namespace a { namespace b {\n"
+   "namespace cc {\n"
+   "}}} // namespace a::b::cc",

owenca wrote:

I agree, but in this particular case the bug occurs when the length is over the 
column limit, not when it's within the limit?

The following test case for `ColumnLimit: 41`:
```
namespace a { namespace b { namespace cc {
}}} // namespace a::b::cc
```
is equivalent to the test case below with `ColumnLimit: 40`:
```
namespace a { namespace b { namespace c {
}}} // namespace a::b::c
```

If you want to test that your fix doesn't break the existing behavior when the 
length is at the limit, I suggest that you reuse the existing test case:
```cpp
   verifyFormat("namespace out {\n"
"int i;\n"
"namespace in {\n"
"int j;\n"
"} // namespace in\n"
"int k;\n"
"} // namespace out",
"namespace out { int i;\n"
"namespace in { int j; } // namespace in\n"
"int k; } // namespace out",
Style);
 
+  Style.ColumnLimit = 41;
   verifyFormat("namespace A { namespace B { namespace C {\n"
"}}} // namespace A::B::C",
"namespace A { namespace B {\n"
"namespace C {\n"
"}} // namespace B::C\n"
"} // namespace A",
Style);
 
   Style.ColumnLimit = 40;
   verifyFormat("namespace aa {\n"
"namespace bb {\n"
"}} // namespace aa::bb",
"namespace aa {\n"
"namespace bb {\n"
"} // namespace bb\n"
"} // namespace aa",
Style);
```
FormatTest.cpp is 28K+ lines long and still growing. It should be broken up 
into multiple files. Until then, I prefer that we don't add nice-to-have new 
tests that aren't absolutely related to the pull request.

https://github.com/llvm/llvm-project/pull/105597
___
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 depercation warning for non-whitelisted global options (PR #121057)

2024-12-29 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

> that it is kept for future deprecations (and would therefore need to be 
> general enough)

Yes, that was my thought, having a general-purpose mechanism for deprecation 
warnings (a bit what I mentioned in the RFC).

Maybe something like `--no-deprecation-warnings` or 
`--ignore-deprecation-warnings`?

> Unless someone is in the position that you've described

I believe


https://github.com/llvm/llvm-project/pull/121057
___
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 depercation warning for non-whitelisted global options (PR #121057)

2024-12-29 Thread Carlos Galvez via cfe-commits

carlosgalvezp wrote:

> that it is kept for future deprecations (and would therefore need to be 
> general enough)

Yes, that was my thought, some general-purpose mechanism for deprecation 
warnings, for example `--disable-deprecation-warnings`, 
`--no-deprecation-warnings`, etc.

The use case I have in mind is when e.g. a 3rd-party .cpp file is pulled in via 
the compilation database, normally it will be analyzed via its own .clang-tidy 
file that normally one doesn't have control over. One could however argue that 
one should probably only analyze own source files, not 3rd-party ones. One 
probably also doesn't want to disable deprecation warnings globally just 
because a 3rd-party triggers them - it'd be better to filter out such 3rd-party 
code from analysis.

Perhaps we can just land this as is for now and introduce the escape hatch if 
we get feedback indicating it's needed?

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


[clang] [clang-format] Add VariableTemplate option (PR #121318)

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

https://github.com/owenca created 
https://github.com/llvm/llvm-project/pull/121318

Closes #120148.

>From 8f61998f9a5339a9c1c04176bf3d74331532eb75 Mon Sep 17 00:00:00 2001
From: Owen Pan 
Date: Sun, 29 Dec 2024 20:17:46 -0800
Subject: [PATCH] [clang-format] Add VariableTemplate option

Closes #120148.
---
 clang/docs/ClangFormatStyleOptions.rst| 13 +++--
 clang/docs/ReleaseNotes.rst   |  1 +
 clang/include/clang/Format/Format.h   | 15 ---
 clang/lib/Format/Format.cpp   |  1 +
 clang/lib/Format/FormatToken.h|  1 +
 clang/lib/Format/FormatTokenLexer.cpp |  4 
 clang/lib/Format/FormatTokenLexer.h   |  3 ++-
 clang/lib/Format/TokenAnnotator.cpp   | 19 +++
 clang/unittests/Format/TokenAnnotatorTest.cpp | 13 +
 9 files changed, 60 insertions(+), 10 deletions(-)

diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4be448171699ca..d7456fb701563d 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6725,8 +6725,8 @@ the configuration (without a prefix: ``Auto``).
 .. _TemplateNames:
 
 **TemplateNames** (``List of Strings``) :versionbadge:`clang-format 20` 
:ref:`¶ `
-  A vector of non-keyword identifiers that should be interpreted as
-  template names.
+  A vector of non-keyword identifiers that should be interpreted as template
+  names.
 
   A ``<`` after a template name is annotated as a template opener instead of
   a binary operator.
@@ -6793,6 +6793,15 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+.. _VariableTemplates:
+
+**VariableTemplates** (``List of Strings``) :versionbadge:`clang-format 20` 
:ref:`¶ `
+  A vector of non-keyword identifiers that should be interpreted as variable
+  template names.
+
+  A ``)`` after a non-variable template instantiation may be annotated as
+  the closing parenthesis of the C-style cast operator.
+
 .. _VerilogBreakBetweenInstancePorts:
 
 **VerilogBreakBetweenInstancePorts** (``Boolean``) :versionbadge:`clang-format 
17` :ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d9b0cb815a15db..f05a95e31dc255 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1118,6 +1118,7 @@ clang-format
   ``Never``, and ``true`` to ``Always``.
 - Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
 - Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
+- Adds ``VariableTemplates`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6383934afa2c40..b245b753624980 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -5038,8 +5038,8 @@ struct FormatStyle {
   /// \version 3.7
   unsigned TabWidth;
 
-  /// A vector of non-keyword identifiers that should be interpreted as
-  /// template names.
+  /// A vector of non-keyword identifiers that should be interpreted as 
template
+  /// names.
   ///
   /// A ``<`` after a template name is annotated as a template opener instead 
of
   /// a binary operator.
@@ -5099,6 +5099,15 @@ struct FormatStyle {
   /// \version 3.7
   UseTabStyle UseTab;
 
+  /// A vector of non-keyword identifiers that should be interpreted as 
variable
+  /// template names.
+  ///
+  /// A ``)`` after a non-variable template instantiation may be annotated as
+  /// the closing parenthesis of the C-style cast operator.
+  ///
+  /// \version 20
+  std::vector VariableTemplates;
+
   /// For Verilog, put each port on its own line in module instantiations.
   /// \code
   ///true:
@@ -5308,7 +5317,7 @@ struct FormatStyle {
TableGenBreakInsideDAGArg == R.TableGenBreakInsideDAGArg &&
TabWidth == R.TabWidth && TemplateNames == R.TemplateNames &&
TypeNames == R.TypeNames && TypenameMacros == R.TypenameMacros &&
-   UseTab == R.UseTab &&
+   UseTab == R.UseTab && VariableTemplates == R.VariableTemplates &&
VerilogBreakBetweenInstancePorts ==
R.VerilogBreakBetweenInstancePorts &&
WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 95129a8fe9240c..fe5465ce7b09de 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1164,6 +1164,7 @@ template <> struct MappingTraits {
 IO.mapOptional("TypeNames", Style.TypeNames);
 IO.mapOptional("TypenameMacros", Style.TypenameMacros);
 IO.mapOptional("UseTab", Style.UseTab);
+IO.mapOptional("VariableTemplates", Style.VariableTemplates);
 IO.mapOptional("VerilogBreakBetweenInstancePorts",
Style.VerilogBreakBetweenInstancePorts);
 IO.mapOptional("WhitespaceSensitiveMacros",
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index f6bb860a1fea31.

[clang] [clang-format] Add VariableTemplate option (PR #121318)

2024-12-29 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Owen Pan (owenca)


Changes

Closes #120148.

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


9 Files Affected:

- (modified) clang/docs/ClangFormatStyleOptions.rst (+11-2) 
- (modified) clang/docs/ReleaseNotes.rst (+1) 
- (modified) clang/include/clang/Format/Format.h (+12-3) 
- (modified) clang/lib/Format/Format.cpp (+1) 
- (modified) clang/lib/Format/FormatToken.h (+1) 
- (modified) clang/lib/Format/FormatTokenLexer.cpp (+4) 
- (modified) clang/lib/Format/FormatTokenLexer.h (+2-1) 
- (modified) clang/lib/Format/TokenAnnotator.cpp (+15-4) 
- (modified) clang/unittests/Format/TokenAnnotatorTest.cpp (+13) 


``diff
diff --git a/clang/docs/ClangFormatStyleOptions.rst 
b/clang/docs/ClangFormatStyleOptions.rst
index 4be448171699ca..d7456fb701563d 100644
--- a/clang/docs/ClangFormatStyleOptions.rst
+++ b/clang/docs/ClangFormatStyleOptions.rst
@@ -6725,8 +6725,8 @@ the configuration (without a prefix: ``Auto``).
 .. _TemplateNames:
 
 **TemplateNames** (``List of Strings``) :versionbadge:`clang-format 20` 
:ref:`¶ `
-  A vector of non-keyword identifiers that should be interpreted as
-  template names.
+  A vector of non-keyword identifiers that should be interpreted as template
+  names.
 
   A ``<`` after a template name is annotated as a template opener instead of
   a binary operator.
@@ -6793,6 +6793,15 @@ the configuration (without a prefix: ``Auto``).
 
 
 
+.. _VariableTemplates:
+
+**VariableTemplates** (``List of Strings``) :versionbadge:`clang-format 20` 
:ref:`¶ `
+  A vector of non-keyword identifiers that should be interpreted as variable
+  template names.
+
+  A ``)`` after a non-variable template instantiation may be annotated as
+  the closing parenthesis of the C-style cast operator.
+
 .. _VerilogBreakBetweenInstancePorts:
 
 **VerilogBreakBetweenInstancePorts** (``Boolean``) :versionbadge:`clang-format 
17` :ref:`¶ `
diff --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index d9b0cb815a15db..f05a95e31dc255 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -1118,6 +1118,7 @@ clang-format
   ``Never``, and ``true`` to ``Always``.
 - Adds ``RemoveEmptyLinesInUnwrappedLines`` option.
 - Adds ``KeepFormFeed`` option and set it to ``true`` for ``GNU`` style.
+- Adds ``VariableTemplates`` option.
 
 libclang
 
diff --git a/clang/include/clang/Format/Format.h 
b/clang/include/clang/Format/Format.h
index 6383934afa2c40..b245b753624980 100644
--- a/clang/include/clang/Format/Format.h
+++ b/clang/include/clang/Format/Format.h
@@ -5038,8 +5038,8 @@ struct FormatStyle {
   /// \version 3.7
   unsigned TabWidth;
 
-  /// A vector of non-keyword identifiers that should be interpreted as
-  /// template names.
+  /// A vector of non-keyword identifiers that should be interpreted as 
template
+  /// names.
   ///
   /// A ``<`` after a template name is annotated as a template opener instead 
of
   /// a binary operator.
@@ -5099,6 +5099,15 @@ struct FormatStyle {
   /// \version 3.7
   UseTabStyle UseTab;
 
+  /// A vector of non-keyword identifiers that should be interpreted as 
variable
+  /// template names.
+  ///
+  /// A ``)`` after a non-variable template instantiation may be annotated as
+  /// the closing parenthesis of the C-style cast operator.
+  ///
+  /// \version 20
+  std::vector VariableTemplates;
+
   /// For Verilog, put each port on its own line in module instantiations.
   /// \code
   ///true:
@@ -5308,7 +5317,7 @@ struct FormatStyle {
TableGenBreakInsideDAGArg == R.TableGenBreakInsideDAGArg &&
TabWidth == R.TabWidth && TemplateNames == R.TemplateNames &&
TypeNames == R.TypeNames && TypenameMacros == R.TypenameMacros &&
-   UseTab == R.UseTab &&
+   UseTab == R.UseTab && VariableTemplates == R.VariableTemplates &&
VerilogBreakBetweenInstancePorts ==
R.VerilogBreakBetweenInstancePorts &&
WhitespaceSensitiveMacros == R.WhitespaceSensitiveMacros;
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 95129a8fe9240c..fe5465ce7b09de 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -1164,6 +1164,7 @@ template <> struct MappingTraits {
 IO.mapOptional("TypeNames", Style.TypeNames);
 IO.mapOptional("TypenameMacros", Style.TypenameMacros);
 IO.mapOptional("UseTab", Style.UseTab);
+IO.mapOptional("VariableTemplates", Style.VariableTemplates);
 IO.mapOptional("VerilogBreakBetweenInstancePorts",
Style.VerilogBreakBetweenInstancePorts);
 IO.mapOptional("WhitespaceSensitiveMacros",
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index f6bb860a1fea31..8917049cefb865 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -186,6 +186,7 @@ namespace format {
   TYPE(UnionLBrace)

[clang-tools-extra] [clang-tidy] Add an option to exclude files not present in the compile database (PR #120348)

2024-12-29 Thread via cfe-commits

https://github.com/wonbinbk updated 
https://github.com/llvm/llvm-project/pull/120348

>From 062cecdcec24a807bd4bab5985a6ad339de3cfe6 Mon Sep 17 00:00:00 2001
From: wonbinbk 
Date: Wed, 18 Dec 2024 15:33:55 +1300
Subject: [PATCH 1/2] [clang-tidy] Add an option to exclude files not present
 in the compilation database

A change list may include files that are not part of the compilation
database, which can cause clang-tidy to fail (e.g., due to missing
included headers). To prevent false negatives, we should allow to skip
processing these files.
---
 .../clang-tidy/tool/clang-tidy-diff.py| 29 +++
 clang-tools-extra/docs/ReleaseNotes.rst   |  3 ++
 2 files changed, 32 insertions(+)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index 62cb4297c50f75..a1d3598422bf24 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -35,6 +35,7 @@
 import tempfile
 import threading
 import traceback
+from pathlib import Path
 
 try:
 import yaml
@@ -124,6 +125,21 @@ def merge_replacement_files(tmpdir, mergefile):
 open(mergefile, "w").close()
 
 
+def get_compiling_files(args):
+""" Read a compile_commands.json database and return a set of file paths 
"""
+current_dir = Path.cwd()
+compile_commands_json = (current_dir / args.build_path) if args.build_path 
else current_dir
+compile_commands_json = (compile_commands_json / "compile_commands.json")
+files = set()
+with open(compile_commands_json) as db_file:
+db_json = json.load(db_file)
+for entry in db_json:
+if "file" not in entry:
+continue
+files.add(Path(entry["file"]))
+return files
+
+
 def main():
 parser = argparse.ArgumentParser(
 description="Run clang-tidy against changed files, and "
@@ -234,6 +250,13 @@ def main():
 action="store_true",
 help="Allow empty enabled checks.",
 )
+parser.add_argument(
+"-only-check-in-db",
+dest="skip_non_compiling",
+default=False,
+action="store_true",
+help="Only check files in the compilation database",
+)
 
 clang_tidy_args = []
 argv = sys.argv[1:]
@@ -243,6 +266,8 @@ def main():
 
 args = parser.parse_args(argv)
 
+compiling_files = get_compiling_files(args) if args.skip_non_compiling 
else None
+
 # Extract changed lines for each file.
 filename = None
 lines_by_file = {}
@@ -260,6 +285,10 @@ def main():
 if not re.match("^%s$" % args.iregex, filename, re.IGNORECASE):
 continue
 
+# Skip any files not in the compiling list
+if compiling_files is not None and (Path.cwd() / filename) not in 
compiling_files:
+continue
+
 match = re.search(r"^@@.*\+(\d+)(,(\d+))?", line)
 if match:
 start_line = int(match.group(1))
diff --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index fabd0cc78ac645..dc2d5871148b35 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -115,6 +115,9 @@ Improvements to clang-tidy
 - Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
   happening on certain platforms when interrupting the script.
 
+- Improved :program:`clang-tidy-diff.py` script. Add an option to exclude files
+  not present in the compilation database to avoid false negative results.
+
 - Improved :program:`clang-tidy` by accepting parameters file in command line.
 
 - Removed :program:`clang-tidy`'s global options for most of checks. All 
options

>From d95df90ab3ea7f8ec4280d6a7a35f3f2aa926f84 Mon Sep 17 00:00:00 2001
From: wonbinbk 
Date: Tue, 24 Dec 2024 09:54:05 +1300
Subject: [PATCH 2/2] [clang-tidy] Use raw string for regex pattern

---
 clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py 
b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
index a1d3598422bf24..2cb1cc4598073b 100755
--- a/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
+++ b/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py
@@ -272,7 +272,7 @@ def main():
 filename = None
 lines_by_file = {}
 for line in sys.stdin:
-match = re.search('^\\+\\+\\+\\ "?(.*?/){%s}([^ \t\n"]*)' % args.p, 
line)
+match = re.search(r'^\+\+\+\ "?(.*?/){%s}([^ \t\n"]*)' % args.p, line)
 if match:
 filename = match.group(2)
 if filename is None:

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


[clang] [diagtool] Make the BuiltinDiagnosticsByID table sorted (PR #120321)

2024-12-29 Thread via cfe-commits


@@ -23,28 +23,29 @@ llvm::ArrayRef 
diagtool::getBuiltinDiagnosticsByName() {
   return llvm::ArrayRef(BuiltinDiagnosticsByName);
 }
 
-
 // FIXME: Is it worth having two tables, especially when this one can get
 // out of sync easily?
+// clang-format off
 static const DiagnosticRecord BuiltinDiagnosticsByID[] = {
 #define DIAG(ENUM, CLASS, DEFAULT_MAPPING, DESC, GROUP, SFINAE, NOWERROR,  
\
  SHOWINSYSHEADER, SHOWINSYSMACRO, DEFER, CATEGORY) 
\
   {#ENUM, diag::ENUM, STR_SIZE(#ENUM, uint8_t)},
 #include "clang/Basic/DiagnosticCommonKinds.inc"
-#include "clang/Basic/DiagnosticCrossTUKinds.inc"
 #include "clang/Basic/DiagnosticDriverKinds.inc"
 #include "clang/Basic/DiagnosticFrontendKinds.inc"
 #include "clang/Basic/DiagnosticSerializationKinds.inc"
 #include "clang/Basic/DiagnosticLexKinds.inc"
 #include "clang/Basic/DiagnosticParseKinds.inc"
 #include "clang/Basic/DiagnosticASTKinds.inc"
 #include "clang/Basic/DiagnosticCommentKinds.inc"
+#include "clang/Basic/DiagnosticCrossTUKinds.inc"

cor3ntin wrote:

This seems brittle - Maybe we should call `std::sort` somewhere instead?

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