[PATCH] D143840: [clang] Add the check of membership for the issue #58674 and improve the lookup process

2023-02-19 Thread Liming Liu via Phabricator via cfe-commits
lime added a comment.

Ping!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143840/new/

https://reviews.llvm.org/D143840

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


[PATCH] D142655: [clang-tidy] Introduce HeaderFileExtensions and ImplementationFileExtensions options

2023-02-19 Thread Carlos Galvez via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5b37cddff8e0: [clang-tidy] Introduce HeaderFileExtensions 
and ImplementationFileExtensions… (authored by carlosgalvezp).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142655/new/

https://reviews.llvm.org/D142655

Files:
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
  clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/FileExtensionsSet.h
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
  clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
  clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
  clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
  clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h
  clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
  clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
  clang-tools-extra/clang-tidy/utils/HeaderGuard.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-include.rst
  clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst
  clang-tools-extra/docs/clang-tidy/checks/google/global-names-in-headers.rst
  clang-tools-extra/docs/clang-tidy/checks/llvm/header-guard.rst
  clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
  clang-tools-extra/docs/clang-tidy/checks/misc/definitions-in-headers.rst
  clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst
  clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
  clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
===
--- clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
+++ clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp
@@ -76,13 +76,20 @@
 
 TEST(ParseConfiguration, ValidConfiguration) {
   llvm::ErrorOr Options =
-  parseConfiguration(llvm::MemoryBufferRef("Checks: \"-*,misc-*\"\n"
-   "HeaderFilterRegex: \".*\"\n"
-   "AnalyzeTemporaryDtors: true\n"
-   "User: some.user",
-   "Options"));
+  parseConfiguration(llvm::MemoryBufferRef(
+  "Checks: \"-*,misc-*\"\n"
+  "HeaderFileExtensions: [\"\",\"h\",\"hh\",\"hpp\",\"hxx\"]\n"
+  "ImplementationFileExtensions: [\"c\",\"cc\",\"cpp\",\"cxx\"]\n"
+  "HeaderFilterRegex: \".*\"\n"
+  "AnalyzeTemporaryDtors: true\n"
+  "User: some.user",
+  "Options"));
   EXPECT_TRUE(!!Options);
   EXPECT_EQ("-*,misc-*", *Options->Checks);
+  EXPECT_EQ(std::vector({"", "h", "hh", "hpp", "hxx"}),
+*Options->HeaderFileExtensions);
+  EXPECT_EQ(std::vector({"c", "cc", "cpp", "cxx"}),
+*Options->ImplementationFileExtensions);
   EXPECT_EQ(".*", *Options->HeaderFilterRegex);
   EXPECT_EQ("some.user", *Options->User);
 }
@@ -105,6 +112,8 @@
   llvm::ErrorOr Options1 =
   parseConfiguration(llvm::MemoryBufferRef(R"(
   Checks: "check1,check2"
+  HeaderFileExtensions: ["h","hh"]
+  ImplementationFileExtensions: ["c","cc"]
   HeaderFilterRegex: "filter1"
   AnalyzeTemporaryDtors: true
   User: user1
@@ -117,6 +126,8 @@
   llvm::ErrorOr Options2 =
   parseConfiguration(llvm::MemoryBufferRef(R"(
   Checks: "check3,check4"
+  HeaderFileExtensions: ["hpp","hxx"]
+  ImplementationFileExtensions: ["cpp","cxx"]
   HeaderFilterRegex: "filter2"
   AnalyzeTemporaryDtors: false
   User: user2
@@ -128,6 +139,10 @@
   ASSERT_TRUE(!!Options2);
   ClangTidyOptions Options = Options1->merge(*Options2, 0);
   EXPECT_EQ("check1,check2,check3,check4", *Options.Checks);
+  

[clang-tools-extra] 5b37cdd - [clang-tidy] Introduce HeaderFileExtensions and ImplementationFileExtensions options

2023-02-19 Thread Carlos Galvez via cfe-commits

Author: Carlos Galvez
Date: 2023-02-19T13:44:11Z
New Revision: 5b37cddff8e0140420ad776066529cf8f41d64d2

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

LOG: [clang-tidy] Introduce HeaderFileExtensions and 
ImplementationFileExtensions options

Re-introduce the patch that was reverted previously.
In the first attempt, the checks would not be able to
read from the global option, since getLocalOrGlobal
only works with string types. Additional logic is needed
in order to support both use cases in the transition
period. All that logic will be removed when the local
options are fully removed.

We have a number of checks designed to analyze problems
in header files only, for example:

bugprone-suspicious-include
google-build-namespaces
llvm-header-guard
misc-definitions-in-header
...

All these checks duplicate the same logic and options
to determine whether a location is placed in the main
source file or in the header. More checks are coming
up with similar requirements.

Thus, to remove duplication, let's move this option
to the top-level configuration of clang-tidy (since
it's something all checks should share).

Add a deprecation notice for all checks that use the
local option, prompting to update to the global option.

Differential Revision: https://reviews.llvm.org/D142655

Added: 
clang-tools-extra/clang-tidy/FileExtensionsSet.h

Modified: 
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
clang-tools-extra/clang-tidy/ClangTidyOptions.h
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.cpp
clang-tools-extra/clang-tidy/bugprone/DynamicStaticInitializersCheck.h
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.cpp
clang-tools-extra/clang-tidy/bugprone/SuspiciousIncludeCheck.h
clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.cpp
clang-tools-extra/clang-tidy/google/GlobalNamesInHeadersCheck.h
clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.cpp
clang-tools-extra/clang-tidy/google/UnnamedNamespaceInHeaderCheck.h
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.cpp
clang-tools-extra/clang-tidy/llvmlibc/InlineFunctionDeclCheck.h
clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.cpp
clang-tools-extra/clang-tidy/misc/DefinitionsInHeadersCheck.h
clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.h
clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.cpp
clang-tools-extra/clang-tidy/misc/UseAnonymousNamespaceCheck.h
clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/clang-tidy/utils/FileExtensionsUtils.h
clang-tools-extra/clang-tidy/utils/HeaderGuard.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/bugprone/suspicious-include.rst
clang-tools-extra/docs/clang-tidy/checks/google/build-namespaces.rst
clang-tools-extra/docs/clang-tidy/checks/google/global-names-in-headers.rst
clang-tools-extra/docs/clang-tidy/checks/llvm/header-guard.rst
clang-tools-extra/docs/clang-tidy/checks/llvmlibc/inline-function-decl.rst
clang-tools-extra/docs/clang-tidy/checks/misc/definitions-in-headers.rst
clang-tools-extra/docs/clang-tidy/checks/misc/unused-using-decls.rst
clang-tools-extra/docs/clang-tidy/checks/misc/use-anonymous-namespace.rst
clang-tools-extra/docs/clang-tidy/index.rst
clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp 
b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
index 11ee7a09a112b..9d693bd94f40a 100644
--- a/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
+++ b/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
@@ -22,6 +22,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/AST/ASTDiagnostic.h"
 #include "clang/AST/Attr.h"
+#include "clang/Basic/CharInfo.h"
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
@@ -222,12 +223,30 @@ void ClangTidyContext::setSourceManager(SourceManager 
*SourceMgr) {
   DiagEngine->setSourceManager(SourceMgr);
 }
 
+static bool parseFileExtensions(llvm::ArrayRef AllFileExtensions,
+FileExtensionsSet ) {
+  FileExtensions.clear();
+  for (StringRef Suffix : AllFileExtensions) {
+StringRef Extension = Suffix.trim();
+if (!llvm::all_of(Extension, isAlphanumeric))
+  return false;
+

[clang-tools-extra] 14fee3d - Fix clang-tools-extra docs build

2023-02-19 Thread Carlos Galvez via cfe-commits

Author: Carlos Galvez
Date: 2023-02-19T13:58:31Z
New Revision: 14fee3d7d36927d3e8940cbcaab70fa4e99e2ec2

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

LOG: Fix clang-tools-extra docs build

Added: 


Modified: 
clang-tools-extra/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang-tools-extra/docs/ReleaseNotes.rst 
b/clang-tools-extra/docs/ReleaseNotes.rst
index 69d89c3ee6c86..6b757656377d3 100644
--- a/clang-tools-extra/docs/ReleaseNotes.rst
+++ b/clang-tools-extra/docs/ReleaseNotes.rst
@@ -166,7 +166,7 @@ Changes in existing checks
 
 - Deprecated check-local options `HeaderFileExtensions`
   in :doc:`misc-unused-using-decls
-  ` check.
+  ` check.
   Global options of the same name should be used instead.
 
 Removed checks



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


[PATCH] D144352: Do not emit exception diagnostics from coroutines and coroutine lambdas

2023-02-19 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci created this revision.
denizevrenci added reviewers: NoQ, gribozavr.
Herald added a subscriber: ChuanqiXu.
Herald added a project: All.
denizevrenci requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Fixes #48797

All exceptions thrown in coroutine bodies are caught and
`unhandled_exception` member of the coroutine promise type is called.
In accordance with the existing rules of diagnostics related to
exceptions thrown in functions marked `noexcept`, even if the promise
type's constructor, `get_return_object`, or `unhandled_exception`
throws, diagnostics should not be emitted.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144352

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp


Index: clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -std=c++20 %s -fcxx-exceptions -fsyntax-only -Wexceptions 
-verify -fdeclspec
+
+#include "Inputs/std-coroutine.h"
+
+// expected-no-diagnostics
+
+template 
+struct promise;
+ 
+template 
+struct task {
+using promise_type = promise;
+
+explicit task(promise_type& p) noexcept { p.return_val = this; }
+
+task(const task&) = delete;
+
+T value;
+};
+ 
+template 
+struct promise {
+task get_return_object() noexcept { return task{*this}; }
+
+std::suspend_never initial_suspend() const noexcept { return {}; }
+
+std::suspend_never final_suspend() const noexcept { return {}; }
+
+template 
+void return_value(U&& val) { return_val->value = static_cast(val); }
+
+void unhandled_exception() {}
+
+task* return_val;
+};
+
+task a_ShouldNotDiag(const int a, const int b) {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+task b_ShouldNotDiag(const int a, const int b) noexcept {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+const auto c_ShouldNotDiag = [](const int a, const int b) -> task {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+};
+
+const auto d_ShouldNotDiag = [](const int a, const int b) noexcept -> 
task {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+};
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2509,7 +2509,7 @@
   // Check for throw out of non-throwing function.
   if (!Diags.isIgnored(diag::warn_throw_in_noexcept_func, D->getBeginLoc()))
 if (const FunctionDecl *FD = dyn_cast(D))
-  if (S.getLangOpts().CPlusPlus && isNoexcept(FD))
+  if (S.getLangOpts().CPlusPlus && !fscope->isCoroutine() && 
isNoexcept(FD))
 checkThrowInNonThrowingFunc(S, FD, AC);
 
   // Emit unsafe buffer usage warnings and fixits.


Index: clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -std=c++20 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -fdeclspec
+
+#include "Inputs/std-coroutine.h"
+
+// expected-no-diagnostics
+
+template 
+struct promise;
+ 
+template 
+struct task {
+using promise_type = promise;
+
+explicit task(promise_type& p) noexcept { p.return_val = this; }
+
+task(const task&) = delete;
+
+T value;
+};
+ 
+template 
+struct promise {
+task get_return_object() noexcept { return task{*this}; }
+
+std::suspend_never initial_suspend() const noexcept { return {}; }
+
+std::suspend_never final_suspend() const noexcept { return {}; }
+
+template 
+void return_value(U&& val) { return_val->value = static_cast(val); }
+
+void unhandled_exception() {}
+
+task* return_val;
+};
+
+task a_ShouldNotDiag(const int a, const int b) {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+task b_ShouldNotDiag(const int a, const int b) noexcept {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+const auto c_ShouldNotDiag = [](const int a, const int b) -> task {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+};
+
+const auto d_ShouldNotDiag = [](const int a, const int b) noexcept -> task {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+};
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2509,7 +2509,7 @@
   // Check for throw out of non-throwing function.
   if (!Diags.isIgnored(diag::warn_throw_in_noexcept_func, D->getBeginLoc()))
 if (const FunctionDecl *FD = dyn_cast(D))
-  if (S.getLangOpts().CPlusPlus && isNoexcept(FD))
+  if (S.getLangOpts().CPlusPlus && !fscope->isCoroutine() && isNoexcept(FD))
 

[PATCH] D135495: [clang-tidy] handle exceptions properly `ExceptionAnalyzer`

2023-02-19 Thread Domján Dániel via Phabricator via cfe-commits
isuckatcs added a comment.

ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135495/new/

https://reviews.llvm.org/D135495

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


[clang] 70d78e0 - [NFC] Remove unused Sema::DirectModuleImports

2023-02-19 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-02-20T15:07:49+08:00
New Revision: 70d78e035801a35c95c55384621724b0ef8ecb35

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

LOG: [NFC] Remove unused Sema::DirectModuleImports

Sema::DirectModuleImports is not used now. Remove it for clearness.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaModule.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index 3e177bae99c5..a6b1102488ae 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2279,9 +2279,6 @@ class Sema final {
   /// The global module fragment of the current translation unit.
   clang::Module *GlobalModuleFragment = nullptr;
 
-  /// The modules we imported directly.
-  llvm::SmallPtrSet DirectModuleImports;
-
   /// Namespace definitions that we will export when they finish.
   llvm::SmallPtrSet DeferredExportedNamespaces;
 
@@ -2332,10 +2329,6 @@ class Sema final {
 return Entity->getOwningModule();
   }
 
-  bool isModuleDirectlyImported(const Module *M) {
-return DirectModuleImports.contains(M);
-  }
-
   // Determine whether the module M belongs to the  current TU.
   bool isModuleUnitOfCurrentTU(const Module *M) const;
 

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index f1c409078f41..f03d98210b5b 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -602,11 +602,6 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
 Diag(ExportLoc, diag::err_export_not_in_module_interface);
   }
 
-  // In some cases we need to know if an entity was present in a directly-
-  // imported module (as opposed to a transitive import).  This avoids
-  // searching both Imports and Exports.
-  DirectModuleImports.insert(Mod);
-
   return Import;
 }
 



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


[clang] 2dfa957 - [NFC] Remove the unused parameter in Sema::PushGlobalModuleFragment

2023-02-19 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-02-20T15:37:55+08:00
New Revision: 2dfa957f120244ddc0238b548282f67d89f1a832

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

LOG: [NFC] Remove the unused parameter in Sema::PushGlobalModuleFragment

The `IsImplicit` parameter should be removed since it is not used now.

Added: 


Modified: 
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaModule.cpp

Removed: 




diff  --git a/clang/include/clang/Sema/Sema.h b/clang/include/clang/Sema/Sema.h
index a6b1102488ae..176d92ae6fb1 100644
--- a/clang/include/clang/Sema/Sema.h
+++ b/clang/include/clang/Sema/Sema.h
@@ -2294,7 +2294,7 @@ class Sema final {
   }
 
   /// Enter the scope of the global module.
-  Module *PushGlobalModuleFragment(SourceLocation BeginLoc, bool IsImplicit);
+  Module *PushGlobalModuleFragment(SourceLocation BeginLoc);
   /// Leave the scope of the global module.
   void PopGlobalModuleFragment();
 

diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index 7bae979fe061..6ec0eacf7a37 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -16363,7 +16363,7 @@ Decl *Sema::ActOnStartLinkageSpecification(Scope *S, 
SourceLocation ExternLoc,
   /// need to attach it again.
   if (getLangOpts().CPlusPlusModules && isCurrentModulePurview()) {
 Module *GlobalModule =
-PushGlobalModuleFragment(ExternLoc, /*IsImplicit=*/true);
+PushGlobalModuleFragment(ExternLoc);
 /// According to [module.reach]p3.2,
 /// The declaration in global module fragment is reachable if it is not
 /// discarded. And the discarded declaration should be deleted. So it

diff  --git a/clang/lib/Sema/SemaExprCXX.cpp b/clang/lib/Sema/SemaExprCXX.cpp
index eb9a3e65763f..81d2c31c564a 100644
--- a/clang/lib/Sema/SemaExprCXX.cpp
+++ b/clang/lib/Sema/SemaExprCXX.cpp
@@ -2979,7 +2979,7 @@ void Sema::DeclareGlobalNewDelete() {
   //   functions are replaceable ([new.delete]); these are attached to the
   //   global module ([module.unit]).
   if (getLangOpts().CPlusPlusModules && getCurrentModule())
-PushGlobalModuleFragment(SourceLocation(), /*IsImplicit=*/true);
+PushGlobalModuleFragment(SourceLocation());
 
   // C++ [basic.std.dynamic]p2:
   //   [...] The following allocation and deallocation functions (18.4) are

diff  --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index f03d98210b5b..59891ec2a817 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -74,10 +74,9 @@ static std::string stringFromPath(ModuleIdPath Path) {
 
 Sema::DeclGroupPtrTy
 Sema::ActOnGlobalModuleFragmentDecl(SourceLocation ModuleLoc) {
-  // We start in the global module; all those declarations are implicitly
-  // module-private (though they do not have module linkage).
+  // We start in the global module;
   Module *GlobalModule =
-  PushGlobalModuleFragment(ModuleLoc, /*IsImplicit=*/false);
+  PushGlobalModuleFragment(ModuleLoc);
 
   // All declarations created from now on are owned by the global module.
   auto *TU = Context.getTranslationUnitDecl();
@@ -956,8 +955,7 @@ Decl *Sema::ActOnFinishExportDecl(Scope *S, Decl *D, 
SourceLocation RBraceLoc) {
   return D;
 }
 
-Module *Sema::PushGlobalModuleFragment(SourceLocation BeginLoc,
-   bool IsImplicit) {
+Module *Sema::PushGlobalModuleFragment(SourceLocation BeginLoc) {
   // We shouldn't create new global module fragment if there is already
   // one.
   if (!GlobalModuleFragment) {



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


[clang] a28b252 - Use APInt::getSignificantBits instead of APInt::getMinSignedBits (NFC)

2023-02-19 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-02-19T23:56:52-08:00
New Revision: a28b252d852c31fb7228e095a213347e6926bb0f

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

LOG: Use APInt::getSignificantBits instead of APInt::getMinSignedBits (NFC)

Note that getMinSignedBits has been soft-deprecated in favor of
getSignificantBits.

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/StaticAnalyzer/Core/APSIntType.cpp
llvm/include/llvm/Analysis/TargetTransformInfoImpl.h
llvm/include/llvm/CodeGen/SelectionDAG.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/CodeGen/CodeGenPrepare.cpp
llvm/lib/CodeGen/MIRParser/MIParser.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/IR/ConstantFold.cpp
llvm/lib/IR/ConstantRange.cpp
llvm/lib/IR/Value.cpp
llvm/lib/Support/APSInt.cpp
llvm/lib/Target/RISCV/RISCVISelLowering.cpp
llvm/lib/Target/RISCV/RISCVTargetTransformInfo.cpp
llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp
llvm/lib/Target/X86/X86ISelDAGToDAG.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
llvm/lib/Transforms/Scalar/Float2Int.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/lib/Transforms/Utils/BypassSlowDivision.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/lib/Transforms/Vectorize/LoadStoreVectorizer.cpp
polly/lib/Support/GICHelper.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index 1a51614bb9d45..c5436141adbf7 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -396,7 +396,7 @@ void fillFunctionTypeAndParams(HoverInfo , const Decl *D,
 // -2^32 => 0xfffe
 static llvm::FormattedNumber printHex(const llvm::APSInt ) {
   uint64_t Bits = V.getExtValue();
-  if (V.isNegative() && V.getMinSignedBits() <= 32)
+  if (V.isNegative() && V.getSignificantBits() <= 32)
 return llvm::format_hex(uint32_t(Bits), 0);
   return llvm::format_hex(Bits, 0);
 }
@@ -430,7 +430,7 @@ std::optional printExprValue(const Expr *E,
 
   // Show enums symbolically, not numerically like APValue::printPretty().
   if (T->isEnumeralType() && Constant.Val.isInt() &&
-  Constant.Val.getInt().getMinSignedBits() <= 64) {
+  Constant.Val.getInt().getSignificantBits() <= 64) {
 // Compare to int64_t to avoid bit-width match requirements.
 int64_t Val = Constant.Val.getInt().getExtValue();
 for (const EnumConstantDecl *ECD :
@@ -442,7 +442,7 @@ std::optional printExprValue(const Expr *E,
   }
   // Show hex value of integers if they're at least 10 (or negative!)
   if (T->isIntegralOrEnumerationType() && Constant.Val.isInt() &&
-  Constant.Val.getInt().getMinSignedBits() <= 64 &&
+  Constant.Val.getInt().getSignificantBits() <= 64 &&
   Constant.Val.getInt().uge(10))
 return llvm::formatv("{0} ({1})", Constant.Val.getAsString(Ctx, T),
  printHex(Constant.Val.getInt()))

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 9d43ad1cfc528..9e67f862ae634 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12008,7 +12008,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
 
-return Success(Val.getBitWidth() - Val.getMinSignedBits(), E);
+return Success(Val.getBitWidth() - Val.getSignificantBits(), E);
   }
 
   case Builtin::BI__builtin_clz:

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 54f7d041a857a..9d5490a99310f 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -12456,7 +12456,7 @@ struct IntRange {
 static IntRange GetValueRange(ASTContext , llvm::APSInt ,
   unsigned MaxWidth) {
   if (value.isSigned() && value.isNegative())
-return IntRange(value.getMinSignedBits(), false);
+return IntRange(value.getSignificantBits(), false);
 
   if (value.getBitWidth() > MaxWidth)
 value = value.trunc(MaxWidth);
@@ -13373,7 +13373,7 @@ static bool AnalyzeBitFieldAssignment(Sema , 
FieldDecl *Bitfield, Expr *Init,
   if (!Value.isSigned() || Value.isNegative())
 if (UnaryOperator *UO = dyn_cast(OriginalInit))
   if (UO->getOpcode() == UO_Minus || UO->getOpcode() == UO_Not)
-OriginalWidth = Value.getMinSignedBits();
+OriginalWidth = Value.getSignificantBits();
 
   if 

[PATCH] D144296: [clang-format] Rewrite how indent is reduced for compacted namespaces

2023-02-19 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

There is no PP stuff in the new tests.

And I see the style was bogus before, but shouldn't all variables start with a 
capital letter? Please fix that in the code you touch.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144296/new/

https://reviews.llvm.org/D144296

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


[PATCH] D144355: [clang-format][NFC] Clean up nullptr comparison style

2023-02-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

For example, use `Next` instead of `Next != nullptr`, and `!Next` instead of 
`Next == nullptr`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144355

Files:
  clang/lib/Format/AffectedRangeManager.cpp
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h

Index: clang/lib/Format/WhitespaceManager.h
===
--- clang/lib/Format/WhitespaceManager.h
+++ clang/lib/Format/WhitespaceManager.h
@@ -294,7 +294,7 @@
 calculateCellWidth(CellIter->Index, CellIter->EndIndex, true);
 if (Changes[CellIter->Index].NewlinesBefore == 0)
   CellWidth += NetWidth;
-for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
+for (const auto *Next = CellIter->NextColumnElement; Next;
  Next = Next->NextColumnElement) {
   auto ThisWidth = calculateCellWidth(Next->Index, Next->EndIndex, true);
   if (Changes[Next->Index].NewlinesBefore == 0)
@@ -312,7 +312,7 @@
 auto MaxNetWidth = getNetWidth(CellStart, CellStop, InitialSpaces);
 auto RowCount = 1U;
 auto Offset = std::distance(CellStart, CellStop);
-for (const auto *Next = CellStop->NextColumnElement; Next != nullptr;
+for (const auto *Next = CellStop->NextColumnElement; Next;
  Next = Next->NextColumnElement) {
   if (RowCount > MaxRowCount)
 break;
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -1172,7 +1172,7 @@
   Changes[CellIter->Index].Spaces = (MaxNetWidth - ThisNetWidth);
 auto RowCount = 1U;
 auto Offset = std::distance(Cells.begin(), CellIter);
-for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
+for (const auto *Next = CellIter->NextColumnElement; Next;
  Next = Next->NextColumnElement) {
   auto *Start = (Cells.begin() + RowCount * CellDescs.CellCounts[0]);
   auto *End = Start + Offset;
@@ -1191,7 +1191,7 @@
 Changes[CellIter->Index].Spaces += (i > 0) ? 1 : 0;
   }
   alignToStartOfCell(CellIter->Index, CellIter->EndIndex);
-  for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
+  for (const auto *Next = CellIter->NextColumnElement; Next;
Next = Next->NextColumnElement) {
 ThisWidth =
 calculateCellWidth(Next->Index, Next->EndIndex, true) + NetWidth;
@@ -1233,7 +1233,7 @@
 }
 auto RowCount = 1U;
 auto Offset = std::distance(Cells.begin(), CellIter);
-for (const auto *Next = CellIter->NextColumnElement; Next != nullptr;
+for (const auto *Next = CellIter->NextColumnElement; Next;
  Next = Next->NextColumnElement) {
   if (RowCount > CellDescs.CellCounts.size())
 break;
@@ -1253,7 +1253,7 @@
 bool WhitespaceManager::isSplitCell(const CellDescription ) {
   if (Cell.HasSplit)
 return true;
-  for (const auto *Next = Cell.NextColumnElement; Next != nullptr;
+  for (const auto *Next = Cell.NextColumnElement; Next;
Next = Next->NextColumnElement) {
 if (Next->HasSplit)
   return true;
@@ -1406,8 +1406,7 @@
 WhitespaceManager::linkCells(CellDescriptions &) {
   auto  = CellDesc.Cells;
   for (auto *CellIter = Cells.begin(); CellIter != Cells.end(); ++CellIter) {
-if (CellIter->NextColumnElement == nullptr &&
-((CellIter + 1) != Cells.end())) {
+if (!CellIter->NextColumnElement && (CellIter + 1) != Cells.end()) {
   for (auto *NextIter = CellIter + 1; NextIter != Cells.end(); ++NextIter) {
 if (NextIter->Cell == CellIter->Cell) {
   CellIter->NextColumnElement = &(*NextIter);
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1166,7 +1166,7 @@
   const FormatToken *FormatTok) {
   // FIXME: This returns true for C/C++ keywords like 'struct'.
   return FormatTok->is(tok::identifier) &&
- (FormatTok->Tok.getIdentifierInfo() == nullptr ||
+ (!FormatTok->Tok.getIdentifierInfo() ||
   !FormatTok->isOneOf(
   Keywords.kw_in, Keywords.kw_of, Keywords.kw_as, Keywords.kw_async,
   Keywords.kw_await, 

[PATCH] D144321: [PowerPC] Correctly use ELFv2 ABI on all OS's that use the ELFv2 ABI

2023-02-19 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.h:430-432
+  if ((Triple.isOSFreeBSD() && (Triple.getOSVersion().empty() ||
+Triple.getOSMajorVersion() >= 13)) ||
+  Triple.isOSOpenBSD() || Triple.isMusl())

I am generally not a fan of keeping multiple instances of a somewhat complex 
conditions in sync. I wonder if the community would be OK with one of:
- Adding a static function in `Triple.h` to test this (`static bool 
isPPCELFv2ABI(const Triple &)`)
- Adding a member function `Triple::isPPCELFv2ABI()` (similar to 
`Triple::isWatchABI()`)

Then of course, we can use that function in both places.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144321/new/

https://reviews.llvm.org/D144321

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


[clang] 55ab77d - Reland "[Fuchsia] Enable llvm-driver build".

2023-02-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-20T01:57:40Z
New Revision: 55ab77d279a1b77ff85d0d040f867d4e764aba3b

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

LOG: Reland "[Fuchsia] Enable llvm-driver build".

The MacOS problem has been fixed. Additionally, don't enable the
driver build on Windows. We can look into enabling it later if
symlinks work better than I think on Windows.

Differential Revision: https://reviews.llvm.org/D144287

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 5a7cf6cf2c887..8a0d19e14a31e 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -26,6 +26,8 @@ set(LLVM_USE_RELATIVE_PATHS_IN_FILES ON CACHE BOOL "")
 
 if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
+else()
+  set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
 endif()
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
@@ -292,6 +294,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cxxfilt
   llvm-debuginfod-find
   llvm-dlltool
+  llvm-driver
   llvm-dwarfdump
   llvm-dwp
   llvm-ifs



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


[clang-tools-extra] 87d02e0 - Recommit "[Support] change StringMap hash function from djbHash to xxHash"

2023-02-19 Thread Erik Desjardins via cfe-commits

Author: Erik Desjardins
Date: 2023-02-19T16:52:26-05:00
New Revision: 87d02e0dfd760de38d092ef69f8a9164f28f2221

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

LOG: Recommit "[Support] change StringMap hash function from djbHash to xxHash"

This reverts commit 37eb9d13f891f7656f811516e765b929b169afe0.

Test failures have been fixed:

- ubsan failure fixed by 72eac42f21c0f45a27f3eaaff9364cbb5189b9e4
- warn-unsafe-buffer-usage-fixits-local-var-span.cpp fixed by
  03cc52dfd1dbb4a59b479da55e87838fb93d2067 (wasn't related)
- test-output-format.ll failure was spurious, build failed at
  https://lab.llvm.org/buildbot/#/builders/54/builds/3545 
(b4431b2d945b6fc19b1a55ac6ce969a8e06e1e93)
  but passed at
  https://lab.llvm.org/buildbot/#/builders/54/builds/3546 
(5ae99be0377248c74346096dc475af254a3fc799)
  which is before my revert
  
https://github.com/llvm/llvm-project/compare/b4431b2d945b6fc19b1a55ac6ce969a8e06e1e93...5ae99be0377248c74346096dc475af254a3fc799

Original commit message:

Depends on https://reviews.llvm.org/D142861.

Alternative to https://reviews.llvm.org/D137601.

xxHash is much faster than djbHash. This makes a simple Rust test case with 
a large constant string 10% faster to compile.

Previous attempts at changing this hash function (e.g. 
https://reviews.llvm.org/D97396) had to be reverted due to breaking tests that 
depended on iteration order.
No additional tests fail with this patch compared to `main` when running 
`check-all` with `-DLLVM_ENABLE_PROJECTS="all"` (on a Linux host), so I hope I 
found everything that needs to be changed.

Differential Revision: https://reviews.llvm.org/D142862

Added: 


Modified: 
clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
clang/unittests/Basic/SarifTest.cpp
compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
llvm/lib/Support/StringMap.cpp
llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
llvm/test/DebugInfo/X86/gnu-public-names.ll
llvm/test/tools/dsymutil/ARM/extern-alias.test
llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
mlir/test/mlir-lsp-server/completion.test

Removed: 




diff  --git a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize 
b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
index 31be95c6b6b3c..afe1ece5eec08 100644
--- a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
+++ b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
@@ -12,5 +12,5 @@
 
 # CHECK: These are the combined files, with problem files preceded by #:
 
-# CHECK: {{.*}}Inputs/CompileError/HasError.h
 # CHECK: Inputs/CompileError/Level1A.h
+# CHECK: {{.*}}Inputs/CompileError/HasError.h

diff  --git a/clang/unittests/Basic/SarifTest.cpp 
b/clang/unittests/Basic/SarifTest.cpp
index 06ad4e7a63091..33bccf56babb7 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -332,7 +332,7 @@ TEST_F(SarifDocumentWriterTest, checkSerializingArtifacts) {
 TEST_F(SarifDocumentWriterTest, checkSerializingCodeflows) {
   // GIVEN:
   const std::string ExpectedOutput =
-  
R"({"$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json","runs":[{"artifacts":[{"length":27,"location":{"index":1,"uri":"file:///test-header-1.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":30,"location":{"index":2,"uri":"file:///test-header-2.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":28,"location":{"index":3,"uri":"file:///test-header-3.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":41,"location":{"index":0,"uri":"file:///main.cpp"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":[{"codeFlows":[{"threadFlows":[{"locations":[{"importance":"essential","location":{"message":{"text":"Message
 
#1"},"physicalLocation":{"artifactLocation":{"index":1,"uri":"file:///test-header-1.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"important","location":{"message":{"text":"Message
 
#2"},"physicalLocation":{"artifactLocation":{"index":2,"uri":"file:///test-header-2.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"unimportant","location":{"message":{"text":"Message
 

[clang] 87d02e0 - Recommit "[Support] change StringMap hash function from djbHash to xxHash"

2023-02-19 Thread Erik Desjardins via cfe-commits

Author: Erik Desjardins
Date: 2023-02-19T16:52:26-05:00
New Revision: 87d02e0dfd760de38d092ef69f8a9164f28f2221

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

LOG: Recommit "[Support] change StringMap hash function from djbHash to xxHash"

This reverts commit 37eb9d13f891f7656f811516e765b929b169afe0.

Test failures have been fixed:

- ubsan failure fixed by 72eac42f21c0f45a27f3eaaff9364cbb5189b9e4
- warn-unsafe-buffer-usage-fixits-local-var-span.cpp fixed by
  03cc52dfd1dbb4a59b479da55e87838fb93d2067 (wasn't related)
- test-output-format.ll failure was spurious, build failed at
  https://lab.llvm.org/buildbot/#/builders/54/builds/3545 
(b4431b2d945b6fc19b1a55ac6ce969a8e06e1e93)
  but passed at
  https://lab.llvm.org/buildbot/#/builders/54/builds/3546 
(5ae99be0377248c74346096dc475af254a3fc799)
  which is before my revert
  
https://github.com/llvm/llvm-project/compare/b4431b2d945b6fc19b1a55ac6ce969a8e06e1e93...5ae99be0377248c74346096dc475af254a3fc799

Original commit message:

Depends on https://reviews.llvm.org/D142861.

Alternative to https://reviews.llvm.org/D137601.

xxHash is much faster than djbHash. This makes a simple Rust test case with 
a large constant string 10% faster to compile.

Previous attempts at changing this hash function (e.g. 
https://reviews.llvm.org/D97396) had to be reverted due to breaking tests that 
depended on iteration order.
No additional tests fail with this patch compared to `main` when running 
`check-all` with `-DLLVM_ENABLE_PROJECTS="all"` (on a Linux host), so I hope I 
found everything that needs to be changed.

Differential Revision: https://reviews.llvm.org/D142862

Added: 


Modified: 
clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
clang/unittests/Basic/SarifTest.cpp
compiler-rt/test/profile/Linux/instrprof-show-debug-info-correlation.c
lldb/test/API/functionalities/gdb_remote_client/TestGDBRemoteClient.py
llvm/lib/Support/StringMap.cpp
llvm/test/DebugInfo/Generic/accel-table-hash-collisions.ll
llvm/test/DebugInfo/Generic/debug-names-hash-collisions.ll
llvm/test/DebugInfo/X86/debug-pubtables-dwarf64.ll
llvm/test/DebugInfo/X86/gnu-public-names-gmlt.ll
llvm/test/DebugInfo/X86/gnu-public-names.ll
llvm/test/tools/dsymutil/ARM/extern-alias.test
llvm/test/tools/llvm-profdata/suppl-instr-with-sample.test
mlir/test/mlir-lsp-server/completion.test

Removed: 




diff  --git a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize 
b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
index 31be95c6b6b3c..afe1ece5eec08 100644
--- a/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
+++ b/clang-tools-extra/test/modularize/ProblemsDisplayLists.modularize
@@ -12,5 +12,5 @@
 
 # CHECK: These are the combined files, with problem files preceded by #:
 
-# CHECK: {{.*}}Inputs/CompileError/HasError.h
 # CHECK: Inputs/CompileError/Level1A.h
+# CHECK: {{.*}}Inputs/CompileError/HasError.h

diff  --git a/clang/unittests/Basic/SarifTest.cpp 
b/clang/unittests/Basic/SarifTest.cpp
index 06ad4e7a63091..33bccf56babb7 100644
--- a/clang/unittests/Basic/SarifTest.cpp
+++ b/clang/unittests/Basic/SarifTest.cpp
@@ -332,7 +332,7 @@ TEST_F(SarifDocumentWriterTest, checkSerializingArtifacts) {
 TEST_F(SarifDocumentWriterTest, checkSerializingCodeflows) {
   // GIVEN:
   const std::string ExpectedOutput =
-  
R"({"$schema":"https://docs.oasis-open.org/sarif/sarif/v2.1.0/cos02/schemas/sarif-schema-2.1.0.json","runs":[{"artifacts":[{"length":27,"location":{"index":1,"uri":"file:///test-header-1.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":30,"location":{"index":2,"uri":"file:///test-header-2.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":28,"location":{"index":3,"uri":"file:///test-header-3.h"},"mimeType":"text/plain","roles":["resultFile"]},{"length":41,"location":{"index":0,"uri":"file:///main.cpp"},"mimeType":"text/plain","roles":["resultFile"]}],"columnKind":"unicodeCodePoints","results":[{"codeFlows":[{"threadFlows":[{"locations":[{"importance":"essential","location":{"message":{"text":"Message
 
#1"},"physicalLocation":{"artifactLocation":{"index":1,"uri":"file:///test-header-1.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"important","location":{"message":{"text":"Message
 
#2"},"physicalLocation":{"artifactLocation":{"index":2,"uri":"file:///test-header-2.h"},"region":{"endColumn":8,"endLine":2,"startColumn":1,"startLine":1,{"importance":"unimportant","location":{"message":{"text":"Message
 

[PATCH] D127910: [Clang][AArch64][SME] Add vector load/store (ld1/st1) intrinsics

2023-02-19 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc marked an inline comment as done.
bryanpkc added inline comments.



Comment at: clang/lib/Headers/CMakeLists.txt:332
+  # Generate arm_sme.h
+  clang_generate_header(-gen-arm-sme-header arm_sme.td arm_sme.h)
   # Generate arm_bf16.h

sdesmalen wrote:
> bryanpkc wrote:
> > bryanpkc wrote:
> > > sdesmalen wrote:
> > > > The ACLE specification is still in a draft (ALP) state, which means 
> > > > there may still be subject to significant changes. To avoid users from 
> > > > using this implementation with the expectation that their code is 
> > > > compliant going forward, it would be good to rename the header file to 
> > > > something that makes it very clear this feature is not yet ready to 
> > > > use. I'm thinking of something like 
> > > > `arm_sme_draft_spec_subject_to_change.h`. When the specification goes 
> > > > out of draft, we can rename it to `arm_sme.h`. Could you rename the 
> > > > file for now?
> > > Would something shorter like `arm_sme_draft.h` or 
> > > `arm_sme_experimental.h` suffice?
> > Renamed to `arm_sme_experimental.h`.
> While `arm_sme_experimental.h` is indeed shorter, it should be unequivocally 
> clear to the user that they shouldn't rely on the function prototypes defined 
> in this header file yet because the specification itself is not finalised. I 
> think that adding the `draft_spec_subject_to_change` to the name makes that 
> more clear than `experimental`, as the latter might suggest that the support 
> is not yet entirely stable or complete. There probably isn't that much to 
> gain from making the user experience better by using a shorter name, if the 
> whole point is to prevent people from using it for any production code. So 
> from that perspective, I still have a slight preference for 
> `arm_sme_draft_spec_subject_to_change.h`.
Renamed as suggested.



Comment at: clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp:3
+
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -triple aarch64-none-linux-gnu 
-target-feature +sve -target-feature +sme -fsyntax-only -verify 
-verify-ignore-unexpected=error %s
+// RUN: %clang_cc1 -D__ARM_FEATURE_SME -DSVE_OVERLOADED_FORMS -triple 
aarch64-none-linux-gnu -target-feature +sve -target-feature +sme -fsyntax-only 
-verify -verify-ignore-unexpected=error %s

david-arm wrote:
> I think you can remove the `-target-feature +sve` flags from the RUN lines 
> because `+sme` should imply that.
If I understand `llvm/lib/Target/AArch64/AArch64.td` and 
`clang/lib/Basic/Targets/AArch64.cpp` correctly, `-target-feature +sme` does 
not imply `-target-feature +sve`. I can remove the `-D__ARM_FEATURE_SME` though.

On the other hand, `-march=armv8+sme` will imply `-target-feature +sve`, which 
I have implemented in D142702.



Comment at: clang/utils/TableGen/SveEmitter.cpp:1477
+
+  OS << "#if !defined(__ARM_FEATURE_SME)\n";
+  OS << "#error \"SME support not enabled\"\n";

dmgreen wrote:
> bryanpkc wrote:
> > dmgreen wrote:
> > > We have been changing how the existing SVE and NEON instrinsics work a 
> > > little. There are some details in https://reviews.llvm.org/D131064. The 
> > > short version is it is best to not rely upon preprocessor macros, and 
> > > instead define the intrinsics so that they can be used if the right 
> > > target features are available. This allows us to do things like this 
> > > below, even without a -march that supports sme, and have them callable at 
> > > runtime under the right situations. We should be doing the same for SME.
> > > ```
> > > __attribute__((target("+sme")))
> > > void sme_func() {
> > >   somesmeintrinsics();
> > > }
> > > ```
> > I have refactored the SME intrinsics in a similar fashion. Could you 
> > confirm if I did it correctly?
> It looks OK - as far as I can see. It might be worth adding a test for it? 
> But otherwise it looks good. Thanks.
Added a test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127910/new/

https://reviews.llvm.org/D127910

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


[clang] 6bb8668 - [Fuchsia] Fix driver build on Windows

2023-02-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-20T03:34:26Z
New Revision: 6bb86689af7e31b23b432f3941d5ce447819ef3b

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

LOG: [Fuchsia] Fix driver build on Windows

Don't include llvm-driver when building for Windows

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 8a0d19e14a31..464f7f89fcea 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -294,7 +294,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cxxfilt
   llvm-debuginfod-find
   llvm-dlltool
-  llvm-driver
   llvm-dwarfdump
   llvm-dwp
   llvm-ifs
@@ -323,6 +322,10 @@ set(LLVM_TOOLCHAIN_TOOLS
   scan-build-py
   CACHE STRING "")
 
+if(NOT WIN32)
+  list(APPEND LLVM_TOOLCHAIN_TOOLS llvm-driver)
+endif()
+
 set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld



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


[PATCH] D143849: [Clang][OpenCL] Allow pointers in structs as kernel arguments from 2.0

2023-02-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:9494
+  // of SVM.
+  if (S.getLangOpts().getOpenCLCompatibleVersion() > 120 &&
+  (ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam))

Ayal wrote:
> Anastasia wrote:
> > Anastasia wrote:
> > > Ayal wrote:
> > > > Anastasia wrote:
> > > > > I think it should be possible to merge this with `if` below to avoid 
> > > > > condition duplication.
> > > > > 
> > > > > 
> > > > Sure, but that trades one duplication for another, rather than clearly 
> > > > separating the early-continue case early?
> > > > 
> > > > ```
> > > >   if (ParamType == PtrKernelParam || ParamType == 
> > > > PtrPtrKernelParam) {
> > > > if (S.getLangOpts().getOpenCLCompatibleVersion() > 120)
> > > >   continue;
> > > > S.Diag(Param->getLocation(),
> > > >diag::err_record_with_pointers_kernel_param)
> > > >   << PT->isUnionType()
> > > >   << PT;
> > > >   } else if (ParamType == InvalidAddrSpacePtrKernelParam) {
> > > > S.Diag(Param->getLocation(),
> > > >diag::err_record_with_pointers_kernel_param)
> > > >   << PT->isUnionType()
> > > >   << PT;
> > > >   } else {
> > > > S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) 
> > > > << PT;
> > > > 
> > > > ```
> > > I am mainly thinking in terms of maintenance if for example someone fixes 
> > > one if and forgets another. Or if ifs will get separated by some other 
> > > code and then it is not easy to see that the same thing is handled 
> > > differently in OpenCL versions. 
> > > 
> > > Unfortunately we have a lot of those cases, I know this function has 
> > > early exists but it is not a common style.
> > > 
> > > 
> > > I was talking about something like:
> > > 
> > > 
> > > ```
> > > if (((S.getLangOpts().getOpenCLCompatibleVersion() <= 120) &&
> > > (ParamType == PtrKernelParam || ParamType == PtrPtrKernelParam)) ||
> > >   ParamType == InvalidAddrSpacePtrKernelParam)
> > > ```
> > > 
> > > It would also be ok to separate `InvalidAddrSpacePtrKernelParam` since 
> > > it's handling different feature.
> > Sorry I have forgotten that this part of the code is expected to handle the 
> > diagnostics only. The decision that the kernel parameter is wrong is done 
> > in `getOpenCLKernelParameterType`. I think you should alter the conditions 
> > there to check for OpenCL version and avoid classifying cases you care 
> > about as `PtrKernelParam` or `PtrPtrKernelParam`. Then here you wouldn't 
> > need this extra if/continue block. 
> Hmm, would that be better? This part of the code, namely 
> `checkIsValidOpenCLKernelParameter()`, does check the validity of arguments 
> classified by `getOpenCLKernelParameterType()` in addition to handling 
> diagnostics. E.g., the first case above decides that arguments of 
> pointer-to-pointer type are wrong along with proper diagnostics for OpenCL 
> 1.x while allowing them for other OpenCL versions.
> 
> Struct arguments are simply classified as records by 
> getOpenCLKernelParameterType(), whereas this part of the code traverses each 
> struct and calls getOpenCLKernelParameterType() on each field - the latter 
> seems  unaware if it was invoked on a struct field or not? If it is (made) 
> aware, it could indeed return a (new kind of?) invalid type instead of 
> pointer type for OpenCL 1.x - how would the right 
> err_record_with_pointers_kernel_param diagnostics then be handled? If 
> desired, such refactoring should probably be done independent of this fix?
That's right there is a mix of everything as I think this code has deviated 
from its original idea, but I still think it's cleaner to avoid doing the same 
kind of checks in multiple places.


Overall I find this code a bit over-engineered, this is maybe why it went off 
track. So some refactoring would indeed be helpful. However I am not sure 
whether it's better to continue the same route or try to simplify the design by 
just adding separate functions for each error case that would detect that the 
type is of a certain kind e.g a pointer or a pointer with wrong address space 
and then also provide the diagnostic straight away . I feel this would match 
better the rest of the diagnostic handling in clang but might result in 
slightly more helper functions or duplication of code.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143849/new/

https://reviews.llvm.org/D143849

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


[PATCH] D144317: [clang-format] Fix handling of TypeScript tuples with optional last member

2023-02-19 Thread Taymon A. Beal via Phabricator via cfe-commits
taymonbeal updated this revision to Diff 498692.
taymonbeal added a comment.

Merge unit test into existing test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144317/new/

https://reviews.llvm.org/D144317

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestJS.cpp


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2221,6 +2221,7 @@
"  aaa?: boolean,\n"
"  aa?: List\n"
"}) {}");
+  verifyFormat("type X = [y?];");
 }
 
 TEST_F(FormatTestJS, IndexSignature) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1248,7 +1248,7 @@
 case tok::question:
   if (Style.isJavaScript() && Tok->Next &&
   Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren,
- tok::r_brace)) {
+ tok::r_brace, tok::r_square)) {
 // Question marks before semicolons, colons, etc. indicate optional
 // types (fields, parameters), e.g.
 //   function(x?: string, y?) {...}


Index: clang/unittests/Format/FormatTestJS.cpp
===
--- clang/unittests/Format/FormatTestJS.cpp
+++ clang/unittests/Format/FormatTestJS.cpp
@@ -2221,6 +2221,7 @@
"  aaa?: boolean,\n"
"  aa?: List\n"
"}) {}");
+  verifyFormat("type X = [y?];");
 }
 
 TEST_F(FormatTestJS, IndexSignature) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1248,7 +1248,7 @@
 case tok::question:
   if (Style.isJavaScript() && Tok->Next &&
   Tok->Next->isOneOf(tok::semi, tok::comma, tok::colon, tok::r_paren,
- tok::r_brace)) {
+ tok::r_brace, tok::r_square)) {
 // Question marks before semicolons, colons, etc. indicate optional
 // types (fields, parameters), e.g.
 //   function(x?: string, y?) {...}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143825: [clang-format] Put ports on separate lines in Verilog module headers

2023-02-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2665
+if (Style.isVerilog() && Precedence == prec::Comma &&
+VerilogFirstOfType != nullptr) {
+  addFakeParenthesis(VerilogFirstOfType, prec::Comma);

sstwcw wrote:
> owenpan wrote:
> > And other places as well.
> @HazardyKnusperkeks Do you agree?  I remember you once said you preferred the 
> `nullptr` style.
See D144355. Not using `nullptr` in conditionals was one of the first LLVM 
styles I had to get used to when I started contributing.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143825/new/

https://reviews.llvm.org/D143825

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


[PATCH] D144347: [clang-tidy] Add readability-forward-usage check

2023-02-19 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
Herald added subscribers: carlosgalvezp, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
PiotrZSL updated this revision to Diff 498666.
PiotrZSL added a comment.
Eugene.Zelenko added reviewers: aaron.ballman, carlosgalvezp.
PiotrZSL marked 4 inline comments as done.
PiotrZSL updated this revision to Diff 498687.
PiotrZSL published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Fix list.rst


PiotrZSL added a comment.

Does anyone know why on WINDOWS generated AST is different:

  LINUX (when function is never called):
  |-FunctionTemplateDecl 0x5577338b2580  line:212:6 
testPartialTemplate
  | |-TemplateTypeParmDecl 0x5577338b2288  col:19 
referenced typename depth 0 index 0 T
  | `-FunctionDecl 0x5577338b24d8  line:212:6 
testPartialTemplate 'void (WrapperEx)'
  |   |-ParmVarDecl 0x5577338b23e0  col:39 referenced value 
'WrapperEx':'WrapperEx'
  |   `-CompoundStmt 0x5577338b28a0 
  | `-CallExpr 0x5577338b2878  ''
  |   |-UnresolvedLookupExpr 0x5577338b2668  '' lvalue (ADL) = 'test' 0x557733898c10
  |   `-CallExpr 0x5577338b2850  ''
  | |-UnresolvedLookupExpr 0x5577338b27b0  '' lvalue (no ADL) = 'forward' 0x5577338961d8 0x557733896818
  | `-DeclRefExpr 0x5577338b2830  'WrapperEx':'WrapperEx' 
lvalue ParmVar 0x5577338b23e0 'value' 'WrapperEx':'WrapperEx'
  
  LINUX (when function is called)
  |-FunctionTemplateDecl 0x556b33e8a5b0  line:212:6 
testPartialTemplate
  | |-TemplateTypeParmDecl 0x556b33e8a2b8  col:19 
referenced typename depth 0 index 0 T
  | |-FunctionDecl 0x556b33e8a508  line:212:6 
testPartialTemplate 'void (WrapperEx)'
  | | |-ParmVarDecl 0x556b33e8a410  col:39 referenced value 
'WrapperEx':'WrapperEx'
  | | `-CompoundStmt 0x556b33e8a8d0 
  | |   `-CallExpr 0x556b33e8a8a8  ''
  | | |-UnresolvedLookupExpr 0x556b33e8a698  '' lvalue (ADL) = 'test' 0x556b33e70c40
  | | `-CallExpr 0x556b33e8a880  ''
  | |   |-UnresolvedLookupExpr 0x556b33e8a7e0  '' lvalue (no ADL) = 'forward' 0x556b33e6e208 0x556b33e6e848
  | |   `-DeclRefExpr 0x556b33e8a860  'WrapperEx':'WrapperEx' 
lvalue ParmVar 0x556b33e8a410 'value' 'WrapperEx':'WrapperEx'
  | `-FunctionDecl 0x556b33e8e888  line:212:6 used 
testPartialTemplate 'void (WrapperEx)'
  
  WINDOWS (when function is never called):
  |-FunctionTemplateDecl 0x1ac13659de0  col:6 
testPartialTemplate
  | |-TemplateTypeParmDecl 0x1ac13652238  col:19 
referenced typename depth 0 index 0 T
  | `-FunctionDecl 0x1ac13659d38  col:6 testPartialTemplate 
'void (WrapperEx)'
  |   |-ParmVarDecl 0x1ac13652390  col:39 value 
'WrapperEx':'WrapperEx'
  |   `-<<>>
  
  WINDOWS (when function is called):
  |-FunctionTemplateDecl 0x1fe6f1b99a0  line:212:6 
testPartialTemplate
  | |-TemplateTypeParmDecl 0x1fe6f1b9568  col:19 
referenced typename depth 0 index 0 T
  | |-FunctionDecl 0x1fe6f1b98f8  line:212:6 
testPartialTemplate 'void (WrapperEx)'
  | | |-ParmVarDecl 0x1fe6f1b96c0  col:39 referenced value 
'WrapperEx':'WrapperEx'
  | | `-CompoundStmt 0x1fe6f1c5070 
  | |   `-CallExpr 0x1fe6f1c5048  ''
  | | |-UnresolvedLookupExpr 0x1fe6f1c4e40  '' lvalue (ADL) = 'test' 0x1fe6f18df70
  | | `-CallExpr 0x1fe6f1c5020  ''
  | |   |-UnresolvedLookupExpr 0x1fe6f1c4f80  '' lvalue (no ADL) = 'forward' 0x1fe6f18c3e8 0x1fe6f18ca28
  | |   `-DeclRefExpr 0x1fe6f1c5000  'WrapperEx':'WrapperEx' 
lvalue ParmVar 0x1fe6f1b96c0 'value' 'WrapperEx':'WrapperEx'
  | `-FunctionDecl 0x1fe6f1bebd8  line:212:6 used 
testPartialTemplate 'void (WrapperEx)'
  |   |-TemplateArgument type 'TestType'

EDIT: Ok, found that -fno-delayed-template-parsing is an workaround for this 
(but still strange).


PiotrZSL added a comment.

Fixed review comments and added -fno-delayed-template-parsing


PiotrZSL added a comment.

Ready for review




Comment at: clang-tools-extra/clang-tidy/readability/ForwardUsageCheck.cpp:46
+inline SourceRange getAnglesLoc(const Expr ) {
+
+  if (const auto *DeclRefExprCallee =

Excessive newline.



Comment at: clang-tools-extra/clang-tidy/readability/ForwardUsageCheck.cpp:55
+   UnresolvedLookupExprCallee->getRAngleLoc());
+  return SourceRange();
+}

`return {};` is shorter.



Comment at: clang-tools-extra/clang-tidy/readability/ForwardUsageCheck.cpp:123
+void ForwardUsageCheck::check(const MatchFinder::MatchResult ) {
+  const auto  = *Result.Nodes.getNodeAs("callee");
+  if (MatchedCallee.getBeginLoc().isMacroID() ||

Usually pointers are used. Same in other similar places..



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/readability/forward-usage.rst:101
+   Disables suggestions for type mismatch situations. When this option is
+enabled, the check treats situations with different types as if they were
+cv-equal and won't suggest using ``static_cast``, but will 

[PATCH] D143348: [Clang][Doc][OpenCL] Release 16 notes

2023-02-19 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia closed this revision.
Anastasia added a comment.

Committed in 
https://github.com/llvm/llvm-project/commit/639db8a90d2adf7789b9d3cec3a7c26502bf819b


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143348/new/

https://reviews.llvm.org/D143348

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


[PATCH] D144321: [PowerPC] Correctly use ELFv2 ABI on all OS's that use the ELFv2 ABI

2023-02-19 Thread Brad Smith via Phabricator via cfe-commits
brad marked an inline comment as done.
brad added inline comments.



Comment at: clang/lib/Basic/Targets/PPC.h:430-432
+  if ((Triple.isOSFreeBSD() && (Triple.getOSVersion().empty() ||
+Triple.getOSMajorVersion() >= 13)) ||
+  Triple.isOSOpenBSD() || Triple.isMusl())

nemanjai wrote:
> I am generally not a fan of keeping multiple instances of a somewhat complex 
> conditions in sync. I wonder if the community would be OK with one of:
> - Adding a static function in `Triple.h` to test this (`static bool 
> isPPCELFv2ABI(const Triple &)`)
> - Adding a member function `Triple::isPPCELFv2ABI()` (similar to 
> `Triple::isWatchABI()`)
> 
> Then of course, we can use that function in both places.
> I am generally not a fan of keeping multiple instances of a somewhat complex 
> conditions in sync. I wonder if the community would be OK with one of:
> - Adding a static function in `Triple.h` to test this (`static bool 
> isPPCELFv2ABI(const Triple &)`)
> - Adding a member function `Triple::isPPCELFv2ABI()` (similar to 
> `Triple::isWatchABI()`)
> 
> Then of course, we can use that function in both places.

Ultimately something like that would be better as it's used in 3 different 
spots.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144321/new/

https://reviews.llvm.org/D144321

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


[clang] a489e11 - [Fuchsia] Use cleaner method of adding driver binary

2023-02-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-20T03:57:23Z
New Revision: a489e11439e36c7e0ec83b28a6fb1596a5c21faa

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

LOG: [Fuchsia] Use cleaner method of adding driver binary

Added: 


Modified: 
clang/cmake/caches/Fuchsia-stage2.cmake

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 464f7f89fcea..54a64a84f231 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -28,6 +28,7 @@ if(WIN32)
   set(LLVM_USE_CRT_RELEASE "MT" CACHE STRING "")
 else()
   set(LLVM_TOOL_LLVM_DRIVER_BUILD ON CACHE BOOL "")
+  set(LLVM_DRIVER_TARGET llvm-driver)
 endif()
 
 set(CLANG_DEFAULT_CXX_STDLIB libc++ CACHE STRING "")
@@ -294,6 +295,7 @@ set(LLVM_TOOLCHAIN_TOOLS
   llvm-cxxfilt
   llvm-debuginfod-find
   llvm-dlltool
+  ${LLVM_DRIVER_TARGET}
   llvm-dwarfdump
   llvm-dwp
   llvm-ifs
@@ -322,10 +324,6 @@ set(LLVM_TOOLCHAIN_TOOLS
   scan-build-py
   CACHE STRING "")
 
-if(NOT WIN32)
-  list(APPEND LLVM_TOOLCHAIN_TOOLS llvm-driver)
-endif()
-
 set(_FUCHSIA_DISTRIBUTION_COMPONENTS
   clang
   lld



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


[PATCH] D143306: [Driver] Default to -fno-openmp-implicit-rpath

2023-02-19 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

Ping for feedback from others


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143306/new/

https://reviews.llvm.org/D143306

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-02-19 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 498730.
ccotter added a comment.

- Add back -fno-delayed-template-parsing to test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141569/new/

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,303 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: false}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: false}]}" -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,STRICT -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- \
+// RUN: -config="{CheckOptions: [{key: cppcoreguidelines-rvalue-reference-param-not-moved.StrictMode, value: true}]}" -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter 'o1' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parameter 'o2' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:47: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: rvalue reference parameter 'o' is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = []() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = []() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = []() {
+  auto f_nested_inner = []() {
+consumes_object(std::move(o));
+  };
+  

[PATCH] D144352: Do not emit exception diagnostics from coroutines and coroutine lambdas

2023-02-19 Thread Deniz Evrenci via Phabricator via cfe-commits
denizevrenci updated this revision to Diff 498695.
denizevrenci added a comment.

Added some throws that should be ignored.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144352/new/

https://reviews.llvm.org/D144352

Files:
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp


Index: clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -std=c++20 %s -fcxx-exceptions -fsyntax-only -Wexceptions 
-verify -fdeclspec
+
+#include "Inputs/std-coroutine.h"
+
+// expected-no-diagnostics
+
+template 
+struct promise;
+ 
+template 
+struct task {
+using promise_type = promise;
+
+explicit task(promise_type& p) { throw 1; p.return_val = this; }
+
+task(const task&) = delete;
+
+T value;
+};
+ 
+template 
+struct promise {
+task get_return_object() { return task{*this}; }
+
+std::suspend_never initial_suspend() const noexcept { return {}; }
+
+std::suspend_never final_suspend() const noexcept { return {}; }
+
+template 
+void return_value(U&& val) { return_val->value = static_cast(val); }
+
+void unhandled_exception() { throw 1; }
+
+task* return_val;
+};
+
+task a_ShouldNotDiag(const int a, const int b) {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+task b_ShouldNotDiag(const int a, const int b) noexcept {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+const auto c_ShouldNotDiag = [](const int a, const int b) -> task {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+};
+
+const auto d_ShouldNotDiag = [](const int a, const int b) noexcept -> 
task {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+};
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2509,7 +2509,7 @@
   // Check for throw out of non-throwing function.
   if (!Diags.isIgnored(diag::warn_throw_in_noexcept_func, D->getBeginLoc()))
 if (const FunctionDecl *FD = dyn_cast(D))
-  if (S.getLangOpts().CPlusPlus && isNoexcept(FD))
+  if (S.getLangOpts().CPlusPlus && !fscope->isCoroutine() && 
isNoexcept(FD))
 checkThrowInNonThrowingFunc(S, FD, AC);
 
   // Emit unsafe buffer usage warnings and fixits.


Index: clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp
@@ -0,0 +1,63 @@
+// RUN: %clang_cc1 -std=c++20 %s -fcxx-exceptions -fsyntax-only -Wexceptions -verify -fdeclspec
+
+#include "Inputs/std-coroutine.h"
+
+// expected-no-diagnostics
+
+template 
+struct promise;
+ 
+template 
+struct task {
+using promise_type = promise;
+
+explicit task(promise_type& p) { throw 1; p.return_val = this; }
+
+task(const task&) = delete;
+
+T value;
+};
+ 
+template 
+struct promise {
+task get_return_object() { return task{*this}; }
+
+std::suspend_never initial_suspend() const noexcept { return {}; }
+
+std::suspend_never final_suspend() const noexcept { return {}; }
+
+template 
+void return_value(U&& val) { return_val->value = static_cast(val); }
+
+void unhandled_exception() { throw 1; }
+
+task* return_val;
+};
+
+task a_ShouldNotDiag(const int a, const int b) {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+task b_ShouldNotDiag(const int a, const int b) noexcept {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+}
+
+const auto c_ShouldNotDiag = [](const int a, const int b) -> task {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+};
+
+const auto d_ShouldNotDiag = [](const int a, const int b) noexcept -> task {
+  if (b == 0)
+throw b;
+
+  co_return a / b;
+};
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -2509,7 +2509,7 @@
   // Check for throw out of non-throwing function.
   if (!Diags.isIgnored(diag::warn_throw_in_noexcept_func, D->getBeginLoc()))
 if (const FunctionDecl *FD = dyn_cast(D))
-  if (S.getLangOpts().CPlusPlus && isNoexcept(FD))
+  if (S.getLangOpts().CPlusPlus && !fscope->isCoroutine() && isNoexcept(FD))
 checkThrowInNonThrowingFunc(S, FD, AC);
 
   // Emit unsafe buffer usage warnings and fixits.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] a98cafd - [CMake] Fix driver build on MacOS

2023-02-19 Thread Alex Brachet via cfe-commits

Author: Alex Brachet
Date: 2023-02-19T23:42:11Z
New Revision: a98cafd1d0f1144bc9149f7781de41c1abf7c960

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

LOG: [CMake] Fix driver build on MacOS

Added: 


Modified: 
clang/tools/driver/CMakeLists.txt
clang/utils/perf-training/CMakeLists.txt

Removed: 




diff  --git a/clang/tools/driver/CMakeLists.txt 
b/clang/tools/driver/CMakeLists.txt
index 237ed453e28fb..2182486f93a55 100644
--- a/clang/tools/driver/CMakeLists.txt
+++ b/clang/tools/driver/CMakeLists.txt
@@ -84,7 +84,14 @@ if (APPLE)
   set(TOOL_INFO_BUILD_VERSION "${LLVM_VERSION_MAJOR}.${LLVM_VERSION_MINOR}")
 
   set(TOOL_INFO_PLIST_OUT "${CMAKE_CURRENT_BINARY_DIR}/${TOOL_INFO_PLIST}")
-  target_link_libraries(clang
+
+  if(LLVM_TOOL_LLVM_DRIVER_BUILD AND clang IN_LIST LLVM_DRIVER_TOOLS)
+set(TARGET_NAME llvm-driver)
+  else()
+set(TARGET_NAME clang)
+  endif()
+
+  target_link_libraries(${TARGET_NAME}
 PRIVATE
 "-Wl,-sectcreate,__TEXT,__info_plist,\"${TOOL_INFO_PLIST_OUT}\"")
   configure_file("${TOOL_INFO_PLIST}.in" "${TOOL_INFO_PLIST_OUT}" @ONLY)

diff  --git a/clang/utils/perf-training/CMakeLists.txt 
b/clang/utils/perf-training/CMakeLists.txt
index 4cd469ddde3ed..0d551baba2ccf 100644
--- a/clang/utils/perf-training/CMakeLists.txt
+++ b/clang/utils/perf-training/CMakeLists.txt
@@ -33,7 +33,9 @@ if(LLVM_BUILD_INSTRUMENTED)
 endif()
 
 find_program(DTRACE dtrace)
-if(APPLE AND DTRACE)
+# TODO: Look into supporting this for the driver build. It will require 
changing
+# the perf-helper.py file to understand to call `llvm` as `llvm clang`.
+if(APPLE AND DTRACE AND NOT LLVM_TOOL_LLVM_DRIVER_BUILD)
   configure_lit_site_cfg(
 ${CMAKE_CURRENT_SOURCE_DIR}/order-files.lit.site.cfg.in
 ${CMAKE_CURRENT_BINARY_DIR}/order-files/lit.site.cfg



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


[clang] c5cb111 - [Modules] Handle the visibility of GMF during the template instantiation

2023-02-19 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-02-20T14:19:50+08:00
New Revision: c5cb1117e19273a26499a1e18770b74bdf3b9ade

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

LOG: [Modules] Handle the visibility of GMF during the template instantiation

Close https://github.com/llvm/llvm-project/issues/60775

Previously, we will mark all the declarations in the GMF as not visible
to other module units. But this is too strict and the users may meet
problems during the template instantiation like the above exampel shows.
The patch addresseds the problem.

Added: 
clang/test/Modules/pr60775.cppm

Modified: 
clang/lib/Sema/SemaLookup.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index b910974d2ce61..5a5428caf170e 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -1858,19 +1858,6 @@ bool LookupResult::isAcceptableSlow(Sema , 
NamedDecl *D,
 }
 
 bool Sema::isModuleVisible(const Module *M, bool ModulePrivate) {
-  // [module.global.frag]p2:
-  // A global-module-fragment specifies the contents of the global module
-  // fragment for a module unit. The global module fragment can be used to
-  // provide declarations that are attached to the global module and usable
-  // within the module unit.
-  //
-  // Global module fragment is special. Global Module fragment is only usable
-  // within the module unit it got defined [module.global.frag]p2. So here we
-  // check if the Module is the global module fragment in current translation
-  // unit.
-  if (M->isGlobalModule() && M != this->GlobalModuleFragment)
-return false;
-
   // The module might be ordinarily visible. For a module-private query, that
   // means it is part of the current module.
   if (ModulePrivate && isUsableModule(M))
@@ -1889,6 +1876,12 @@ bool Sema::isModuleVisible(const Module *M, bool 
ModulePrivate) {
   if (LookupModules.empty())
 return false;
 
+  // The global module fragments are visible to its corresponding module unit.
+  // So the global module fragment should be visible if the its corresponding
+  // module unit is visible.
+  if (M->isGlobalModule())
+M = M->getTopLevelModule();
+
   // If our lookup set contains the module, it's visible.
   if (LookupModules.count(M))
 return true;
@@ -3888,40 +3881,8 @@ void Sema::ArgumentDependentLookup(DeclarationName Name, 
SourceLocation Loc,
   if (!getLangOpts().CPlusPlusModules)
 continue;
 
-  // A partial mock implementation for instantiation context for
-  // modules. [module.context]p1:
-  //The instantiation context is a set of points within the program
-  //that determines which declarations are found by
-  //argument-dependent name lookup...
-  //
-  // FIXME: This didn't implement [module.context] well. For example,
-  // [module.context]p3 says:
-  //During the implicit instantiation of a template whose point of
-  //instantiation is specified as that of an enclosing
-  //specialization if the template is defined in a module interface
-  //unit of a module M and the point of instantiation is not in a
-  //module interface unit of M, the point at the end of the
-  //declaration-seq of the primary module interface unit of M.
-  //
-  // But we didn't check if the template is defined in a module
-  // interface unit nor we check the context for the primary module
-  // interface.
-  Module *FM = D->getOwningModule();
-  if (FM && !FM->isHeaderLikeModule()) {
-// LookupModules will contain all the modules we visited during the
-// template instantiation (if any). And if LookupModules contains
-// FM, the declarations in FM should be visible for the
-// instantiation.
-const auto  = getLookupModules();
-// Note: We can't use 'Module::isModuleVisible()' since that is for
-// clang modules.
-if (LookupModules.count(FM->getTopLevelModule())) {
-  Visible = true;
-  break;
-}
-  }
-
   if (D->isInExportDeclContext()) {
+Module *FM = D->getOwningModule();
 // C++20 [basic.lookup.argdep] p4.3 .. are exported ...
 // exports are only valid in module purview and outside of any
 // PMF (although a PMF should not even be present in a module

diff  --git a/clang/test/Modules/pr60775.cppm b/clang/test/Modules/pr60775.cppm
new file mode 100644
index 0..e581a876ab17a
--- /dev/null
+++ b/clang/test/Modules/pr60775.cppm
@@ -0,0 +1,97 @@
+// 

[PATCH] D143767: [SVE][Builtins] Lower X forms of fp binop/mla arithmetic builtins to dedicated intrinsics

2023-02-19 Thread dewen via Phabricator via cfe-commits
dewen added a comment.

Hi, thank you. When will this patch be pushed to the master?@paulwalker-arm


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143767/new/

https://reviews.llvm.org/D143767

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


[PATCH] D144355: [clang-format][NFC] Clean up nullptr comparison style

2023-02-19 Thread sstwcw via Phabricator via cfe-commits
sstwcw added a comment.

@MyDeveloperDay Looking at the return lines in the functions in `FormatToken.h` 
got me to check the similar functions not changed by this patch.  And I noticed 
that the final `==` in `isCSharpKeyword` seems to return true when the token is 
not a keyword.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144355/new/

https://reviews.llvm.org/D144355

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


[PATCH] D143825: [clang-format] Put ports on separate lines in Verilog module headers

2023-02-19 Thread sstwcw via Phabricator via cfe-commits
sstwcw added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2665
+if (Style.isVerilog() && Precedence == prec::Comma &&
+VerilogFirstOfType != nullptr) {
+  addFakeParenthesis(VerilogFirstOfType, prec::Comma);

owenpan wrote:
> And other places as well.
@HazardyKnusperkeks Do you agree?  I remember you once said you preferred the 
`nullptr` style.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143825/new/

https://reviews.llvm.org/D143825

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


[PATCH] D144296: [clang-format] Rewrite how indent is reduced for compacted namespaces

2023-02-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D144296#4137508 , 
@HazardyKnusperkeks wrote:

> And I see the style was bogus before, but shouldn't all variables start with 
> a capital letter? Please fix that in the code you touch.

+1.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144296/new/

https://reviews.llvm.org/D144296

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


[clang] cbde212 - Use APInt::popcount instead of APInt::countPopulation (NFC)

2023-02-19 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-02-19T11:29:12-08:00
New Revision: cbde2124f153f8fd084e8ff1221c0357442ea707

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

LOG: Use APInt::popcount instead of APInt::countPopulation (NFC)

This is for consistency with the C++20-style bit manipulation
functions in .

Added: 


Modified: 
clang/lib/AST/ExprConstant.cpp
llvm/include/llvm/ADT/APInt.h
llvm/include/llvm/CodeGen/BasicTTIImpl.h
llvm/include/llvm/Support/KnownBits.h
llvm/lib/Analysis/ConstantFolding.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstCombineIntrinsic.cpp
llvm/lib/Target/AMDGPU/AMDGPUInstructionSelector.cpp
llvm/lib/Target/ARM/ARMISelDAGToDAG.cpp
llvm/lib/Target/ARM/ARMISelLowering.cpp
llvm/lib/Target/Mips/MipsSEISelDAGToDAG.cpp
llvm/lib/Target/X86/X86ISelLowering.cpp
llvm/lib/Target/X86/X86TargetTransformInfo.cpp
llvm/lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/utils/TableGen/CodeGenSchedule.cpp
mlir/lib/Dialect/Math/IR/MathOps.cpp

Removed: 




diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 3e2164c4eebc8..e44aa546aae6c 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -12142,7 +12142,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
 
-return Success(Val.countPopulation() % 2, E);
+return Success(Val.popcount() % 2, E);
   }
 
   case Builtin::BI__builtin_popcount:
@@ -12152,7 +12152,7 @@ bool IntExprEvaluator::VisitBuiltinCallExpr(const 
CallExpr *E,
 if (!EvaluateInteger(E->getArg(0), Val, Info))
   return false;
 
-return Success(Val.countPopulation(), E);
+return Success(Val.popcount(), E);
   }
 
   case Builtin::BI__builtin_rotateleft8:

diff  --git a/llvm/include/llvm/ADT/APInt.h b/llvm/include/llvm/ADT/APInt.h
index 948e3f71ddae3..aa78d648c46a7 100644
--- a/llvm/include/llvm/ADT/APInt.h
+++ b/llvm/include/llvm/ADT/APInt.h
@@ -347,7 +347,7 @@ class [[nodiscard]] APInt {
   ///
   /// \returns true if this APInt only has the specified bit set.
   bool isOneBitSet(unsigned BitNo) const {
-return (*this)[BitNo] && countPopulation() == 1;
+return (*this)[BitNo] && popcount() == 1;
   }
 
   /// Determine if all bits are set.  This is true for zero-width values.

diff  --git a/llvm/include/llvm/CodeGen/BasicTTIImpl.h 
b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
index ce1caafb92fb9..02eff6ad1e1ed 100644
--- a/llvm/include/llvm/CodeGen/BasicTTIImpl.h
+++ b/llvm/include/llvm/CodeGen/BasicTTIImpl.h
@@ -1508,7 +1508,7 @@ class BasicTTIImplBase : public 
TargetTransformInfoImplCRTPBase {
   // SelectionDAGBuilder.
   APInt Exponent = RHSC->getValue().abs();
   unsigned ActiveBits = Exponent.getActiveBits();
-  unsigned PopCount = Exponent.countPopulation();
+  unsigned PopCount = Exponent.popcount();
   InstructionCost Cost = (ActiveBits + PopCount - 2) *
  thisT()->getArithmeticInstrCost(
  Instruction::FMul, RetTy, CostKind);

diff  --git a/llvm/include/llvm/Support/KnownBits.h 
b/llvm/include/llvm/Support/KnownBits.h
index 83b962a11ea34..caa0aef93e028 100644
--- a/llvm/include/llvm/Support/KnownBits.h
+++ b/llvm/include/llvm/Support/KnownBits.h
@@ -49,7 +49,7 @@ struct KnownBits {
   /// Returns true if we know the value of all bits.
   bool isConstant() const {
 assert(!hasConflict() && "KnownBits conflict!");
-return Zero.countPopulation() + One.countPopulation() == getBitWidth();
+return Zero.popcount() + One.popcount() == getBitWidth();
   }
 
   /// Returns the value when all bits have a known value. This just returns One
@@ -290,13 +290,11 @@ struct KnownBits {
   }
 
   /// Returns the number of bits known to be one.
-  unsigned countMinPopulation() const {
-return One.countPopulation();
-  }
+  unsigned countMinPopulation() const { return One.popcount(); }
 
   /// Returns the maximum number of bits that could be one.
   unsigned countMaxPopulation() const {
-return getBitWidth() - Zero.countPopulation();
+return getBitWidth() - Zero.popcount();
   }
 
   /// Returns the maximum number of bits needed to represent all possible

diff  --git a/llvm/lib/Analysis/ConstantFolding.cpp 
b/llvm/lib/Analysis/ConstantFolding.cpp
index a43402d2b62ce..5a6490a4ca13c 100644
--- 

[PATCH] D143507: [RISCV][MC] Mark Zawrs extension as non-experimental

2023-02-19 Thread Alex Bradbury via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd41a73aa94cb: [RISCV][MC] Mark Zawrs extension as 
non-experimental (authored by asb).

Changed prior to commit:
  https://reviews.llvm.org/D143507?vs=495562=498691#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143507/new/

https://reviews.llvm.org/D143507

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVFeatures.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/Zawrs-valid.s

Index: llvm/test/MC/RISCV/Zawrs-valid.s
===
--- llvm/test/MC/RISCV/Zawrs-valid.s
+++ llvm/test/MC/RISCV/Zawrs-valid.s
@@ -1,12 +1,12 @@
-# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zawrs -riscv-no-aliases -show-encoding \
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+zawrs -riscv-no-aliases -show-encoding \
 # RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
-# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zawrs -riscv-no-aliases -show-encoding \
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+zawrs -riscv-no-aliases -show-encoding \
 # RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
-# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zawrs < %s \
-# RUN: | llvm-objdump --mattr=+experimental-zawrs -M no-aliases -d -r - \
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+zawrs < %s \
+# RUN: | llvm-objdump --mattr=+zawrs -M no-aliases -d -r - \
 # RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
-# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zawrs < %s \
-# RUN: | llvm-objdump --mattr=+experimental-zawrs -M no-aliases -d -r - \
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+zawrs < %s \
+# RUN: | llvm-objdump --mattr=+zawrs -M no-aliases -d -r - \
 # RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
 
 # CHECK-ASM-AND-OBJ: wrs.nto
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -97,7 +97,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+xtheadbs %s -o - | FileCheck --check-prefixes=CHECK,RV64XTHEADBS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+xtheadmac %s -o - | FileCheck --check-prefixes=CHECK,RV64XTHEADMAC %s
 ; RUN: llc -mtriple=riscv64 -mattr=+xtheadvdot %s -o - | FileCheck --check-prefixes=CHECK,RV64XTHEADVDOT %s
-; RUN: llc -mtriple=riscv64 -mattr=+experimental-zawrs %s -o - | FileCheck --check-prefixes=CHECK,RV64ZAWRS %s
+; RUN: llc -mtriple=riscv64 -mattr=+zawrs %s -o - | FileCheck --check-prefixes=CHECK,RV64ZAWRS %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-ztso %s -o - | FileCheck --check-prefixes=CHECK,RV64ZTSO %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zca %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefixes=CHECK,RV64ZCB %s
Index: llvm/lib/Target/RISCV/RISCVFeatures.td
===
--- llvm/lib/Target/RISCV/RISCVFeatures.td
+++ llvm/lib/Target/RISCV/RISCVFeatures.td
@@ -467,9 +467,8 @@
   AssemblerPredicate<(all_of FeatureStdExtZtso),
   "'Ztso' (Memory Model - Total Store Order)">;
 
-def FeatureStdExtZawrs
-: SubtargetFeature<"experimental-zawrs", "HasStdExtZawrs", "true",
-   "'Zawrs' (Wait on Reservation Set)">;
+def FeatureStdExtZawrs : SubtargetFeature<"zawrs", "HasStdExtZawrs", "true",
+  "'Zawrs' (Wait on Reservation Set)">;
 def HasStdExtZawrs : Predicate<"Subtarget->hasStdExtZawrs()">,
AssemblerPredicate<(all_of FeatureStdExtZawrs),
"'Zawrs' (Wait on Reservation Set)">;
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -106,6 +106,8 @@
 {"zicsr", RISCVExtensionVersion{2, 0}},
 {"zifencei", RISCVExtensionVersion{2, 0}},
 
+{"zawrs", RISCVExtensionVersion{1, 0}},
+
 {"svnapot", RISCVExtensionVersion{1, 0}},
 {"svpbmt", RISCVExtensionVersion{1, 0}},
 {"svinval", RISCVExtensionVersion{1, 0}},
@@ -128,7 +130,6 @@
 {"zcf", RISCVExtensionVersion{1, 0}},
 {"zfa", RISCVExtensionVersion{0, 1}},
 {"zvfh", RISCVExtensionVersion{0, 1}},
-{"zawrs", RISCVExtensionVersion{1, 0}},
 {"ztso", RISCVExtensionVersion{0, 1}},
 };
 
Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -112,6 

[clang] d41a73a - [RISCV][MC] Mark Zawrs extension as non-experimental

2023-02-19 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-02-19T20:43:03Z
New Revision: d41a73aa94cb8945dcd0f2906992c2fcea6ed001

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

LOG: [RISCV][MC] Mark Zawrs extension as non-experimental

Support for the unratified 1.0-rc3 specification was introduced in
D133443. The specification has since been ratified (in November 2022
according to the recently ratified extensions list
.

A review of the diff
 of the
1.0-rc3 spec vs the current/ratified document shows no changes to the
instruction encoding or naming. At one point, a note was added

indicating Zawrs depends on the Zalrsc extension (not officially
specified, but I believe to be just the LR/SC instructions from the A
extension). The final text ended up as "The instructions in the Zawrs
extension are only useful in conjunction with the LR instructions, which
are provided by the A extension, and which we also expect to be provided
by a narrower Zalrsc extension in the future." I think it's consistent
with this phrasing to not require the A extension for Zawrs, which
matches what was implemented.

No intrinsics are implemented for Zawrs currently, meaning we don't need
to additionally review whether those intrinsics can be considered
finalised and ready for exposure to end users.

Differential Revision: https://reviews.llvm.org/D143507

Added: 


Modified: 
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/docs/ReleaseNotes.rst
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/RISCVFeatures.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/MC/RISCV/Zawrs-valid.s

Removed: 




diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index f965f1ee8748c..755248f63edff 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -424,11 +424,11 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZICBOP-EXT %s
 // CHECK-ZICBOP-EXT: __riscv_zicbop 100{{$}}
 
-// RUN: %clang -target riscv32-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv32izawrs1p0 -x c -E -dM %s \
+// RUN: %clang -target riscv32-unknown-linux-gnu \
+// RUN: -march=rv32izawrs -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZAWRS-EXT %s
-// RUN: %clang -target riscv64-unknown-linux-gnu 
-menable-experimental-extensions \
-// RUN: -march=rv64izawrs1p0 -x c -E -dM %s \
+// RUN: %clang -target riscv64-unknown-linux-gnu \
+// RUN: -march=rv64izawrs -x c -E -dM %s \
 // RUN: -o - | FileCheck --check-prefix=CHECK-ZAWRS-EXT %s
 // CHECK-ZAWRS-EXT: __riscv_zawrs 100{{$}}
 

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 677d87e964241..f685908b618af 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -57,6 +57,7 @@ on support follow.
  ``Svnapot``  Assembly Support
  ``Svpbmt``   Supported
  ``V``Supported
+ ``Zawrs``Assembly Support
  ``Zba``  Supported
  ``Zbb``  Supported
  ``Zbc``  Supported
@@ -139,9 +140,6 @@ LLVM supports (to various degrees) a number of experimental 
extensions.  All exp
 
 The primary goal of experimental support is to assist in the process of 
ratification by providing an existence proof of an implementation, and 
simplifying efforts to validate the value of a proposed extension against large 
code bases.  Experimental extensions are expected to either transition to 
ratified status, or be eventually removed.  The decision on whether to accept 
an experimental extension is currently done on an entirely case by case basis; 
if you want to propose one, attending the bi-weekly RISC-V sync-up call is 
strongly advised.
 
-``experimental-zawrs``
-  LLVM implements the `1.0-rc3 draft specification 
`_.  
Note that have been backwards incompatible changes made between release 
candidates for the 1.0 draft.
-
 ``experimental-zca``
   LLVM implements the `1.0.1 draft specification 
`_.
 

diff  --git a/llvm/docs/ReleaseNotes.rst b/llvm/docs/ReleaseNotes.rst
index c0bc8e0a3299c..31f7c4e229ba3 100644
--- a/llvm/docs/ReleaseNotes.rst
+++ b/llvm/docs/ReleaseNotes.rst
@@ -112,6 +112,7 @@ Changes to the RISC-V Backend
 * Adds support for the vendor-defined XTHeadBb (basic bit-manipulation) 
extension.
 * Adds support for the vendor-defined XTHeadBs 

[PATCH] D127910: [Clang][AArch64][SME] Add vector load/store (ld1/st1) intrinsics

2023-02-19 Thread Bryan Chan via Phabricator via cfe-commits
bryanpkc updated this revision to Diff 498700.
bryanpkc marked 2 inline comments as done and an inline comment as not done.
bryanpkc added a comment.

Addressed review comments.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D127910/new/

https://reviews.llvm.org/D127910

Files:
  clang/include/clang/Basic/BuiltinsNEON.def
  clang/include/clang/Basic/BuiltinsSME.def
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TargetBuiltins.h
  clang/include/clang/Basic/arm_sme.td
  clang/include/clang/Basic/arm_sve.td
  clang/include/clang/Basic/arm_sve_sme_incl.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Headers/CMakeLists.txt
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_ld1_vnum.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_st1.c
  clang/test/CodeGen/aarch64-sme-intrinsics/acle_sme_st1_vnum.c
  clang/test/Sema/aarch64-sme-intrinsics/acle_sme_imm.cpp
  clang/test/Sema/aarch64-sme-target.c
  clang/utils/TableGen/SveEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h

Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -101,6 +101,11 @@
 void EmitSveTypeFlags(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitSveRangeChecks(llvm::RecordKeeper , llvm::raw_ostream );
 
+void EmitSmeHeader(llvm::RecordKeeper , llvm::raw_ostream );
+void EmitSmeBuiltins(llvm::RecordKeeper , llvm::raw_ostream );
+void EmitSmeBuiltinCG(llvm::RecordKeeper , llvm::raw_ostream );
+void EmitSmeRangeChecks(llvm::RecordKeeper , llvm::raw_ostream );
+
 void EmitMveHeader(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitMveBuiltinDef(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitMveBuiltinSema(llvm::RecordKeeper , llvm::raw_ostream );
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -81,6 +81,10 @@
   GenArmSveBuiltinCG,
   GenArmSveTypeFlags,
   GenArmSveRangeChecks,
+  GenArmSmeHeader,
+  GenArmSmeBuiltins,
+  GenArmSmeBuiltinCG,
+  GenArmSmeRangeChecks,
   GenArmCdeHeader,
   GenArmCdeBuiltinDef,
   GenArmCdeBuiltinSema,
@@ -219,6 +223,14 @@
"Generate arm_sve_typeflags.inc for clang"),
 clEnumValN(GenArmSveRangeChecks, "gen-arm-sve-sema-rangechecks",
"Generate arm_sve_sema_rangechecks.inc for clang"),
+clEnumValN(GenArmSmeHeader, "gen-arm-sme-header",
+   "Generate arm_sme.h for clang"),
+clEnumValN(GenArmSmeBuiltins, "gen-arm-sme-builtins",
+   "Generate arm_sme_builtins.inc for clang"),
+clEnumValN(GenArmSmeBuiltinCG, "gen-arm-sme-builtin-codegen",
+   "Generate arm_sme_builtin_cg_map.inc for clang"),
+clEnumValN(GenArmSmeRangeChecks, "gen-arm-sme-sema-rangechecks",
+   "Generate arm_sme_sema_rangechecks.inc for clang"),
 clEnumValN(GenArmMveHeader, "gen-arm-mve-header",
"Generate arm_mve.h for clang"),
 clEnumValN(GenArmMveBuiltinDef, "gen-arm-mve-builtin-def",
@@ -438,6 +450,18 @@
   case GenArmSveRangeChecks:
 EmitSveRangeChecks(Records, OS);
 break;
+  case GenArmSmeHeader:
+EmitSmeHeader(Records, OS);
+break;
+  case GenArmSmeBuiltins:
+EmitSmeBuiltins(Records, OS);
+break;
+  case GenArmSmeBuiltinCG:
+EmitSmeBuiltinCG(Records, OS);
+break;
+  case GenArmSmeRangeChecks:
+EmitSmeRangeChecks(Records, OS);
+break;
   case GenArmCdeHeader:
 EmitCdeHeader(Records, OS);
 break;
Index: clang/utils/TableGen/SveEmitter.cpp
===
--- clang/utils/TableGen/SveEmitter.cpp
+++ clang/utils/TableGen/SveEmitter.cpp
@@ -228,7 +228,7 @@
   }
 
   /// Emits the intrinsic declaration to the ostream.
-  void emitIntrinsic(raw_ostream ) const;
+  void emitIntrinsic(raw_ostream , SVEEmitter ) const;
 
 private:
   std::string getMergeSuffix() const { return MergeSuffix; }
@@ -346,8 +346,21 @@
   /// Create the SVETypeFlags used in CGBuiltins
   void createTypeFlags(raw_ostream );
 
+  /// Emit arm_sme.h.
+  void createSMEHeader(raw_ostream );
+
+  /// Emit all the SME __builtin prototypes and code needed by Sema.
+  void createSMEBuiltins(raw_ostream );
+
+  /// Emit all the information needed to map builtin -> LLVM IR intrinsic.
+  void createSMECodeGenMap(raw_ostream );
+
+  /// Emit all the range checks for the immediates.
+  void createSMERangeChecks(raw_ostream );
+
   /// Create intrinsic and add it to \p Out
-  void createIntrinsic(Record *R, 

[PATCH] D144296: [clang-format] Rewrite how indent is reduced for compacted namespaces

2023-02-19 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D144296#4136133 , @rymiel wrote:

> Note: this patch also makes `LevelIndentTracker::skipLine` obsolete. I 
> suppose I could clean that up in a following patch

I'd delete it in this patch.




Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:369
 if (Style.CompactNamespaces) {
-  if (auto nsToken = TheLine->First->getNamespaceToken()) {
-int i = 0;
-unsigned closingLine = TheLine->MatchingClosingBlockLineIndex - 1;
-for (; I + 1 + i != E &&
-   nsToken->TokenText == getNamespaceTokenText(I[i + 1]) &&
-   closingLine == I[i + 1]->MatchingClosingBlockLineIndex &&
-   I[i + 1]->Last->TotalLength < Limit;
- i++, --closingLine) {
-  // No extra indent for compacted namespaces.
-  IndentTracker.skipLine(*I[i + 1]);
+  if (auto *nsToken = TheLine->First->getNamespaceToken()) {
+int j = 1;





Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:371-373
+unsigned closingLineIndex = TheLine->MatchingClosingBlockLineIndex - 1;
 
+for (; I + j != E &&





Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:377
+   I[j]->Last->TotalLength < Limit;
+ j++, --closingLineIndex) {
+  Limit -= I[j]->Last->TotalLength;





Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:381
+  // Reduce indent level for bodies of namespaces which were compacted,
+  // but only if their content was indented in the first place
+  auto *closingLine = AnnotatedLines.begin() + closingLineIndex + 1;





Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:383
+  auto *closingLine = AnnotatedLines.begin() + closingLineIndex + 1;
+  auto dedentBy = I[j]->Level - TheLine->Level;
+  for (auto *compactedLine = I + j; compactedLine <= closingLine;

`outdentBy`?



Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:385
+  for (auto *compactedLine = I + j; compactedLine <= closingLine;
+   compactedLine++) {
+if (!(*compactedLine)->InPPDirective)





Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:387
+if (!(*compactedLine)->InPPDirective)
+  (*compactedLine)->Level-= dedentBy;
+  }

Did git-clang-format miss this?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D144296/new/

https://reviews.llvm.org/D144296

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


[PATCH] D143825: [clang-format] Put ports on separate lines in Verilog module headers

2023-02-19 Thread sstwcw via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e473aeffdc1: [clang-format] Put ports on separate lines in 
Verilog module headers (authored by sstwcw).

Changed prior to commit:
  https://reviews.llvm.org/D143825?vs=498376=498711#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143825/new/

https://reviews.llvm.org/D143825

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTestVerilog.cpp

Index: clang/unittests/Format/FormatTestVerilog.cpp
===
--- clang/unittests/Format/FormatTestVerilog.cpp
+++ clang/unittests/Format/FormatTestVerilog.cpp
@@ -252,6 +252,34 @@
Style);
 }
 
+TEST_F(FormatTestVerilog, Declaration) {
+  verifyFormat("wire mynet;");
+  verifyFormat("wire mynet, mynet1;");
+  verifyFormat("wire mynet, //\n"
+   " mynet1;");
+  verifyFormat("wire mynet = enable;");
+  verifyFormat("wire mynet = enable, mynet1;");
+  verifyFormat("wire mynet = enable, //\n"
+   " mynet1;");
+  verifyFormat("wire mynet, mynet1 = enable;");
+  verifyFormat("wire mynet, //\n"
+   " mynet1 = enable;");
+  verifyFormat("wire mynet = enable, mynet1 = enable;");
+  verifyFormat("wire mynet = enable, //\n"
+   " mynet1 = enable;");
+  verifyFormat("wire (strong1, pull0) mynet;");
+  verifyFormat("wire (strong1, pull0) mynet, mynet1;");
+  verifyFormat("wire (strong1, pull0) mynet, //\n"
+   "  mynet1;");
+  verifyFormat("wire (strong1, pull0) mynet = enable;");
+  verifyFormat("wire (strong1, pull0) mynet = enable, mynet1;");
+  verifyFormat("wire (strong1, pull0) mynet = enable, //\n"
+   "  mynet1;");
+  verifyFormat("wire (strong1, pull0) mynet, mynet1 = enable;");
+  verifyFormat("wire (strong1, pull0) mynet, //\n"
+   "  mynet1 = enable;");
+}
+
 TEST_F(FormatTestVerilog, Delay) {
   // Delay by the default unit.
   verifyFormat("#0;");
@@ -275,6 +303,155 @@
 "x = x;"));
 }
 
+TEST_F(FormatTestVerilog, Headers) {
+  // Test headers with multiple ports.
+  verifyFormat("module mh1\n"
+   "(input var int in1,\n"
+   " input var shortreal in2,\n"
+   " output tagged_st out);\n"
+   "endmodule");
+  // Ports should be grouped by types.
+  verifyFormat("module test\n"
+   "(input [7 : 0] a,\n"
+   " input signed [7 : 0] b, c, d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "(input [7 : 0] a,\n"
+   " (* x = x *) input signed [7 : 0] b, c, d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "(input [7 : 0] a = 0,\n"
+   " input signed [7 : 0] b = 0, c = 0, d = 0);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "#(parameter x)\n"
+   "(input [7 : 0] a,\n"
+   " input signed [7 : 0] b, c, d);\n"
+   "endmodule");
+  // When a line needs to be broken, ports of the same type should be aligned to
+  // the same column.
+  verifyFormat("module test\n"
+   "(input signed [7 : 0] b, c, //\n"
+   "  d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "((* x = x *) input signed [7 : 0] b, c, //\n"
+   "  d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "(input signed [7 : 0] b = 0, c, //\n"
+   "  d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "(input signed [7 : 0] b, c = 0, //\n"
+   "  d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "(input signed [7 : 0] b, c, //\n"
+   "  d = 0);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "(input wire logic signed [7 : 0][0 : 1] b, c, //\n"
+   "d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "(input signed [7 : 0] b, //\n"
+   "  c, //\n"
+   "  d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+   "(input [7 : 0] a,\n"
+   " input signed [7 : 0] b, //\n"
+   "  c, //\n"
+   "  d);\n"
+   "endmodule");
+  verifyFormat("module test\n"
+

[clang] 6e473ae - [clang-format] Put ports on separate lines in Verilog module headers

2023-02-19 Thread via cfe-commits

Author: sstwcw
Date: 2023-02-20T03:24:13Z
New Revision: 6e473aeffdc1c26307e19f68252767a32e0047ad

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

LOG: [clang-format] Put ports on separate lines in Verilog module headers

New:
```
module mh1
(input var int in1,
 input var in2, in3,
 output tagged_st out);
endmodule
```

Old:
```
module mh1
(input var int in1, input var in2, in3, output tagged_st out);
endmodule
```

`getNextNonComment` was modified to return a non-const pointer because
we needed to use it that way in `verilogGroupDecl`.

The comment on line 2626 was a typo.  We corrected it while modifying
the function.

Reviewed By: MyDeveloperDay

Differential Revision: https://reviews.llvm.org/D143825

Added: 


Modified: 
clang/lib/Format/FormatToken.h
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTestVerilog.cpp

Removed: 




diff  --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index d5a2a39094bea..d06a59e5ec1e4 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -152,8 +152,12 @@ namespace format {
   TYPE(VerilogDimensionedTypeName) 
\
   /* for the base in a number literal, not including the quote */  
\
   TYPE(VerilogNumberBase)  
\
+  /* like `(strong1, pull0)` */
\
+  TYPE(VerilogStrength)
\
   /* Things inside the table in user-defined primitives. */
\
   TYPE(VerilogTableItem)   
\
+  /* those that separate ports of 
diff erent types */   \
+  TYPE(VerilogTypeComma)   
\
   TYPE(Unknown)
 
 /// Determines the semantic type of a syntactic token, e.g. whether "<" is a
@@ -1792,6 +1796,27 @@ struct AdditionalKeywords {
 kw_input, kw_output, kw_sequence)));
   }
 
+  bool isVerilogQualifier(const FormatToken ) const {
+switch (Tok.Tok.getKind()) {
+case tok::kw_extern:
+case tok::kw_signed:
+case tok::kw_static:
+case tok::kw_unsigned:
+case tok::kw_virtual:
+  return true;
+case tok::identifier:
+  return Tok.isOneOf(
+  kw_let, kw_var, kw_ref, kw_automatic, kw_bins, kw_coverpoint,
+  kw_ignore_bins, kw_illegal_bins, kw_inout, kw_input, kw_interconnect,
+  kw_local, kw_localparam, kw_output, kw_parameter, kw_pure, kw_rand,
+  kw_randc, kw_scalared, kw_specparam, kw_tri, kw_tri0, kw_tri1,
+  kw_triand, kw_trior, kw_trireg, kw_uwire, kw_vectored, kw_wand,
+  kw_wildcard, kw_wire, kw_wor);
+default:
+  return false;
+}
+  }
+
 private:
   /// The JavaScript keywords beyond the C++ keyword set.
   std::unordered_set JsExtraKeywords;

diff  --git a/clang/lib/Format/TokenAnnotator.cpp 
b/clang/lib/Format/TokenAnnotator.cpp
index 34c51c240cd34..0461531c32b18 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2596,8 +2596,21 @@ class ExpressionParser {
 FormatToken *Start = Current;
 FormatToken *LatestOperator = nullptr;
 unsigned OperatorIndex = 0;
+// The first name of the current type in a port list.
+FormatToken *VerilogFirstOfType = nullptr;
 
 while (Current) {
+  // In Verilog ports in a module header that don't have a type take the
+  // type of the previous one.  For example,
+  //   module a(output b,
+  //   c,
+  //output d);
+  // In this case there need to be fake parentheses around b and c.
+  if (Style.isVerilog() && Precedence == prec::Comma) {
+VerilogFirstOfType =
+verilogGroupDecl(VerilogFirstOfType, LatestOperator);
+  }
+
   // Consume operators with higher precedence.
   parse(Precedence + 1);
 
@@ -2610,7 +2623,7 @@ class ExpressionParser {
 Start = Current;
   }
 
-  // At the end of the line or when an operator with higher precedence is
+  // At the end of the line or when an operator with lower precedence is
   // found, insert fake parenthesis and return.
   if (!Current ||
   (Current->closesScope() &&
@@ -2647,6 +2660,10 @@ class ExpressionParser {
   }
 }
 
+// Group variables of the same type.
+if (Style.isVerilog() && Precedence == prec::Comma && VerilogFirstOfType)
+  addFakeParenthesis(VerilogFirstOfType, prec::Comma);
+
 if (LatestOperator && (Current || Precedence > 0)) {
   // The requires clauses do not neccessarily end in a semicolon or