[PATCH] D141310: [clang] add -Wcompare-function-pointers

2023-01-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

@adriandole do you plan to deploy this in a codebase? Have you tried it on a 
codebase already?

I'd worry this would just be too noisy, and there's probably enough benign 
pointer comparisons that'll never hit the ICF false-equality situation (eg: 
putting some callbacks in a map/set/something - where the callbacks all do 
genuinely different things, so they'd never end up with accidental identical 
functions/folding) that it wouldn't be feasible to use this in a real codebase?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141310

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


[PATCH] D131858: [clang] Track the templated entity in type substitution.

2023-01-14 Thread Vassil Vassilev via Phabricator via cfe-commits
v.g.vassilev added a comment.

In D131858#4052031 , @erichkeane 
wrote:

> In D131858#4052026 , @v.g.vassilev 
> wrote:
>
>> Thanks a lot @rsmith for providing a fix and thanks a lot @aaron.ballman and 
>> @erichkeane for the efforts saving @mizvekov work over the summer. I believe 
>> he has sporadic access to internet and soon he will be back to normal. Great 
>> example of team work here!!
>
> Note we don't yet have the evidence that this is savable yet, we should know 
> in the next day or so.  At minimum, at least 1 of his patches needs to be 
> reverted due to the memory regression.

I see that https://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/6584/ 
picked up your revert and seems successful. Then the next build is green as 
well and then starts failing for a reason that’s unrelated to this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131858

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


[PATCH] D141738: [WIP] Add initial support for cross compile Windows runtimes under Linux when building Fuchsia clang toolchain

2023-01-14 Thread Petr Hosek via Phabricator via cfe-commits
phosek added inline comments.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:73
+
+if(WIN32 OR (LINUX AND WINDOWS_SDK_DIR))
+#if(WINDOWS_SDK_DIR)

I'd drop this part altogether, let's build these anytime when `WINDOWS_SDK_DIR` 
is set.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:96-99
+-Xclang
+-ivfsoverlay
+-Xclang
+"${WINDOWS_SDK_DIR}/llvm-vfsoverlay.yaml"

I think we should introduce a new LLVM CMake option for setting this akin to 
`LLVM_WINSYSROOT` (for example `LLVM_VFSOVERLAY`).



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:100-101
+"${WINDOWS_SDK_DIR}/llvm-vfsoverlay.yaml"
+/winsysroot
+${WINDOWS_SDK_DIR})
+string(REPLACE ";" " " CLANG_WINDOWS_CROSS_FLAGS 
"${CLANG_WINDOWS_CROSS_FLAGS}")

Can we instead set `BUILTINS_${target}_LLVM_WINSYSROOT` to `${WINDOWS_SDK_DIR}`?



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:105-108
+-libpath:"${WINDOWS_SDK_DIR}/VC/Tools/MSVC/14.34.31933/lib/x64"
+-libpath:"${WINDOWS_SDK_DIR}/VC/Tools/MSVC/14.34.31933/atlmfc/lib/x64"
+-libpath:"${WINDOWS_SDK_DIR}/Windows Kits/10/Lib/10.0.19041.0/ucrt/x64"
+-libpath:"${WINDOWS_SDK_DIR}/Windows Kits/10/Lib/10.0.19041.0/um/x64")

These should be set automatically if you set `/winsysroot` (through 
`LLVM_WINSYSROOT`), see 
https://github.com/llvm/llvm-project/blob/a64846bee0bb4b4912c8cf6bf018ba5d892065d1/clang/lib/Driver/ToolChains/MSVC.cpp#L107.



Comment at: clang/cmake/caches/Fuchsia-stage2.cmake:144-145
+"${WINDOWS_SDK_DIR}/llvm-vfsoverlay.yaml"
+/winsysroot
+${WINDOWS_SDK_DIR})
+string(REPLACE ";" " " CLANG_WINDOWS_CROSS_FLAGS 
"${CLANG_WINDOWS_CROSS_FLAGS}")

Can we instead set `RUNTIMES_${target}_LLVM_WINSYSROOT` to `${WINDOWS_SDK_DIR}`?



Comment at: llvm/cmake/modules/LLVMExternalProjectUtils.cmake:172
+  
-DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang-cl${CMAKE_EXECUTABLE_SUFFIX}
+  
-DCMAKE_RC_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-rc
+  -DCMAKE_MT=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-mt

This should be in a separate block just like other tools below guarded by a 
`llvm-rc IN_LIST TOOLCHAIN_TOOLS` condition.



Comment at: llvm/cmake/modules/LLVMExternalProjectUtils.cmake:173
+  
-DCMAKE_RC_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-rc
+  -DCMAKE_MT=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-mt
+  )

This should be in a separate block just like other tools below guarded by a 
`llvm-mt IN_LIST TOOLCHAIN_TOOLS` condition. 



Comment at: llvm/runtimes/CMakeLists.txt:359
 
-  if(NOT RUNTIMES_${name}_LLVM_USE_LINKER AND NOT 
RUNTIMES_${target}_LLVM_USE_LINKER)
+  if(NOT RUNTIMES_${name}_LLVM_USE_LINKER AND NOT 
RUNTIMES_${target}_LLVM_USE_LINKER AND NOT ${target} STREQUAL 
"x86_64-pc-windows-msvc")
 list(APPEND ${name}_extra_args -DLLVM_USE_LINKER=${LLVM_USE_LINKER})

We should fix the build so that this isn't needed, it should be possible to use 
`LLVM_USE_LINKER=lld` when targeting Windows.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141738

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


[PATCH] D141744: [Clang] Add lifetimebound attribute to std::move/std::forward

2023-01-14 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
alexander-shaposhnikov updated this revision to Diff 489322.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141744

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/SemaCXX/attr-lifetimebound.cpp
  clang/test/SemaCXX/builtin-std-move.cpp
  clang/test/SemaCXX/builtins.cpp

Index: clang/test/SemaCXX/builtins.cpp
===
--- clang/test/SemaCXX/builtins.cpp
+++ clang/test/SemaCXX/builtins.cpp
@@ -40,7 +40,7 @@
   struct U { int n : 5; } u;
   int *pbf = __builtin_addressof(u.n); // expected-error {{address of bit-field requested}}
 
-  S *ptmp = __builtin_addressof(S{}); // expected-error {{taking the address of a temporary}}
+  S *ptmp = __builtin_addressof(S{}); // expected-error {{taking the address of a temporary}} expected-warning {{temporary whose address is used as value of local variable 'ptmp' will be destroyed at the end of the full-expression}}
 }
 
 namespace function_start {
Index: clang/test/SemaCXX/builtin-std-move.cpp
===
--- clang/test/SemaCXX/builtin-std-move.cpp
+++ clang/test/SemaCXX/builtin-std-move.cpp
@@ -85,7 +85,7 @@
 
 A &forward_rval_as_lval() {
   std::forward(A()); // expected-warning {{const attribute}}
-  return std::forward(A()); // expected-note {{instantiation of}}
+  return std::forward(A()); // expected-note {{instantiation of}} expected-warning {{returning reference}}
 }
 
 struct B {};
Index: clang/test/SemaCXX/attr-lifetimebound.cpp
===
--- clang/test/SemaCXX/attr-lifetimebound.cpp
+++ clang/test/SemaCXX/attr-lifetimebound.cpp
@@ -113,3 +113,77 @@
   std::map m;
   const std::string &v = findOrDefault(m, "foo"s, "bar"s); // expected-warning {{temporary bound to local reference 'v'}}
 }
+
+// definitions for std::move, std::forward et al.
+namespace std {
+inline namespace foo {
+
+template  struct remove_reference {
+typedef T type;
+};
+template  struct remove_reference {
+typedef T type;
+};
+template  struct remove_reference {
+typedef T type;
+};
+
+template  constexpr typename remove_reference::type &&move(T &&t) {
+return static_cast::type>(t);
+}
+
+template 
+constexpr T &&forward(typename remove_reference::type &t) {
+return static_cast(t);
+}
+
+template 
+constexpr T &&forward(typename remove_reference::type &&t) {
+return static_cast(t);
+}
+
+template  constexpr const T &as_const(T &x) { return x; }
+
+template  struct PickRef {
+using type = typename remove_reference::type &;
+};
+template  struct PickRef {
+using type = typename remove_reference::type &&;
+};
+
+template 
+auto move_if_noexcept(T &t) ->
+typename PickRef(t)))>::type {
+return static_cast<
+typename PickRef(t)))>::type>(t);
+}
+
+template  T *addressof(T &arg) {
+return reinterpret_cast(
+&const_cast(reinterpret_cast(arg)));
+}
+
+} // namespace foo
+} // namespace std
+
+namespace move_forward_et_al_examples {
+  struct S {
+S &self() [[clang::lifetimebound]] { return *this; }
+  };
+
+  S &&Move = std::move(S{}); // expected-warning {{temporary bound to local reference 'Move' will be destroyed at the end of the full-expression}}
+  S MoveOk = std::move(S{});
+
+  S &&Forward = std::forward(S{}); // expected-warning {{temporary bound to local reference 'Forward' will be destroyed at the end of the full-expression}}
+  S ForwardOk = std::forward(S{});
+
+  const S &Const = std::as_const(S{}.self()); // expected-warning {{temporary bound to local reference 'Const' will be destroyed at the end of the full-expression}}
+  const S ConstOk = std::as_const(S{}.self());
+
+  S &&MoveIfNoExcept = std::move_if_noexcept(S{}.self()); // expected-warning {{temporary bound to local reference 'MoveIfNoExcept' will be destroyed at the end of the full-expression}}
+  S MoveIfNoExceptOk = std::move_if_noexcept(S{}.self());
+
+  S *AddressOf = std::addressof(S{}.self()); // expected-warning {{temporary whose address is used as value of local variable 'AddressOf' will be destroyed at the end of the full-expression}}
+  S X;
+  S *AddressOfOk = std::addressof(X);
+} // namespace move_forward_et_al_examples
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -16180,6 +16180,24 @@
 default:
   break;
 }
+
+// Add lifetime attribute to std::move, std::fowrard et al.
+switch (BuiltinID) {
+case Builtin::BIaddressof:
+case Builtin::BI__addressof:
+case Builtin::BI__builtin_addressof:
+case Builtin::BIas_const:
+case Builtin::BIforward:
+case Builtin::BImove:
+case Builtin::BImove_if_noexcept:
+  if (ParmVarDecl *P = FD->getParamDecl(0u);
+  !P->hasAttr())
+P->addAttr(
+LifetimeBoundAttr::C

[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-14 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer updated this revision to Diff 489317.

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

https://reviews.llvm.org/D138546

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang/bindings/python/tests/cindex/test_cdb.py
  clang/docs/tools/clang-formatted-files.txt
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp
  llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
@@ -37,7 +37,6 @@
 "ExpandResponseFilesCompilationDatabase.cpp",
 "FileMatchTrie.cpp",
 "FixIt.cpp",
-"GuessTargetAndModeCompilationDatabase.cpp",
 "InterpolatingCompilationDatabase.cpp",
 "JSONCompilationDatabase.cpp",
 "NodeIntrospection.cpp",
Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -929,31 +929,6 @@
   EXPECT_TRUE(CCRef != CCTest);
 }
 
-class TargetAndModeTest : public MemDBTest {
-public:
-  TargetAndModeTest() { llvm::InitializeAllTargetInfos(); }
-
-protected:
-  // Look up the command from a relative path, and return it in string form.
-  std::string getCommand(llvm::StringRef F) {
-auto Results = inferTargetAndDriverMode(std::make_unique(Entries))
-   ->getCompileCommands(path(F));
-if (Results.empty())
-  return "none";
-return llvm::join(Results[0].CommandLine, " ");
-  }
-};
-
-TEST_F(TargetAndModeTest, TargetAndMode) {
-  add("foo.cpp", "clang-cl", "");
-  add("bar.cpp", "clang++", "");
-
-  EXPECT_EQ(getCommand("foo.cpp"),
-"clang-cl --driver-mode=cl foo.cpp -D foo.cpp");
-  EXPECT_EQ(getCommand("bar.cpp"),
-"clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
-}
-
 class ExpandResponseFilesTest : public MemDBTest {
 public:
   ExpandResponseFilesTest() : FS(new llvm::vfs::InMemoryFileSystem) {}
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -165,9 +165,8 @@
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
-return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(expandResponseFiles(
-  std::move(Base), llvm::vfs::getRealFileSystem(
+return Base ? inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem()))
 : nullptr;
   }
 };
Index: clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
===
--- clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//===- GuessTargetAndModeCompilationDatabase.cpp --===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "clang/Tooling/CompilationDatabase.h"
-#include "clang/Tooling/Tooling.h"
-#include 
-
-namespace clang {
-namespace tooling {
-
-namespace {
-class TargetAndModeAdderDatabase : public CompilationDatabase {
-public:
-  TargetAndModeAdderDatabase(std::unique_ptr Base)
-  : Base(std::move(Base)) {
-assert(this->Base != nullptr);
-  }
-
-  std::vector getAllFiles() const override {
-return Base->getAllFiles();
-  }
-
-  std::vector getAllCompileCommands() const override {
-return addTargetAndMode(Base->getAllCompileCommands());
-  }
-
-  std::vector
-  getCompileCommands(StringRef FilePath) const override {
-return addTargetAndMode(Base->getCompileCommands(FilePath));
-  }
-
-private:
-  std::vector
-  addTargetAndMode(std::vector Cmds) const {
-for (auto &Cmd : Cmds) {
-  if (Cmd.CommandLine.empty())
-continue;
-  addTargetAndModeForProgramName(Cmd.CommandLine, Cmd.CommandLine.front());
-}
-return Cmds;
-  }
-  std

[clang-tools-extra] 91682b2 - Remove redundant initialization of std::optional (NFC)

2023-01-14 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-14T14:06:18-08:00
New Revision: 91682b2631b224a9f6dca9512b5e0951cc4a7762

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

LOG: Remove redundant initialization of std::optional (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/ClangdServer.h
flang/include/flang/Lower/ComponentPath.h
flang/lib/Lower/Bridge.cpp
flang/lib/Lower/CallInterface.cpp
lld/MachO/LTO.cpp
lldb/include/lldb/Core/DataFileCache.h
lldb/include/lldb/Host/File.h
lldb/include/lldb/Target/TraceDumper.h
lldb/source/Plugins/Trace/intel-pt/DecodedThread.h
lldb/source/Plugins/Trace/intel-pt/TraceIntelPTConstants.h
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/ExecutionEngine/ExecutionEngine.h
mlir/lib/Dialect/Bufferization/Transforms/OneShotAnalysis.cpp
mlir/lib/Dialect/SparseTensor/IR/SparseTensorDialect.cpp
mlir/lib/Dialect/SparseTensor/Transforms/SparseStorageSpecifierToLLVM.cpp
mlir/lib/Dialect/Utils/ReshapeOpsUtils.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/ClangdServer.h 
b/clang-tools-extra/clangd/ClangdServer.h
index 360967de40ada..b87ff0bf54b70 100644
--- a/clang-tools-extra/clangd/ClangdServer.h
+++ b/clang-tools-extra/clangd/ClangdServer.h
@@ -142,7 +142,7 @@ class ClangdServer {
 /// defaults and -resource-dir compiler flag).
 /// If None, ClangdServer calls CompilerInvocation::GetResourcePath() to
 /// obtain the standard resource directory.
-std::optional ResourceDir = std::nullopt;
+std::optional ResourceDir;
 
 /// Time to wait after a new file version before computing diagnostics.
 DebouncePolicy UpdateDebounce = DebouncePolicy{

diff  --git a/flang/include/flang/Lower/ComponentPath.h 
b/flang/include/flang/Lower/ComponentPath.h
index 69960bad4e056..daf65db79dc7e 100644
--- a/flang/include/flang/Lower/ComponentPath.h
+++ b/flang/include/flang/Lower/ComponentPath.h
@@ -69,7 +69,7 @@ class ComponentPath {
   /// This optional continuation allows the generation of those dereferences.
   /// These accesses are always on Fortran entities of record types, which are
   /// implicitly in-memory objects.
-  std::optional extendCoorRef = std::nullopt;
+  std::optional extendCoorRef;
 
 private:
   void setPC(bool isImplicit);

diff  --git a/flang/lib/Lower/Bridge.cpp b/flang/lib/Lower/Bridge.cpp
index b729b47465709..71e06ed347cdc 100644
--- a/flang/lib/Lower/Bridge.cpp
+++ b/flang/lib/Lower/Bridge.cpp
@@ -1043,7 +1043,7 @@ class FirConverter : public 
Fortran::lower::AbstractConverter {
 assert(stmt.typedCall && "Call was not analyzed");
 mlir::Value res{};
 if (bridge.getLoweringOptions().getLowerToHighLevelFIR()) {
-  std::optional resultType = std::nullopt;
+  std::optional resultType;
   if (stmt.typedCall->hasAlternateReturns())
 resultType = builder->getIndexType();
   auto hlfirRes = Fortran::lower::convertCallToHLFIR(

diff  --git a/flang/lib/Lower/CallInterface.cpp 
b/flang/lib/Lower/CallInterface.cpp
index 2034c7c6055e1..bc9967f3e64e6 100644
--- a/flang/lib/Lower/CallInterface.cpp
+++ b/flang/lib/Lower/CallInterface.cpp
@@ -108,7 +108,7 @@ bool Fortran::lower::CallerInterface::requireDispatchCall() 
const {
 std::optional
 Fortran::lower::CallerInterface::getPassArgIndex() const {
   unsigned passArgIdx = 0;
-  std::optional passArg = std::nullopt;
+  std::optional passArg;
   for (const auto &arg : getCallDescription().arguments()) {
 if (arg && arg->isPassedObject()) {
   passArg = passArgIdx;

diff  --git a/lld/MachO/LTO.cpp b/lld/MachO/LTO.cpp
index 565a66df38b97..2f5e9d06f396f 100644
--- a/lld/MachO/LTO.cpp
+++ b/lld/MachO/LTO.cpp
@@ -278,7 +278,7 @@ std::vector BitcodeCompiler::compile() {
 // not use the cached MemoryBuffer directly to ensure dsymutil does not
 // race with the cache pruner.
 StringRef objBuf;
-std::optional cachePath = std::nullopt;
+std::optional cachePath;
 if (files[i]) {
   objBuf = files[i]->getBuffer();
   cachePath = files[i]->getBufferIdentifier();

diff  --git a/lldb/include/lldb/Core/DataFileCache.h 
b/lldb/include/lldb/Core/DataFileCache.h
index 5b634435ad768..8a233afaff386 100644
--- a/lldb/include/lldb/Core/DataFileCache.h
+++ b/lldb/include/lldb/Core/DataFileCache.h
@@ -108,13 +108,13 @@ class DataFileCache {
 /// it is out of date.
 struct CacheSignature {
   /// UUID of object file or module.
-  std::optional m_uuid = std::nullopt;
+  std::optional m_uuid;
   /// Modification time of file on disk.
-  std::optional m_mod_time = std::nullopt;
+  std::optional m_mod_time;
   /// If this describes a .o file with a BSD archive, the BSD archive's
   /// modification time will be in m_mod_time, and the .o file's modification
  

[clang] b53e0d1 - Use std::nullopt instead of None in comments (NFC)

2023-01-14 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-14T13:53:40-08:00
New Revision: b53e0d1b341f142e6d27e53058141d283837fbbd

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

LOG: Use std::nullopt instead of None in comments (NFC)

Added: 


Modified: 
clang/lib/Frontend/PrecompiledPreamble.cpp
llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
llvm/lib/Transforms/Scalar/LoopFuse.cpp
mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
mlir/include/mlir/Tools/PDLL/AST/Nodes.h
mlir/lib/Dialect/Affine/Analysis/AffineStructures.cpp

Removed: 




diff  --git a/clang/lib/Frontend/PrecompiledPreamble.cpp 
b/clang/lib/Frontend/PrecompiledPreamble.cpp
index 17f960f47b787..579a0b8b614de 100644
--- a/clang/lib/Frontend/PrecompiledPreamble.cpp
+++ b/clang/lib/Frontend/PrecompiledPreamble.cpp
@@ -100,7 +100,7 @@ class MissingFileCollector : public PPCallbacks {
   OptionalFileEntryRef File, StringRef SearchPath,
   StringRef RelativePath, const Module *Imported,
   SrcMgr::CharacteristicKind FileType) override {
-// File is None if it wasn't found.
+// File is std::nullopt if it wasn't found.
 // (We have some false negatives if PP recovered e.g.  -> "foo")
 if (File)
   return;

diff  --git a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp 
b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
index 12fbac99ee413..6113f78aeb4ee 100644
--- a/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
+++ b/llvm/lib/ProfileData/Coverage/CoverageMapping.cpp
@@ -454,7 +454,7 @@ class SegmentBuilder {
 
   /// Emit segments for active regions which end before \p Loc.
   ///
-  /// \p Loc: The start location of the next region. If None, all active
+  /// \p Loc: The start location of the next region. If std::nullopt, all 
active
   /// regions are completed.
   /// \p FirstCompletedRegion: Index of the first completed region.
   void completeRegionsUntil(std::optional Loc,

diff  --git a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp 
b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
index 0c1c6e14b02bf..ea3403aa799ad 100644
--- a/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
+++ b/llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp
@@ -144,8 +144,8 @@ class AArch64InstructionSelector : public 
InstructionSelector {
Register Scalar,
MachineIRBuilder &MIRBuilder) const;
 
-  /// Emit a lane insert into \p DstReg, or a new vector register if None is
-  /// provided.
+  /// Emit a lane insert into \p DstReg, or a new vector register if
+  /// std::nullopt is provided.
   ///
   /// The lane inserted into is defined by \p LaneIdx. The vector source
   /// register is given by \p SrcReg. The register containing the element is

diff  --git a/llvm/lib/Transforms/Scalar/LoopFuse.cpp 
b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
index 714bb94c5449a..0eecec3737366 100644
--- a/llvm/lib/Transforms/Scalar/LoopFuse.cpp
+++ b/llvm/lib/Transforms/Scalar/LoopFuse.cpp
@@ -885,8 +885,8 @@ struct LoopFuser {
   // Check if the candidates have identical tripcounts (first value of
   // pair), and if not check the 
diff erence in the tripcounts between
   // the loops (second value of pair). The 
diff erence is not equal to
-  // None iff the loops iterate a constant number of times, and have a
-  // single exit.
+  // std::nullopt iff the loops iterate a constant number of times, and
+  // have a single exit.
   std::pair> IdenticalTripCountRes =
   haveIdenticalTripCounts(*FC0, *FC1);
   bool SameTripCount = IdenticalTripCountRes.first;

diff  --git a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h 
b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
index 3be4ee72cd5a5..f85e607f893fa 100644
--- a/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
+++ b/mlir/include/mlir/Dialect/Linalg/Transforms/Transforms.h
@@ -264,7 +264,8 @@ using CopyCallbackFn =
 std::function;
 
 struct LinalgPromotionOptions {
-  /// Indices of subViews to promote. If `None`, try to promote all operands.
+  /// Indices of subViews to promote. If `std::nullopt`, try to promote all
+  /// operands.
   std::optional> operandsToPromote = std::nullopt;
   LinalgPromotionOptions &setOperandsToPromote(ArrayRef operands) {
 operandsToPromote = DenseSet();
@@ -292,7 +293,7 @@ struct LinalgPromotionOptions {
 useFullTileBuffersDefault = use;
 return *this;
   }
-  /// Alignment of promoted buffer. If `None` do not specify alignment.
+  /// Alignment of promoted

[clang] 2d86143 - [clang] Remove remaining uses of llvm::Optional (NFC)

2023-01-14 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-14T13:37:25-08:00
New Revision: 2d861436a9eb789bb70a3644393b21e548240ac6

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

LOG: [clang] Remove remaining uses of llvm::Optional (NFC)

This patch removes several "using" declarations and #include
"llvm/ADT/Optional.h".

This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716

Added: 


Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/ASTImporter.h
clang/include/clang/AST/ASTStructuralEquivalence.h
clang/include/clang/AST/Decl.h
clang/include/clang/AST/ExprCXX.h
clang/include/clang/AST/ExprObjC.h
clang/include/clang/AST/ExternalASTSource.h
clang/include/clang/AST/NSAPI.h
clang/include/clang/AST/TemplateBase.h
clang/include/clang/AST/Type.h
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
clang/include/clang/ASTMatchers/Dynamic/Parser.h
clang/include/clang/ASTMatchers/Dynamic/Registry.h
clang/include/clang/ASTMatchers/Dynamic/VariantValue.h
clang/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
clang/include/clang/Analysis/BodyFarm.h
clang/include/clang/Analysis/CFG.h
clang/include/clang/Analysis/FlowSensitive/DataflowAnalysis.h
clang/include/clang/Analysis/FlowSensitive/Solver.h
clang/include/clang/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.h
clang/include/clang/Analysis/MacroExpansionContext.h
clang/include/clang/Analysis/PathDiagnostic.h
clang/include/clang/Analysis/ProgramPoint.h
clang/include/clang/Basic/Diagnostic.h
clang/include/clang/Basic/Module.h
clang/include/clang/Basic/ProfileList.h
clang/include/clang/Basic/Sarif.h
clang/include/clang/Basic/TargetInfo.h
clang/include/clang/CrossTU/CrossTranslationUnit.h
clang/include/clang/Frontend/ASTUnit.h
clang/include/clang/Lex/HeaderMap.h
clang/include/clang/Lex/Lexer.h
clang/include/clang/Lex/PreprocessingRecord.h
clang/include/clang/Lex/Preprocessor.h
clang/include/clang/Sema/CodeCompleteConsumer.h
clang/include/clang/Sema/Lookup.h
clang/include/clang/Sema/Sema.h
clang/include/clang/Sema/SemaConcept.h
clang/include/clang/Sema/TemplateDeduction.h
clang/include/clang/Serialization/ASTReader.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CallDescription.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerHelpers.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/FunctionSummary.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SValBuilder.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/SVals.h
clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
clang/include/clang/Tooling/Core/Replacement.h
clang/lib/ARCMigrate/Internals.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ASTStructuralEquivalence.cpp
clang/lib/AST/Decl.cpp
clang/lib/AST/ExprConstant.cpp
clang/lib/AST/Linkage.h
clang/lib/ASTMatchers/Dynamic/Marshallers.cpp
clang/lib/ASTMatchers/Dynamic/Marshallers.h
clang/lib/ASTMatchers/Dynamic/Parser.cpp
clang/lib/ASTMatchers/Dynamic/Registry.cpp
clang/lib/Analysis/CFG.cpp
clang/lib/Analysis/CalledOnceCheck.cpp
clang/lib/Analysis/Consumed.cpp
clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp
clang/lib/Analysis/PathDiagnostic.cpp
clang/lib/Analysis/ThreadSafety.cpp
clang/lib/Analysis/UninitializedValues.cpp
clang/lib/Basic/SourceManager.cpp
clang/lib/CodeGen/CGDebugInfo.h
clang/lib/CodeGen/CGExprScalar.cpp
clang/lib/CodeGen/CGHLSLRuntime.h
clang/lib/CodeGen/CoverageMappingGen.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Frontend/ASTUnit.cpp
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/Lex/MacroInfo.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Lex/PreprocessingRecord.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDeclAttr.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaTemplateDeduction.cpp
clang/lib/Serialization/ASTReader.cpp
clang/lib/Serialization/ASTWriter.cpp
clang/lib/StaticAnalyzer/Checkers/CastValueChecker.cpp
clang/lib/StaticAnalyzer/Checkers/ReturnValueChecker.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/ASTUtils.cpp
clang/lib/StaticAnalyzer/Checkers/WebKit/PtrTypesSemantics.cpp
clang/lib/StaticAnalyzer/Cor

[PATCH] D140775: [clangd] Hover: show CalleeArgInfo for literals

2023-01-14 Thread Tom Praschan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG343b1ae3622a: [clangd] Hover: show CalleeArgInfo for 
literals and expressions (authored by tom-anders).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140775

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -900,6 +900,40 @@
  HI.CalleeArgInfo->Type = "int &";
  HI.CallPassType = HoverInfo::PassType{PassMode::Ref, false};
}},
+  {// Literal passed to function call
+   R"cpp(
+  void fun(int arg_a, const int &arg_b) {};
+  void code() {
+int a = 1;
+fun(a, [[^2]]);
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "literal";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_b";
+ HI.CalleeArgInfo->Type = "const int &";
+ HI.CallPassType = HoverInfo::PassType{PassMode::ConstRef, false};
+   }},
+  {// Expression passed to function call
+   R"cpp(
+  void fun(int arg_a, const int &arg_b) {};
+  void code() {
+int a = 1;
+fun(a, 1 [[^+]] 2);
+  }
+  )cpp",
+   [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Kind = index::SymbolKind::Unknown;
+ HI.Type = "int";
+ HI.Value = "3";
+ HI.CalleeArgInfo.emplace();
+ HI.CalleeArgInfo->Name = "arg_b";
+ HI.CalleeArgInfo->Type = "const int &";
+ HI.CallPassType = HoverInfo::PassType{PassMode::ConstRef, false};
+   }},
   {// Extra info for method call.
R"cpp(
   class C {
@@ -1226,8 +1260,10 @@
   } Tests[] = {
   // Integer tests
   {"int_by_value([[^int_x]]);", PassMode::Value, false},
+  {"int_by_value([[^123]]);", PassMode::Value, false},
   {"int_by_ref([[^int_x]]);", PassMode::Ref, false},
   {"int_by_const_ref([[^int_x]]);", PassMode::ConstRef, false},
+  {"int_by_const_ref([[^123]]);", PassMode::ConstRef, false},
   {"int_by_value([[^int_ref]]);", PassMode::Value, false},
   {"int_by_const_ref([[^int_ref]]);", PassMode::ConstRef, false},
   {"int_by_const_ref([[^int_ref]]);", PassMode::ConstRef, false},
@@ -1245,6 +1281,8 @@
   {"float_by_value([[^int_x]]);", PassMode::Value, true},
   {"float_by_value([[^int_ref]]);", PassMode::Value, true},
   {"float_by_value([[^int_const_ref]]);", PassMode::Value, true},
+  {"float_by_value([[^123.0f]]);", PassMode::Value, false},
+  {"float_by_value([[^123]]);", PassMode::Value, true},
   {"custom_by_value([[^int_x]]);", PassMode::Ref, true},
   {"custom_by_value([[^float_x]]);", PassMode::Value, true},
   {"custom_by_value([[^base]]);", PassMode::ConstRef, true},
@@ -3043,6 +3081,18 @@
 
 // In test::Bar
 int foo = 3)",
+  },
+  {
+  [](HoverInfo &HI) {
+HI.Kind = index::SymbolKind::Variable;
+HI.Name = "foo";
+HI.CalleeArgInfo.emplace();
+HI.CalleeArgInfo->Type = "int";
+HI.CallPassType = HoverInfo::PassType{PassMode::Value, false};
+  },
+  R"(variable foo
+
+Passed by value)",
   },
   {
   [](HoverInfo &HI) {
Index: clang-tools-extra/clangd/Hover.cpp
===
--- clang-tools-extra/clangd/Hover.cpp
+++ clang-tools-extra/clangd/Hover.cpp
@@ -795,7 +795,7 @@
  llvm::isa(E) ||
  llvm::isa(E) || llvm::isa(E) ||
  llvm::isa(E) || llvm::isa(E) ||
- llvm::isa(E);
+ llvm::isa(E) || llvm::isa(E);
 }
 
 llvm::StringLiteral getNameForExpr(const Expr *E) {
@@ -809,34 +809,53 @@
   return llvm::StringLiteral("expression");
 }
 
+void maybeAddCalleeArgInfo(const SelectionTree::Node *N, HoverInfo &HI,
+   const PrintingPolicy &PP);
+
 // Generates hover info for `this` and evaluatable expressions.
 // FIXME: Support hover for literals (esp user-defined)
-std::optional getHoverContents(const Expr *E, ParsedAST &AST,
+std::optional getHoverContents(const SelectionTree::Node *N,
+  const Expr *E, ParsedAST &AST,
   const PrintingPolicy &PP,
   const SymbolIndex *Index) {
-  // There's not much value in hovering over "42" and getting a hover card
-  // saying "42 is an int", similar for other literals.
-  if (isLiteral(E))
+  std::optional HI;
+
+  if (const StringLiteral *SL = dyn_cast(E)) {
+// Print the type and the

[clang-tools-extra] 343b1ae - [clangd] Hover: show CalleeArgInfo for literals and expressions

2023-01-14 Thread Tom Praschan via cfe-commits

Author: Tom Praschan
Date: 2023-01-14T23:20:42+01:00
New Revision: 343b1ae3622afed50c9734a8f40b368d8afef5c5

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

LOG: [clangd] Hover: show CalleeArgInfo for literals and expressions

This is very useful when inlay hints are disabled.

Also, improve presentation of Hover when variable is passed by value to
a function with an unnamed parameter

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

Added: 


Modified: 
clang-tools-extra/clangd/Hover.cpp
clang-tools-extra/clangd/unittests/HoverTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/Hover.cpp 
b/clang-tools-extra/clangd/Hover.cpp
index d05ea6a10f6f..7f09e091afcb 100644
--- a/clang-tools-extra/clangd/Hover.cpp
+++ b/clang-tools-extra/clangd/Hover.cpp
@@ -795,7 +795,7 @@ bool isLiteral(const Expr *E) {
  llvm::isa(E) ||
  llvm::isa(E) || llvm::isa(E) ||
  llvm::isa(E) || llvm::isa(E) ||
- llvm::isa(E);
+ llvm::isa(E) || llvm::isa(E);
 }
 
 llvm::StringLiteral getNameForExpr(const Expr *E) {
@@ -809,34 +809,53 @@ llvm::StringLiteral getNameForExpr(const Expr *E) {
   return llvm::StringLiteral("expression");
 }
 
+void maybeAddCalleeArgInfo(const SelectionTree::Node *N, HoverInfo &HI,
+   const PrintingPolicy &PP);
+
 // Generates hover info for `this` and evaluatable expressions.
 // FIXME: Support hover for literals (esp user-defined)
-std::optional getHoverContents(const Expr *E, ParsedAST &AST,
+std::optional getHoverContents(const SelectionTree::Node *N,
+  const Expr *E, ParsedAST &AST,
   const PrintingPolicy &PP,
   const SymbolIndex *Index) {
-  // There's not much value in hovering over "42" and getting a hover card
-  // saying "42 is an int", similar for other literals.
-  if (isLiteral(E))
+  std::optional HI;
+
+  if (const StringLiteral *SL = dyn_cast(E)) {
+// Print the type and the size for string literals
+HI = getStringLiteralContents(SL, PP);
+  } else if (isLiteral(E)) {
+// There's not much value in hovering over "42" and getting a hover card
+// saying "42 is an int", similar for most other literals.
+// However, if we have CalleeArgInfo, it's still useful to show it.
+maybeAddCalleeArgInfo(N, HI.emplace(), PP);
+if (HI->CalleeArgInfo) {
+  // FIXME Might want to show the expression's value here instead?
+  // E.g. if the literal is in hex it might be useful to show the decimal
+  // value here.
+  HI->Name = "literal";
+  return HI;
+}
 return std::nullopt;
+  }
 
-  HoverInfo HI;
-  // Print the type and the size for string literals
-  if (const StringLiteral *SL = dyn_cast(E))
-return getStringLiteralContents(SL, PP);
   // For `this` expr we currently generate hover with pointee type.
   if (const CXXThisExpr *CTE = dyn_cast(E))
-return getThisExprHoverContents(CTE, AST.getASTContext(), PP);
+HI = getThisExprHoverContents(CTE, AST.getASTContext(), PP);
   if (const PredefinedExpr *PE = dyn_cast(E))
-return getPredefinedExprHoverContents(*PE, AST.getASTContext(), PP);
+HI = getPredefinedExprHoverContents(*PE, AST.getASTContext(), PP);
   // For expressions we currently print the type and the value, iff it is
   // evaluatable.
   if (auto Val = printExprValue(E, AST.getASTContext())) {
-HI.Type = printType(E->getType(), AST.getASTContext(), PP);
-HI.Value = *Val;
-HI.Name = std::string(getNameForExpr(E));
-return HI;
+HI.emplace();
+HI->Type = printType(E->getType(), AST.getASTContext(), PP);
+HI->Value = *Val;
+HI->Name = std::string(getNameForExpr(E));
   }
-  return std::nullopt;
+
+  if (HI)
+maybeAddCalleeArgInfo(N, *HI, PP);
+
+  return HI;
 }
 
 // Generates hover info for attributes.
@@ -973,6 +992,10 @@ void maybeAddCalleeArgInfo(const SelectionTree::Node *N, 
HoverInfo &HI,
   if (const auto *E = N->ASTNode.get()) {
 if (E->getType().isConstQualified())
   PassType.PassBy = HoverInfo::PassType::ConstRef;
+
+// No implicit node, literal passed by value
+if (isLiteral(E) && N->Parent == OuterNode.Parent)
+  PassType.PassBy = HoverInfo::PassType::Value;
   }
 
   for (auto *CastNode = N->Parent;
@@ -1010,6 +1033,10 @@ void maybeAddCalleeArgInfo(const SelectionTree::Node *N, 
HoverInfo &HI,
 PassType.PassBy = HoverInfo::PassType::Value;
   else
 PassType.Converted = true;
+} else if (const auto *MTE =
+   CastNode->ASTNode.get()) {
+  // Can't bind a non-const-ref to a temporary, so has to be const-ref
+  PassType.PassBy = HoverInfo::PassType::ConstRef;
 } else { // U

[PATCH] D141775: [Clang] Export CanPassInRegisters as a type trait

2023-01-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson created this revision.
royjacobson added reviewers: erichkeane, aaron.ballman.
Herald added a project: All.
royjacobson requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

While working on D140664 , I thought it would 
be nice to be able to write tests 
for parameter passing ABI. Currently we test this by dumping the AST and
matching the results which makes it hard to write new tests.
Adding this builtin will allow writing better ABI tests which
can help improve our coverage in this area.

While less useful, maybe some users would also find it useful for asserting
against pessimisations for their classes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141775

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/TokenKinds.def
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/SemaCXX/type-traits.cpp


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3055,6 +3055,23 @@
 
 } // namespace is_trivially_relocatable
 
+namespace can_pass_in_regs {
+
+struct A { };
+
+struct B {
+  ~B();
+};
+
+static_assert(__can_pass_in_regs(A), "");
+static_assert(__can_pass_in_regs(A&), "");
+static_assert(!__can_pass_in_regs(B), "");
+static_assert(__can_pass_in_regs(B&), "");
+static_assert(__can_pass_in_regs(int), "");
+static_assert(__can_pass_in_regs(int&), "");
+
+}
+
 struct S {};
 template  using remove_const_t = __remove_const(T);
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4892,6 +4892,7 @@
   case UTT_IsLiteral:
   // By analogy, is_trivially_relocatable imposes the same constraints.
   case UTT_IsTriviallyRelocatable:
+  case UTT_CanPassInRegs:
   // Per the GCC type traits documentation, T shall be a complete type, cv 
void,
   // or an array of unknown bound. But GCC actually imposes the same 
constraints
   // as above.
@@ -5380,6 +5381,10 @@
 return T.isTriviallyRelocatableType(C);
   case UTT_IsReferenceable:
 return T.isReferenceable();
+  case UTT_CanPassInRegs:
+if (CXXRecordDecl *RD = T->getAsCXXRecordDecl())
+  return RD->canPassInRegisters();
+return true;
   }
 }
 
Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -523,6 +523,7 @@
 TYPE_TRAIT_1(__is_nullptr, IsNullPointer, KEYCXX)
 TYPE_TRAIT_1(__is_scoped_enum, IsScopedEnum, KEYCXX)
 TYPE_TRAIT_1(__is_referenceable, IsReferenceable, KEYCXX)
+TYPE_TRAIT_1(__can_pass_in_regs, CanPassInRegs, KEYCXX)
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
 
 // Embarcadero Expression Traits
Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -1398,6 +1398,10 @@
 * ``__array_extent(type, dim)`` (Embarcadero):
   The ``dim``'th array bound in the type ``type``, or ``0`` if
   ``dim >= __array_rank(type)``.
+* ``__can_pass_in_regs`` (C++)
+  Returns whether a class can be passed in registers under the current
+  ABI. Returns ``true`` for non-class types like builtins or references.
+  This is not a portable type trait.
 * ``__has_nothrow_assign`` (GNU, Microsoft, Embarcadero):
   Deprecated, use ``__is_nothrow_assignable`` instead.
 * ``__has_nothrow_move_assign`` (GNU, Microsoft):


Index: clang/test/SemaCXX/type-traits.cpp
===
--- clang/test/SemaCXX/type-traits.cpp
+++ clang/test/SemaCXX/type-traits.cpp
@@ -3055,6 +3055,23 @@
 
 } // namespace is_trivially_relocatable
 
+namespace can_pass_in_regs {
+
+struct A { };
+
+struct B {
+  ~B();
+};
+
+static_assert(__can_pass_in_regs(A), "");
+static_assert(__can_pass_in_regs(A&), "");
+static_assert(!__can_pass_in_regs(B), "");
+static_assert(__can_pass_in_regs(B&), "");
+static_assert(__can_pass_in_regs(int), "");
+static_assert(__can_pass_in_regs(int&), "");
+
+}
+
 struct S {};
 template  using remove_const_t = __remove_const(T);
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4892,6 +4892,7 @@
   case UTT_IsLiteral:
   // By analogy, is_trivially_relocatable imposes the same constraints.
   case UTT_IsTriviallyRelocatable:
+  case UTT_CanPassInRegs:
   // Per the GCC type traits documentation, T shall be a complete type, cv void,
   // or an array of unknown bound. But GCC actually imposes the same constraints
   // as above.
@@ -5380,6 +5381,10 @@
 return T.isTriviall

[PATCH] D141768: [WIP][11/N][Clang][RISCV][NFC] Remove Policy::PolicyType::Omit

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489306.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141768

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -969,9 +969,8 @@
 }
 
 llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
-  return {
-  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
-  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+  return {Policy(Policy::PolicyType::Undisturbed), // TU
+  Policy(Policy::PolicyType::Agnostic)};   // TA
 }
 
 llvm::SmallVector
@@ -1029,28 +1028,33 @@
 BuiltinName += "_ta";
 }
   } else {
-if (PolicyAttrs.isTUMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tum");
-else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tam");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_mu");
-else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_ma");
-else if (PolicyAttrs.isTUMUPolicy())
-  appendPolicySuffix("_tumu");
-else if (PolicyAttrs.isTAMUPolicy())
-  appendPolicySuffix("_tamu");
-else if (PolicyAttrs.isTUMAPolicy())
-  appendPolicySuffix("_tuma");
-else if (PolicyAttrs.isTAMAPolicy())
-  appendPolicySuffix("_tama");
-else if (PolicyAttrs.isTUPolicy() && !IsMasked)
-  appendPolicySuffix("_tu");
-else if (PolicyAttrs.isTAPolicy() && !IsMasked)
-  appendPolicySuffix("_ta");
-else
-  llvm_unreachable("Unhandled policy condition");
+if (IsMasked) {
+  if (PolicyAttrs.isTUMAPolicy() && !HasMaskPolicy)
+appendPolicySuffix("_tum");
+  else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
+appendPolicySuffix("_tam");
+  else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+appendPolicySuffix("_mu");
+  else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+appendPolicySuffix("_ma");
+  else if (PolicyAttrs.isTUMUPolicy())
+appendPolicySuffix("_tumu");
+  else if (PolicyAttrs.isTAMUPolicy())
+appendPolicySuffix("_tamu");
+  else if (PolicyAttrs.isTUMAPolicy())
+appendPolicySuffix("_tuma");
+  else if (PolicyAttrs.isTAMAPolicy())
+appendPolicySuffix("_tama");
+  else
+llvm_unreachable("Unhandled policy condition");
+} else {
+  if (PolicyAttrs.isTUPolicy())
+appendPolicySuffix("_tu");
+  else if (PolicyAttrs.isTAPolicy())
+appendPolicySuffix("_ta");
+  else
+llvm_unreachable("Unhandled policy condition");
+}
   }
 }
 
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -97,13 +97,13 @@
   enum PolicyType {
 Undisturbed,
 Agnostic,
-Omit, // No policy required.
   };
   PolicyType TailPolicy = Agnostic;
   PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
-  Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
-  : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}
+  Policy(PolicyType TailPolicy) : TailPolicy(TailPolicy) {}
+  Policy(PolicyType TailPolicy, PolicyType MaskPolicy)
+  : TailPolicy(TailPolicy), MaskPolicy(MaskPolicy) {}
 
   bool isTAMAPolicy() const {
 return TailPolicy == Agnostic && MaskPolicy == Agnostic;


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -969,9 +969,8 @@
 }
 
 llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
-  return {
-  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
-  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+  return {Policy(Policy::PolicyType::Undisturbed), // TU
+  Policy(Policy::PolicyType::Agnostic)};   // TA
 }
 
 llvm::SmallVector
@@ -1029,28 +1028,33 @@
 BuiltinName += "_ta";
 }
   } else {
-if (PolicyAttrs.isTUMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tum");
-else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tam");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_mu");
-else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_ma");
-else if (PolicyAttrs.isTUMUPolicy())
-  appendPolicySuffix("_tumu");
-else if (Poli

[PATCH] D141767: [WIP][10/N][Clang][RISCV][NFC] Don't need to check for `MaskPolicy` in `isTAPolicy` and `isTUPolicy`

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489305.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141767

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -122,11 +122,11 @@
   }
 
   bool isTAPolicy() const {
-return TailPolicy == Agnostic && MaskPolicy == Omit;
+return TailPolicy == Agnostic;
   }
 
   bool isTUPolicy() const {
-return TailPolicy == Undisturbed && MaskPolicy == Omit;
+return TailPolicy == Undisturbed;
   }
 
   bool isMAPolicy() const {


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -122,11 +122,11 @@
   }
 
   bool isTAPolicy() const {
-return TailPolicy == Agnostic && MaskPolicy == Omit;
+return TailPolicy == Agnostic;
   }
 
   bool isTUPolicy() const {
-return TailPolicy == Undisturbed && MaskPolicy == Omit;
+return TailPolicy == Undisturbed;
   }
 
   bool isMAPolicy() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141764: [WIP][9/N][Clang][RISCV][NFC] Use correct type for `RVVTypeCache::computeTypes` under RISCVVEmitter.cpp

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489304.
eopXD added a comment.

Dump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141764

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -585,7 +585,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -585,7 +585,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141762: [WIP][8/N][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489303.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141762

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141759: [WIP][7/N][Clang][RISCV][NFC] Correct the default value for Policy to TAMU

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489302.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141759

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141756: [WIP][6/N][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489301.
eopXD added a comment.

I was mistaken. Nothing was mistakenly fused. Recover the patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141756

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,6 @@
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -996,8 +993,8 @@
Policy::PolicyType::Agnostic)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
 return {
-Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-Policy(Policy::PolicyType::Omit,
+Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic), // 
MA
+Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
"and mask policy");
@@ -1036,6 +1033,10 @@
   appendPolicySuffix("_tum");
 else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
   appendPolicySuffix("_tam");
+else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_mu");
+else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_ma");
 else if (PolicyAttrs.isTUMUPolicy())
   appendPolicySuffix("_tumu");
 else if (PolicyAttrs.isTAMUPolicy())
@@ -1048,13 +1049,7 @@
   appendPolicySuffix("_tu");
 else if (PolicyAttrs.isTAPolicy() && !IsMasked)
   appendPolicySuffix("_ta");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy) {
-  appendPolicySuffix("_mu");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy) {
-  appendPolicySuffix("_ma");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else
+else
   llvm_unreachable("Unhandled policy condition");
   }
 }
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -130,11 +130,11 @@
   }
 
   bool isMAPolicy() const {
-return MaskPolicy == Agnostic && TailPolicy == Omit;
+return MaskPolicy == Agnostic;
   }
 
   bool isMUPolicy() const {
-return MaskPolicy == Undisturbed && TailPolicy == Omit;
+return MaskPolicy == Undisturbed;
   }
 
   bool isUnspecified() const { return IsUnspecified; }


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,6 @@
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -996,8 +993,8 @@
Policy::PolicyType::Agnostic)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
 return {
-Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-Policy(Policy::PolicyType::Omit,
+Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic), // MA
+Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
"and mask policy");
@@ -1036,6 +1033,10 @@
   appendPolicySuffix("_tum");
 else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
   appendPolicySuffix("_tam");
+else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_mu");
+else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_ma");
 else if (PolicyAttrs.isTUMUPolicy())
   appendPolicySuffix("_tumu")

[PATCH] D141768: [WIP][11/N][Clang][RISCV][NFC] Remove Policy::PolicyType::Omit

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489298.
eopXD added a comment.

Rebase to latset main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141768

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -969,9 +969,8 @@
 }
 
 llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
-  return {
-  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
-  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+  return {Policy(Policy::PolicyType::Undisturbed), // TU
+  Policy(Policy::PolicyType::Agnostic)};   // TA
 }
 
 llvm::SmallVector
@@ -1029,28 +1028,33 @@
 BuiltinName += "_ta";
 }
   } else {
-if (PolicyAttrs.isTUMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tum");
-else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tam");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_mu");
-else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_ma");
-else if (PolicyAttrs.isTUMUPolicy())
-  appendPolicySuffix("_tumu");
-else if (PolicyAttrs.isTAMUPolicy())
-  appendPolicySuffix("_tamu");
-else if (PolicyAttrs.isTUMAPolicy())
-  appendPolicySuffix("_tuma");
-else if (PolicyAttrs.isTAMAPolicy())
-  appendPolicySuffix("_tama");
-else if (PolicyAttrs.isTUPolicy() && !IsMasked)
-  appendPolicySuffix("_tu");
-else if (PolicyAttrs.isTAPolicy() && !IsMasked)
-  appendPolicySuffix("_ta");
-else
-  llvm_unreachable("Unhandled policy condition");
+if (IsMasked) {
+  if (PolicyAttrs.isTUMAPolicy() && !HasMaskPolicy)
+appendPolicySuffix("_tum");
+  else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
+appendPolicySuffix("_tam");
+  else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+appendPolicySuffix("_mu");
+  else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+appendPolicySuffix("_ma");
+  else if (PolicyAttrs.isTUMUPolicy())
+appendPolicySuffix("_tumu");
+  else if (PolicyAttrs.isTAMUPolicy())
+appendPolicySuffix("_tamu");
+  else if (PolicyAttrs.isTUMAPolicy())
+appendPolicySuffix("_tuma");
+  else if (PolicyAttrs.isTAMAPolicy())
+appendPolicySuffix("_tama");
+  else
+llvm_unreachable("Unhandled policy condition");
+} else {
+  if (PolicyAttrs.isTUPolicy())
+appendPolicySuffix("_tu");
+  else if (PolicyAttrs.isTAPolicy())
+appendPolicySuffix("_ta");
+  else
+llvm_unreachable("Unhandled policy condition");
+}
   }
 }
 
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -97,13 +97,13 @@
   enum PolicyType {
 Undisturbed,
 Agnostic,
-Omit, // No policy required.
   };
   PolicyType TailPolicy = Agnostic;
   PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
-  Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
-  : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}
+  Policy(PolicyType TailPolicy) : TailPolicy(TailPolicy) {}
+  Policy(PolicyType TailPolicy, PolicyType MaskPolicy)
+  : TailPolicy(TailPolicy), MaskPolicy(MaskPolicy) {}
 
   bool isTAMAPolicy() const {
 return TailPolicy == Agnostic && MaskPolicy == Agnostic;


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -969,9 +969,8 @@
 }
 
 llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
-  return {
-  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
-  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+  return {Policy(Policy::PolicyType::Undisturbed), // TU
+  Policy(Policy::PolicyType::Agnostic)};   // TA
 }
 
 llvm::SmallVector
@@ -1029,28 +1028,33 @@
 BuiltinName += "_ta";
 }
   } else {
-if (PolicyAttrs.isTUMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tum");
-else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tam");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_mu");
-else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_ma");
-else if (PolicyAttrs.isTUMUPolicy())
-  appendPolicySuffix("_tumu");
-   

[PATCH] D141767: [WIP][10/N][Clang][RISCV][NFC] Don't need to check for `MaskPolicy` in `isTAPolicy` and `isTUPolicy`

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489297.
eopXD added a comment.

Rebase upon latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141767

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -122,11 +122,11 @@
   }
 
   bool isTAPolicy() const {
-return TailPolicy == Agnostic && MaskPolicy == Omit;
+return TailPolicy == Agnostic;
   }
 
   bool isTUPolicy() const {
-return TailPolicy == Undisturbed && MaskPolicy == Omit;
+return TailPolicy == Undisturbed;
   }
 
   bool isMAPolicy() const {


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -122,11 +122,11 @@
   }
 
   bool isTAPolicy() const {
-return TailPolicy == Agnostic && MaskPolicy == Omit;
+return TailPolicy == Agnostic;
   }
 
   bool isTUPolicy() const {
-return TailPolicy == Undisturbed && MaskPolicy == Omit;
+return TailPolicy == Undisturbed;
   }
 
   bool isMAPolicy() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141764: [WIP][9/N][Clang][RISCV][NFC] Use correct type for `RVVTypeCache::computeTypes` under RISCVVEmitter.cpp

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489296.
eopXD added a comment.

Rebase upon latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141764

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -585,7 +585,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -585,7 +585,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141762: [WIP][8/N][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489295.
eopXD added a comment.

Rebase upon latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141762

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D140915: [clangd] Fix getQueryScopes for using-directive with inline namespace

2023-01-14 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:674
+else if (const auto *ND = dyn_cast(Context)) {
+  if (ND->isInlineNamespace())
+Scopes.AccessibleScopes.push_back(printQualifiedName(*ND) + "::");

kadircet wrote:
> tom-anders wrote:
> > kadircet wrote:
> > > tom-anders wrote:
> > > > kadircet wrote:
> > > > > since we know that the `Context` is a `NamespaceDecl` it should be 
> > > > > safe to use `printQualifiedName` always. any reason for the extra 
> > > > > branching here (apart from minimizing the change to behaviour)? if 
> > > > > not I think we can get rid of the special casing.
> > > > Unfortunately, this fails CompletionTest.EnclosingScopeComesFirst and 
> > > > CompletionTest.NoDuplicatedQueryScopes, I think because of anonymous 
> > > > namespaces (where printNameSpaceScope would return an empty string, but 
> > > > (printQualifiedName(*ND) + "::" does not). 
> > > i see. taking a closer look at this `getQueryScopes` is used for two 
> > > things:
> > > - The scopes to query with fuzzyfind requests, hence this should use the 
> > > same "serialization" as symbolcollector (which only strips anon 
> > > namespaces today, but initially it were to strip both anon & inline 
> > > namespaces. it got changed inside clang without clangd tests catching it).
> > > - The shortening of the fully qualified name in `CodeCompletionBuilder`. 
> > > Not having inline namespaces spelled in the available namespaces implies 
> > > getting wrong qualifiers (such as the bug you're fixing).
> > > 
> > > so considering the requirements here:
> > > - when querying index, we actually want to hide inline namespaces (as 
> > > `ns::hidden::Foo` should be a viable alternative even if only `ns::` is 
> > > accessible). so we should actually fix `printQualifiedName` to set 
> > > `SuppressInlineNamespace` in printing policy to restore the old behaviour 
> > > (and keep using `printNamespaceScope` here).
> > > - inside `CodeCompletionBuilder`, we shouldn't use the same scopes we use 
> > > during index queries. we should use the visible namespaces while 
> > > preserving inline namespace information and only ignoring the anonymous 
> > > namespaces.
> > > 
> > > hence can we have 2 separate scopes in `CodeCompleteFlow` instead?
> > > One called `QueryScopes`, which has the behavior we have today (fixing 
> > > printQualifiedName is a separate issues).
> > > Other called `AccessibleScopes`, which has accessible namespaces spelled 
> > > **with** inline namespaces, so that we can get proper qualification 
> > > during code-complete.
> > > 
> > > does that make sense?
> > tbh I'm a bit confused - I understand your requirements, but am not sure I 
> > understand your proposed solution. Can you expand a bit further? Looking at 
> > the code, there are already both `QueryScopes` and `AccessibleScopes` 
> > variables/fields in various classes, I'm not really sure at which places 
> > you want to make changes.
> sorry for the long and confusing answer :D
> 
> I was talking about `CodeCompleteFlow` class specifically, inside 
> `CodeComplete.cpp`. Currently it only has `QueryScopes`, derived from the 
> visible contexts reported by Sema. Unfortunately it loses some granularity to 
> fetch more symbols from index hence it should not be used when picking the 
> required qualifier.
> My suggestion is to add a new field in `CodeCompleteFlow` called 
> `AccessibleScope`, which is derived at the same stage as `QueryScopes`, while 
> preserving inline namespaces, and used when creating `CodeCompletionBuilder` 
> in `CodeCompleteFlow::toCodeCompletion` (instead of `QueryScopes`).
Ok, think I got it - To make this a bit less confusing, I first renamed 
SpecifiedScope::AccessibleScopes to SpecifiedScope::QueryScopes (that's the 
number under which it is (and was) stored in CodeCompleteFlow anyway) and then 
added a back a new field AccessibleScopes, that keeps the inline namespaces. 
This is then stored in CodeCompleteFlow:AccessibleScopes and passed to the 
CodeCompletionBuilder instead of QueryScopes.

This now still passes all existing tests and I verified in my editor that it 
also fixes the original issue. 

I couldn't figure out how to write a regression test for this now though :(


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140915

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


[PATCH] D141759: [WIP][7/N][Clang][RISCV][NFC] Correct the default value for Policy to TAMU

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489294.
eopXD added a comment.

Rebase upon latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141759

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141756: [WIP][6/N][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489293.
eopXD added a comment.

Rebase upon latest main.

Also [10/N] was mistakenly fused into this patch. Removed it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141756

Files:
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,6 @@
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -996,8 +993,8 @@
Policy::PolicyType::Agnostic)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
 return {
-Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-Policy(Policy::PolicyType::Omit,
+Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic), // 
MA
+Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
"and mask policy");
@@ -1036,6 +1033,10 @@
   appendPolicySuffix("_tum");
 else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
   appendPolicySuffix("_tam");
+else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_mu");
+else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_ma");
 else if (PolicyAttrs.isTUMUPolicy())
   appendPolicySuffix("_tumu");
 else if (PolicyAttrs.isTAMUPolicy())
@@ -1048,13 +1049,7 @@
   appendPolicySuffix("_tu");
 else if (PolicyAttrs.isTAPolicy() && !IsMasked)
   appendPolicySuffix("_ta");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy) {
-  appendPolicySuffix("_mu");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy) {
-  appendPolicySuffix("_ma");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else
+else
   llvm_unreachable("Unhandled policy condition");
   }
 }


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,6 @@
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -996,8 +993,8 @@
Policy::PolicyType::Agnostic)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
 return {
-Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-Policy(Policy::PolicyType::Omit,
+Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic), // MA
+Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
"and mask policy");
@@ -1036,6 +1033,10 @@
   appendPolicySuffix("_tum");
 else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
   appendPolicySuffix("_tam");
+else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_mu");
+else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_ma");
 else if (PolicyAttrs.isTUMUPolicy())
   appendPolicySuffix("_tumu");
 else if (PolicyAttrs.isTAMUPolicy())
@@ -1048,13 +1049,7 @@
   appendPolicySuffix("_tu");
 else if (PolicyAttrs.isTAPolicy() && !IsMasked)
   appendPolicySuffix("_ta");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy) {
-  appendPolicySuffix("_mu");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy) {
-  appendPolicySuffix("_ma");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else
+else
   llvm_unreachable("Unhandled policy condition");
   }
 }
__

[PATCH] D141754: [WIP][5/N][Clang][RISCV][NFC] Remove extra attribute Policy::IntrinsicWithoutMU by reusing HasTailPolicy and HasMaskPolicy

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489292.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141754

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -569,9 +569,9 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName,
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
-UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-Policy()));
+UnMaskedPolicyScheme, HasTailPolicy, HasMaskPolicy,
+SupportOverloading, HasBuiltinAlias, ManualCodegen, *Types,
+IntrinsicTypes, RequiredFeatures, NF, Policy()));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
@@ -584,9 +584,9 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName,
 /*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL,
-UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures,
-NF, P));
+UnMaskedPolicyScheme, HasTailPolicy, HasMaskPolicy,
+SupportOverloading, HasBuiltinAlias, ManualCodegen,
+*PolicyTypes, IntrinsicTypes, RequiredFeatures, NF, P));
   }
 if (!HasMasked)
   continue;
@@ -596,8 +596,9 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
-SupportOverloading, HasBuiltinAlias, ManualCodegen, *MaskTypes,
-IntrinsicTypes, RequiredFeatures, NF, Policy()));
+HasTailPolicy, HasMaskPolicy, SupportOverloading, HasBuiltinAlias,
+ManualCodegen, *MaskTypes, IntrinsicTypes, RequiredFeatures, NF,
+Policy()));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
@@ -610,9 +611,9 @@
   Out.push_back(std::make_unique(
   Name, SuffixStr, OverloadedName, OverloadedSuffixStr,
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
-  MaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-  ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures, NF,
-  P));
+  MaskedPolicyScheme, HasTailPolicy, HasMaskPolicy,
+  SupportOverloading, HasBuiltinAlias, ManualCodegen, *PolicyTypes,
+  IntrinsicTypes, RequiredFeatures, NF, P));
 }
   } // End for Log2LMULList
 }   // End for TypeRange
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -847,7 +847,8 @@
StringRef NewOverloadedName,
StringRef OverloadedSuffix, StringRef IRName,
bool IsMasked, bool HasMaskedOffOperand, bool HasVL,
-   PolicyScheme Scheme, bool SupportOverloading,
+   PolicyScheme Scheme, const bool HasTailPolicy,
+   const bool HasMaskPolicy, bool SupportOverloading,
bool HasBuiltinAlias, StringRef ManualCodegen,
const RVVTypes &OutInTypes,
const std::vector &NewIntrinsicTypes,
@@ -855,6 +856,7 @@
unsigned NF, Policy NewPolicyAttrs)
 : IRName(IRName), IsMasked(IsMasked),
   HasMaskedOffOperand(HasMaskedOffOperand), HasVL(HasVL), Scheme(Scheme),
+  HasTailPolicy(HasTailPolicy), HasMaskPolicy(HasMaskPolicy),
   SupportOverloading(SupportOverloading), HasBuiltinAlias(HasBuiltinAlias),
   ManualCodegen(ManualCodegen.str()), NF(NF), PolicyAttrs(NewPolicyAttrs) {
 
@@ -870,8 +872,8 @@
   if (!OverloadedSuffix.empty())
 OverloadedName += "_" + OverloadedSuffix.str();
 
-  updateNamesAndPolicy(IsMasked, hasPolicy(), Name, BuiltinName, OverloadedName,
-   PolicyAttrs);
+  updateNamesAndPolicy(IsMasked, hasPolicy(), HasTailPolicy, HasMaskPolicy,
+ 

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

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 489291.
carlosgalvezp added a comment.

Remove buggy empty extension for ImplementationFilesExtension


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  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/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);
+  EXPECT_EQ(std::vector({"hpp", "hxx"}),
+*Options.HeaderFileExtensions);
+  EXPECT_EQ(std::vector({"cpp", "cxx"}),
+*Options.ImplementationFileExtensions);
   EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
   EXPECT_EQ("user2", *Options.User);
   ASSERT_TRUE(Options.ExtraArgs.has_value());
Index: clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
@@ -3,6 +3,8 @@
 
 // RUN: not clang-tidy -verify-config \
 // RUN: --checks='-*,bad*glob,llvm*,llvm-includeorder,my-made-up-check' --config='{Checks: "readability-else-after-ret", \
+// RUN: HeaderFileExtensions: ["h", "hh", "hpp"], \
+// RUN: ImplementationFileExtensions: ["c", "cc", "hpp"], \
 // RUN: CheckOptions: [{key: "IgnoreMacros", value: "true"}, \
 // RUN:{key: "StriceMode", value: "true"}, \
 // RUN:{key: modernize-lop-convert.UseCxx20ReverseRanges, value: true} \
@@ -12,6 +14,7 @@
 // CHECK-VERIFY-DAG: command-line option '-config': warning: unknown check 'readability-else-after-ret'; did you mean 'readability-else-after-return' [-verify-config]
 // CHECK-VERIFY-DAG: command-line option '-config': warning: unknown check option 'modernize-lop-convert.UseCxx20ReverseRanges'; did you mean 'modernize-loop-convert.UseCxx20ReverseRanges' [-verify-config]
 // CHECK-VERIFY-DAG: co

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

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 489289.
carlosgalvezp added a comment.

Add missing empty header extension to the default list.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  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/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);
+  EXPECT_EQ(std::vector({"hpp", "hxx"}),
+*Options.HeaderFileExtensions);
+  EXPECT_EQ(std::vector({"cpp", "cxx"}),
+*Options.ImplementationFileExtensions);
   EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
   EXPECT_EQ("user2", *Options.User);
   ASSERT_TRUE(Options.ExtraArgs.has_value());
Index: clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
@@ -3,6 +3,8 @@
 
 // RUN: not clang-tidy -verify-config \
 // RUN: --checks='-*,bad*glob,llvm*,llvm-includeorder,my-made-up-check' --config='{Checks: "readability-else-after-ret", \
+// RUN: HeaderFileExtensions: ["h", "hh", "hpp"], \
+// RUN: ImplementationFileExtensions: ["c", "cc", "hpp"], \
 // RUN: CheckOptions: [{key: "IgnoreMacros", value: "true"}, \
 // RUN:{key: "StriceMode", value: "true"}, \
 // RUN:{key: modernize-lop-convert.UseCxx20ReverseRanges, value: true} \
@@ -12,6 +14,7 @@
 // CHECK-VERIFY-DAG: command-line option '-config': warning: unknown check 'readability-else-after-ret'; did you mean 'readability-else-after-return' [-verify-config]
 // CHECK-VERIFY-DAG: command-line option '-config': warning: unknown check option 'modernize-lop-convert.UseCxx20ReverseRanges'; did you mean 'modernize-loop-convert.UseCxx20ReverseRanges' [-verify-config]
 // CHECK-VERIFY-DAG: command-

[PATCH] D141577: [WIP][4/N][Clang][RISCV][NFC] Remove unnecessary logic under RVVIntrinsic::computeBuiltinTypes

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489288.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141577

Files:
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -918,12 +918,6 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isUnspecified()) {
-if (!IsMasked) {
-  PolicyAttrs.IsUnspecified = false;
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
-}
-  }
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -918,12 +918,6 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isUnspecified()) {
-if (!IsMasked) {
-  PolicyAttrs.IsUnspecified = false;
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
-}
-  }
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141575: [WIP][3/N][Clang][RISCV][NFC] Clarify edge cases of RVVIntrinsic::getSupportedMaskedPolicies for clarity

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489287.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141575

Files:
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -992,16 +993,18 @@
Policy::PolicyType::Undisturbed), // TUMU
 Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // TAMU
-
-  if (HasTailPolicy)
+  if (HasTailPolicy && !HasMaskPolicy)
 return {Policy(Policy::PolicyType::Undisturbed,
Policy::PolicyType::Agnostic, true), // TUM
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
true)}; // TAM
-
-  return {
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed)}; // MU
+  if (!HasTailPolicy && HasMaskPolicy)
+return {
+Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
+Policy(Policy::PolicyType::Omit,
+   Policy::PolicyType::Undisturbed)}; // MU
+  llvm_unreachable("An RVV instruction should not be without both tail policy "
+   "and mask policy");
 }
 
 void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -13,6 +13,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/Twine.h"
+#include "llvm/Support/ErrorHandling.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -992,16 +993,18 @@
Policy::PolicyType::Undisturbed), // TUMU
 Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // TAMU
-
-  if (HasTailPolicy)
+  if (HasTailPolicy && !HasMaskPolicy)
 return {Policy(Policy::PolicyType::Undisturbed,
Policy::PolicyType::Agnostic, true), // TUM
 Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic,
true)}; // TAM
-
-  return {
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-  Policy(Policy::PolicyType::Omit, Policy::PolicyType::Undisturbed)}; // MU
+  if (!HasTailPolicy && HasMaskPolicy)
+return {
+Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
+Policy(Policy::PolicyType::Omit,
+   Policy::PolicyType::Undisturbed)}; // MU
+  llvm_unreachable("An RVV instruction should not be without both tail policy "
+   "and mask policy");
 }
 
 void RVVIntrinsic::updateNamesAndPolicy(bool IsMasked, bool HasPolicy,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141574: [WIP][2/N][Clang][RISCV][NFC] Rename Policy::IsPolicyNone to IsUnspecifed

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489286.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141574

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,9 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isPolicyNonePolicy()) {
+  if (PolicyAttrs.isUnspecified()) {
 if (!IsMasked) {
-  PolicyAttrs.PolicyNone = false;
+  PolicyAttrs.IsUnspecified = false;
   PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
 }
   }
@@ -1016,8 +1016,8 @@
 OverloadedName += suffix;
   };
 
-  if (PolicyAttrs.isPolicyNonePolicy()) {
-PolicyAttrs.PolicyNone = false;
+  if (PolicyAttrs.isUnspecified()) {
+PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   // FIXME: Currently _m default policy implementation is different with
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -93,7 +93,7 @@
 };
 
 struct Policy {
-  bool PolicyNone = false;
+  bool IsUnspecified = false;
   enum PolicyType {
 Undisturbed,
 Agnostic,
@@ -102,7 +102,7 @@
   PolicyType TailPolicy = Omit;
   PolicyType MaskPolicy = Omit;
   bool IntrinsicWithoutMU = false;
-  Policy() : PolicyNone(true) {}
+  Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy,
  bool _IntrinsicWithoutMU = false)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy),
@@ -150,11 +150,11 @@
 return MaskPolicy == Undisturbed && TailPolicy == Omit;
   }
 
-  bool isPolicyNonePolicy() const { return PolicyNone; }
+  bool isUnspecified() const { return IsUnspecified; }
 
   bool operator==(const Policy &Other) const {
-return PolicyNone == Other.PolicyNone && TailPolicy == Other.TailPolicy &&
-   MaskPolicy == Other.MaskPolicy &&
+return IsUnspecified == Other.IsUnspecified &&
+   TailPolicy == Other.TailPolicy && MaskPolicy == Other.MaskPolicy &&
IntrinsicWithoutMU == Other.IntrinsicWithoutMU;
   }
 
@@ -431,7 +431,7 @@
 return IntrinsicTypes;
   }
   Policy getPolicyAttrs() const {
-assert(PolicyAttrs.PolicyNone == false);
+assert(PolicyAttrs.IsUnspecified == false);
 return PolicyAttrs;
   }
   unsigned getPolicyAttrsBits() const {
@@ -441,7 +441,7 @@
 // constexpr unsigned TAIL_AGNOSTIC_MASK_AGNOSTIC = 3;
 // FIXME: how about value 2
 // int PolicyAttrs = TAIL_UNDISTURBED;
-assert(PolicyAttrs.PolicyNone == false);
+assert(PolicyAttrs.IsUnspecified == false);
 
 if (PolicyAttrs.isTUMAPolicy())
   return 2;


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,9 @@
   // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
   if (PolicyAttrs.isMAPolicy())
 PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
-  if (PolicyAttrs.isPolicyNonePolicy()) {
+  if (PolicyAttrs.isUnspecified()) {
 if (!IsMasked) {
-  PolicyAttrs.PolicyNone = false;
+  PolicyAttrs.IsUnspecified = false;
   PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TA
 }
   }
@@ -1016,8 +1016,8 @@
 OverloadedName += suffix;
   };
 
-  if (PolicyAttrs.isPolicyNonePolicy()) {
-PolicyAttrs.PolicyNone = false;
+  if (PolicyAttrs.isUnspecified()) {
+PolicyAttrs.IsUnspecified = false;
 if (IsMasked) {
   Name += "_m";
   // FIXME: Currently _m default policy implementation is different with
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -93,7 +93,7 @@
 };
 
 struct Policy {
-  bool PolicyNone = false;
+  bool IsUnspecified = false;
   enum PolicyType {
 Undisturbed,
 Agnostic,
@@ -102,7 +102,7 @@
   PolicyType TailPolicy = Omit;
   PolicyType MaskPolicy = Omit;
   bool IntrinsicWithoutMU = false;
-  Policy() : PolicyNone(true) {}
+  Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy,
  bool _IntrinsicWithoutMU = false)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy),
@@ -150,11

[PATCH] D141573: [WIP][1/N][Clang][RISCV][NFC] Extract common utility to RISCVVIntrinsicUtils

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489285.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141573

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -528,12 +528,8 @@
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
 
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
 SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(HasTailPolicy, HasMaskPolicy);
 
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -974,6 +974,12 @@
   return NewPrototype;
 }
 
+llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
+  return {
+  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
+  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+}
+
 llvm::SmallVector
 RVVIntrinsic::getSupportedMaskedPolicies(bool HasTailPolicy,
  bool HasMaskPolicy) {
Index: clang/lib/Sema/SemaRISCVVectorLookup.cpp
===
--- clang/lib/Sema/SemaRISCVVectorLookup.cpp
+++ clang/lib/Sema/SemaRISCVVectorLookup.cpp
@@ -204,13 +204,9 @@
 
 bool UnMaskedHasPolicy = UnMaskedPolicyScheme != PolicyScheme::SchemeNone;
 bool MaskedHasPolicy = MaskedPolicyScheme != PolicyScheme::SchemeNone;
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
-llvm::SmallVector SupportedMaskedPolicies =
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
+SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(Record.HasTailPolicy,
  Record.HasMaskPolicy);
 
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -472,6 +472,8 @@
   bool IsMasked, bool HasMaskedOffOperand, bool HasVL,
   unsigned NF, PolicyScheme DefaultScheme,
   Policy PolicyAttrs);
+
+  static llvm::SmallVector getSupportedUnMaskedPolicies();
   static llvm::SmallVector
   getSupportedMaskedPolicies(bool HasTailPolicy, bool HasMaskPolicy);
 


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -528,12 +528,8 @@
 StringRef MaskedIRName = R->getValueAsString("MaskedIRName");
 unsigned NF = R->getValueAsInt("NF");
 
-// If unmasked builtin supports policy, they should be TU or TA.
-llvm::SmallVector SupportedUnMaskedPolicies;
-SupportedUnMaskedPolicies.emplace_back(Policy(
-Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit)); // TU
-SupportedUnMaskedPolicies.emplace_back(
-Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)); // TA
+SmallVector SupportedUnMaskedPolicies =
+RVVIntrinsic::getSupportedUnMaskedPolicies();
 SmallVector SupportedMaskedPolicies =
 RVVIntrinsic::getSupportedMaskedPolicies(HasTailPolicy, HasMaskPolicy);
 
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -974,6 +974,12 @@
   return NewPrototype;
 }
 
+llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
+  return {
+  Policy(P

[PATCH] D140915: [clangd] Fix getQueryScopes for using-directive with inline namespace

2023-01-14 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders updated this revision to Diff 489284.
tom-anders added a comment.

Address review comment: Introduce new AccessibleScopes variable


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140915

Files:
  clang-tools-extra/clangd/CodeComplete.cpp

Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -307,7 +307,7 @@
 struct CodeCompletionBuilder {
   CodeCompletionBuilder(ASTContext *ASTCtx, const CompletionCandidate &C,
 CodeCompletionString *SemaCCS,
-llvm::ArrayRef QueryScopes,
+llvm::ArrayRef AccessibleScopes,
 const IncludeInserter &Includes,
 llvm::StringRef FileName,
 CodeCompletionContext::Kind ContextKind,
@@ -361,7 +361,7 @@
   // avoids unneeded qualifiers in cases like with `using ns::X`.
   if (Completion.RequiredQualifier.empty() && !C.SemaResult) {
 llvm::StringRef ShortestQualifier = C.IndexResult->Scope;
-for (llvm::StringRef Scope : QueryScopes) {
+for (llvm::StringRef Scope : AccessibleScopes) {
   llvm::StringRef Qualifier = C.IndexResult->Scope;
   if (Qualifier.consume_front(Scope) &&
   Qualifier.size() < ShortestQualifier.size())
@@ -643,16 +643,27 @@
   //   "using namespace std; namespace ns { vec^ }" => {"ns::", "std::", ""}
   //
   // "" for global namespace, "ns::" for normal namespace.
+  std::vector QueryScopes;
+  // Like QueryScopes, but also contains inline namespaces.
   std::vector AccessibleScopes;
   // The full scope qualifier as typed by the user (without the leading "::").
   // Set if the qualifier is not fully resolved by Sema.
   llvm::Optional UnresolvedQualifier;
 
+  // Construct scopes to use for code completion. The results are deduplicated.
+  std::vector scopesForCodeCompletion() {
+std::set Results;
+for (llvm::StringRef AS : AccessibleScopes)
+  Results.insert(
+  (AS + (UnresolvedQualifier ? *UnresolvedQualifier : "")).str());
+return {Results.begin(), Results.end()};
+  }
+
   // Construct scopes being queried in indexes. The results are deduplicated.
   // This method format the scopes to match the index request representation.
   std::vector scopesForIndexQuery() {
 std::set Results;
-for (llvm::StringRef AS : AccessibleScopes)
+for (llvm::StringRef AS : QueryScopes)
   Results.insert(
   (AS + (UnresolvedQualifier ? *UnresolvedQualifier : "")).str());
 return {Results.begin(), Results.end()};
@@ -662,16 +673,19 @@
 // Get all scopes that will be queried in indexes and whether symbols from
 // any scope is allowed. The first scope in the list is the preferred scope
 // (e.g. enclosing namespace).
-std::pair, bool>
+std::tuple, std::vector, bool>
 getQueryScopes(CodeCompletionContext &CCContext, const Sema &CCSema,
const CompletionPrefix &HeuristicPrefix,
const CodeCompleteOptions &Opts) {
   SpecifiedScope Scopes;
   for (auto *Context : CCContext.getVisitedContexts()) {
-if (isa(Context))
-  Scopes.AccessibleScopes.push_back(""); // global namespace
-else if (isa(Context))
-  Scopes.AccessibleScopes.push_back(printNamespaceScope(*Context));
+if (isa(Context)) {
+  Scopes.QueryScopes.push_back("");
+  Scopes.AccessibleScopes.push_back("");
+} else if (const auto *ND = dyn_cast(Context)) {
+  Scopes.QueryScopes.push_back(printNamespaceScope(*Context));
+  Scopes.AccessibleScopes.push_back(printQualifiedName(*ND) + "::");
+}
   }
 
   const CXXScopeSpec *SemaSpecifier =
@@ -684,39 +698,52 @@
   vlog("Sema said no scope specifier, but we saw {0} in the source code",
HeuristicPrefix.Qualifier);
   StringRef SpelledSpecifier = HeuristicPrefix.Qualifier;
-  if (SpelledSpecifier.consume_front("::"))
+  if (SpelledSpecifier.consume_front("::")) {
 Scopes.AccessibleScopes = {""};
+Scopes.QueryScopes = {""};
+  }
   Scopes.UnresolvedQualifier = std::string(SpelledSpecifier);
-  return {Scopes.scopesForIndexQuery(), false};
+  return {Scopes.scopesForIndexQuery(), Scopes.scopesForCodeCompletion(),
+  false};
 }
 // The enclosing namespace must be first, it gets a quality boost.
-std::vector EnclosingAtFront;
+std::vector EnclosingAtFrontForIndex;
+std::vector EnclosingAtFrontForCompletion;
 std::string EnclosingScope = printNamespaceScope(*CCSema.CurContext);
-EnclosingAtFront.push_back(EnclosingScope);
+EnclosingAtFrontForIndex.push_back(EnclosingScope);
+EnclosingAtFrontForCompletion.push_back(EnclosingScope);
 for (auto &S : Scopes.scopesForIndexQuery()) {
   if (EnclosingSco

[PATCH] D140954: [7/7][Clang][RISCV][NFC] Remove attribute `IsPrototypeDefaultTU`

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489283.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140954

Files:
  clang/include/clang/Basic/riscv_vector.td
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -66,7 +66,6 @@
   bool HasMasked :1;
   bool HasVL :1;
   bool HasMaskedOffOperand :1;
-  bool IsPrototypeDefaultTU : 1;
   bool HasTailPolicy : 1;
   bool HasMaskPolicy : 1;
   uint8_t UnMaskedPolicyScheme : 2;
@@ -518,7 +517,6 @@
 std::vector Log2LMULList = R->getValueAsListOfInts("Log2LMUL");
 bool HasTailPolicy = R->getValueAsBit("HasTailPolicy");
 bool HasMaskPolicy = R->getValueAsBit("HasMaskPolicy");
-bool IsPrototypeDefaultTU = R->getValueAsBit("IsPrototypeDefaultTU");
 bool SupportOverloading = R->getValueAsBit("SupportOverloading");
 bool HasBuiltinAlias = R->getValueAsBit("HasBuiltinAlias");
 StringRef ManualCodegen = R->getValueAsString("ManualCodegen");
@@ -549,13 +547,13 @@
 parsePrototypes(OverloadedSuffixProto);
 
 // Compute Builtin types
-auto Prototype = RVVIntrinsic::computeBuiltinTypes(
-BasicPrototype, /*IsMasked=*/false,
-/*HasMaskedOffOperand=*/false, HasVL, NF, IsPrototypeDefaultTU,
-UnMaskedPolicyScheme, Policy());
+auto Prototype =
+RVVIntrinsic::computeBuiltinTypes(BasicPrototype, /*IsMasked=*/false,
+  /*HasMaskedOffOperand=*/false, HasVL,
+  NF, UnMaskedPolicyScheme, Policy());
 auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-IsPrototypeDefaultTU, MaskedPolicyScheme, Policy());
+MaskedPolicyScheme, Policy());
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {
@@ -577,22 +575,22 @@
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
 ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-Policy(), IsPrototypeDefaultTU));
+Policy()));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
 RVVIntrinsic::computeBuiltinTypes(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF,
-IsPrototypeDefaultTU, UnMaskedPolicyScheme, P);
+UnMaskedPolicyScheme, P);
 std::optional PolicyTypes =
 TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName,
 /*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL,
 UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-ManualCodegen, *PolicyTypes, IntrinsicTypes,
-RequiredFeatures, NF, P, IsPrototypeDefaultTU));
+ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures,
+NF, P));
   }
 if (!HasMasked)
   continue;
@@ -602,24 +600,23 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
-SupportOverloading, HasBuiltinAlias, ManualCodegen,
-*MaskTypes, IntrinsicTypes, RequiredFeatures, NF,
-Policy(), IsPrototypeDefaultTU));
+SupportOverloading, HasBuiltinAlias, ManualCodegen, *MaskTypes,
+IntrinsicTypes, RequiredFeatures, NF, Policy()));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
   SmallVector PolicyPrototype =
   RVVIntrinsic::computeBuiltinTypes(
   BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
-  NF, IsPrototypeDefaultTU, MaskedPolicyScheme, P);
+  NF, MaskedPolicyScheme, P);
   std::optional PolicyTypes =
   TypeCache.computeTypes(BT, Log2LMUL, NF, PolicyPrototype);
   Out.push_back(std::make_unique(
   Name, SuffixStr, OverloadedName, OverloadedSuffixStr,
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
   M

[PATCH] D141772: [clang][Interp] Fix record initialization via CallExpr subclasses

2023-01-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, erichkeane, tahonermann, shafik.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

  We can't just use VisitCallExpr() here, as that doesn't handle CallExpr
  subclasses such as CXXMemberCallExpr.

I think the patch itself is mostly obvious, but I was wondering if it is the 
right time to add such RUN lines to existing test cases like I do here for 
`test/SemaCXX/constexpr-nqueens.cpp`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141772

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/test/AST/Interp/constexpr-nqueens.cpp
  clang/test/AST/Interp/records.cpp
  clang/test/SemaCXX/constexpr-nqueens.cpp


Index: clang/test/SemaCXX/constexpr-nqueens.cpp
===
--- clang/test/SemaCXX/constexpr-nqueens.cpp
+++ clang/test/SemaCXX/constexpr-nqueens.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only 
-fexperimental-new-constant-interpreter %s
 
 typedef unsigned long uint64_t;
 
Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -98,12 +98,20 @@
 int b;
 
   constexpr C() : a(100), b(200) {}
+
+  constexpr C get() const {
+return *this;
+  }
 };
 
 constexpr C c;
 static_assert(c.a == 100, "");
 static_assert(c.b == 200, "");
 
+constexpr C c2 = C().get();
+static_assert(c.a == 100, "");
+static_assert(c.b == 200, "");
+
 constexpr int getB() {
   C c;
   int &j = c.b;
Index: clang/test/AST/Interp/constexpr-nqueens.cpp
===
--- clang/test/AST/Interp/constexpr-nqueens.cpp
+++ clang/test/AST/Interp/constexpr-nqueens.cpp
@@ -52,7 +52,7 @@
   return Row == N ? Board(0, true) :
  B.ok(Row, Col) ?
  tryBoard(buildBoardRecurse(N, Col + 1, B.addQueen(Row, Col)), // 
ref-note {{in call to '&Board()->addQueen(0, 0)}} \
-   // 
expected-note {{in call to '&B.addQueen(Row, Col).B.addQueen(Row, 
Col)->addQueen(0, 0)}}
+   // 
expected-note {{in call to '&Board().Board()->addQueen(0, 0)}}
   N, Col, Row+1, B) :
  buildBoardScan(N, Col, Row + 1, B);
 }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1421,7 +1421,7 @@
 if (!this->emitDupPtr(Initializer))
   return false;
 
-return this->VisitCallExpr(CE);
+return this->visit(CE);
   } else if (const auto *DIE = dyn_cast(Initializer)) {
 return this->visitInitializer(DIE->getExpr());
   } else if (const auto *CE = dyn_cast(Initializer)) {


Index: clang/test/SemaCXX/constexpr-nqueens.cpp
===
--- clang/test/SemaCXX/constexpr-nqueens.cpp
+++ clang/test/SemaCXX/constexpr-nqueens.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -fexperimental-new-constant-interpreter %s
 
 typedef unsigned long uint64_t;
 
Index: clang/test/AST/Interp/records.cpp
===
--- clang/test/AST/Interp/records.cpp
+++ clang/test/AST/Interp/records.cpp
@@ -98,12 +98,20 @@
 int b;
 
   constexpr C() : a(100), b(200) {}
+
+  constexpr C get() const {
+return *this;
+  }
 };
 
 constexpr C c;
 static_assert(c.a == 100, "");
 static_assert(c.b == 200, "");
 
+constexpr C c2 = C().get();
+static_assert(c.a == 100, "");
+static_assert(c.b == 200, "");
+
 constexpr int getB() {
   C c;
   int &j = c.b;
Index: clang/test/AST/Interp/constexpr-nqueens.cpp
===
--- clang/test/AST/Interp/constexpr-nqueens.cpp
+++ clang/test/AST/Interp/constexpr-nqueens.cpp
@@ -52,7 +52,7 @@
   return Row == N ? Board(0, true) :
  B.ok(Row, Col) ?
  tryBoard(buildBoardRecurse(N, Col + 1, B.addQueen(Row, Col)), // ref-note {{in call to '&Board()->addQueen(0, 0)}} \
-   // expected-note {{in call to '&B.addQueen(Row, Col).B.addQueen(Row, Col)->addQueen(0, 0)}}
+   // expected-note {{in call to '&Board().Board()->addQueen(0, 0)}}
   N, Col, Row+1, B) :
  buildBoardScan(N, Col, Row + 1, B);
 }
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen

[PATCH] D140947: [6/7][Clang][RISCV] Remove default tail-undisturbed for vmv_s_x and vfmv_s_f intrinsics

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489281.
eopXD added a comment.

Rebase upon latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140947

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmv.c
@@ -547,15 +547,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf8(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv1i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf8_t test_vmv_s_x_i8mf8(vint8mf8_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8mf4_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv2i8( [[SRC:%.*]])
@@ -565,15 +556,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf4(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv2i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf4_t test_vmv_s_x_i8mf4(vint8mf4_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8mf2_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv4i8( [[SRC:%.*]])
@@ -583,15 +565,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8mf2(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv4i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8mf2_t test_vmv_s_x_i8mf2(vint8mf2_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m1_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv8i8( [[SRC:%.*]])
@@ -601,15 +574,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m1(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv8i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m1_t test_vmv_s_x_i8m1(vint8m1_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m2_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv16i8( [[SRC:%.*]])
@@ -619,15 +583,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m2(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv16i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m2_t test_vmv_s_x_i8m2(vint8m2_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m4_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv32i8( [[SRC:%.*]])
@@ -637,15 +592,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m4(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv32i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m4_t test_vmv_s_x_i8m4(vint8m4_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i8m8_i8(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i8 @llvm.riscv.vmv.x.s.nxv64i8( [[SRC:%.*]])
@@ -655,15 +601,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i8m8(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vmv.s.x.nxv64i8.i64( [[DEST:%.*]], i8 [[SRC:%.*]], i64 [[VL:%.*]])
-// CHECK-RV64-NEXT:ret  [[TMP0]]
-//
-vint8m8_t test_vmv_s_x_i8m8(vint8m8_t dest, int8_t src, size_t vl) {
-  return vmv_s(dest, src, vl);
-}
-
 // CHECK-RV64-LABEL: @test_vmv_x_s_i16mf4_i16(
 // CHECK-RV64-NEXT:  entry:
 // CHECK-RV64-NEXT:[[TMP0:%.*]] = call i16 @llvm.riscv.vmv.x.s.nxv1i16( [[SRC:%.*]])
@@ -673,15 +610,6 @@
   return vmv_x(src);
 }
 
-// CHECK-RV64-LABEL: @test_vmv_s_x_i16mf4(
-// CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-N

[PATCH] D141744: [Clang] Add lifetimebound attribute to std::move/std::forward

2023-01-14 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

> This diff is motivated by https://github.com/llvm/llvm-project/issues/59900

Not https://github.com/llvm/llvm-project/issues/60020 ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141744

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


[PATCH] D140942: [5/7][Clang][RISCV] Remove default tail-undisturbed for vcompress intrinsics

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489279.
eopXD added a comment.

Rebase upon latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140942

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vcompress.c
@@ -9,532 +9,532 @@
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16mf4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv1f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf4_t test_vcompress_vm_f16mf4(vfloat16mf4_t dest, vfloat16mf4_t src, vbool64_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16mf4_t test_vcompress_vm_f16mf4(vfloat16mf4_t src, vbool64_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv2f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16mf2_t test_vcompress_vm_f16mf2(vfloat16mf2_t dest, vfloat16mf2_t src, vbool32_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16mf2_t test_vcompress_vm_f16mf2(vfloat16mf2_t src, vbool32_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv4f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m1_t test_vcompress_vm_f16m1(vfloat16m1_t dest, vfloat16m1_t src, vbool16_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16m1_t test_vcompress_vm_f16m1(vfloat16m1_t src, vbool16_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv8f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m2_t test_vcompress_vm_f16m2(vfloat16m2_t dest, vfloat16m2_t src, vbool8_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16m2_t test_vcompress_vm_f16m2(vfloat16m2_t src, vbool8_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv16f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m4_t test_vcompress_vm_f16m4(vfloat16m4_t dest, vfloat16m4_t src, vbool4_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16m4_t test_vcompress_vm_f16m4(vfloat16m4_t src, vbool4_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f16m8(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv32f16.i64( [[DEST:%.*]],  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv32f16.i64( poison,  [[SRC:%.*]],  [[MASK:%.*]], i64 [[VL:%.*]])
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
-vfloat16m8_t test_vcompress_vm_f16m8(vfloat16m8_t dest, vfloat16m8_t src, vbool2_t mask, size_t vl) {
-  return vcompress(dest, src, mask, vl);
+vfloat16m8_t test_vcompress_vm_f16m8(vfloat16m8_t src, vbool2_t mask, size_t vl) {
+  return vcompress(src, mask, vl);
 }
 
 // CHECK-RV64-LABEL: @test_vcompress_vm_f32mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vcompress.nxv1f32.i64( [[DEST:

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

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:151-152
   Options.WarningsAsErrors = "";
+  Options.HeaderFileExtensions = {"h", "hh", "hpp", "hxx"};
+  Options.ImplementationFileExtensions = {"c", "cc", "cpp", "cxx"};
   Options.HeaderFilterRegex = "";

njames93 wrote:
> clang-tidy also works on ObjectiveC, ObjectiveC++ and cuda source files, We 
> shouldn't be ignoring those in the defaults here.
> Also some libraries(including the standard library) make use of 
> extension-less header files, maybe its worth adding an empty entry in the 
> header file extensions.
Fully agree, but I'd like to keep the scope of this patch focused only on 
moving the options from local to global options - it should be a NFC. I took 
the defaults that we have today in all checks, which also happen to be the 
hardcoded defaults in `FileExtensionUtils.h`:

```
inline StringRef defaultHeaderFileExtensions() { return ";h;hh;hpp;hxx"; }
```

Adding more extensions requires changes to those source files as well, increase 
sizes of `SmallVector`s therein, etc, so I think it'd fit better as a separate 
patch. Would you agree?

By the way, does the initial semicolon above mean that we consider 
extension-less headers? I can fix that in this patch.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

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


[PATCH] D141770: [clang-tidy][NFC] Use C++17 nested namespaces in the clang-tidy folder

2023-01-14 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.
This revision is now accepted and ready to land.

Assuming the pre-merge is happy, this LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141770

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


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

2023-01-14 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

On the topic of Objective-C, they use `.m` and `.M` extensions, it may be worth 
pointing out that this list is case sensitive (I'm assuming that's going to be 
the case.)




Comment at: clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:151-152
   Options.WarningsAsErrors = "";
+  Options.HeaderFileExtensions = {"h", "hh", "hpp", "hxx"};
+  Options.ImplementationFileExtensions = {"c", "cc", "cpp", "cxx"};
   Options.HeaderFilterRegex = "";

clang-tidy also works on ObjectiveC, ObjectiveC++ and cuda source files, We 
shouldn't be ignoring those in the defaults here.
Also some libraries(including the standard library) make use of extension-less 
header files, maybe its worth adding an empty entry in the header file 
extensions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

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


[PATCH] D141741: Add some subdirectories to the list of Abseil paths.

2023-01-14 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

Can you update some of the tests to make use of these new directories as well 
as update the release notes to mention these changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141741

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


[PATCH] D137302: [clang-tidy] Add modernize-type-traits check

2023-01-14 Thread Nathan James via Phabricator via cfe-commits
njames93 marked an inline comment as done.
njames93 added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:172
+void TypeTraitsCheck::registerMatchers(MatchFinder *Finder) {
+  static const ast_matchers::internal::VariadicDynCastAllOfMatcher<
+  Stmt,

carlosgalvezp wrote:
> `static` not needed here, remove. I don't think LLVM guidelines enforce 
> strict const correctness either so the `const` could be removed as well if 
> wanted.
const correctness isn't enforced, but it doesn't harm



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp:38
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tinTemplate();
+

carlosgalvezp wrote:
> njames93 wrote:
> > carlosgalvezp wrote:
> > > There should be a space in here, right? Same for the rest.
> > I'm assuming you mean between `` and `inTemplate`.
> > If so, because we disable clang-format in the tests, the code isn't being 
> > reformatted and the replacement logic happens to get rid of the space too. 
> > As missing the space doesn't break the code and clang-format would reformat 
> > the code for us in typical use cases, its not worth worrying about.
> I disagree, just because the code "compiles" it doesn't mean it's good. The 
> only time I've seen code like this is in [[ https://www.ioccc.org/ | 
> obfuscated code competitions ]] :) 
> 
> We should not force the user to run clang-format to fix this - clang-tidy 
> should preserve the existing space. This is not a matter of style either, 
> it's a de-facto way of writting C++ (and many other languages): variable 
> types and variable names in a declaration are separated by a space.
One of the original design decisions of clang-tidy was that check authors 
should not worry about formatting. This is partly because not everyone can 
agree on a style, but the main driving factor is that clang-tidy runs 
clang-format on the fixes that it generates unless you explicitly tell 
clang-tidy not to reformat your fixes.
Given that the set of real world projects that have a clang-tidy configuration 
file is nearly a perfect subset of the projects that have a clang-format 
configuration file, it's safe to assume that fixes would always be reformatted 
when running clang-tidy


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137302

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


[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp abandoned this revision.
carlosgalvezp added a comment.

Merged into https://reviews.llvm.org/D141770


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141769

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


[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/rename_check.py:311-314
+  # TODO: remove below replacement when all clang-tidy checks have been
+  # updated with C++17 nested namespaces.
   replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
  'namespace ' + new_namespace)

carlosgalvezp wrote:
> Eugene.Zelenko wrote:
> > njames93 wrote:
> > > I'd argue the change to update all checks should go in at the same time.
> > `Clang-tidy` or just  `all checks`, since script is about Clang-tidy.
> Patch for that here, would you like me to merge them?
> 
> https://reviews.llvm.org/D141770
Let's do everything in the same patch, I'll abandon this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141769

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


[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:109-110
 
+- Use C++17 nested namespaces in `add_new_check.py` and `rename_check.py`.
+
 New checks

njames93 wrote:
> Such a trivial change like this probably doesn't need to go in the release 
> notes, @Eugene.Zelenko thoughts?
Probably should not, since entire code base was moved to C++17.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141769

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


[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/rename_check.py:311
   filename = fileRename(filename, old_module_path, new_module_path)
+  # TODO: remove below replacement when all clang-tidy checks have been
+  # updated with C++17 nested namespaces.

njames93 wrote:
> I'd argue the change to update all checks should go in at the same time.
`Clang-tidy` or just  `all checks`, since script is about Clang-tidy.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141769

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


[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/rename_check.py:311-314
+  # TODO: remove below replacement when all clang-tidy checks have been
+  # updated with C++17 nested namespaces.
   replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
  'namespace ' + new_namespace)

njames93 wrote:
> I'd argue the change to update all checks should go in at the same time.
Patch for that here, would you like me to merge them?

https://reviews.llvm.org/D141770


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141769

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


[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Nathan James via Phabricator via cfe-commits
njames93 accepted this revision.
njames93 added a comment.

LGTM, just a couple points




Comment at: clang-tools-extra/clang-tidy/rename_check.py:311-314
+  # TODO: remove below replacement when all clang-tidy checks have been
+  # updated with C++17 nested namespaces.
   replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
  'namespace ' + new_namespace)

I'd argue the change to update all checks should go in at the same time.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:109-110
 
+- Use C++17 nested namespaces in `add_new_check.py` and `rename_check.py`.
+
 New checks

Such a trivial change like this probably doesn't need to go in the release 
notes, @Eugene.Zelenko thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141769

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


[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko accepted this revision.
Eugene.Zelenko added a comment.
This revision is now accepted and ready to land.

But will be good idea if other eyes will look too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141769

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


[PATCH] D141760: [clangd] fix extract function tweak signature spelling out lambda types

2023-01-14 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti abandoned this revision.
5chmidti added a comment.

Nvmd, `Wrapped` won't work. I'll look into this some more.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141760

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


[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 489271.
carlosgalvezp added a comment.

Update release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141769

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py
  clang-tools-extra/docs/ReleaseNotes.rst


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -106,6 +106,8 @@
   which is no longer in use. The option will be fully removed in
   :program:`clang-tidy` version 18.
 
+- Use C++17 nested namespaces in `add_new_check.py` and `rename_check.py`.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -308,8 +308,13 @@
 for filename in check_implementation_files:
   # Move check implementation to the directory of the new module.
   filename = fileRename(filename, old_module_path, new_module_path)
+  # TODO: remove below replacement when all clang-tidy checks have been
+  # updated with C++17 nested namespaces.
   replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
  'namespace ' + new_namespace)
+  replaceInFileRegex(filename,
+ 'namespace clang::tidy::' + old_module + '[^ \n]*',
+ 'namespace clang::tidy::' + new_namespace)
 
   if (args.old_check_name == args.new_check_name):
 return
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -77,9 +77,7 @@
 
 #include "../ClangTidyCheck.h"
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 /// FIXME: Write a short description.
 ///
@@ -93,9 +91,7 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace %(namespace)s
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::%(namespace)s
 
 #endif // %(header_guard)s
 """ % {'header_guard': header_guard,
@@ -129,9 +125,7 @@
 
 using namespace clang::ast_matchers;
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 void %(check_name)s::registerMatchers(MatchFinder *Finder) {
   // FIXME: Add matchers.
@@ -149,9 +143,7 @@
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
 
-} // namespace %(namespace)s
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::%(namespace)s
 """ % {'check_name': check_name_camel,
'module': module,
'namespace': namespace})


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -106,6 +106,8 @@
   which is no longer in use. The option will be fully removed in
   :program:`clang-tidy` version 18.
 
+- Use C++17 nested namespaces in `add_new_check.py` and `rename_check.py`.
+
 New checks
 ^^
 
Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -308,8 +308,13 @@
 for filename in check_implementation_files:
   # Move check implementation to the directory of the new module.
   filename = fileRename(filename, old_module_path, new_module_path)
+  # TODO: remove below replacement when all clang-tidy checks have been
+  # updated with C++17 nested namespaces.
   replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
  'namespace ' + new_namespace)
+  replaceInFileRegex(filename,
+ 'namespace clang::tidy::' + old_module + '[^ \n]*',
+ 'namespace clang::tidy::' + new_namespace)
 
   if (args.old_check_name == args.new_check_name):
 return
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -77,9 +77,7 @@
 
 #include "../ClangTidyCheck.h"
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 /// FIXME: Write a short description.
 ///
@@ -93,9 +91,7 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace %(namespace)s
-} // namespace tidy
-} /

[PATCH] D141769: [clang-tidy][NFC] Use C++17 nested namespaces in add_new_check.py and rename_check.py

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp created this revision.
Herald added a subscriber: xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
carlosgalvezp requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141769

Files:
  clang-tools-extra/clang-tidy/add_new_check.py
  clang-tools-extra/clang-tidy/rename_check.py


Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -308,8 +308,13 @@
 for filename in check_implementation_files:
   # Move check implementation to the directory of the new module.
   filename = fileRename(filename, old_module_path, new_module_path)
+  # TODO: remove below replacement when all clang-tidy checks have been
+  # updated with C++17 nested namespaces.
   replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
  'namespace ' + new_namespace)
+  replaceInFileRegex(filename,
+ 'namespace clang::tidy::' + old_module + '[^ \n]*',
+ 'namespace clang::tidy::' + new_namespace)
 
   if (args.old_check_name == args.new_check_name):
 return
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -77,9 +77,7 @@
 
 #include "../ClangTidyCheck.h"
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 /// FIXME: Write a short description.
 ///
@@ -93,9 +91,7 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace %(namespace)s
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::%(namespace)s
 
 #endif // %(header_guard)s
 """ % {'header_guard': header_guard,
@@ -129,9 +125,7 @@
 
 using namespace clang::ast_matchers;
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 void %(check_name)s::registerMatchers(MatchFinder *Finder) {
   // FIXME: Add matchers.
@@ -149,9 +143,7 @@
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
 
-} // namespace %(namespace)s
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::%(namespace)s
 """ % {'check_name': check_name_camel,
'module': module,
'namespace': namespace})


Index: clang-tools-extra/clang-tidy/rename_check.py
===
--- clang-tools-extra/clang-tidy/rename_check.py
+++ clang-tools-extra/clang-tidy/rename_check.py
@@ -308,8 +308,13 @@
 for filename in check_implementation_files:
   # Move check implementation to the directory of the new module.
   filename = fileRename(filename, old_module_path, new_module_path)
+  # TODO: remove below replacement when all clang-tidy checks have been
+  # updated with C++17 nested namespaces.
   replaceInFileRegex(filename, 'namespace ' + old_module + '[^ \n]*',
  'namespace ' + new_namespace)
+  replaceInFileRegex(filename,
+ 'namespace clang::tidy::' + old_module + '[^ \n]*',
+ 'namespace clang::tidy::' + new_namespace)
 
   if (args.old_check_name == args.new_check_name):
 return
Index: clang-tools-extra/clang-tidy/add_new_check.py
===
--- clang-tools-extra/clang-tidy/add_new_check.py
+++ clang-tools-extra/clang-tidy/add_new_check.py
@@ -77,9 +77,7 @@
 
 #include "../ClangTidyCheck.h"
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 /// FIXME: Write a short description.
 ///
@@ -93,9 +91,7 @@
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
 };
 
-} // namespace %(namespace)s
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::%(namespace)s
 
 #endif // %(header_guard)s
 """ % {'header_guard': header_guard,
@@ -129,9 +125,7 @@
 
 using namespace clang::ast_matchers;
 
-namespace clang {
-namespace tidy {
-namespace %(namespace)s {
+namespace clang::tidy::%(namespace)s {
 
 void %(check_name)s::registerMatchers(MatchFinder *Finder) {
   // FIXME: Add matchers.
@@ -149,9 +143,7 @@
   << FixItHint::CreateInsertion(MatchedDecl->getLocation(), "awesome_");
 }
 
-} // namespace %(namespace)s
-} // namespace tidy
-} // namespace clang
+} // namespace clang::tidy::%(namespace)s
 """ % {'check_name': check_name_camel,
'module': module,
'namespace': namespace})
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http

[PATCH] D140941: [4/7][Clang][RISCV] Remove default tail-undisturbed for multiply-add intrinsics

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489268.
eopXD added a comment.

Rebase to latest main.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140941

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccsu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwmaccus.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccsu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwmaccus.c

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


[PATCH] D140936: [2/7][Clang][RISCV] Remove default tail-undisturbed for vslideup intrinsics

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489265.
eopXD added a comment.

Rebase to latest main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140936

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vslideup.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vslideup.c
@@ -9,7 +9,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16mf4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv1f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16mf4_t test_vslideup_vx_f16mf4(vfloat16mf4_t dest, vfloat16mf4_t src, size_t offset, size_t vl) {
@@ -18,7 +18,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv2f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16mf2_t test_vslideup_vx_f16mf2(vfloat16mf2_t dest, vfloat16mf2_t src, size_t offset, size_t vl) {
@@ -27,7 +27,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv4f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m1_t test_vslideup_vx_f16m1(vfloat16m1_t dest, vfloat16m1_t src, size_t offset, size_t vl) {
@@ -36,7 +36,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv8f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m2_t test_vslideup_vx_f16m2(vfloat16m2_t dest, vfloat16m2_t src, size_t offset, size_t vl) {
@@ -45,7 +45,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m4(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv16f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m4_t test_vslideup_vx_f16m4(vfloat16m4_t dest, vfloat16m4_t src, size_t offset, size_t vl) {
@@ -54,7 +54,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f16m8(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv32f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv32f16.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat16m8_t test_vslideup_vx_f16m8(vfloat16m8_t dest, vfloat16m8_t src, size_t offset, size_t vl) {
@@ -63,7 +63,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f32mf2(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv1f32.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv1f32.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 1)
 // CHECK-RV64-NEXT:ret  [[TMP0]]
 //
 vfloat32mf2_t test_vslideup_vx_f32mf2(vfloat32mf2_t dest, vfloat32mf2_t src, size_t offset, size_t vl) {
@@ -72,7 +72,7 @@
 
 // CHECK-RV64-LABEL: @test_vslideup_vx_f32m1(
 // CHECK-RV64-NEXT:  entry:
-// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv2f32.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i64 0)
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = call  @llvm.riscv.vslideup.nxv2f32.i64( [[DEST:%.*]],  [[SRC:%.*]], i64 [[OFFSET:%.*]], i64 [[VL:%.*]], i

[PATCH] D140895: [1/7][Clang][RISCV] Remove default tail-undisturbed for vector reduction intrinsics

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489264.
eopXD added a comment.

Rebase to latest main


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140895

Files:
  clang/include/clang/Basic/riscv_vector.td
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredand.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmaxu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredminu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vredxor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/non-overloaded/vwredsumu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vfwredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredand.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmaxu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredminu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vredxor.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwredsum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vwredsumu.c

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


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

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 489263.
carlosgalvezp added a comment.

Merge release notes into one line


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  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/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);
+  EXPECT_EQ(std::vector({"hpp", "hxx"}),
+*Options.HeaderFileExtensions);
+  EXPECT_EQ(std::vector({"cpp", "cxx"}),
+*Options.ImplementationFileExtensions);
   EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
   EXPECT_EQ("user2", *Options.User);
   ASSERT_TRUE(Options.ExtraArgs.has_value());
Index: clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
@@ -3,6 +3,8 @@
 
 // RUN: not clang-tidy -verify-config \
 // RUN: --checks='-*,bad*glob,llvm*,llvm-includeorder,my-made-up-check' --config='{Checks: "readability-else-after-ret", \
+// RUN: HeaderFileExtensions: ["h", "hh", "hpp"], \
+// RUN: ImplementationFileExtensions: ["c", "cc", "hpp"], \
 // RUN: CheckOptions: [{key: "IgnoreMacros", value: "true"}, \
 // RUN:{key: "StriceMode", value: "true"}, \
 // RUN:{key: modernize-lop-convert.UseCxx20ReverseRanges, value: true} \
@@ -12,6 +14,7 @@
 // CHECK-VERIFY-DAG: command-line option '-config': warning: unknown check 'readability-else-after-ret'; did you mean 'readability-else-after-return' [-verify-config]
 // CHECK-VERIFY-DAG: command-line option '-config': warning: unknown check option 'modernize-lop-convert.UseCxx20ReverseRanges'; did you mean 'modernize-loop-convert.UseCxx20ReverseRanges' [-verify-config]
 // CHECK-VERIFY-DAG: command-line option '-config': warning:

[PATCH] D141762: [WIP][8/N][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489260.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141762

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141768: [WIP][11/N][Clang][RISCV][NFC] Remove Policy::PolicyType::Omit

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

The attribute can be removed now as preceeding patches have removed its
users.

Depends on D141767 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141768

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -975,9 +975,8 @@
 }
 
 llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
-  return {
-  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
-  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+  return {Policy(Policy::PolicyType::Undisturbed), // TU
+  Policy(Policy::PolicyType::Agnostic)};   // TA
 }
 
 llvm::SmallVector
@@ -1035,28 +1034,33 @@
 BuiltinName += "_ta";
 }
   } else {
-if (PolicyAttrs.isTUMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tum");
-else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
-  appendPolicySuffix("_tam");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_mu");
-else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
-  appendPolicySuffix("_ma");
-else if (PolicyAttrs.isTUMUPolicy())
-  appendPolicySuffix("_tumu");
-else if (PolicyAttrs.isTAMUPolicy())
-  appendPolicySuffix("_tamu");
-else if (PolicyAttrs.isTUMAPolicy())
-  appendPolicySuffix("_tuma");
-else if (PolicyAttrs.isTAMAPolicy())
-  appendPolicySuffix("_tama");
-else if (PolicyAttrs.isTUPolicy() && !IsMasked)
-  appendPolicySuffix("_tu");
-else if (PolicyAttrs.isTAPolicy() && !IsMasked)
-  appendPolicySuffix("_ta");
-else
-  llvm_unreachable("Unhandled policy condition");
+if (IsMasked) {
+  if (PolicyAttrs.isTUMAPolicy() && !HasMaskPolicy)
+appendPolicySuffix("_tum");
+  else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
+appendPolicySuffix("_tam");
+  else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+appendPolicySuffix("_mu");
+  else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+appendPolicySuffix("_ma");
+  else if (PolicyAttrs.isTUMUPolicy())
+appendPolicySuffix("_tumu");
+  else if (PolicyAttrs.isTAMUPolicy())
+appendPolicySuffix("_tamu");
+  else if (PolicyAttrs.isTUMAPolicy())
+appendPolicySuffix("_tuma");
+  else if (PolicyAttrs.isTAMAPolicy())
+appendPolicySuffix("_tama");
+  else
+llvm_unreachable("Unhandled policy condition");
+} else {
+  if (PolicyAttrs.isTUPolicy())
+appendPolicySuffix("_tu");
+  else if (PolicyAttrs.isTAPolicy())
+appendPolicySuffix("_ta");
+  else
+llvm_unreachable("Unhandled policy condition");
+}
   }
 }
 
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -97,13 +97,13 @@
   enum PolicyType {
 Undisturbed,
 Agnostic,
-Omit, // No policy required.
   };
   PolicyType TailPolicy = Agnostic;
   PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
-  Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
-  : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}
+  Policy(PolicyType TailPolicy) : TailPolicy(TailPolicy) {}
+  Policy(PolicyType TailPolicy, PolicyType MaskPolicy)
+  : TailPolicy(TailPolicy), MaskPolicy(MaskPolicy) {}
 
   bool isTAMAPolicy() const {
 return TailPolicy == Agnostic && MaskPolicy == Agnostic;


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -975,9 +975,8 @@
 }
 
 llvm::SmallVector RVVIntrinsic::getSupportedUnMaskedPolicies() {
-  return {
-  Policy(Policy::PolicyType::Undisturbed, Policy::PolicyType::Omit), // TU
-  Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Omit)};   // TA
+  return {Policy(Policy::PolicyType::Undisturbed), // TU
+  Policy(Policy::PolicyType::Agnostic)};   // TA
 }
 
 llvm::SmallVector
@@ -1035,28 +1034,33 @@
   

[PATCH] D141767: [WIP][10/N][Clang][RISCV][NFC] Don't need to check for `MaskPolicy` in `isTAPolicy` and `isTUPolicy`

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Caller of the two utilities is always companied with a predicate to
check for `!IsMask`, so we don't need to check for the mask policy
here.

This also removes dependency to `Policy::PolicyType::Omit`, which will
be removed.

Depends on D141764 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141767

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -122,11 +122,11 @@
   }
 
   bool isTAPolicy() const {
-return TailPolicy == Agnostic && MaskPolicy == Omit;
+return TailPolicy == Agnostic;
   }
 
   bool isTUPolicy() const {
-return TailPolicy == Undisturbed && MaskPolicy == Omit;
+return TailPolicy == Undisturbed;
   }
 
   bool isMAPolicy() const {


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -122,11 +122,11 @@
   }
 
   bool isTAPolicy() const {
-return TailPolicy == Agnostic && MaskPolicy == Omit;
+return TailPolicy == Agnostic;
   }
 
   bool isTUPolicy() const {
-return TailPolicy == Undisturbed && MaskPolicy == Omit;
+return TailPolicy == Undisturbed;
   }
 
   bool isMAPolicy() const {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139114: [Clang][Sema] Enabled implicit conversion warning for CompoundAssignment operator.

2023-01-14 Thread Nathan Chancellor via Phabricator via cfe-commits
nathanchance added a comment.

> In D139114#4053166 , @nathanchance 
> wrote:
>
>> For what it’s worth, this triggers a LOT in the Linux kernel for the pattern 
>> that @MaskRay pointed out:
>
> Out of curiosity, has it found any true positives that you can tell?

I have not been able to look too closely since I am on mobile until Wednesday 
but of the instances I examined, they all appear to be false positives (or 
maybe true positives that we really just don’t care about) .

The Linux kernel has a macro `BIT(x)`, which is just `1UL << x`, so any 
negation is going to be a really large number but expected to truncate when 
assigning to a narrower width variable because the bit being cleared might only 
be in the first few positions. That is at least the case with the really noisy 
instance of the warning that I mentioned above

  #define FWNODE_FLAG_LINKS_ADDED   BIT(0)
  #define FWNODE_FLAG_NOT_DEVICEBIT(1)
  #define FWNODE_FLAG_INITIALIZED   BIT(2)
  #define FWNODE_FLAG_NEEDS_CHILD_BOUND_ON_ADD  BIT(3)
  #define FWNODE_FLAG_BEST_EFFORT   BIT(4)
  
  struct fwnode_handle {
struct fwnode_handle *secondary;
const struct fwnode_operations *ops;
struct device *dev;
struct list_head suppliers;
struct list_head consumers;
u8 flags;
  };
  …
  if (initialized)
fwnode->flags |= FWNODE_FLAG_INITIALIZED;
  else
fwnode->flags &= ~FWNODE_FLAG_INITIALIZED;



>> It would be nice if this was split into a separate flag that could be 
>> disabled, as -Wconstant-conversion has not been very noisy up until this 
>> point.
>
> We can definitely split it into a separate flag. Alternatively, we could 
> investigate disabling the warning for that code pattern (or moving that bit 
> under its own flag).

Right, I would suspect that emitting this for `&=` will rarely show anything 
interesting. I’ll have to filter the warnings to see if there are any other 
instances with other operators that appear problematic. I’ll see how easy that 
is or if there is a simple way to omit those instances that can be added to the 
patch itself for testing.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139114

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


[PATCH] D141764: [WIP][9/N][Clang][RISCV][NFC] Use correct type for `RVVTypeCache::computeTypes` under RISCVVEmitter.cpp

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489255.
eopXD added a comment.

Bump CI upon update of preceeding patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141764

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -585,7 +585,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -585,7 +585,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141762: [WIP][8/N][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489254.
eopXD added a comment.

Bump CI upon update of preceeding patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141762

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141759: [WIP][7/N][Clang][RISCV][NFC] Correct the default value for Policy to TAMU

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489252.
eopXD added a comment.

Update code: default is TAMU.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141759

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Agnostic;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141765: [FPEnv] Fix complex operations in strictfp mode

2023-01-14 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff created this revision.
sepavloff added reviewers: rjmccall, kpn, aaron.ballman.
Herald added a project: All.
sepavloff requested review of this revision.
Herald added a project: clang.

Operations on floating-point complex data had incorrect FP attributes
in strictfp mode, because IRBuilder object was not synchronized with AST
node attributes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141765

Files:
  clang/lib/CodeGen/CGExprComplex.cpp
  clang/test/CodeGen/complex-strictfp.c

Index: clang/test/CodeGen/complex-strictfp.c
===
--- clang/test/CodeGen/complex-strictfp.c
+++ clang/test/CodeGen/complex-strictfp.c
@@ -5,8 +5,8 @@
 // Test that the constrained intrinsics are picking up the exception
 // metadata from the AST instead of the global default from the command line.
 // Include rounding metadata in the testing.
-// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
-// FIXME: All cases of "round.tonearest" in this test are wrong.
+// All cases of "fpexcept.maytrap" in this test are wrong.
+// All cases of "round.tonearest" in this test are wrong.
 
 #pragma float_control(except, on)
 #pragma STDC FENV_ROUND FE_UPWARD
@@ -15,7 +15,7 @@
 _Complex float cf;
 double D;
 
-// CHECK-LABEL: define {{[^@]+}}@test3a(
+// CHECK-LABEL: @test3a(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = load double, ptr @D, align 8
 // CHECK-NEXT:[[CF_REAL:%.*]] = load float, ptr @cf, align 4
@@ -33,7 +33,7 @@
   cf += D;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@test3b(
+// CHECK-LABEL: @test3b(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[CF_REAL:%.*]] = load float, ptr @cf, align 4
 // CHECK-NEXT:[[CF_IMAG:%.*]] = load float, ptr getelementptr inbounds ({ float, float }, ptr @cf, i32 0, i32 1), align 4
@@ -48,7 +48,7 @@
   D += cf;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@test3c(
+// CHECK-LABEL: @test3c(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[G1_REAL:%.*]] = load double, ptr @g1, align 8
 // CHECK-NEXT:[[G1_IMAG:%.*]] = load double, ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
@@ -69,12 +69,12 @@
   cf /= g1;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@test3d(
+// CHECK-LABEL: @test3d(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[G1_REAL:%.*]] = load double, ptr @g1, align 8
 // CHECK-NEXT:[[G1_IMAG:%.*]] = load double, ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
 // CHECK-NEXT:[[TMP0:%.*]] = load double, ptr @D, align 8
-// CHECK-NEXT:[[ADD_R:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[G1_REAL]], double [[TMP0]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR2]]
+// CHECK-NEXT:[[ADD_R:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[G1_REAL]], double [[TMP0]], metadata !"round.upward", metadata !"fpexcept.strict") #[[ATTR2]]
 // CHECK-NEXT:store double [[ADD_R]], ptr @g1, align 8
 // CHECK-NEXT:store double [[G1_IMAG]], ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
 // CHECK-NEXT:ret void
@@ -83,12 +83,12 @@
   g1 = g1 + D;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@test3e(
+// CHECK-LABEL: @test3e(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[TMP0:%.*]] = load double, ptr @D, align 8
 // CHECK-NEXT:[[G1_REAL:%.*]] = load double, ptr @g1, align 8
 // CHECK-NEXT:[[G1_IMAG:%.*]] = load double, ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
-// CHECK-NEXT:[[ADD_R:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[TMP0]], double [[G1_REAL]], metadata !"round.tonearest", metadata !"fpexcept.maytrap") #[[ATTR2]]
+// CHECK-NEXT:[[ADD_R:%.*]] = call double @llvm.experimental.constrained.fadd.f64(double [[TMP0]], double [[G1_REAL]], metadata !"round.upward", metadata !"fpexcept.strict") #[[ATTR2]]
 // CHECK-NEXT:store double [[ADD_R]], ptr @g1, align 8
 // CHECK-NEXT:store double [[G1_IMAG]], ptr getelementptr inbounds ({ double, double }, ptr @g1, i32 0, i32 1), align 8
 // CHECK-NEXT:ret void
@@ -97,7 +97,7 @@
   g1 = D + g1;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@t1(
+// CHECK-LABEL: @t1(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[CONV:%.*]] = call float @llvm.experimental.constrained.fptrunc.f32.f64(double 4.00e+00, metadata !"round.upward", metadata !"fpexcept.strict") #[[ATTR2]]
 // CHECK-NEXT:store float [[CONV]], ptr @cf, align 4
@@ -107,7 +107,7 @@
   (__real__ cf) = 4.0;
 }
 
-// CHECK-LABEL: define {{[^@]+}}@t2(
+// CHECK-LABEL: @t2(
 // CHECK-NEXT:  entry:
 // CHECK-NEXT:[[CONV:%.*]] = call float @llvm.experimental.constrained.fptrunc.f32.f64(double 4.00e+00, metadata !"round.upward", metadata !"fpexcept.strict") #[[ATTR2]]
 // CHECK-NEXT:store float [[CONV]], ptr getelementptr inbounds ({ float, float }, ptr @cf, i32 0, i32 1), align 4
@@ -117,7 +117,7 @@
   (__imag__ cf) = 4.0;
 }
 
-// CHECK-LABEL: 

[PATCH] D141764: [WIP][9/N][Clang][RISCV][NFC] Use correct type for `RVVTypeCache::computeTypes` under RISCVVEmitter.cpp

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

`MaskedPrototype` is used nowhere, by context and symmetry it should be
used by `RVVTypeCache::computeTypes`. The existing code is doing fine
because the default policy for unmasked intrinsics are set to TAMU.

This is something to be fixed because if the default policy is TAMA,
the code will be incorrect.

Depends on D141762 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141764

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -585,7 +585,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -585,7 +585,7 @@
   continue;
 // Create a masked intrinsic
 std::optional MaskTypes =
-TypeCache.computeTypes(BT, Log2LMUL, NF, Prototype);
+TypeCache.computeTypes(BT, Log2LMUL, NF, MaskedPrototype);
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141762: [WIP][8/N][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489245.
eopXD added a comment.

Update code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141762

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -163,18 +163,11 @@
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
-  // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141762: [WIP][8/N][Clang][RISCV][NFC] Always emit PolicyAttr in riscv_vector_builtin_cg.inc

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

Depends on D141759 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141762

Files:
  clang/utils/TableGen/RISCVVEmitter.cpp


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -164,17 +164,10 @@
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
   // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;


Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -164,17 +164,10 @@
   if (RVVI->getNF() >= 2)
 OS << "  NF = " + utostr(RVVI->getNF()) + ";\n";
   // We had initialized PolicyAttrs as TU/TUMU in CodeGen function.
-  if (!RVVI->getPolicyAttrs().isTUPolicy() &&
-  !RVVI->getPolicyAttrs().isTUMUPolicy() && !RVVI->hasPassthruOperand() &&
-  !RVVI->hasManualCodegen() && RVVI->hasVL())
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
+  OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
 
   if (RVVI->hasManualCodegen()) {
-OS << "  PolicyAttrs = " << RVVI->getPolicyAttrsBits() << ";\n";
-if (RVVI->isMasked())
-  OS << "IsMasked = true;\n";
-else
-  OS << "IsMasked = false;\n";
+OS << "IsMasked = " << (RVVI->isMasked() ? "true" : "false") << ";\n";
 OS << RVVI->getManualCodegen();
 OS << "break;\n";
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2023-01-14 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko accepted this revision.
Eugene.Zelenko added a comment.
This revision is now accepted and ready to land.

Looks OK for me, but please improve Release Notes. Will be good idea to wait 
for developers approval.




Comment at: clang-tools-extra/docs/ReleaseNotes.rst:109
 
+- New global configuration file option `HeaderFileExtensions`, replacing the 
check-local
+  option of the same name.

Will be good idea to combine two sentences into one because options are closely 
related.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

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


[PATCH] D141760: [clangd] fix extract function tweak signature spelling out lambda types

2023-01-14 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti created this revision.
5chmidti added reviewers: sammccall, nridge.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
5chmidti requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Fixes the signature of the extracted function when the signature contains a 
lambda.
Previously spelled out the type (i.e. loc, ...) of the lambda, now specifies 
auto.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141760

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
  clang-tools-extra/docs/ReleaseNotes.rst


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -78,6 +78,8 @@
 Miscellaneous
 ^
 
+- Fixed extracted function signatures spelling out lambda types.
+
 Improvements to clang-doc
 -
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -190,6 +190,32 @@
 }]]
   )cpp";
   EXPECT_EQ(apply(CompoundFailInput), "unavailable");
+
+  std::string LambdaInput = R"cpp(
+auto bar() {
+  int x = 10;
+  auto lambda = [x]() { return x; };
+  [[int y = 42;
+  int z = lambda();]]
+
+  return lambda();
+}
+  )cpp";
+
+  std::string LambdaOutput = R"cpp(
+void extracted(auto &lambda) {
+int y = 42;
+  int z = lambda();
+}
+auto bar() {
+  int x = 10;
+  auto lambda = [x]() { return x; };
+  extracted(lambda);
+
+  return lambda();
+}
+  )cpp";
+  EXPECT_EQ(apply(LambdaInput), LambdaOutput);
 }
 
 TEST_F(ExtractFunctionTest, DifferentHeaderSourceTest) {
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -430,6 +430,11 @@
   PrintCB PCB(&CurContext);
   PP.Callbacks = &PCB;
 
+  if (const auto *const RDecl = QT->getAsCXXRecordDecl();
+  RDecl && RDecl->isLambda()) {
+return "auto";
+  }
+
   QT.print(OS, PP, Placeholder);
   return OS.str();
 }


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -78,6 +78,8 @@
 Miscellaneous
 ^
 
+- Fixed extracted function signatures spelling out lambda types.
+
 Improvements to clang-doc
 -
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractFunctionTests.cpp
@@ -190,6 +190,32 @@
 }]]
   )cpp";
   EXPECT_EQ(apply(CompoundFailInput), "unavailable");
+
+  std::string LambdaInput = R"cpp(
+auto bar() {
+  int x = 10;
+  auto lambda = [x]() { return x; };
+  [[int y = 42;
+  int z = lambda();]]
+
+  return lambda();
+}
+  )cpp";
+
+  std::string LambdaOutput = R"cpp(
+void extracted(auto &lambda) {
+int y = 42;
+  int z = lambda();
+}
+auto bar() {
+  int x = 10;
+  auto lambda = [x]() { return x; };
+  extracted(lambda);
+
+  return lambda();
+}
+  )cpp";
+  EXPECT_EQ(apply(LambdaInput), LambdaOutput);
 }
 
 TEST_F(ExtractFunctionTest, DifferentHeaderSourceTest) {
Index: clang-tools-extra/clangd/AST.cpp
===
--- clang-tools-extra/clangd/AST.cpp
+++ clang-tools-extra/clangd/AST.cpp
@@ -430,6 +430,11 @@
   PrintCB PCB(&CurContext);
   PP.Callbacks = &PCB;
 
+  if (const auto *const RDecl = QT->getAsCXXRecordDecl();
+  RDecl && RDecl->isLambda()) {
+return "auto";
+  }
+
   QT.print(OS, PP, Placeholder);
   return OS.str();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D138499: [clangd] Extract Function: add hoisting support

2023-01-14 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti added a comment.

Ping


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138499

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


[PATCH] D141759: [WIP][7/N][Clang][RISCV][NFC] Correct the default value for Policy to undisturbed

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 489234.
eopXD added a comment.

Bump CI


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141759

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Undisturbed;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Undisturbed;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D141759: [WIP][7/N][Clang][RISCV][NFC] Correct the default value for Policy to undisturbed

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

The default value is set to `Omit`, but in fact the value is set under
`updateNamesAndPolicy`, which is set to TUMU when masked and TAMU when
unmasked.

This commit demonstrates so and further remove another dependency of
`Omit.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141759

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Undisturbed;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}


Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -99,8 +99,8 @@
 Agnostic,
 Omit, // No policy required.
   };
-  PolicyType TailPolicy = Omit;
-  PolicyType MaskPolicy = Omit;
+  PolicyType TailPolicy = Undisturbed;
+  PolicyType MaskPolicy = Undisturbed;
   Policy() : IsUnspecified(true) {}
   Policy(PolicyType _TailPolicy, PolicyType _MaskPolicy)
   : TailPolicy(_TailPolicy), MaskPolicy(_MaskPolicy) {}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D139114: [Clang][Sema] Enabled implicit conversion warning for CompoundAssignment operator.

2023-01-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added a comment.
This revision now requires changes to proceed.

Marking as changes requested so it's clear this isn't ready to re-land


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139114

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


[PATCH] D139114: [Clang][Sema] Enabled implicit conversion warning for CompoundAssignment operator.

2023-01-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D139114#4053022 , @chapuni wrote:

> Excuse me, I have reverted this.
>
> Before landing this, could you please fix new warnings in the current 
> codebase, please?

Thank you for the revert (and good to see you again!).

In D139114#4053166 , @nathanchance 
wrote:

> For what it’s worth, this triggers a LOT in the Linux kernel for the pattern 
> that @MaskRay pointed out:

Out of curiosity, has it found any true positives that you can tell?

> It would be nice if this was split into a separate flag that could be 
> disabled, as -Wconstant-conversion has not been very noisy up until this 
> point.

We can definitely split it into a separate flag. Alternatively, we could 
investigate disabling the warning for that code pattern (or moving that bit 
under its own flag).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139114

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


[PATCH] D141757: [clangd] allow extracting to variable for complete lambda expressions

2023-01-14 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti updated this revision to Diff 489232.
5chmidti added a comment.

Add change to release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141757

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  clang-tools-extra/docs/ReleaseNotes.rst


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -78,6 +78,8 @@
 Miscellaneous
 ^
 
+- The extract variable tweak gained support for extracting complete lambda 
expressions to a variable.
+
 Improvements to clang-doc
 -
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -98,6 +98,7 @@
   return [[t]].bar([[t]].z);
 }
 void v() { return; }
+template  void callable_sink(T) {}
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -131,6 +132,21 @@
   goto label;
   label:
 a = [[1]];
+
+  // lambdas
+  callable_sink([][[(){}]]);
+
+  // captures
+  int x = 0;
+  callable_sink([ [[=]] ](){});
+  callable_sink([ [[&]] ](){});
+  callable_sink([ [[x]] ](){});
+  callable_sink([ [[&x] ]](){});
+  callable_sink([y = [[x]] ](){});
+  callable_sink([ [[y = x]] ](){});
+
+  // default args
+  callable_sink([](int x = [[10]]){});
 }
   )cpp";
   EXPECT_UNAVAILABLE(UnavailableCases);
@@ -282,6 +298,19 @@
  void f() {
auto placeholder = S(2) + S(3) + S(4); S x = S(1) + 
placeholder + S(5);
  })cpp"},
+  // Complete lambda expressions
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f([[ [](){ return 42; }]]);
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2() {
+  auto placeholder = [](){ return 42; }; f( placeholder);
+}
+)cpp"},
+  {R"cpp(void f() { auto x = [[ [](){ return 42; }]]; })cpp",
+   R"cpp(void f() { auto placeholder = [](){ return 42; }; auto x =  
placeholder; })cpp"},
   // Don't try to analyze across macro boundaries
   // FIXME: it'd be nice to do this someday (in a safe way)
   {R"cpp(#define ECHO(X) X
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -152,10 +152,11 @@
   auto CanExtractOutside =
   [](const SelectionTree::Node *InsertionPoint) -> bool {
 if (const clang::Stmt *Stmt = InsertionPoint->ASTNode.get()) {
-  // Allow all expressions except LambdaExpr since we don't want to extract
-  // from the captures/default arguments of a lambda
+  // Allow all expressions except partial LambdaExpr selections since we
+  // don't want to extract from the captures/default arguments of a lambda
   if (isa(Stmt))
-return !isa(Stmt);
+return !(isa(Stmt) &&
+ InsertionPoint->Selected != SelectionTree::Complete);
   // We don't yet allow extraction from switch/case stmt as we would need 
to
   // jump over the switch stmt even if there is a CompoundStmt inside the
   // switch. And there are other Stmts which we don't care about (e.g.


Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -78,6 +78,8 @@
 Miscellaneous
 ^
 
+- The extract variable tweak gained support for extracting complete lambda expressions to a variable.
+
 Improvements to clang-doc
 -
 
Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -98,6 +98,7 @@
   return [[t]].bar([[t]].z);
 }
 void v() { return; }
+template  void callable_sink(T) {}
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -131,6 +132,21 @@
   goto label;
   label:
 a = [[1]];
+
+  // lambdas
+  callable_sink([][[(){}]]);
+
+  // captures
+  int x = 0;
+  callable_sink([ [[=]] ](){});
+  callable_s

[PATCH] D141757: [clangd] allow extracting to variable for complete lambda expressions

2023-01-14 Thread Julian Schmidt via Phabricator via cfe-commits
5chmidti created this revision.
5chmidti added reviewers: sammccall, nridge.
Herald added subscribers: kadircet, arphaman.
Herald added a project: All.
5chmidti requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay, ilya-biryukov.
Herald added a project: clang-tools-extra.

Support for extracting complete lambda expressions, e.g. extracting a lambda 
from a callexpr (e.g. algorithms/ranges) to a named variable.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141757

Files:
  clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp


Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -98,6 +98,7 @@
   return [[t]].bar([[t]].z);
 }
 void v() { return; }
+template  void callable_sink(T) {}
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -131,6 +132,21 @@
   goto label;
   label:
 a = [[1]];
+
+  // lambdas
+  callable_sink([][[(){}]]);
+
+  // captures
+  int x = 0;
+  callable_sink([ [[=]] ](){});
+  callable_sink([ [[&]] ](){});
+  callable_sink([ [[x]] ](){});
+  callable_sink([ [[&x] ]](){});
+  callable_sink([y = [[x]] ](){});
+  callable_sink([ [[y = x]] ](){});
+
+  // default args
+  callable_sink([](int x = [[10]]){});
 }
   )cpp";
   EXPECT_UNAVAILABLE(UnavailableCases);
@@ -282,6 +298,19 @@
  void f() {
auto placeholder = S(2) + S(3) + S(4); S x = S(1) + 
placeholder + S(5);
  })cpp"},
+  // Complete lambda expressions
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f([[ [](){ return 42; }]]);
+}
+)cpp",
+   R"cpp(template  void f(T) {}
+void f2() {
+  auto placeholder = [](){ return 42; }; f( placeholder);
+}
+)cpp"},
+  {R"cpp(void f() { auto x = [[ [](){ return 42; }]]; })cpp",
+   R"cpp(void f() { auto placeholder = [](){ return 42; }; auto x =  
placeholder; })cpp"},
   // Don't try to analyze across macro boundaries
   // FIXME: it'd be nice to do this someday (in a safe way)
   {R"cpp(#define ECHO(X) X
Index: clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/ExtractVariable.cpp
@@ -152,10 +152,11 @@
   auto CanExtractOutside =
   [](const SelectionTree::Node *InsertionPoint) -> bool {
 if (const clang::Stmt *Stmt = InsertionPoint->ASTNode.get()) {
-  // Allow all expressions except LambdaExpr since we don't want to extract
-  // from the captures/default arguments of a lambda
+  // Allow all expressions except partial LambdaExpr selections since we
+  // don't want to extract from the captures/default arguments of a lambda
   if (isa(Stmt))
-return !isa(Stmt);
+return !(isa(Stmt) &&
+ InsertionPoint->Selected != SelectionTree::Complete);
   // We don't yet allow extraction from switch/case stmt as we would need 
to
   // jump over the switch stmt even if there is a CompoundStmt inside the
   // switch. And there are other Stmts which we don't care about (e.g.


Index: clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
===
--- clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
+++ clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
@@ -98,6 +98,7 @@
   return [[t]].bar([[t]].z);
 }
 void v() { return; }
+template  void callable_sink(T) {}
 // function default argument
 void f(int b = [[1]]) {
   // empty selection
@@ -131,6 +132,21 @@
   goto label;
   label:
 a = [[1]];
+
+  // lambdas
+  callable_sink([][[(){}]]);
+
+  // captures
+  int x = 0;
+  callable_sink([ [[=]] ](){});
+  callable_sink([ [[&]] ](){});
+  callable_sink([ [[x]] ](){});
+  callable_sink([ [[&x] ]](){});
+  callable_sink([y = [[x]] ](){});
+  callable_sink([ [[y = x]] ](){});
+
+  // default args
+  callable_sink([](int x = [[10]]){});
 }
   )cpp";
   EXPECT_UNAVAILABLE(UnavailableCases);
@@ -282,6 +298,19 @@
  void f() {
auto placeholder = S(2) + S(3) + S(4); S x = S(1) + placeholder + S(5);
  })cpp"},
+  // Complete lambda expressions
+  {R"cpp(template  void f(T) {}
+void f2() {
+  f(

[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'll take care of fixing this up on Tuesday (Mon is a holiday here), but if 
anyone wants to get to it sooner, what I plan to do is:

- Add a new `Extension` diagnostic about allowing you to define a type in 
`__builtin_offsetof`
- Replace the error in C with the extension warning (C++ will continue to err)
- Add documentation to the extensions manual for the builtin
- Update the release note and tests accordingly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D141230: [clang-format-diff.py] give clang-format-diff a job pool (10x speed)

2023-01-14 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

I can see why you have the desire for something that takes 22 seconds and not 
16 mins!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141230

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


[PATCH] D141756: [WIP][6/N][Clang][RISCV][NFC] Instructions with a mask destination register is always tail agnostic

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

The logic under `computeBuiltinTypes` and `updateNamesAndPolicy` is an
amendmendment to setting Policy as `Omit`. The tail policy should be
set to agnostic for those intrinsics that has `HasTailPolicy = false`,
which are the intrinsics with a mask destination register.

Depends on D141754 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141756

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,6 @@
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -1002,8 +999,8 @@
Policy::PolicyType::Agnostic)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
 return {
-Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-Policy(Policy::PolicyType::Omit,
+Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic), // 
MA
+Policy(Policy::PolicyType::Agnostic,
Policy::PolicyType::Undisturbed)}; // MU
   llvm_unreachable("An RVV instruction should not be without both tail policy "
"and mask policy");
@@ -1042,6 +1039,10 @@
   appendPolicySuffix("_tum");
 else if (PolicyAttrs.isTAMAPolicy() && !HasMaskPolicy)
   appendPolicySuffix("_tam");
+else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_mu");
+else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy)
+  appendPolicySuffix("_ma");
 else if (PolicyAttrs.isTUMUPolicy())
   appendPolicySuffix("_tumu");
 else if (PolicyAttrs.isTAMUPolicy())
@@ -1054,13 +1055,7 @@
   appendPolicySuffix("_tu");
 else if (PolicyAttrs.isTAPolicy() && !IsMasked)
   appendPolicySuffix("_ta");
-else if (PolicyAttrs.isMUPolicy() && !HasTailPolicy) {
-  appendPolicySuffix("_mu");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else if (PolicyAttrs.isMAPolicy() && !HasTailPolicy) {
-  appendPolicySuffix("_ma");
-  PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic;
-} else
+else
   llvm_unreachable("Unhandled policy condition");
   }
 }
Index: clang/include/clang/Support/RISCVVIntrinsicUtils.h
===
--- clang/include/clang/Support/RISCVVIntrinsicUtils.h
+++ clang/include/clang/Support/RISCVVIntrinsicUtils.h
@@ -130,11 +130,11 @@
   }
 
   bool isMAPolicy() const {
-return MaskPolicy == Agnostic && TailPolicy == Omit;
+return MaskPolicy == Agnostic;
   }
 
   bool isMUPolicy() const {
-return MaskPolicy == Undisturbed && TailPolicy == Omit;
+return MaskPolicy == Undisturbed;
   }
 
   bool isUnspecified() const { return IsUnspecified; }


Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -917,9 +917,6 @@
 PolicyScheme DefaultScheme, Policy PolicyAttrs) {
   SmallVector NewPrototype(Prototype.begin(),
 Prototype.end());
-  // Update PolicyAttrs if need (TA or TAMA) for compute builtin types.
-  if (PolicyAttrs.isMAPolicy())
-PolicyAttrs.TailPolicy = Policy::PolicyType::Agnostic; // TAMA
   bool HasPassthruOp = DefaultScheme == PolicyScheme::HasPassthruOperand;
   if (IsMasked) {
 // If HasMaskedOffOperand, insert result type as first input operand if
@@ -1002,8 +999,8 @@
Policy::PolicyType::Agnostic)}; // TAM
   if (!HasTailPolicy && HasMaskPolicy)
 return {
-Policy(Policy::PolicyType::Omit, Policy::PolicyType::Agnostic), // MA
-Policy(Policy::PolicyType::Omit,
+Policy(Policy::PolicyType::Agnostic, Policy::PolicyType::Agnostic),

[PATCH] D141206: [clang] [MinGW] Avoid adding /include and /lib when cross compiling

2023-01-14 Thread Alvin Wong via Phabricator via cfe-commits
alvinhochun accepted this revision.
alvinhochun added a comment.

Also lgtm


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141206

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


[PATCH] D141754: [WIP][5/N][Clang][RISCV][NFC] Remove extra attribute Policy::IntrinsicWithoutMU by reusing HasTailPolicy and HasMaskPolicy

2023-01-14 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
Herald added subscribers: sunshaoce, VincentWu, vkmr, frasercrmck, evandro, 
luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, 
PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, 
arichardson.
Herald added a project: All.
eopXD requested review of this revision.
Herald added subscribers: cfe-commits, pcwang-thead, MaskRay.
Herald added a project: clang.

The goal here is to remove the PolicyScheme::Omit, which does not make
sense because an RVV intrinsic always executes with `vta` and `vma` set
to a certain value.

Depends on D141577 .


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141754

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -569,9 +569,9 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName,
 /*IsMasked=*/false, /*HasMaskedOffOperand=*/false, HasVL,
-UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-ManualCodegen, *Types, IntrinsicTypes, RequiredFeatures, NF,
-Policy()));
+UnMaskedPolicyScheme, HasTailPolicy, HasMaskPolicy,
+SupportOverloading, HasBuiltinAlias, ManualCodegen, *Types,
+IntrinsicTypes, RequiredFeatures, NF, Policy()));
 if (UnMaskedPolicyScheme != PolicyScheme::SchemeNone)
   for (auto P : SupportedUnMaskedPolicies) {
 SmallVector PolicyPrototype =
@@ -584,9 +584,9 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, IRName,
 /*IsMask=*/false, /*HasMaskedOffOperand=*/false, HasVL,
-UnMaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures,
-NF, P));
+UnMaskedPolicyScheme, HasTailPolicy, HasMaskPolicy,
+SupportOverloading, HasBuiltinAlias, ManualCodegen,
+*PolicyTypes, IntrinsicTypes, RequiredFeatures, NF, P));
   }
 if (!HasMasked)
   continue;
@@ -596,8 +596,9 @@
 Out.push_back(std::make_unique(
 Name, SuffixStr, OverloadedName, OverloadedSuffixStr, MaskedIRName,
 /*IsMasked=*/true, HasMaskedOffOperand, HasVL, MaskedPolicyScheme,
-SupportOverloading, HasBuiltinAlias, ManualCodegen, *MaskTypes,
-IntrinsicTypes, RequiredFeatures, NF, Policy()));
+HasTailPolicy, HasMaskPolicy, SupportOverloading, HasBuiltinAlias,
+ManualCodegen, *MaskTypes, IntrinsicTypes, RequiredFeatures, NF,
+Policy()));
 if (MaskedPolicyScheme == PolicyScheme::SchemeNone)
   continue;
 for (auto P : SupportedMaskedPolicies) {
@@ -610,9 +611,9 @@
   Out.push_back(std::make_unique(
   Name, SuffixStr, OverloadedName, OverloadedSuffixStr,
   MaskedIRName, /*IsMasked=*/true, HasMaskedOffOperand, HasVL,
-  MaskedPolicyScheme, SupportOverloading, HasBuiltinAlias,
-  ManualCodegen, *PolicyTypes, IntrinsicTypes, RequiredFeatures, NF,
-  P));
+  MaskedPolicyScheme, HasTailPolicy, HasMaskPolicy,
+  SupportOverloading, HasBuiltinAlias, ManualCodegen, *PolicyTypes,
+  IntrinsicTypes, RequiredFeatures, NF, P));
 }
   } // End for Log2LMULList
 }   // End for TypeRange
Index: clang/lib/Support/RISCVVIntrinsicUtils.cpp
===
--- clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -847,7 +847,8 @@
StringRef NewOverloadedName,
StringRef OverloadedSuffix, StringRef IRName,
bool IsMasked, bool HasMaskedOffOperand, bool HasVL,
-   PolicyScheme Scheme, bool SupportOverloading,
+   PolicyScheme Scheme, const bool HasTailPolicy,
+   const bool HasMaskPolicy, bool SupportOverloading,
bool HasBuiltinAlias, StringRef ManualCodegen,
const RVVTypes &OutInTypes,
const std::vector &NewIntrinsicTypes,
@@ -855,6 +856,7 @@
unsigned NF, Policy NewPolicyAttrs)
 : IRName(IRName), IsMasked(IsMasked),
   HasMaskedOffOperand(HasMaskedOffOperand), HasVL(H

[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-14 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer updated this revision to Diff 489217.

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

https://reviews.llvm.org/D138546

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test
  clang-tools-extra/clangd/unittests/CompileCommandsTests.cpp
  clang/bindings/python/tests/cindex/test_cdb.py
  clang/docs/tools/clang-formatted-files.txt
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp
  llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
@@ -37,7 +37,6 @@
 "ExpandResponseFilesCompilationDatabase.cpp",
 "FileMatchTrie.cpp",
 "FixIt.cpp",
-"GuessTargetAndModeCompilationDatabase.cpp",
 "InterpolatingCompilationDatabase.cpp",
 "JSONCompilationDatabase.cpp",
 "NodeIntrospection.cpp",
Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -929,31 +929,6 @@
   EXPECT_TRUE(CCRef != CCTest);
 }
 
-class TargetAndModeTest : public MemDBTest {
-public:
-  TargetAndModeTest() { llvm::InitializeAllTargetInfos(); }
-
-protected:
-  // Look up the command from a relative path, and return it in string form.
-  std::string getCommand(llvm::StringRef F) {
-auto Results = inferTargetAndDriverMode(std::make_unique(Entries))
-   ->getCompileCommands(path(F));
-if (Results.empty())
-  return "none";
-return llvm::join(Results[0].CommandLine, " ");
-  }
-};
-
-TEST_F(TargetAndModeTest, TargetAndMode) {
-  add("foo.cpp", "clang-cl", "");
-  add("bar.cpp", "clang++", "");
-
-  EXPECT_EQ(getCommand("foo.cpp"),
-"clang-cl --driver-mode=cl foo.cpp -D foo.cpp");
-  EXPECT_EQ(getCommand("bar.cpp"),
-"clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
-}
-
 class ExpandResponseFilesTest : public MemDBTest {
 public:
   ExpandResponseFilesTest() : FS(new llvm::vfs::InMemoryFileSystem) {}
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -165,9 +165,8 @@
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
-return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(expandResponseFiles(
-  std::move(Base), llvm::vfs::getRealFileSystem(
+return Base ? inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem()))
 : nullptr;
   }
 };
Index: clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
===
--- clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//===- GuessTargetAndModeCompilationDatabase.cpp --===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "clang/Tooling/CompilationDatabase.h"
-#include "clang/Tooling/Tooling.h"
-#include 
-
-namespace clang {
-namespace tooling {
-
-namespace {
-class TargetAndModeAdderDatabase : public CompilationDatabase {
-public:
-  TargetAndModeAdderDatabase(std::unique_ptr Base)
-  : Base(std::move(Base)) {
-assert(this->Base != nullptr);
-  }
-
-  std::vector getAllFiles() const override {
-return Base->getAllFiles();
-  }
-
-  std::vector getAllCompileCommands() const override {
-return addTargetAndMode(Base->getAllCompileCommands());
-  }
-
-  std::vector
-  getCompileCommands(StringRef FilePath) const override {
-return addTargetAndMode(Base->getCompileCommands(FilePath));
-  }
-
-private:
-  std::vector
-  addTargetAndMode(std::vector Cmds) const {
-for (auto &Cmd : Cmds) {
-  if (Cmd.CommandLine.empty())
-continue;
-  addTargetAndModeForProgramName(Cmd.CommandLine, Cmd.CommandLine.front());
-}
-return Cmds;
-  }
-  std

[PATCH] D141750: [docs] Add llvm & clang release notes for LoongArch

2023-01-14 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added a comment.

In D141750#4053473 , @MaskRay wrote:

>   pip3 install --user recommonmark sphinx # sphinx-automodapi for lldb
>   
>   cmake ...
>   
>   ninja ... docs-llvm-html

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141750

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


[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-14 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer updated this revision to Diff 489216.

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

https://reviews.llvm.org/D138546

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test
  clang/bindings/python/tests/cindex/test_cdb.py
  clang/docs/tools/clang-formatted-files.txt
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp
  llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
@@ -37,7 +37,6 @@
 "ExpandResponseFilesCompilationDatabase.cpp",
 "FileMatchTrie.cpp",
 "FixIt.cpp",
-"GuessTargetAndModeCompilationDatabase.cpp",
 "InterpolatingCompilationDatabase.cpp",
 "JSONCompilationDatabase.cpp",
 "NodeIntrospection.cpp",
Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -929,31 +929,6 @@
   EXPECT_TRUE(CCRef != CCTest);
 }
 
-class TargetAndModeTest : public MemDBTest {
-public:
-  TargetAndModeTest() { llvm::InitializeAllTargetInfos(); }
-
-protected:
-  // Look up the command from a relative path, and return it in string form.
-  std::string getCommand(llvm::StringRef F) {
-auto Results = inferTargetAndDriverMode(std::make_unique(Entries))
-   ->getCompileCommands(path(F));
-if (Results.empty())
-  return "none";
-return llvm::join(Results[0].CommandLine, " ");
-  }
-};
-
-TEST_F(TargetAndModeTest, TargetAndMode) {
-  add("foo.cpp", "clang-cl", "");
-  add("bar.cpp", "clang++", "");
-
-  EXPECT_EQ(getCommand("foo.cpp"),
-"clang-cl --driver-mode=cl foo.cpp -D foo.cpp");
-  EXPECT_EQ(getCommand("bar.cpp"),
-"clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
-}
-
 class ExpandResponseFilesTest : public MemDBTest {
 public:
   ExpandResponseFilesTest() : FS(new llvm::vfs::InMemoryFileSystem) {}
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -165,9 +165,8 @@
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
-return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(expandResponseFiles(
-  std::move(Base), llvm::vfs::getRealFileSystem(
+return Base ? inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem()))
 : nullptr;
   }
 };
Index: clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
===
--- clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//===- GuessTargetAndModeCompilationDatabase.cpp --===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "clang/Tooling/CompilationDatabase.h"
-#include "clang/Tooling/Tooling.h"
-#include 
-
-namespace clang {
-namespace tooling {
-
-namespace {
-class TargetAndModeAdderDatabase : public CompilationDatabase {
-public:
-  TargetAndModeAdderDatabase(std::unique_ptr Base)
-  : Base(std::move(Base)) {
-assert(this->Base != nullptr);
-  }
-
-  std::vector getAllFiles() const override {
-return Base->getAllFiles();
-  }
-
-  std::vector getAllCompileCommands() const override {
-return addTargetAndMode(Base->getAllCompileCommands());
-  }
-
-  std::vector
-  getCompileCommands(StringRef FilePath) const override {
-return addTargetAndMode(Base->getCompileCommands(FilePath));
-  }
-
-private:
-  std::vector
-  addTargetAndMode(std::vector Cmds) const {
-for (auto &Cmd : Cmds) {
-  if (Cmd.CommandLine.empty())
-continue;
-  addTargetAndModeForProgramName(Cmd.CommandLine, Cmd.CommandLine.front());
-}
-return Cmds;
-  }
-  std::unique_ptr Base;
-};
-} // namespace
-
-std::unique_ptr
-inf

[PATCH] D139741: [clang][CodeGen] Use base subobject type layout for potentially-overlapping fields

2023-01-14 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev updated this revision to Diff 489215.
dzhidzhoev added a comment.

Clang-format'ted


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139741

Files:
  clang/include/clang/AST/Decl.h
  clang/lib/AST/Decl.cpp
  clang/lib/AST/RecordLayoutBuilder.cpp
  clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
  clang/test/CodeGenCXX/no-unique-address-3.cpp

Index: clang/test/CodeGenCXX/no-unique-address-3.cpp
===
--- /dev/null
+++ clang/test/CodeGenCXX/no-unique-address-3.cpp
@@ -0,0 +1,173 @@
+// RUN: %clang_cc1 -triple aarch64-unknown-linux-gnu -emit-llvm -fdump-record-layouts -std=c++17 %s -o %t | FileCheck %s
+
+// CHECK-LABEL:  0 | class Empty (empty)
+// CHECK-NEXT: | [sizeof=1, dsize=1, align=1,
+// CHECK-NEXT: |  nvsize=1, nvalign=1]
+// CHECK-LABEL:  0 | class Second
+// CHECK-NEXT:   0 |   class Empty (base) (empty)
+// CHECK-NEXT:   0:0-0 |   short A
+// CHECK-NEXT: | [sizeof=2, dsize=1, align=2,
+// CHECK-NEXT: |  nvsize=1, nvalign=2]
+// CHECK-LABEL:  0 | class Foo
+// CHECK-NEXT:   0 |   class Empty (base) (empty)
+// CHECK-NEXT:   2 |   class Second NZNoUnique
+// CHECK-NEXT:   2 | class Empty (base) (empty)
+// CHECK-NEXT:   2:0-0 | short A
+// CHECK-NEXT:   3 |   char B
+// CHECK-NEXT: | [sizeof=4, dsize=4, align=2,
+// CHECK-NEXT: |  nvsize=4, nvalign=2]
+
+class Empty {};
+
+// CHECK-LABEL: LLVMType:%class.Second = type { i8, i8 }
+// CHECK-NEXT:  NonVirtualBaseLLVMType:%class.Second.base = type { i8 }
+class Second : Empty {
+  short A : 1;
+};
+
+// CHECK-LABEL:   LLVMType:%class.Foo = type { [2 x i8], %class.Second.base, i8 }
+// CHECK-NEXT:NonVirtualBaseLLVMType:%class.Foo = type { [2 x i8], %class.Second.base, i8 }
+class Foo : Empty {
+  [[no_unique_address]] Second NZNoUnique;
+  char B;
+};
+Foo I;
+
+// CHECK-LABEL:  0 | class SecondEmpty (empty)
+// CHECK-NEXT:   0 |   class Empty (base) (empty)
+// CHECK-NEXT: | [sizeof=1, dsize=0, align=1,
+// CHECK-NEXT: |  nvsize=1, nvalign=1]
+class SecondEmpty: Empty {
+};
+
+// CHECK-LABEL:  0 | class Bar
+// CHECK-NEXT:   0 |   class Empty (base) (empty)
+// CHECK-NEXT:   1 |   class SecondEmpty ZNoUnique (empty)
+// CHECK-NEXT:   1 | class Empty (base) (empty)
+// CHECK-NEXT:   0 |   char C
+// CHECK-NEXT: | [sizeof=2, dsize=1, align=1,
+// CHECK-NEXT: |  nvsize=2, nvalign=1]
+
+// CHECK-LABEL:  LLVMType:%class.Bar = type { i8, i8 }
+// CHECK-NEXT:   NonVirtualBaseLLVMType:%class.Bar = type { i8, i8 }
+class Bar : Empty {
+  [[no_unique_address]] SecondEmpty ZNoUnique;
+  char C;
+};
+Bar J;
+
+// CHECK-LABEL:  0 | class IntFieldClass
+// CHECK-NEXT:   0 |   class Empty (base) (empty)
+// CHECK-NEXT:   2 |   class Second Field
+// CHECK-NEXT:   2 | class Empty (base) (empty)
+// CHECK-NEXT:   2:0-0 | short A
+// CHECK-NEXT:   4 |   int C
+// CHECK-NEXT: | [sizeof=8, dsize=8, align=4,
+// CHECK-NEXT: |  nvsize=8, nvalign=4]
+
+// CHECK-LABEL:   LLVMType:%class.IntFieldClass = type { [2 x i8], %class.Second.base, i32 }
+// CHECK-NEXT:NonVirtualBaseLLVMType:%class.IntFieldClass = type { [2 x i8], %class.Second.base, i32 }
+class IntFieldClass : Empty {
+  [[no_unique_address]] Second Field;
+  int C;
+};
+IntFieldClass K;
+
+// CHECK-LABEL: 0 | class UnionClass
+// CHECK-NEXT:  0 |   class Empty (base) (empty)
+// CHECK-NEXT:  0 |   union UnionClass
+// CHECK-NEXT:  0 | int I
+// CHECK-NEXT:  0 | char C
+// CHECK-NEXT:  4 |   int C
+// CHECK-NEXT:| [sizeof=8, dsize=8, align=4,
+// CHECK-NEXT:|  nvsize=8, nvalign=4]
+
+// CHECK-LABEL:  LLVMType:%class.UnionClass = type { %union.anon, i32 }
+// CHECK-NEXT:   NonVirtualBaseLLVMType:%class.UnionClass = type { %union.anon, i32 }
+// CHECK-NEXT:   IsZeroInitializable:1
+// CHECK-NEXT:   BitFields:[
+// CHECK-NEXT: ]>
+class UnionClass : Empty {
+  [[no_unique_address]] union {
+int I;
+char C;
+  } U;
+  int C;
+};
+UnionClass L;
+
+// CHECK-LABEL: 0 | class EnumClass
+// CHECK-NEXT:  0 |   class Empty (base) (empty)
+// CHECK-NEXT:  0 |   enum E A
+// CHECK-NEXT:  4 |   int C
+// CHECK-NEXT:| [sizeof=8, dsize=8, align=4,
+// CHECK-NEXT:|  nvsize=8, nvalign=4]
+
+// CHECK-LABEL:  LLVMType:%class.EnumClass = type { i32, i32 }
+// CHECK-NEXT:   NonVirtualBaseLLVMType:%class.EnumClass = type { i32, i32 }
+// CHECK-NEXT:   IsZeroInitializable:1
+// CHECK-NEXT:   BitFields:[
+// CHECK-NEXT: ]>
+class EnumClass : Empty {
+  [[no_unique_address]] enum class E { X, Y, Z } A;
+  int C;

[PATCH] D141654: [clang-format] Replace DeriveLineEnding and UseCRLF with LineEnding

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

In D141654#4053470 , @rymiel wrote:

> This also made me wonder, is there an actual policy on deprecated options? As 
> in, when they are actually removed. Is there even prior precedent for doing 
> this? (I wouldn't know because I'm a very recent user)

I think the first one was D108752  and the 
documentation can handle that since D127578 .
Removing an option is not different than changing the type of an option, users 
of `libformat` have to adapt, and users of `clang-format` don't notice (if 
everything is done right), because the parsing for the removed options is still 
there, see lines 1068 and following of `Format.cpp` in this change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141654

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


[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-14 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer updated this revision to Diff 489214.

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

https://reviews.llvm.org/D138546

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test
  clang/docs/tools/clang-formatted-files.txt
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp
  llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
@@ -37,7 +37,6 @@
 "ExpandResponseFilesCompilationDatabase.cpp",
 "FileMatchTrie.cpp",
 "FixIt.cpp",
-"GuessTargetAndModeCompilationDatabase.cpp",
 "InterpolatingCompilationDatabase.cpp",
 "JSONCompilationDatabase.cpp",
 "NodeIntrospection.cpp",
Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -929,31 +929,6 @@
   EXPECT_TRUE(CCRef != CCTest);
 }
 
-class TargetAndModeTest : public MemDBTest {
-public:
-  TargetAndModeTest() { llvm::InitializeAllTargetInfos(); }
-
-protected:
-  // Look up the command from a relative path, and return it in string form.
-  std::string getCommand(llvm::StringRef F) {
-auto Results = inferTargetAndDriverMode(std::make_unique(Entries))
-   ->getCompileCommands(path(F));
-if (Results.empty())
-  return "none";
-return llvm::join(Results[0].CommandLine, " ");
-  }
-};
-
-TEST_F(TargetAndModeTest, TargetAndMode) {
-  add("foo.cpp", "clang-cl", "");
-  add("bar.cpp", "clang++", "");
-
-  EXPECT_EQ(getCommand("foo.cpp"),
-"clang-cl --driver-mode=cl foo.cpp -D foo.cpp");
-  EXPECT_EQ(getCommand("bar.cpp"),
-"clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
-}
-
 class ExpandResponseFilesTest : public MemDBTest {
 public:
   ExpandResponseFilesTest() : FS(new llvm::vfs::InMemoryFileSystem) {}
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -165,9 +165,8 @@
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
-return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(expandResponseFiles(
-  std::move(Base), llvm::vfs::getRealFileSystem(
+return Base ? inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem()))
 : nullptr;
   }
 };
Index: clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
===
--- clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//===- GuessTargetAndModeCompilationDatabase.cpp --===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
-//
-//===--===//
-
-#include "clang/Tooling/CompilationDatabase.h"
-#include "clang/Tooling/Tooling.h"
-#include 
-
-namespace clang {
-namespace tooling {
-
-namespace {
-class TargetAndModeAdderDatabase : public CompilationDatabase {
-public:
-  TargetAndModeAdderDatabase(std::unique_ptr Base)
-  : Base(std::move(Base)) {
-assert(this->Base != nullptr);
-  }
-
-  std::vector getAllFiles() const override {
-return Base->getAllFiles();
-  }
-
-  std::vector getAllCompileCommands() const override {
-return addTargetAndMode(Base->getAllCompileCommands());
-  }
-
-  std::vector
-  getCompileCommands(StringRef FilePath) const override {
-return addTargetAndMode(Base->getCompileCommands(FilePath));
-  }
-
-private:
-  std::vector
-  addTargetAndMode(std::vector Cmds) const {
-for (auto &Cmd : Cmds) {
-  if (Cmd.CommandLine.empty())
-continue;
-  addTargetAndModeForProgramName(Cmd.CommandLine, Cmd.CommandLine.front());
-}
-return Cmds;
-  }
-  std::unique_ptr Base;
-};
-} // namespace
-
-std::unique_ptr
-inferTargetAndDriverMode(std::unique_ptr Base) {
-  

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

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

@Eugene.Zelenko @njames93 I believe I have addressed all the outstanding 
comments, is there anything else you think needs fix? Otherwise I would like to 
land the patch before January 24th when they will start a new release.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

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


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

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp updated this revision to Diff 489213.
carlosgalvezp added a comment.

Rebase and fix formatting of "clang-tidy" in the docs.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141000

Files:
  clang-tools-extra/clang-tidy/ClangTidyOptions.cpp
  clang-tools-extra/clang-tidy/ClangTidyOptions.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  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/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);
+  EXPECT_EQ(std::vector({"hpp", "hxx"}),
+*Options.HeaderFileExtensions);
+  EXPECT_EQ(std::vector({"cpp", "cxx"}),
+*Options.ImplementationFileExtensions);
   EXPECT_EQ("filter2", *Options.HeaderFilterRegex);
   EXPECT_EQ("user2", *Options.User);
   ASSERT_TRUE(Options.ExtraArgs.has_value());
Index: clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
===
--- clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
+++ clang-tools-extra/test/clang-tidy/infrastructure/verify-config.cpp
@@ -3,6 +3,8 @@
 
 // RUN: not clang-tidy -verify-config \
 // RUN: --checks='-*,bad*glob,llvm*,llvm-includeorder,my-made-up-check' --config='{Checks: "readability-else-after-ret", \
+// RUN: HeaderFileExtensions: ["h", "hh", "hpp"], \
+// RUN: ImplementationFileExtensions: ["c", "cc", "hpp"], \
 // RUN: CheckOptions: [{key: "IgnoreMacros", value: "true"}, \
 // RUN:{key: "StriceMode", value: "true"}, \
 // RUN:{key: modernize-lop-convert.UseCxx20ReverseRanges, value: true} \
@@ -12,6 +14,7 @@
 // CHECK-VERIFY-DAG: command-line option '-config': warning: unknown check 'readability-else-after-ret'; did you mean 'readability-else-after-return' [-verify-config]
 // CHECK-VERIFY-DAG: command-line option '-config': warning: unknown check option 'modernize-lop-convert.UseCxx20ReverseRanges'; did you mean 'modernize-loop-convert.UseCxx20ReverseRanges' [-verify-config]
 // CHECK-VERIFY-DAG: command-line optio

[PATCH] D138546: Clangd: Preserve target flags in system includes extractor

2023-01-14 Thread Christopher Sauer via Phabricator via cfe-commits
cpsauer updated this revision to Diff 489208.
cpsauer added a comment.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

@nridge, I took a shot at the change you suggested. Confirming that this what 
you were thinking of, removing `inferTargetAndDriverMode` from database load 
and replacing it with a call to the underlying `addTargetAndModeForProgramName` 
in the `CommandMangler` after the `SystemIncludeExtractor` is invoked?
Note that I also saw a parallel call to `inferTargetAndDriverMode` in 
`JSONCompilationDatabasePlugin`, which seemed like it might cause the same 
problem, so I eliminated the call in there, too. I then culled the dead code, 
since there weren't other call sites for the `addTargetAndModeForProgramName` 
wrappings. Could I ask you to sanity check that? I know that's a more general 
tooling library; I was having trouble determining whether other tooling needed 
the target inference or not.  
Also, @ArcsinX, could I get your take? Do you think this would fix the layering 
issue you raised?

We're definitely stretching my (currently quite limited) understanding of how 
clangd's implementation fits together, so I think I'll need to ask for 
help/guidance if that looks wrong.

Thanks again, guys!
-CS


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

https://reviews.llvm.org/D138546

Files:
  clang-tools-extra/clangd/CompileCommands.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/SystemIncludeExtractor.cpp
  clang-tools-extra/clangd/test/system-include-extractor.test
  clang/docs/tools/clang-formatted-files.txt
  clang/include/clang/Tooling/CompilationDatabase.h
  clang/lib/Tooling/CMakeLists.txt
  clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
  clang/lib/Tooling/JSONCompilationDatabase.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp
  llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn

Index: llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
===
--- llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
+++ llvm/utils/gn/secondary/clang/lib/Tooling/BUILD.gn
@@ -37,7 +37,6 @@
 "ExpandResponseFilesCompilationDatabase.cpp",
 "FileMatchTrie.cpp",
 "FixIt.cpp",
-"GuessTargetAndModeCompilationDatabase.cpp",
 "InterpolatingCompilationDatabase.cpp",
 "JSONCompilationDatabase.cpp",
 "NodeIntrospection.cpp",
Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -929,31 +929,6 @@
   EXPECT_TRUE(CCRef != CCTest);
 }
 
-class TargetAndModeTest : public MemDBTest {
-public:
-  TargetAndModeTest() { llvm::InitializeAllTargetInfos(); }
-
-protected:
-  // Look up the command from a relative path, and return it in string form.
-  std::string getCommand(llvm::StringRef F) {
-auto Results = inferTargetAndDriverMode(std::make_unique(Entries))
-   ->getCompileCommands(path(F));
-if (Results.empty())
-  return "none";
-return llvm::join(Results[0].CommandLine, " ");
-  }
-};
-
-TEST_F(TargetAndModeTest, TargetAndMode) {
-  add("foo.cpp", "clang-cl", "");
-  add("bar.cpp", "clang++", "");
-
-  EXPECT_EQ(getCommand("foo.cpp"),
-"clang-cl --driver-mode=cl foo.cpp -D foo.cpp");
-  EXPECT_EQ(getCommand("bar.cpp"),
-"clang++ --driver-mode=g++ bar.cpp -D bar.cpp");
-}
-
 class ExpandResponseFilesTest : public MemDBTest {
 public:
   ExpandResponseFilesTest() : FS(new llvm::vfs::InMemoryFileSystem) {}
Index: clang/lib/Tooling/JSONCompilationDatabase.cpp
===
--- clang/lib/Tooling/JSONCompilationDatabase.cpp
+++ clang/lib/Tooling/JSONCompilationDatabase.cpp
@@ -165,9 +165,8 @@
 llvm::sys::path::append(JSONDatabasePath, "compile_commands.json");
 auto Base = JSONCompilationDatabase::loadFromFile(
 JSONDatabasePath, ErrorMessage, JSONCommandLineSyntax::AutoDetect);
-return Base ? inferTargetAndDriverMode(
-  inferMissingCompileCommands(expandResponseFiles(
-  std::move(Base), llvm::vfs::getRealFileSystem(
+return Base ? inferMissingCompileCommands(expandResponseFiles(
+  std::move(Base), llvm::vfs::getRealFileSystem()))
 : nullptr;
   }
 };
Index: clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
===
--- clang/lib/Tooling/GuessTargetAndModeCompilationDatabase.cpp
+++ /dev/null
@@ -1,57 +0,0 @@
-//===- GuessTargetAndModeCompilationDatabase.cpp --===//
-//
-// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
-// See https://llvm.org/LICENSE.txt for license information.
-// SPDX-License-Identifier: A

[PATCH] D141380: [clang-repl] XFAIL riscv targets in simple-exception test case

2023-01-14 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld accepted this revision.
Hahnfeld added a comment.
This revision is now accepted and ready to land.

Yes, this is correct: The JITLink backend for RISC-V doesn't (yet) register the 
eh frames into libunwind, so throwing and catching exceptions through JITted 
code doesn't work (yet). I know in principle how to make this happen and it's 
on my list, but I couldn't give it priority before a talk on Thursday. Sorry 
for not realizing we have a test for this in `clang-repl` - does this mean we 
have bots running this natively on RISC-V?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141380

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


[PATCH] D137302: [clang-tidy] Add modernize-type-traits check

2023-01-14 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added inline comments.



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.cpp:172
+void TypeTraitsCheck::registerMatchers(MatchFinder *Finder) {
+  static const ast_matchers::internal::VariadicDynCastAllOfMatcher<
+  Stmt,

`static` not needed here, remove. I don't think LLVM guidelines enforce strict 
const correctness either so the `const` could be removed as well if wanted.



Comment at: clang-tools-extra/clang-tidy/modernize/TypeTraitsCheck.h:17
+namespace tidy {
+namespace modernize {
+

njames93 wrote:
> carlosgalvezp wrote:
> > njames93 wrote:
> > > Eugene.Zelenko wrote:
> > > > tschuett wrote:
> > > > > Why do you refuse to use nested namespaces in `modernize` ?
> > > > I think this is done for legacy reasons. This should be done for all 
> > > > checks and `add_new_check.py`.
> > > Because the add_new_check script hasn't been updated since we went to 
> > > c++17
> > Is the goal to update all existing checks to C++17 format?
> It should be done separately as an NFC change
Sounds good, just want to make sure it's something we see value in fixing (as 
opposed to just being "churn"). I'm happy to put up an NFC patch for that!



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/modernize/type-traits.cpp:38
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use c++14 style type templates
+// CHECK-FIXES: std::enable_if_tinTemplate();
+

njames93 wrote:
> carlosgalvezp wrote:
> > There should be a space in here, right? Same for the rest.
> I'm assuming you mean between `` and `inTemplate`.
> If so, because we disable clang-format in the tests, the code isn't being 
> reformatted and the replacement logic happens to get rid of the space too. As 
> missing the space doesn't break the code and clang-format would reformat the 
> code for us in typical use cases, its not worth worrying about.
I disagree, just because the code "compiles" it doesn't mean it's good. The 
only time I've seen code like this is in [[ https://www.ioccc.org/ | obfuscated 
code competitions ]] :) 

We should not force the user to run clang-format to fix this - clang-tidy 
should preserve the existing space. This is not a matter of style either, it's 
a de-facto way of writting C++ (and many other languages): variable types and 
variable names in a declaration are separated by a space.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137302

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


[PATCH] D133574: [C2x] reject type definitions in offsetof

2023-01-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

+1 on this being disruptive. Also, not only GCC, but also MSVC seem to handle 
the existing constructs in the wild. I ran into this at 
https://github.com/FFmpeg/FFmpeg/blob/n5.1.2/libavutil/video_enc_params.c#L30-L34
 (where it probably would be trivial to fix, but leaving current releases 
broken with newer clang) and at 
https://github.com/wine-mirror/wine/blob/wine-8.0-rc4/include/winnt.h#L399-L405 
(where it works with clang in the usual gnuc mode, but falls back on the UB 
construct with clang in msvc mode).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D141750: [docs] Add llvm & clang release notes for LoongArch

2023-01-14 Thread Lu Weining via Phabricator via cfe-commits
SixWeining updated this revision to Diff 489204.
SixWeining added a comment.

Fix the issue "Title underline too short" reported by sphinx-build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141750

Files:
  clang/docs/ReleaseNotes.rst
  llvm/docs/ReleaseNotes.rst


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -47,6 +47,8 @@
is not a constant in coroutines. This decision may cause unnecessary
performance regressions and we plan to fix it in later versions.
 
+*  The LoongArch target is promoted to "official" (see below for more details).
+
 * ...
 
 Update on required toolchains to build LLVM
@@ -154,6 +156,19 @@
 
 * ...
 
+Changes to the LoongArch Backend
+
+
+* The LoongArch target is no longer "experimental"! It's now built by default,
+  rather than needing to be enabled with 
``LLVM_EXPERIMENTAL_TARGETS_TO_BUILD``.
+
+* The backend has full codegen support for the base (both integer and
+  floating-point) instruction set and it conforms to psABI v2. Testing has been
+  performed with Linux, including native compilation of a large corpus of Linux
+  applications.
+
+* Support GHC calling convention.
+
 Changes to the MIPS Backend
 ---
 
@@ -279,9 +294,13 @@
 Changes to LLDB
 -
 
+* Initial support for debugging Linux LoongArch 64-bit binaries.
+
 Changes to Sanitizers
 -
 
+* Many Sanitizers (asan, fuzzer, lsan, safestack, scudo, tsan, ubsan) have
+  support for Linux LoongArch 64-bit variant. Some of them may be rudimentary.
 
 Other Changes
 -
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -798,6 +798,19 @@
 - Clang now supports CUDA SDK up to 11.8
 - Added support for targeting sm_{87,89,90} GPUs.
 
+LoongArch Support in Clang
+--
+- Clang now supports LoongArch. Along with the backend, clang is able to build 
a
+  large corpus of Linux applications. Test-suite 100% pass.
+- Support basic option ``-march=`` which is used to select the target
+  architecture, i.e. the basic set of ISA modules to be enabled. Possible 
values
+  are ``loongarch64`` and ``la464``.
+- Support basic option ``-mabi=`` which is used select the base ABI type.
+  Possible values are ``lp64d``, ``lp64f``, ``lp64s``, ``ilp32d``, ``ilp32f``
+  and ``ilp32s``.
+- Support extended options: ``-msoft-float``, ``-msingle-float``, 
``-mdouble-float`` and ``mfpu=``.
+  See `LoongArch toolchain conventions 
`_.
+
 RISC-V Support in Clang
 ---
 - ``sifive-7-rv32`` and ``sifive-7-rv64`` are no longer supported for 
``-mcpu``.


Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -47,6 +47,8 @@
is not a constant in coroutines. This decision may cause unnecessary
performance regressions and we plan to fix it in later versions.
 
+*  The LoongArch target is promoted to "official" (see below for more details).
+
 * ...
 
 Update on required toolchains to build LLVM
@@ -154,6 +156,19 @@
 
 * ...
 
+Changes to the LoongArch Backend
+
+
+* The LoongArch target is no longer "experimental"! It's now built by default,
+  rather than needing to be enabled with ``LLVM_EXPERIMENTAL_TARGETS_TO_BUILD``.
+
+* The backend has full codegen support for the base (both integer and
+  floating-point) instruction set and it conforms to psABI v2. Testing has been
+  performed with Linux, including native compilation of a large corpus of Linux
+  applications.
+
+* Support GHC calling convention.
+
 Changes to the MIPS Backend
 ---
 
@@ -279,9 +294,13 @@
 Changes to LLDB
 -
 
+* Initial support for debugging Linux LoongArch 64-bit binaries.
+
 Changes to Sanitizers
 -
 
+* Many Sanitizers (asan, fuzzer, lsan, safestack, scudo, tsan, ubsan) have
+  support for Linux LoongArch 64-bit variant. Some of them may be rudimentary.
 
 Other Changes
 -
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -798,6 +798,19 @@
 - Clang now supports CUDA SDK up to 11.8
 - Added support for targeting sm_{87,89,90} GPUs.
 
+LoongArch Support in Clang
+--
+- Clang now supports LoongArch. Along with the backend, clang is able to build a
+  large corpus of Linux applications. Test-suite 100% pass.
+- Support basic optio