[PATCH] D152054: [OpenMP] Codegen support for thread_limit on target directive

2023-06-03 Thread Sandeep via Phabricator via cfe-commits
sandeepkosuri created this revision.
sandeepkosuri added reviewers: ABataev, soumitra, koops, RitanyaB, dreachem.
Herald added subscribers: sunshaoce, guansong, yaxunl.
Herald added a project: All.
sandeepkosuri requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, openmp-commits, cfe-commits, jplehr, 
sstefan1.
Herald added projects: clang, OpenMP, LLVM.

- This patch adds support for thread_limit clause on target directive according 
to OpenMP 51 [2.14.5]
- The idea is to create an outer task for target region, when there is a 
thread_limit clause, and manipulate the thread_limit of task instead. This way, 
thread_limit will be applied to all the relevant constructs enclosed by the 
target region.




Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152054

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/test/OpenMP/target_codegen.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  openmp/runtime/src/kmp.h
  openmp/runtime/src/kmp_csupport.cpp
  openmp/runtime/src/kmp_ftn_entry.h
  openmp/runtime/src/kmp_global.cpp
  openmp/runtime/src/kmp_runtime.cpp
  openmp/runtime/test/target/target_thread_limit.cpp

Index: openmp/runtime/test/target/target_thread_limit.cpp
===
--- /dev/null
+++ openmp/runtime/test/target/target_thread_limit.cpp
@@ -0,0 +1,81 @@
+// RUN: %libomp-cxx-compile -fopenmp-version=51
+// RUN: %libomp-run | FileCheck %s --check-prefix OMP51
+
+#include 
+#include 
+
+void foo() {
+#pragma omp parallel num_threads(10)
+  { printf("\ntarget: foo(): parallel num_threads(10)"); }
+}
+
+int main(void) {
+
+  int tl = 4;
+  printf("\nmain: thread_limit = %d", omp_get_thread_limit());
+  // OMP51: main: thread_limit = {{[0-9]+}}
+
+#pragma omp target thread_limit(tl)
+  {
+printf("\ntarget: thread_limit = %d", omp_get_thread_limit());
+// OMP51: target: thread_limit = 4
+// check whether thread_limit is honoured
+#pragma omp parallel
+{ printf("\ntarget: parallel"); }
+// OMP51: target: parallel
+// OMP51: target: parallel
+// OMP51: target: parallel
+// OMP51: target: parallel
+
+// check whether num_threads is honoured
+#pragma omp parallel num_threads(2)
+{ printf("\ntarget: parallel num_threads(2)"); }
+// OMP51: target: parallel num_threads(2)
+// OMP51: target: parallel num_threads(2)
+
+// check whether thread_limit is honoured when there is a conflicting
+// num_threads
+#pragma omp parallel num_threads(10)
+{ printf("\ntarget: parallel num_threads(10)"); }
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+// OMP51: target: parallel num_threads(10)
+
+// check whether threads are limited across functions
+foo();
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+// OMP51: target: foo(): parallel num_threads(10)
+  }
+
+// checking consecutive target regions with different thread_limits
+#pragma omp target thread_limit(3)
+  {
+printf("\nsecond target: thread_limit = %d", omp_get_thread_limit());
+// OMP51: second target: thread_limit = 3
+#pragma omp parallel
+{ printf("\nsecond target: parallel"); }
+// OMP51: second target: parallel
+// OMP51: second target: parallel
+// OMP51: second target: parallel
+  }
+
+// confirm that thread_limit's effects are limited to target region
+  printf("\nmain: thread_limit = %d", omp_get_thread_limit());
+// OMP51: main: thread_limit = {{[0-9]+}}
+#pragma omp parallel num_threads(10)
+  { printf("\nmain: parallel num_threads(10)"); }
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  // OMP51: main: parallel num_threads(10)
+  return 0;
+}
Index: openmp/runtime/src/kmp_runtime.cpp
===
--- openmp/runtime/src/kmp_runtime.cpp
+++ openmp/runtime/src/kmp_runtime.cpp
@@ -1867,6 +1867,7 @@
   int nthreads;
   int master_active;
   int master_set_numthreads;
+  int task_thread_limit = 0;
   int level;
   int active_level;
   int teams_level;
@@ -1905,6 +1906,8 @@
 root = master_th->th.th_root;
 master_active = root->r.r_active;
 master_set_numthreads = master_th->th.th_set_nproc;
+task_thread_limit =
+master_th->th.th_current_task->td_icvs.task_thread_limit;
 
 #if OMPT_SUPPORT
 ompt_data_t ompt_parallel_data = ompt_data_none;
@@ -1995,6 +1998,11 @@
  

[PATCH] D152009: [clang] Fix assertion while parsing an invalid for loop

2023-06-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added inline comments.



Comment at: clang/lib/Parse/ParseStmt.cpp:2200
 Diag(Tok, diag::err_expected_semi_for);
-  else
-// Skip until semicolon or rparen, don't consume it.

shafik wrote:
> Can you explain why you removed this?
The current diagnostics are pretty bad https://godbolt.org/z/z9odv3zjb - this 
fixes that



Comment at: clang/test/Parser/cxx0x-for-range.cpp:67
+int a[] = {1, 2, 3, 4, 5};
+for (auto x = n ? 1 : 2 : a); // expected-error {{expected ';' in 'for' 
statement specifier}} \
+  // expected-error {{expected expression}}

shafik wrote:
> Did you try dropping the `;` at the end of this line to make sure it still 
> does what we expect?
yup, you think it's worth adding a test?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152009

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


[PATCH] D152057: [CMake][Fuchsia] Add LLVM_ENABLE_HTTPLIB to Stage 2 build

2023-06-03 Thread Aiden Grossman via Phabricator via cfe-commits
aidengrossman created this revision.
Herald added subscribers: ekilmer, abrachet.
Herald added a project: All.
aidengrossman requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch sets the LLVM_ENABLE_HTTPLIB flag to ON in the stage 2 build
similar to how many of the other dependency flags are already specified.
This is necessary to configure the stage 2 build by itself, otherwise
the CMake configuration crashes.

This is currently causing the MLGO demo to fail since we're only using
stage 2 to avoid having to build stage 1 to save some compile time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152057

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


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -11,6 +11,7 @@
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
+set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
 set(LLVM_ENABLE_LLD ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -11,6 +11,7 @@
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
+set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
 set(LLVM_ENABLE_LLD ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148793: [clang-tidy] Implement an include-cleaner check.

2023-06-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

I'm getting completely incomprehensible build errors on Gentoo from this, as of 
aa7eace8431ba213c5431638b894b0e1b4b481c7 
:

  samu: job failed: : && /usr/lib/ccache/bin/x86_64-pc-linux-gnu-g++ 
-march=znver2 --param=l1-cache-size=32 --param=l1-cache-line-size=64 -O2 -pipe 
-frecord-gcc-switches -fPIC -fno-semantic-interposition 
-fvisibility-inlines-hidden -Werror=date-time -fno-lifetime-dse -Wall -Wextra 
-Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -Wimplicit-fallthrough -Wno-class-memaccess 
-Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wsuggest-override -Wno-comment 
-Wno-misleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color 
-ffunction-sections -fdata-sections -fno-common -Woverloaded-virtual 
-fno-strict-aliasing -pedantic -Wno-long-long -Wl,-O1 -Wl,--as-needed 
-Wl,--hash-style=gnu   -Wl,--export-dynamic -rdynamic  
-Wl,-rpath-link,/var/tmp/portage/sys-devel/clang-17.0.0_pre20230603/work/x/y/clang-abi_x86_64.amd64/./lib64
 tools/extra/clang-tidy/tool/CMakeFiles/clang-tidy.dir/ClangTidyToolMain.cpp.o 
-o bin/clang-tidy -L/usr/lib/llvm/17/lib64 
-Wl,-rpath,"\$ORIGIN/../lib64:/usr/lib/llvm/17/lib64:/var/tmp/portage/sys-devel/clang-17.0.0_pre20230603/work/x/y/clang-abi_x86_64.amd64/lib64:"
  lib64/libclangTidy.a  lib64/libclangTidyMain.a  
lib64/libclangTidyAndroidModule.a  lib64/libclangTidyAbseilModule.a  
lib64/libclangTidyAlteraModule.a  lib64/libclangTidyBoostModule.a  
lib64/libclangTidyBugproneModule.a  lib64/libclangTidyCERTModule.a  
lib64/libclangTidyConcurrencyModule.a  
lib64/libclangTidyCppCoreGuidelinesModule.a  lib64/libclangTidyDarwinModule.a  
lib64/libclangTidyFuchsiaModule.a  lib64/libclangTidyGoogleModule.a  
lib64/libclangTidyHICPPModule.a  lib64/libclangTidyLinuxKernelModule.a  
lib64/libclangTidyLLVMModule.a  lib64/libclangTidyLLVMLibcModule.a  
lib64/libclangTidyMiscModule.a  lib64/libclangTidyModernizeModule.a  
lib64/libclangTidyObjCModule.a  lib64/libclangTidyOpenMPModule.a  
lib64/libclangTidyPerformanceModule.a  lib64/libclangTidyPortabilityModule.a  
lib64/libclangTidyReadabilityModule.a  lib64/libclangTidyZirconModule.a  
lib64/libclangTidyMPIModule.a  lib64/libclangTidyBugproneModule.a  
lib64/libclangTidyCppCoreGuidelinesModule.a  lib64/libclangTidyGoogleModule.a  
lib64/libclangTidyMiscModule.a  lib64/libclangAnalysis.a  
lib64/libclangASTMatchers.a  lib64/libclangAST.a  lib64/libclangLex.a  
lib64/libclangBasic.a  lib64/libclangTidyModernizeModule.a  
lib64/libclangTidyReadabilityModule.a  lib64/libclangTidyUtils.a  
lib64/libclangTidy.a  lib64/libclang-cpp.so.17gitaa7eace8  
/usr/lib/llvm/17/lib64/libLLVM-17gitaa7eace8.so && :
  /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
lib64/libclangTidyMiscModule.a(IncludeCleanerCheck.cpp.o): in function 
`clang::tidy::misc::IncludeCleanerCheck::registerPPCallbacks(clang::SourceManager
 const&, clang::Preprocessor*, clang::Preprocessor*) [clone .localalias]':
  
IncludeCleanerCheck.cpp:(.text._ZN5clang4tidy4misc19IncludeCleanerCheck19registerPPCallbacksERKNS_13SourceManagerEPNS_12PreprocessorES7_+0x24):
 undefined reference to 
`clang::include_cleaner::RecordedPP::record(clang::Preprocessor const&)'
  /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
IncludeCleanerCheck.cpp:(.text._ZN5clang4tidy4misc19IncludeCleanerCheck19registerPPCallbacksERKNS_13SourceManagerEPNS_12PreprocessorES7_+0x94):
 undefined reference to 
`clang::include_cleaner::PragmaIncludes::record(clang::Preprocessor&)'
  /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
lib64/libclangTidyMiscModule.a(IncludeCleanerCheck.cpp.o): in function 
`clang::tidy::misc::IncludeCleanerCheck::check(clang::ast_matchers::MatchFinder::MatchResult
 const&) [clone .localalias]':
  
IncludeCleanerCheck.cpp:(.text._ZN5clang4tidy4misc19IncludeCleanerCheck5checkERKNS_12ast_matchers11MatchFinder11MatchResultE+0x508):
 undefined reference to 
`clang::include_cleaner::walkUsed(llvm::ArrayRef, 
llvm::ArrayRef, 
clang::include_cleaner::PragmaIncludes const*, clang::SourceManager const&, 
llvm::function_ref)>)'
  /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
IncludeCleanerCheck.cpp:(.text._ZN5clang4tidy4misc19IncludeCleanerCheck5checkERKNS_12ast_matchers11MatchFinder11MatchResultE+0x604):
 undefined reference to 
`clang::include_cleaner::PragmaIncludes::getPublic(clang::FileEntry const*) 
const'
  /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
IncludeCleanerCheck.cpp:(.text._ZN5clang4tidy4misc19IncludeCleanerCheck5checkERKNS_12ast_matchers11MatchFinder11MatchResultE+0x9e8):
 undefined reference to `clang::include_cleaner::Include::quote[abi:cxx11]() 
const'
  /usr/lib/gcc/x86_64-pc-linux-gnu/13/../../../../x86_64-pc-linux-gnu/bin/ld: 
IncludeCleanerCheck.cpp

[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-06-03 Thread Charalampos Mitrodimas via Phabricator via cfe-commits
charmitro added inline comments.



Comment at: clang/test/Frontend/absolute-paths.c:6
+// NORMAL: In file included from [[ROOT_ABSOLUTE]]:4:
+// ABSOLUTE: In file included from [[ROOT_ABSOLUTE]]:4:
 

tbaeder wrote:
> charmitro wrote:
> > tbaeder wrote:
> > > charmitro wrote:
> > > > tbaeder wrote:
> > > > > This checks the same thing in both cases, but in the `NORMAL` case, 
> > > > > it should //not// use the absolute path, shouldn't it?
> > > > You're correct. I was constantly testing it from the same path.
> > > > 
> > > > Since the relative path is going to be different depending on where you 
> > > > running from, would it be wise to accept a regular expression of any 
> > > > string in the `NORMAL` case?
> > > > 
> > > > For example, 
> > > > ```
> > > > NORMAL: In file included from {{.*}}:
> > > > ```
> > > I wonder if it would make sense to just check for the filename in the 
> > > `NORMAL` case and then do a `NORMAL-NOT: [[ROOT_ABSOLUTE]]`?
> > Yes, that way we are testing if the warning contains the correct 
> > filename+LOC.
> > 
> > Something like: `// NORMAL: In file included from 
> > {{.*absolute-paths.c:4}}:`.
> > 
> > But why changefrom `ABSOLUTE:` to `NORMAL-NOT`?
> Your regex checks if the path ends with the file name, right? That would be 
> true in both cases.
What else do you propose here?

Let me explain why this was the only obvious option for me.

In the case of `NORMAL`, it checks for the relative path based on the location 
you invoke the test commands. 

Given that, if we, for example,
1. run `llvm-lit` from the project root, the `NORMAL` case expects:
```
In file included from clang/test/Frontend/absolute-paths.c:4:
```
2. run `llvm-lit` from `$PROJECT_ROOT/clang/test/`, the `NORMAL` case expects:
```
In file included from Frontend/absolute-paths.c:4:
```

It seems unwise to me to hard-code the path based on what the CI excepts in the 
`NORMAL` scenario, because that way, whoever runs the test cases manually, will 
experience test failure.


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

https://reviews.llvm.org/D151833

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


[clang] 0beffb8 - [CMake] Ensure `CLANG_RESOURCE_DIR` is respected.

2023-06-03 Thread Tom Stellard via cfe-commits

Author: paperchalice
Date: 2023-06-03T04:21:35-07:00
New Revision: 0beffb854209a41f31beb18f9631258349a99299

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

LOG: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected.

re-commit of 39aa0f5c434b463520ac39a8dbe933ee8c4c5ea7 with missing file:
cmake/Modules/GetClangResourceDir.cmake.

Added: 
cmake/Modules/GetClangResourceDir.cmake

Modified: 
clang/lib/Headers/CMakeLists.txt
clang/lib/Tooling/CMakeLists.txt
clang/runtime/CMakeLists.txt
compiler-rt/cmake/base-config-ix.cmake
lldb/source/Plugins/ExpressionParser/Clang/ClangHost.cpp
lldb/unittests/Expression/ClangParserTest.cpp
llvm/cmake/modules/LLVMExternalProjectUtils.cmake
openmp/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Headers/CMakeLists.txt 
b/clang/lib/Headers/CMakeLists.txt
index bbd3d0f2d719a..f2ee2e036deb9 100644
--- a/clang/lib/Headers/CMakeLists.txt
+++ b/clang/lib/Headers/CMakeLists.txt
@@ -298,7 +298,8 @@ set(openmp_wrapper_files
   openmp_wrappers/new
 )
 
-set(output_dir 
${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}/include)
+include(GetClangResourceDir)
+get_clang_resource_dir(output_dir PREFIX ${LLVM_LIBRARY_OUTPUT_INTDIR}/.. 
SUBDIR include)
 set(out_files)
 set(generated_files)
 
@@ -456,7 +457,7 @@ add_header_target("openmp-resource-headers" 
${openmp_wrapper_files})
 add_header_target("windows-resource-headers" ${windows_only_files})
 add_header_target("utility-resource-headers" ${utility_files})
 
-set(header_install_dir 
lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}/include)
+get_clang_resource_dir(header_install_dir SUBDIR include)
 
 #
 # Install rules for the catch-all clang-resource-headers target

diff  --git a/clang/lib/Tooling/CMakeLists.txt 
b/clang/lib/Tooling/CMakeLists.txt
index e4ce43762d6b6..aff39e4de13c0 100644
--- a/clang/lib/Tooling/CMakeLists.txt
+++ b/clang/lib/Tooling/CMakeLists.txt
@@ -53,6 +53,8 @@ else()
 list(APPEND implicitDirs -I ${implicitDir})
   endforeach()
 
+  include(GetClangResourceDir)
+  get_clang_resource_dir(resource_dir PREFIX ${LLVM_BINARY_DIR})
   add_custom_command(
   COMMENT Generate ASTNodeAPI.json
   OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ASTNodeAPI.json
@@ -61,7 +63,7 @@ else()
   $
 # Skip this in debug mode because parsing AST.h is too slow
 --skip-processing=${skip_expensive_processing}
--I ${LLVM_BINARY_DIR}/lib/clang/${CLANG_VERSION_MAJOR}/include
+-I ${resource_dir}/include
 -I ${CLANG_SOURCE_DIR}/include
 -I ${LLVM_BINARY_DIR}/tools/clang/include
 -I ${LLVM_BINARY_DIR}/include

diff  --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt
index 94b5d783ce361..2dd305428c9ac 100644
--- a/clang/runtime/CMakeLists.txt
+++ b/clang/runtime/CMakeLists.txt
@@ -66,6 +66,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS 
${COMPILER_RT_SRC_ROOT}/)
 list(APPEND compiler_rt_configure_deps LLVMTestingSupport)
   endif()
 
+  include(GetClangResourceDir)
+  get_clang_resource_dir(output_resource_dir PREFIX ${LLVM_BINARY_DIR})
+  get_clang_resource_dir(install_resource_dir)
   ExternalProject_Add(compiler-rt
 DEPENDS llvm-config clang ${compiler_rt_configure_deps}
 PREFIX ${COMPILER_RT_PREFIX}
@@ -82,9 +85,9 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS 
${COMPILER_RT_SRC_ROOT}/)
-DCMAKE_CXX_COMPILER_LAUNCHER=${CMAKE_CXX_COMPILER_LAUNCHER}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config
-DLLVM_LIT_ARGS=${LLVM_LIT_ARGS}
-   
-DCOMPILER_RT_OUTPUT_DIR=${LLVM_LIBRARY_OUTPUT_INTDIR}/clang/${CLANG_VERSION_MAJOR}
+   -DCOMPILER_RT_OUTPUT_DIR=${output_resource_dir}
-DCOMPILER_RT_EXEC_OUTPUT_DIR=${LLVM_RUNTIME_OUTPUT_INTDIR}
-   
-DCOMPILER_RT_INSTALL_PATH:PATH=lib${LLVM_LIBDIR_SUFFIX}/clang/${CLANG_VERSION_MAJOR}
+   -DCOMPILER_RT_INSTALL_PATH:PATH=${install_resource_dir}
-DCOMPILER_RT_INCLUDE_TESTS=${LLVM_INCLUDE_TESTS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLLVM_LIBDIR_SUFFIX=${LLVM_LIBDIR_SUFFIX}

diff  --git a/cmake/Modules/GetClangResourceDir.cmake 
b/cmake/Modules/GetClangResourceDir.cmake
new file mode 100644
index 0..fb56e611a0e88
--- /dev/null
+++ b/cmake/Modules/GetClangResourceDir.cmake
@@ -0,0 +1,27 @@
+# get clang resource directory
+#
+# usage:
+#  get_clang_resource_dir(out_var [PREFIX prefix] [SUBDIR subdirectory])
+#
+# user can use `PREFIX` to prepend some path to it or use `SUBDIR` to
+# get subdirectory under clang resource dir
+
+function(get_clang_resource_dir out_var)
+  cmake_parse_arguments(ARG "" "PREFIX

[PATCH] D152061: [clang] fix TranslateXarchArgs to support -Xarch_device -O* Origin code: when passed -Xarch_device -O1, TranslateXarchArgs will parse -O1 as a CLFlag, which has flags NoXarchOption ,

2023-06-03 Thread Chenguang Qiu via Phabricator via cfe-commits
chenguang created this revision.
Herald added a project: All.
chenguang requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152061

Files:
  clang/lib/Driver/ToolChain.cpp
  clang/test/Driver/hip-options.hip


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -33,6 +33,11 @@
 // DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" 
{{.*}} "-fcf-protection=branch" {{.*}}"-mllvm" "--inline-threshold=100"
 // DEV-NOT: clang{{.*}} {{.*}} "-debug-info-kind={{.*}}"
 
+// RUN: %clang -### -Xarch_device -O1 --cuda-gpu-arch=gfx900 -v \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=DEV %s
+// DEV: "-cc1" {{.*}} "-O1" {{.*}} 
+
+
 // RUN: %clang -### -Xarch_host -g -nogpulib --cuda-gpu-arch=gfx900 \
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=HOST %s
 // HOST-NOT: "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1327,28 +1327,18 @@
 
   unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(ValuePos));
   unsigned Prev = Index;
-  std::unique_ptr XarchArg(Opts.ParseOneArg(Args, Index));
+  std::unique_ptr XarchArg(
+  Opts.ParseOneArg(Args, Index, 0, options::NoXarchOption));
 
   // If the argument parsing failed or more than one argument was
   // consumed, the -Xarch_ argument's parameter tried to consume
   // extra arguments. Emit an error and ignore.
-  //
-  // We also want to disallow any options which would alter the
-  // driver behavior; that isn't going to work in our model. We
-  // use options::NoXarchOption to control this.
   if (!XarchArg || Index > Prev + 1) {
 getDriver().Diag(diag::err_drv_invalid_Xarch_argument_with_args)
 << A->getAsString(Args);
 return;
-  } else if (XarchArg->getOption().hasFlag(options::NoXarchOption)) {
-auto &Diags = getDriver().getDiags();
-unsigned DiagID =
-Diags.getCustomDiagID(DiagnosticsEngine::Error,
-  "invalid Xarch argument: '%0', not all driver "
-  "options can be forwared via Xarch argument");
-Diags.Report(DiagID) << A->getAsString(Args);
-return;
   }
+
   XarchArg->setBaseArg(A);
   A = XarchArg.release();
   if (!AllocatedArgs)


Index: clang/test/Driver/hip-options.hip
===
--- clang/test/Driver/hip-options.hip
+++ clang/test/Driver/hip-options.hip
@@ -33,6 +33,11 @@
 // DEV: "-cc1"{{.*}} "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}" {{.*}} "-fcf-protection=branch" {{.*}}"-mllvm" "--inline-threshold=100"
 // DEV-NOT: clang{{.*}} {{.*}} "-debug-info-kind={{.*}}"
 
+// RUN: %clang -### -Xarch_device -O1 --cuda-gpu-arch=gfx900 -v \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=DEV %s
+// DEV: "-cc1" {{.*}} "-O1" {{.*}} 
+
+
 // RUN: %clang -### -Xarch_host -g -nogpulib --cuda-gpu-arch=gfx900 \
 // RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck -check-prefix=HOST %s
 // HOST-NOT: "-fcuda-is-device" {{.*}} "-debug-info-kind={{.*}}"
Index: clang/lib/Driver/ToolChain.cpp
===
--- clang/lib/Driver/ToolChain.cpp
+++ clang/lib/Driver/ToolChain.cpp
@@ -1327,28 +1327,18 @@
 
   unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(ValuePos));
   unsigned Prev = Index;
-  std::unique_ptr XarchArg(Opts.ParseOneArg(Args, Index));
+  std::unique_ptr XarchArg(
+  Opts.ParseOneArg(Args, Index, 0, options::NoXarchOption));
 
   // If the argument parsing failed or more than one argument was
   // consumed, the -Xarch_ argument's parameter tried to consume
   // extra arguments. Emit an error and ignore.
-  //
-  // We also want to disallow any options which would alter the
-  // driver behavior; that isn't going to work in our model. We
-  // use options::NoXarchOption to control this.
   if (!XarchArg || Index > Prev + 1) {
 getDriver().Diag(diag::err_drv_invalid_Xarch_argument_with_args)
 << A->getAsString(Args);
 return;
-  } else if (XarchArg->getOption().hasFlag(options::NoXarchOption)) {
-auto &Diags = getDriver().getDiags();
-unsigned DiagID =
-Diags.getCustomDiagID(DiagnosticsEngine::Error,
-  "invalid Xarch argument: '%0', not all driver "
-  "options can be forwared via Xarch argument");
-Diags.Report(DiagID) << A->getAsString(Args);
-return;
   }
+
   XarchArg->setBaseArg(A);
   A = XarchArg.release();
   if (!AllocatedArgs)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/c

[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-06-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:19217
+
+  // Verify comments and empty lines break the alignment
+  verifyFormat("switch (level) {\n"





Comment at: clang/unittests/Format/FormatTest.cpp:19218
+  // Verify comments and empty lines break the alignment
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"

If both strings are the same, you only need to supply it once.

Or are they different and I can't see it?



Comment at: clang/unittests/Format/FormatTest.cpp:19257
+
+  Alignment.ColumnLimit = 80;
+  Alignment.SpaceBeforeCaseColon = true;

For what is this?


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

https://reviews.llvm.org/D151761

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


[PATCH] D152051: libclang-cpp: Add external visibility attribute to all classes

2023-06-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/include/clang/Format/Format.h:4532
 /// Returns ``true`` if the Style has been set.
-bool getPredefinedStyle(StringRef Name, FormatStyle::LanguageKind Language,
+LLVM_EXTERNAL_VISIBILITY bool getPredefinedStyle(StringRef Name, 
FormatStyle::LanguageKind Language,
 FormatStyle *Style);

This doesn't look formatted.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152051

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


[clang] 684f3c9 - [Clang] Fix status of P0960

2023-06-03 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2023-06-03T17:03:42+02:00
New Revision: 684f3c968d6bbf124014128b9f5e4f03a50f28c5

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

LOG: [Clang] Fix status of P0960

P0960R3 and P1975R0 were marked not implemented because
of #61145,

This issue has been fixed and backported to LLVM 16,
the status page should reflect that.

Reviewed By: #clang-language-wg, ayzhao, erichkeane

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

Added: 


Modified: 
clang/www/cxx_status.html

Removed: 




diff  --git a/clang/www/cxx_status.html b/clang/www/cxx_status.html
index 91706be09f158..26b4e55cf180e 100755
--- a/clang/www/cxx_status.html
+++ b/clang/www/cxx_status.html
@@ -686,7 +686,7 @@ C++20 implementation status
 
   Parenthesized initialization of aggregates
   https://wg21.link/p0960r3";>P0960R3
-  No
+  Clang 16
 

 https://wg21.link/p1975r0";>P1975R0



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


[PATCH] D150122: [Clang] Fix status of P0960

2023-06-03 Thread Corentin Jabot via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG684f3c968d6b: [Clang] Fix status of P0960 (authored by 
cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150122

Files:
  clang/www/cxx_status.html


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -686,7 +686,7 @@
 
   Parenthesized initialization of aggregates
   https://wg21.link/p0960r3";>P0960R3
-  No
+  Clang 16
 

 https://wg21.link/p1975r0";>P1975R0


Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -686,7 +686,7 @@
 
   Parenthesized initialization of aggregates
   https://wg21.link/p0960r3";>P0960R3
-  No
+  Clang 16
 

 https://wg21.link/p1975r0";>P1975R0
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147717: [C++20][NFC] Claim full support for consteval again

2023-06-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

I think we should make sure to land this for clang 17. The rate of consteval 
bugs is no greater than that of any other feature at this point.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147717

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


[PATCH] D134475: [Clang] Add support for [[msvc::constexpr]] C++11 attribute

2023-06-03 Thread Richard Dzenis via Phabricator via cfe-commits
RIscRIpt updated this revision to Diff 528112.
RIscRIpt added a comment.

Added diagnostics for [[msvc::constexpr]] virtual

Regarding [[msvc::constexpr]] constructors, unfortunatelly I cannot find a 
reasonable way to support it.

During development I found out about Clang's experimental Constant Interpreter 
(`-fexperimental-new-constant-interpreter`),
I suppose it would be much easier to implement complete support for 
`[[msvc::constexpr]]` there.
I am not aware about policy regarding constant evaulation/interpreter:
do you approve new constant evaluation features in the current (AST-based) 
approach without extending the experimental one?
Because I'd rather tacke with experimental Constant Interpreter in a follow-up 
(if I ever find time for this).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134475

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticASTKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/test/AST/msvc-attrs-invalid.cpp
  clang/test/AST/msvc-attrs.cpp
  clang/test/AST/msvc-constexpr-new.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test

Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -83,6 +83,7 @@
 // CHECK-NEXT: LoaderUninitialized (SubjectMatchRule_variable_is_global)
 // CHECK-NEXT: Lockable (SubjectMatchRule_record)
 // CHECK-NEXT: MIGServerRoutine (SubjectMatchRule_function, SubjectMatchRule_objc_method, SubjectMatchRule_block)
+// CHECK-NEXT: MSConstexpr (SubjectMatchRule_function)
 // CHECK-NEXT: MSStruct (SubjectMatchRule_record)
 // CHECK-NEXT: MaybeUndef (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: MicroMips (SubjectMatchRule_function)
Index: clang/test/AST/msvc-constexpr-new.cpp
===
--- /dev/null
+++ clang/test/AST/msvc-constexpr-new.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fms-extensions -std=c++20 -ast-dump %s | FileCheck %s
+
+// CHECK: used operator new
+// CHECK: MSConstexprAttr 0x{{[0-9a-f]+}} 
+[[nodiscard]] [[msvc::constexpr]] inline void* __cdecl operator new(decltype(sizeof(void*)), void* p) noexcept { return p; }
+
+// CHECK: used constexpr construct_at
+// CHECK: AttributedStmt 0x{{[0-9a-f]+}} 
+// CHECK-NEXT: MSConstexprAttr 0x{{[0-9a-f]+}} 
+// CHECK-NEXT: ReturnStmt 0x{{[0-9a-f]+}} 
+constexpr int* construct_at(int* p, int v) { [[msvc::constexpr]] return ::new (p) int(v); }
+
+constexpr bool check_construct_at() { int x; return *construct_at(&x, 42) == 42; }
+
+static_assert(check_construct_at());
Index: clang/test/AST/msvc-attrs.cpp
===
--- /dev/null
+++ clang/test/AST/msvc-attrs.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -fms-extensions -std=c++20 -ast-dump %s | FileCheck %s
+
+// [[msvc::constexpr]] tests
+
+// MSConstexprDocs (1)
+// CHECK: used f1 'bool ()'
+// CHECK: MSConstexprAttr 0x{{[0-9a-f]+}} 
+[[msvc::constexpr]] bool f1() { return true; }
+
+// MSConstexprDocs (2)
+// CHECK: used constexpr f2 'bool ()'
+// CHECK: AttributedStmt 0x{{[0-9a-f]+}} 
+// CHECK-NEXT: MSConstexprAttr 0x{{[0-9a-f]+}} 
+// CHECK-NEXT: ReturnStmt 0x{{[0-9a-f]+}} 
+constexpr bool f2() { [[msvc::constexpr]] return f1(); }
+
+static_assert(f2());
+
+constexpr bool f3() { [[msvc::constexpr]] return f1() || f1() && f1(); }
+static_assert(f3());
+
+[[msvc::constexpr]] int f4(int x) { [[msvc::constexpr]] return x > 1 ? 1 + f4(x / 2) : 0; }
+constexpr bool f5() { [[msvc::constexpr]] return f4(32) == 5; }
+static_assert(f5());
+
+[[msvc::constexpr]] int f6(int x)
+{
+switch (x)
+{
+case 42: return 1337;
+default:
+ if (x < 0) [[msvc::constexpr]] return f4(-x);
+ else return x;
+}
+}
+
+constexpr bool f7() { [[msvc::constexpr]] return f6(f6(42) - 1337 + f6(-32) - 5 + (f6(1) ? f6(0) : f6(2))) == f6(0); }
+static_assert(f7());
+
+constexpr bool f8() { return true; }
+[[msvc::constexpr]] bool f9() { return f8(); }
+constexpr bool f10() { [[msvc::constexpr]] return f9(); }
+static_assert(f10());
+
+struct S1 {
+[[msvc::constexpr]] virtual bool vm() { return true; }
+constexpr bool cm() { [[msvc::constexpr]] return vm(); }
+};
+static_assert(S1{}.cm());
+
+/*
+// TODO: Add support for [[msvc::constexpr]] constructor
+struct S2 {
+[[msvc::constexpr]] S2() {}
+[[msvc::constexpr]] bool value() { return true; }
+static constexpr bool check() { [[msvc::constexpr]] return S2{}.value(); }
+};
+static_as

[PATCH] D134334: [Clang] Fix crash in isCXXDeclarationSpecifier when attempting to annotate template name

2023-06-03 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin accepted this revision.
cor3ntin added a comment.

This makes sense to me, thanks!


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

https://reviews.llvm.org/D134334

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


[clang] 8dc7647 - [AST] Use DenseMapBase::lookup (NFC)

2023-06-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-06-03T09:37:36-07:00
New Revision: 8dc7647845a4357f6aee7ffe40839c97f2474d99

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

LOG: [AST] Use DenseMapBase::lookup (NFC)

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/AST/ASTImporter.cpp
clang/lib/AST/ExternalASTMerger.cpp
clang/lib/AST/Interp/Record.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index ef3242e81e65f..9af6fa67db1ef 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -499,10 +499,7 @@ const RawComment *ASTContext::getRawCommentForAnyRedecl(
   // Any redeclarations of D that we haven't checked for comments yet?
   // We can't use DenseMap::iterator directly since it'd get invalid.
   auto LastCheckedRedecl = [this, CanonicalD]() -> const Decl * {
-auto LookupRes = CommentlessRedeclChains.find(CanonicalD);
-if (LookupRes != CommentlessRedeclChains.end())
-  return LookupRes->second;
-return nullptr;
+return CommentlessRedeclChains.lookup(CanonicalD);
   }();
 
   for (const auto Redecl : D->redecls()) {
@@ -1523,11 +1520,7 @@ ASTContext::setTemplateOrSpecializationInfo(VarDecl 
*Inst,
 
 NamedDecl *
 ASTContext::getInstantiatedFromUsingDecl(NamedDecl *UUD) {
-  auto Pos = InstantiatedFromUsingDecl.find(UUD);
-  if (Pos == InstantiatedFromUsingDecl.end())
-return nullptr;
-
-  return Pos->second;
+  return InstantiatedFromUsingDecl.lookup(UUD);
 }
 
 void
@@ -1546,11 +1539,7 @@ ASTContext::setInstantiatedFromUsingDecl(NamedDecl 
*Inst, NamedDecl *Pattern) {
 
 UsingEnumDecl *
 ASTContext::getInstantiatedFromUsingEnumDecl(UsingEnumDecl *UUD) {
-  auto Pos = InstantiatedFromUsingEnumDecl.find(UUD);
-  if (Pos == InstantiatedFromUsingEnumDecl.end())
-return nullptr;
-
-  return Pos->second;
+  return InstantiatedFromUsingEnumDecl.lookup(UUD);
 }
 
 void ASTContext::setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst,
@@ -1561,12 +1550,7 @@ void 
ASTContext::setInstantiatedFromUsingEnumDecl(UsingEnumDecl *Inst,
 
 UsingShadowDecl *
 ASTContext::getInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst) {
-  llvm::DenseMap::const_iterator Pos
-= InstantiatedFromUsingShadowDecl.find(Inst);
-  if (Pos == InstantiatedFromUsingShadowDecl.end())
-return nullptr;
-
-  return Pos->second;
+  return InstantiatedFromUsingShadowDecl.lookup(Inst);
 }
 
 void
@@ -1577,12 +1561,7 @@ 
ASTContext::setInstantiatedFromUsingShadowDecl(UsingShadowDecl *Inst,
 }
 
 FieldDecl *ASTContext::getInstantiatedFromUnnamedFieldDecl(FieldDecl *Field) {
-  llvm::DenseMap::iterator Pos
-= InstantiatedFromUnnamedFieldDecl.find(Field);
-  if (Pos == InstantiatedFromUnnamedFieldDecl.end())
-return nullptr;
-
-  return Pos->second;
+  return InstantiatedFromUnnamedFieldDecl.lookup(Field);
 }
 
 void ASTContext::setInstantiatedFromUnnamedFieldDecl(FieldDecl *Inst,

diff  --git a/clang/lib/AST/ASTImporter.cpp b/clang/lib/AST/ASTImporter.cpp
index 6e2566b638609..6c04bc80270ae 100644
--- a/clang/lib/AST/ASTImporter.cpp
+++ b/clang/lib/AST/ASTImporter.cpp
@@ -8994,11 +8994,7 @@ Expected ASTImporter::Import(const Attr 
*FromAttr) {
 }
 
 Decl *ASTImporter::GetAlreadyImportedOrNull(const Decl *FromD) const {
-  auto Pos = ImportedDecls.find(FromD);
-  if (Pos != ImportedDecls.end())
-return Pos->second;
-  else
-return nullptr;
+  return ImportedDecls.lookup(FromD);
 }
 
 TranslationUnitDecl *ASTImporter::GetFromTU(Decl *ToD) {

diff  --git a/clang/lib/AST/ExternalASTMerger.cpp 
b/clang/lib/AST/ExternalASTMerger.cpp
index a2ef270d7a9c5..8bad3b36244e1 100644
--- a/clang/lib/AST/ExternalASTMerger.cpp
+++ b/clang/lib/AST/ExternalASTMerger.cpp
@@ -187,10 +187,7 @@ class LazyASTImporter : public ASTImporter {
   /// Implements the ASTImporter interface for tracking back a declaration
   /// to its original declaration it came from.
   Decl *GetOriginalDecl(Decl *To) override {
-auto It = ToOrigin.find(To);
-if (It != ToOrigin.end())
-  return It->second;
-return nullptr;
+return ToOrigin.lookup(To);
   }
 
   /// Whenever a DeclContext is imported, ensure that ExternalASTSource's 
origin
@@ -541,4 +538,3 @@ void ExternalASTMerger::FindExternalLexicalDecls(
 return false;
   });
 }
-

diff  --git a/clang/lib/AST/Interp/Record.cpp b/clang/lib/AST/Interp/Record.cpp
index c8cbdb314f512..909416e6e1a1a 100644
--- a/clang/lib/AST/Interp/Record.cpp
+++ b/clang/lib/AST/Interp/Record.cpp
@@ -44,9 +44,7 @@ const Record::Base *Record::getBase(QualType T) const {
 return nullptr;
 
   const RecordDecl *RD = T->getAs()->getDecl();
-  if (auto It = BaseMap.find(RD); It != BaseMap.end())
-return It->second;
-  return nullptr;
+  return BaseMap.lookup(RD);
 }
 
 const Record:

[clang] 8e6e659 - [Serialization] Remove unused function getKnownModules

2023-06-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-06-03T09:37:37-07:00
New Revision: 8e6e659cc800a13876d3239f9f29ea6615d86f40

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

LOG: [Serialization] Remove unused function getKnownModules

The last use was removed by:

  commit 603cd869f7cdb0da7a545e86a1786f3175f72475
  Author: Douglas Gregor 
  Date:   Fri Mar 22 18:50:14 2013 +

Added: 


Modified: 
clang/include/clang/Serialization/GlobalModuleIndex.h
clang/lib/Serialization/GlobalModuleIndex.cpp

Removed: 




diff  --git a/clang/include/clang/Serialization/GlobalModuleIndex.h 
b/clang/include/clang/Serialization/GlobalModuleIndex.h
index 9d6b52a97f52e..d82e0dd294b90 100644
--- a/clang/include/clang/Serialization/GlobalModuleIndex.h
+++ b/clang/include/clang/Serialization/GlobalModuleIndex.h
@@ -136,12 +136,6 @@ class GlobalModuleIndex {
   /// The caller accepts ownership of the returned object.
   IdentifierIterator *createIdentifierIterator() const;
 
-  /// Retrieve the set of modules that have up-to-date indexes.
-  ///
-  /// \param ModuleFiles Will be populated with the set of module files that
-  /// have been indexed.
-  void getKnownModules(llvm::SmallVectorImpl &ModuleFiles);
-
   /// Retrieve the set of module files on which the given module file
   /// directly depends.
   void getModuleDependencies(ModuleFile *File,

diff  --git a/clang/lib/Serialization/GlobalModuleIndex.cpp 
b/clang/lib/Serialization/GlobalModuleIndex.cpp
index 307a1477213c8..1b8c1303a2886 100644
--- a/clang/lib/Serialization/GlobalModuleIndex.cpp
+++ b/clang/lib/Serialization/GlobalModuleIndex.cpp
@@ -281,15 +281,6 @@ GlobalModuleIndex::readIndex(StringRef Path) {
 llvm::Error::success());
 }
 
-void
-GlobalModuleIndex::getKnownModules(SmallVectorImpl &ModuleFiles) 
{
-  ModuleFiles.clear();
-  for (unsigned I = 0, N = Modules.size(); I != N; ++I) {
-if (ModuleFile *MF = Modules[I].File)
-  ModuleFiles.push_back(MF);
-  }
-}
-
 void GlobalModuleIndex::getModuleDependencies(
ModuleFile *File,
SmallVectorImpl &Dependencies) {



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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-06-03 Thread Galen Elias via Phabricator via cfe-commits
galenelias updated this revision to Diff 528118.
galenelias added a comment.

Fixup up review comments.


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

https://reviews.llvm.org/D151761

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/WhitespaceManager.cpp
  clang/lib/Format/WhitespaceManager.h
  clang/unittests/Format/ConfigParseTest.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -19192,6 +19192,147 @@
BracedAlign);
 }
 
+TEST_F(FormatTest, AlignConsecutiveShortCaseStatements) {
+  FormatStyle Alignment = getLLVMStyle();
+  Alignment.AllowShortCaseLabelsOnASingleLine = true;
+  Alignment.AlignConsecutiveShortCaseStatements.Enabled = true;
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "default:   return \"default\";\n"
+   "}",
+   Alignment);
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info: return \"info\";\n"
+   "case log::warning:\n"
+   "  return \"warning\";\n"
+   "}",
+   Alignment);
+
+  // Verify comments and empty lines break the alignment.
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "// comment\n"
+   "case log::critical: return \"critical\";\n"
+   "default:return \"default\";\n"
+   "\n"
+   "case log::severe: return \"severe\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "// comment\n"
+   "case log::critical: return \"critical\";\n"
+   "default:return \"default\";\n"
+   "\n"
+   "case log::severe: return \"severe\";\n"
+   "}",
+   Alignment);
+
+  // Verify adjacent non-short case statements don't change the alignment, and
+  // properly break the set of consecutive statements.
+  verifyFormat("switch (level) {\n"
+   "case log::critical:\n"
+   "  // comment\n"
+   "  return \"critical\";\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "default:\n"
+   "  // comment\n"
+   "  return \"\";\n"
+   "case log::error:  return \"error\";\n"
+   "case log::severe: return \"severe\";\n"
+   "case log::extra_critical:\n"
+   "  // comment\n"
+   "  return \"extra critical\";\n"
+   "}",
+   Alignment);
+
+  Alignment.SpaceBeforeCaseColon = true;
+  verifyFormat("switch (level) {\n"
+   "case log::info :return \"info\";\n"
+   "case log::warning : return \"warning\";\n"
+   "default :   return \"default\";\n"
+   "}",
+   Alignment);
+  Alignment.SpaceBeforeCaseColon = false;
+
+  // Make sure we don't incorrectly align correctly across nested switch cases.
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "case log::other:\n"
+   "  switch (sublevel) {\n"
+   "  case log::info:return \"info\";\n"
+   "  case log::warning: return \"warning\";\n"
+   "  }\n"
+   "  break;\n"
+   "case log::error: return \"error\";\n"
+   "default: return \"default\";\n"
+   "}",
+   "switch (level) {\n"
+   "case log::info:return \"info\";\n"
+   "case log::warning: return \"warning\";\n"
+   "case log::other: switch (sublevel) {\n"
+   "  case log::info:return \"info\";\n"
+   "  case log::warning: return \"warning\";\n"
+   "}\n"
+   "break;\n"
+   "case log::error: return \"error\";\n"
+   "default: return \"default\";\n"
+   "}",
+   Alignment);
+
+  Alignment.AlignConsecutiveShortCaseStatements.AcrossEmptyLines = true;
+
+  verifyFormat("switch (level) {\n"
+   "case log::info:   

[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-06-03 Thread Galen Elias via Phabricator via cfe-commits
galenelias marked 3 inline comments as done.
galenelias added inline comments.



Comment at: clang/unittests/Format/FormatTest.cpp:19218
+  // Verify comments and empty lines break the alignment
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"

HazardyKnusperkeks wrote:
> If both strings are the same, you only need to supply it once.
> 
> Or are they different and I can't see it?
They are the same, but I can't use the single string version, as that one calls 
test::messUp on the string which will strip blank lines, which then invalidates 
the test case.  It seems pretty much all tests which are trying to validate 
behavior around empty spaces has to use the two string version.



Comment at: clang/unittests/Format/FormatTest.cpp:19257
+
+  Alignment.ColumnLimit = 80;
+  Alignment.SpaceBeforeCaseColon = true;

HazardyKnusperkeks wrote:
> For what is this?
Oops, I was trying to set ColumnLimit = 0 before to stop it from merging 
multi-line case statements, but it wasn't working as expected, so I ended up 
inserting comments instead, and forgot to remove resetting this.  Good catch!



Comment at: clang/unittests/Format/FormatTest.cpp:19206
+
+  // Make sure we don't incorrectly align correctly across nested switch cases
+  EXPECT_EQ("switch (level) {\n"

HazardyKnusperkeks wrote:
> 
I'll get used to adding full stops eventually... sorry for not catching this.


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

https://reviews.llvm.org/D151761

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


[clang] 1cb3827 - [Clang][RISCV] Avoid generating MaskedPrototype if the intrinsic does not have a masked version. NFC

2023-06-03 Thread via cfe-commits

Author: eopXD
Date: 2023-06-03T10:20:04-07:00
New Revision: 1cb382718a35f55f51cf3a8e3fa7d627bfa63e85

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

LOG: [Clang][RISCV] Avoid generating MaskedPrototype if the intrinsic does not 
have a masked version. NFC

The function should not be called if an intrinsic does not have a masked 
version.

Signed-off by: eop Chen 

Added: 


Modified: 
clang/utils/TableGen/RISCVVEmitter.cpp

Removed: 




diff  --git a/clang/utils/TableGen/RISCVVEmitter.cpp 
b/clang/utils/TableGen/RISCVVEmitter.cpp
index 35b2203cecf34..a20d7f5eba385 100644
--- a/clang/utils/TableGen/RISCVVEmitter.cpp
+++ b/clang/utils/TableGen/RISCVVEmitter.cpp
@@ -533,9 +533,11 @@ void RVVEmitter::createRVVIntrinsics(
 BasicPrototype, /*IsMasked=*/false,
 /*HasMaskedOffOperand=*/false, HasVL, NF, UnMaskedPolicyScheme,
 DefaultPolicy, IsTuple);
-auto MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
-BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
-MaskedPolicyScheme, DefaultPolicy, IsTuple);
+llvm::SmallVector MaskedPrototype;
+if (HasMasked)
+  MaskedPrototype = RVVIntrinsic::computeBuiltinTypes(
+  BasicPrototype, /*IsMasked=*/true, HasMaskedOffOperand, HasVL, NF,
+  MaskedPolicyScheme, DefaultPolicy, IsTuple);
 
 // Create Intrinsics for each type and LMUL.
 for (char I : TypeRange) {



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


[PATCH] D152069: [1/11][Clang][Type] Expand BuiltinTypeBits from 8 to 16 bits

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, kito-cheng, rogfer01, frasercrmck.
Herald added a project: All.
eopXD requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The next patch introduces a number of new RVV tuple types and lets the
total of builtin types exceed the current limit (256). This patch
attempts to increase the bits used so we can continue to expand new
builtin types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152069

Files:
  clang/include/clang/AST/Type.h


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1649,7 +1649,7 @@
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
-unsigned Kind : 8;
+unsigned Kind : 16;
   };
 
   /// FunctionTypeBitfields store various bits belonging to FunctionProtoType.


Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -1649,7 +1649,7 @@
 unsigned : NumTypeBits;
 
 /// The kind (BuiltinType::Kind) of builtin type this is.
-unsigned Kind : 8;
+unsigned Kind : 16;
   };
 
   /// FunctionTypeBitfields store various bits belonging to FunctionProtoType.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152070: [2/N][Clang][RISCV] Expand all variants of RVV intrinsic tuple types

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, kito-cheng, rogfer01, frasercrmck.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, luismarques, 
apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, 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.

This patch also removes redundant checks related to tuples and dedicate
the check to happen in `RVVType::verifyType`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152070

Files:
  clang/include/clang/Basic/RISCVVTypes.def
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -156,6 +156,24 @@
   }
 }
 
+static VectorTypeModifier getTupleVTM(unsigned NF) {
+  switch(NF) {
+case 2: return VectorTypeModifier::Tuple2;
+case 3: return VectorTypeModifier::Tuple3;
+case 4:
+  return VectorTypeModifier::Tuple4;
+case 5:
+  return VectorTypeModifier::Tuple5;
+case 6:
+  return VectorTypeModifier::Tuple6;
+case 7:
+  return VectorTypeModifier::Tuple7;
+case 8:
+  return VectorTypeModifier::Tuple8;
+  }
+  llvm_unreachable("2 <= NF <= 8");
+}
+
 void emitCodeGenSwitchBody(const RVVIntrinsic *RVVI, raw_ostream &OS) {
   if (!RVVI->getIRName().empty())
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
@@ -364,15 +382,19 @@
 TypeModifier::UnsignedInteger));
 printType(*UT);
   }
-  // FIXME: Expand more type declaration
-  if (I == 'i' && Log2LMUL == 0) { // vint32m1x2_t
+  for (int NF = 2; NF <= 8; ++NF) {
 auto TupleT = TypeCache.computeType(
 BT, Log2LMUL,
-PrototypeDescriptor(BaseTypeModifier::Vector,
-VectorTypeModifier::Tuple2,
+PrototypeDescriptor(BaseTypeModifier::Vector, getTupleVTM(NF),
 TypeModifier::SignedInteger));
+auto TupleUT = TypeCache.computeType(
+BT, Log2LMUL,
+PrototypeDescriptor(BaseTypeModifier::Vector, getTupleVTM(NF),
+TypeModifier::UnsignedInteger));
 if (TupleT)
   printType(*TupleT);
+if (TupleUT)
+  printType(*TupleUT);
   }
 }
   }
@@ -383,6 +405,14 @@
   auto T = TypeCache.computeType(BT, Log2LMUL, PrototypeDescriptor::Vector);
   if (T)
 printType(*T);
+  for (int NF = 2; NF <= 8; ++NF) {
+auto TupleT = TypeCache.computeType(
+BT, Log2LMUL,
+PrototypeDescriptor(BaseTypeModifier::Vector, getTupleVTM(NF),
+TypeModifier::Float));
+if (TupleT)
+  printType(*TupleT);
+  }
 }
   }
 
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
@@ -72,7 +72,232 @@
 // CHECK-NEXT:[[F64M2:%.*]] = alloca , align 8
 // CHECK-NEXT:[[F64M4:%.*]] = alloca , align 8
 // CHECK-NEXT:[[F64M8:%.*]] = alloca , align 8
+// CHECK-NEXT:[[I8MF8X2:%.*]] = alloca { ,  }, align 1
+// CHECK-NEXT:[[I8MF8X3:%.*]] = alloca { , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X4:%.*]] = alloca { , , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X5:%.*]] = alloca { , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X6:%.*]] = alloca { , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X7:%.*]] = alloca { , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X8:%.*]] = alloca { , , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X2:%.*]] = alloca { ,  }, align 1
+// CHECK-NEXT:[[I8MF4X3:%.*]] = alloca { , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X4:%.*]] = alloca { , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X5:%.*]] = alloca { , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X6:%.*]] = alloca { , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X7:%.*]] = alloca { , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X8:%.*]] = alloca { , , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X2:%.*]] = alloca { ,  }, align 1
+// CHECK-NEXT:[[I8MF2X3:%.*]] = alloca { , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X4:%.*]] = alloca { , , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X5:%.*]] = alloca { , , , ,  }, align 1
+// CHECK

[PATCH] D152072: [4/N][Clang][RISCV] Expand all variants for unit stride segment store

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, kito-cheng, rogfer01, frasercrmck.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, luismarques, 
apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, 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.

This patch expands all variants for unit stride segment store. The
store intrinsics does not have any policy variants. This patch also
fixes the trailing suffix in the intrinsics' function name that
representing the return type, adding `x{NF}`.

For the same reason mentioned in [2/N], only full test case for
vsseg2e32 is added.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152072

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

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e32_tuple.c
@@ -0,0 +1,345 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_f32mf2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv1f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_f32mf2x2(float *base, vfloat32mf2x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_tuple(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_f32m1x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv2f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_f32m1x2(float *base, vfloat32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_tuple(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_f32m2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv4f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_f32m2x2(float *base, vfloat32m2x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_tuple(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_f32m4x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]

[PATCH] D152075: [7/N][Clang][RISCV] Expand all variants for strided segment store

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, kito-cheng, rogfer01, frasercrmck.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, luismarques, 
apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, 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.

This patch expands all variants for strided segment store. The store
intrinsics does not have any policy variants. This patch also fixes the
trailing suffix in the intrinsics' function name that representing the
return type, adding `x{NF}`.

For the same reason mentioned in [2/N], only full test case for
vssseg2e32 is added for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152075

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

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c
@@ -0,0 +1,345 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32mf2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv1f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32mf2x2(float *base, ptrdiff_t bstride, vfloat32mf2x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m1x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv2f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32m1x2(float *base, ptrdiff_t bstride, vfloat32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv4f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32m2x2(float *base, ptrdiff_t bstride, vfloat32m2x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m4x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-

[PATCH] D152076: [8/N][Clang][RISCV] Expand all variants for indexed strided segment load

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, kito-cheng, rogfer01, frasercrmck.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, luismarques, 
apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, arphaman, 
the_o, brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, 
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.

This patch expands all variants of indexed strided segment load,
including the policy variants. This patch also fixes the trailing suffix
in the intrinsics' function name that representing the return type,
adding `x{NF}`.

For the same reason mentioned in [2/N], only full test case for
vluxseg2ei32, vloxseg2ei32 is added for now.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152076

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

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


[PATCH] D152078: [10/N][Clang][RISCV] Expand all variants for vget on tuple types

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, kito-cheng, rogfer01, frasercrmck.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, luismarques, 
apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, 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.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152078

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

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


[PATCH] D152079: [11/N][Clang][RISCV] Expand all variants for vset on tuple types

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD created this revision.
eopXD added reviewers: craig.topper, kito-cheng, rogfer01, frasercrmck.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, luismarques, 
apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, 
brucehoult, MartinMosbeck, edward-jones, zzheng, jrtc27, shiva0217, 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.

This patch also fixes the suffix for non-overloaded variants for
vset on tuple types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152079

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

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


[PATCH] D152070: [2/11][Clang][RISCV] Expand all variants of RVV intrinsic tuple types

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 528135.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152070

Files:
  clang/include/clang/Basic/RISCVVTypes.def
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp

Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -156,6 +156,24 @@
   }
 }
 
+static VectorTypeModifier getTupleVTM(unsigned NF) {
+  switch(NF) {
+case 2: return VectorTypeModifier::Tuple2;
+case 3: return VectorTypeModifier::Tuple3;
+case 4:
+  return VectorTypeModifier::Tuple4;
+case 5:
+  return VectorTypeModifier::Tuple5;
+case 6:
+  return VectorTypeModifier::Tuple6;
+case 7:
+  return VectorTypeModifier::Tuple7;
+case 8:
+  return VectorTypeModifier::Tuple8;
+  }
+  llvm_unreachable("2 <= NF <= 8");
+}
+
 void emitCodeGenSwitchBody(const RVVIntrinsic *RVVI, raw_ostream &OS) {
   if (!RVVI->getIRName().empty())
 OS << "  ID = Intrinsic::riscv_" + RVVI->getIRName() + ";\n";
@@ -364,15 +382,19 @@
 TypeModifier::UnsignedInteger));
 printType(*UT);
   }
-  // FIXME: Expand more type declaration
-  if (I == 'i' && Log2LMUL == 0) { // vint32m1x2_t
+  for (int NF = 2; NF <= 8; ++NF) {
 auto TupleT = TypeCache.computeType(
 BT, Log2LMUL,
-PrototypeDescriptor(BaseTypeModifier::Vector,
-VectorTypeModifier::Tuple2,
+PrototypeDescriptor(BaseTypeModifier::Vector, getTupleVTM(NF),
 TypeModifier::SignedInteger));
+auto TupleUT = TypeCache.computeType(
+BT, Log2LMUL,
+PrototypeDescriptor(BaseTypeModifier::Vector, getTupleVTM(NF),
+TypeModifier::UnsignedInteger));
 if (TupleT)
   printType(*TupleT);
+if (TupleUT)
+  printType(*TupleUT);
   }
 }
   }
@@ -383,6 +405,14 @@
   auto T = TypeCache.computeType(BT, Log2LMUL, PrototypeDescriptor::Vector);
   if (T)
 printType(*T);
+  for (int NF = 2; NF <= 8; ++NF) {
+auto TupleT = TypeCache.computeType(
+BT, Log2LMUL,
+PrototypeDescriptor(BaseTypeModifier::Vector, getTupleVTM(NF),
+TypeModifier::Float));
+if (TupleT)
+  printType(*TupleT);
+  }
 }
   }
 
Index: clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
===
--- clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-handcrafted/rvv-intrinsic-datatypes.cpp
@@ -72,7 +72,232 @@
 // CHECK-NEXT:[[F64M2:%.*]] = alloca , align 8
 // CHECK-NEXT:[[F64M4:%.*]] = alloca , align 8
 // CHECK-NEXT:[[F64M8:%.*]] = alloca , align 8
+// CHECK-NEXT:[[I8MF8X2:%.*]] = alloca { ,  }, align 1
+// CHECK-NEXT:[[I8MF8X3:%.*]] = alloca { , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X4:%.*]] = alloca { , , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X5:%.*]] = alloca { , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X6:%.*]] = alloca { , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X7:%.*]] = alloca { , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF8X8:%.*]] = alloca { , , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X2:%.*]] = alloca { ,  }, align 1
+// CHECK-NEXT:[[I8MF4X3:%.*]] = alloca { , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X4:%.*]] = alloca { , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X5:%.*]] = alloca { , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X6:%.*]] = alloca { , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X7:%.*]] = alloca { , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF4X8:%.*]] = alloca { , , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X2:%.*]] = alloca { ,  }, align 1
+// CHECK-NEXT:[[I8MF2X3:%.*]] = alloca { , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X4:%.*]] = alloca { , , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X5:%.*]] = alloca { , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X6:%.*]] = alloca { , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X7:%.*]] = alloca { , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8MF2X8:%.*]] = alloca { , , , , , , ,  }, align 1
+// CHECK-NEXT:[[I8M1X2:%.*]] = alloca { ,  }, align 1
+// CHECK-NEXT:[[I8M1X3:%.*]] = alloca { , ,  }, align 1
+// CHECK-NEXT:[[I8M1X4:%.*]] = alloca { , , ,  }, align 1
+// CHECK-NEXT:[[I8M1X5:%.*]] = alloca { , , , ,  }, align 1
+// CHECK-NEXT:[[I8M1X6:%.*]] = alloca { , , , , ,  }, align 1
+// CHECK

[PATCH] D152072: [4/11][Clang][RISCV] Expand all variants for unit stride segment store

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 528139.
eopXD added a comment.

Bump BI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152072

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

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vsseg2e32_tuple.c
@@ -0,0 +1,345 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_f32mf2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv1f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_f32mf2x2(float *base, vfloat32mf2x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_tuple(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_f32m1x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv2f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_f32m1x2(float *base, vfloat32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_tuple(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_f32m2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv4f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_f32m2x2(float *base, vfloat32m2x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_tuple(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_f32m4x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vsseg2.nxv8f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vsseg2e32_v_f32m4x2(float *base, vfloat32m4x2_t v_tuple, size_t vl) {
+  return __riscv_vsseg2e32_tuple(base, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vsseg2e32_v_i32mf2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERC

[PATCH] D152075: [7/11][Clang][RISCV] Expand all variants for strided segment store

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 528142.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152075

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

Index: clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c
===
--- /dev/null
+++ clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/non-policy/overloaded/vssseg2e32_tuple.c
@@ -0,0 +1,345 @@
+// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py UTC_ARGS: --version 2
+// REQUIRES: riscv-registered-target
+// RUN: %clang_cc1 -triple riscv64 -target-feature +v -target-feature +zfh \
+// RUN:   -target-feature +experimental-zvfh -disable-O0-optnone  \
+// RUN:   -emit-llvm %s -o - | opt -S -passes=mem2reg | \
+// RUN:   FileCheck --check-prefix=CHECK-RV64 %s
+
+#include 
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32mf2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0:[0-9]+]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv1f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32mf2x2(float *base, ptrdiff_t bstride, vfloat32mf2x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m1x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv2f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32m1x2(float *base, ptrdiff_t bstride, vfloat32m1x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m2x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv4f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32m2x2(float *base, ptrdiff_t bstride, vfloat32m2x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_f32m4x2
+// CHECK-RV64-SAME: (ptr noundef [[BASE:%.*]], i64 noundef [[BSTRIDE:%.*]],  [[V_TUPLE_COERCE0:%.*]],  [[V_TUPLE_COERCE1:%.*]], i64 noundef [[VL:%.*]]) #[[ATTR0]] {
+// CHECK-RV64-NEXT:  entry:
+// CHECK-RV64-NEXT:[[TMP0:%.*]] = insertvalue { ,  } poison,  [[V_TUPLE_COERCE0]], 0
+// CHECK-RV64-NEXT:[[TMP1:%.*]] = insertvalue { ,  } [[TMP0]],  [[V_TUPLE_COERCE1]], 1
+// CHECK-RV64-NEXT:[[TMP2:%.*]] = extractvalue { ,  } [[TMP1]], 0
+// CHECK-RV64-NEXT:[[TMP3:%.*]] = extractvalue { ,  } [[TMP1]], 1
+// CHECK-RV64-NEXT:call void @llvm.riscv.vssseg2.nxv8f32.i64( [[TMP2]],  [[TMP3]], ptr [[BASE]], i64 [[BSTRIDE]], i64 [[VL]])
+// CHECK-RV64-NEXT:ret void
+//
+void test_vssseg2e32_v_f32m4x2(float *base, ptrdiff_t bstride, vfloat32m4x2_t v_tuple, size_t vl) {
+  return __riscv_vssseg2e32_tuple(base, bstride, v_tuple, vl);
+}
+
+// CHECK-RV64-LABEL: define dso_local void @test_vssseg2e32_v_i32mf2x2
+// CHECK-RV64-SAME: (p

[PATCH] D152076: [8/11][Clang][RISCV] Expand all variants for indexed strided segment load

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 528143.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152076

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

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


[PATCH] D152078: [10/11][Clang][RISCV] Expand all variants for vget on tuple types

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 528145.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152078

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

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


[PATCH] D152079: [11/11][Clang][RISCV] Expand all variants for vset on tuple types

2023-06-03 Thread Yueh-Ting (eop) Chen via Phabricator via cfe-commits
eopXD updated this revision to Diff 528146.
eopXD added a comment.

Bump CI.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152079

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

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


[PATCH] D151761: clang-format: Add AlignConsecutiveShortCaseStatements

2023-06-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks accepted this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

Please wait for some other approval (or comments) for a few days.




Comment at: clang/unittests/Format/FormatTest.cpp:19218
+  // Verify comments and empty lines break the alignment
+  verifyFormat("switch (level) {\n"
+   "case log::info:return \"info\";\n"

galenelias wrote:
> HazardyKnusperkeks wrote:
> > If both strings are the same, you only need to supply it once.
> > 
> > Or are they different and I can't see it?
> They are the same, but I can't use the single string version, as that one 
> calls test::messUp on the string which will strip blank lines, which then 
> invalidates the test case.  It seems pretty much all tests which are trying 
> to validate behavior around empty spaces has to use the two string version.
Check.


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

https://reviews.llvm.org/D151761

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


[PATCH] D148793: [clang-tidy] Implement an include-cleaner check.

2023-06-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D148793#4392788 , @mgorny wrote:

> I'm getting completely incomprehensible build errors on Gentoo from this

I'm also hitting this; it only seems to happen if building with 
`-DLLVM_LINK_LLVM_DYLIB=ON`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148793

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


[PATCH] D148793: [clang-tidy] Implement an include-cleaner check.

2023-06-03 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

My educated guess would be that `clangIncludeCleaner` is being linked via 
`clang_target_link_libraries` while it's not part of `libclang-cpp`, so it 
should go into regular `target_link_libraries`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148793

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


[PATCH] D148793: [clang-tidy] Implement an include-cleaner check.

2023-06-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In D148793#4393385 , @mgorny wrote:

> My educated guess would be that `clangIncludeCleaner` is being linked via 
> `clang_target_link_libraries` while it's not part of `libclang-cpp`, so it 
> should go into regular `target_link_libraries`.

Yes, that does seem to do the trick. LGTM from my PoV if you can push such a 
fix, otherwise I can try to do it in a little while...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148793

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


[clang] 4b97649 - [clang-format] Fix overlapping replacements before PPDirectives

2023-06-03 Thread Owen Pan via cfe-commits

Author: Owen Pan
Date: 2023-06-03T12:33:03-07:00
New Revision: 4b9764959dc4b8783e18747c1742ab164e4bc4ee

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

LOG: [clang-format] Fix overlapping replacements before PPDirectives

If the first token of an annotated line is finalized, reuse its
NewlinesBefore value to avoid potential overlapping whitespace
replacements before preprocessor branching directives.

Fixes #62892.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineFormatter.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineFormatter.cpp 
b/clang/lib/Format/UnwrappedLineFormatter.cpp
index 33be74dfe1b9f..fc5d4150ed777 100644
--- a/clang/lib/Format/UnwrappedLineFormatter.cpp
+++ b/clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1418,19 +1418,12 @@ unsigned UnwrappedLineFormatter::format(
   return Penalty;
 }
 
-void UnwrappedLineFormatter::formatFirstToken(
-const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
-const AnnotatedLine *PrevPrevLine,
-const SmallVectorImpl &Lines, unsigned Indent,
-unsigned NewlineIndent) {
-  FormatToken &RootToken = *Line.First;
-  if (RootToken.is(tok::eof)) {
-unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
-unsigned TokenIndent = Newlines ? NewlineIndent : 0;
-Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
-   TokenIndent);
-return;
-  }
+static auto newlinesBeforeLine(const AnnotatedLine &Line,
+   const AnnotatedLine *PreviousLine,
+   const AnnotatedLine *PrevPrevLine,
+   const SmallVectorImpl &Lines,
+   const FormatStyle &Style) {
+  const auto &RootToken = *Line.First;
   unsigned Newlines =
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
@@ -1510,6 +1503,27 @@ void UnwrappedLineFormatter::formatFirstToken(
 }
   }
 
+  return Newlines;
+}
+
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
+const AnnotatedLine *PrevPrevLine,
+const SmallVectorImpl &Lines, unsigned Indent,
+unsigned NewlineIndent) {
+  FormatToken &RootToken = *Line.First;
+  if (RootToken.is(tok::eof)) {
+unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
+unsigned TokenIndent = Newlines ? NewlineIndent : 0;
+Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
+   TokenIndent);
+return;
+  }
+
+  const auto Newlines =
+  RootToken.Finalized
+  ? RootToken.NewlinesBefore
+  : newlinesBeforeLine(Line, PreviousLine, PrevPrevLine, Lines, Style);
   if (Newlines)
 Indent = NewlineIndent;
 

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index 28a4008080566..f188ab6f581cf 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -12856,6 +12856,22 @@ TEST_F(FormatTest, FormatsAfterAccessModifiers) {
"  void f() {}\n"
"};\n",
Style);
+  verifyFormat("struct foo {\n"
+   "#ifdef FOO\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   "struct foo {\n"
+   "#ifdef FOO\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "\n"
+   "#endif\n"
+   "};",
+   Style);
 
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"



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


[PATCH] D151954: [clang-format] Fix overlapping whitespace replacements before PPDirective

2023-06-03 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4b9764959dc4: [clang-format] Fix overlapping replacements 
before PPDirectives (authored by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151954

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12856,6 +12856,22 @@
"  void f() {}\n"
"};\n",
Style);
+  verifyFormat("struct foo {\n"
+   "#ifdef FOO\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   "struct foo {\n"
+   "#ifdef FOO\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "\n"
+   "#endif\n"
+   "};",
+   Style);
 
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1418,19 +1418,12 @@
   return Penalty;
 }
 
-void UnwrappedLineFormatter::formatFirstToken(
-const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
-const AnnotatedLine *PrevPrevLine,
-const SmallVectorImpl &Lines, unsigned Indent,
-unsigned NewlineIndent) {
-  FormatToken &RootToken = *Line.First;
-  if (RootToken.is(tok::eof)) {
-unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
-unsigned TokenIndent = Newlines ? NewlineIndent : 0;
-Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
-   TokenIndent);
-return;
-  }
+static auto newlinesBeforeLine(const AnnotatedLine &Line,
+   const AnnotatedLine *PreviousLine,
+   const AnnotatedLine *PrevPrevLine,
+   const SmallVectorImpl &Lines,
+   const FormatStyle &Style) {
+  const auto &RootToken = *Line.First;
   unsigned Newlines =
   std::min(RootToken.NewlinesBefore, Style.MaxEmptyLinesToKeep + 1);
   // Remove empty lines before "}" where applicable.
@@ -1510,6 +1503,27 @@
 }
   }
 
+  return Newlines;
+}
+
+void UnwrappedLineFormatter::formatFirstToken(
+const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
+const AnnotatedLine *PrevPrevLine,
+const SmallVectorImpl &Lines, unsigned Indent,
+unsigned NewlineIndent) {
+  FormatToken &RootToken = *Line.First;
+  if (RootToken.is(tok::eof)) {
+unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
+unsigned TokenIndent = Newlines ? NewlineIndent : 0;
+Whitespaces->replaceWhitespace(RootToken, Newlines, TokenIndent,
+   TokenIndent);
+return;
+  }
+
+  const auto Newlines =
+  RootToken.Finalized
+  ? RootToken.NewlinesBefore
+  : newlinesBeforeLine(Line, PreviousLine, PrevPrevLine, Lines, Style);
   if (Newlines)
 Indent = NewlineIndent;
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -12856,6 +12856,22 @@
"  void f() {}\n"
"};\n",
Style);
+  verifyFormat("struct foo {\n"
+   "#ifdef FOO\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "#endif\n"
+   "};",
+   "struct foo {\n"
+   "#ifdef FOO\n"
+   "#else\n"
+   "private:\n"
+   "\n"
+   "\n"
+   "#endif\n"
+   "};",
+   Style);
 
   Style.EmptyLineAfterAccessModifier = FormatStyle::ELAAMS_Always;
   verifyFormat("struct foo {\n"
Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -1418,19 +1418,12 @@
   return Penalty;
 }
 
-void UnwrappedLineFormatter::formatFirstToken(
-const AnnotatedLine &Line, const AnnotatedLine *PreviousLine,
-const AnnotatedLine *PrevPrevLine,
-const SmallVectorImpl &Lines, unsigned Indent,
-unsigned NewlineIndent) {
-  FormatToken &RootToken = *Line.First;
-  if (RootToken.is(tok::eof)) {
-unsigned Newlines = std::min(RootToken.NewlinesBefore, 1u);
-unsigne

[PATCH] D152057: [CMake][Fuchsia] Add LLVM_ENABLE_HTTPLIB to Stage 2 build

2023-06-03 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152057

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


[clang-tools-extra] ac0ea75 - [clang-tools-extra] Fix linking when built with CLANG_LINK_CLANG_DYLIB=ON

2023-06-03 Thread Martin Storsjö via cfe-commits

Author: Martin Storsjö
Date: 2023-06-03T23:25:33+03:00
New Revision: ac0ea7555ee4ae872bcd153e04513ba0b88b8985

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

LOG: [clang-tools-extra] Fix linking when built with CLANG_LINK_CLANG_DYLIB=ON

clangIncludeCleaner isn't part of libclang-cpp, so link it with
target_link_libraries instead of clang_target_link_libraries.

This fixes a regression from
c28506ba4b6961950849f8fdecd0cf7e503a14f9.

Fix suggested by Michal Gorny.

Added: 


Modified: 
clang-tools-extra/clang-tidy/misc/CMakeLists.txt

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
index fde72f6b25a54..a37f7b29ec999 100644
--- a/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/misc/CMakeLists.txt
@@ -56,10 +56,13 @@ clang_target_link_libraries(clangTidyMiscModule
   clangASTMatchers
   clangBasic
   clangFormat
-  clangIncludeCleaner
   clangLex
   clangSerialization
   clangTooling
   clangToolingInclusions
   clangToolingInclusionsStdlib
   )
+target_link_libraries(clangTidyMiscModule
+  PRIVATE
+  clangIncludeCleaner
+  )



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


[PATCH] D152083: Warning for uninitialized elements in fixed-size arrays

2023-06-03 Thread Louis Burda via Phabricator via cfe-commits
Sinitax created this revision.
Sinitax added a project: clang.
Herald added a project: All.
Sinitax requested review of this revision.
Herald added a subscriber: cfe-commits.

This patch implements a warning for uninitialized elements in fixed-size arrays.

Without warnings a 'gap' in an array can go unnoticed when the size increases. 
Consider what happens with the array `const char *err_msg[ERR_TYPE_COUNT]` when 
a new `ERR_..` enum value is added.

Note: There is most likely a better way of doing this (first encounter with 
llvm internals), but I hope it will get some eyes on the problem such that it 
can be merged soon-ish.

Related: https://github.com/llvm/llvm-project/issues/22692


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152083

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -980,6 +980,22 @@
 if (RequiresSecondPass && !hadError)
   FillInEmptyInitializations(Entity, FullyStructuredList,
  RequiresSecondPass, nullptr, 0);
+
+if (const ConstantArrayType *CAType = dyn_cast(T)) {
+  if (FullyStructuredList->getNumInits() < 
CAType->getSize().getZExtValue()) {
+S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array)
+  << IL->getSourceRange();
+  } else {
+Expr **inits = FullyStructuredList->getInits();
+for (unsigned i = 0, e = FullyStructuredList->getNumInits(); i != e; 
++i) {
+  if (inits[i] == nullptr) {
+S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array)
+  << IL->getSourceRange();
+break;
+  }
+}
+  }
+}
   }
   if (hadError && FullyStructuredList)
 FullyStructuredList->markError();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2214,6 +2214,9 @@
   "reference %0 is not yet bound to a value when used within its own"
   " initialization">,
   InGroup;
+def warn_uninit_fixed_size_array : Warning<
+  "fixed-size array contains uninitialized elements">,
+  InGroup, DefaultIgnore;
 def warn_uninit_var : Warning<
   "variable %0 is uninitialized when %select{used here|captured by block}1">,
   InGroup, DefaultIgnore;


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -980,6 +980,22 @@
 if (RequiresSecondPass && !hadError)
   FillInEmptyInitializations(Entity, FullyStructuredList,
  RequiresSecondPass, nullptr, 0);
+
+if (const ConstantArrayType *CAType = dyn_cast(T)) {
+  if (FullyStructuredList->getNumInits() < CAType->getSize().getZExtValue()) {
+S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array)
+  << IL->getSourceRange();
+  } else {
+Expr **inits = FullyStructuredList->getInits();
+for (unsigned i = 0, e = FullyStructuredList->getNumInits(); i != e; ++i) {
+  if (inits[i] == nullptr) {
+S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array)
+  << IL->getSourceRange();
+break;
+  }
+}
+  }
+}
   }
   if (hadError && FullyStructuredList)
 FullyStructuredList->markError();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2214,6 +2214,9 @@
   "reference %0 is not yet bound to a value when used within its own"
   " initialization">,
   InGroup;
+def warn_uninit_fixed_size_array : Warning<
+  "fixed-size array contains uninitialized elements">,
+  InGroup, DefaultIgnore;
 def warn_uninit_var : Warning<
   "variable %0 is uninitialized when %select{used here|captured by block}1">,
   InGroup, DefaultIgnore;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2ff0aa2 - [CMake][Fuchsia] Add LLVM_ENABLE_HTTPLIB to Stage 2 build

2023-06-03 Thread Aiden Grossman via cfe-commits

Author: Aiden Grossman
Date: 2023-06-03T22:30:19Z
New Revision: 2ff0aa207fd55604604bb9eec33dada1a80842db

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

LOG: [CMake][Fuchsia] Add LLVM_ENABLE_HTTPLIB to Stage 2 build

This patch sets the LLVM_ENABLE_HTTPLIB flag to ON in the stage 2 build
similar to how many of the other dependency flags are already specified.
This is necessary to configure the stage 2 build by itself, otherwise
the CMake configuration crashes.

This is currently causing the MLGO demo to fail since we're only using
stage 2 to avoid having to build stage 1 to save some compile time.

Reviewed By: phosek

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

Added: 


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

Removed: 




diff  --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index 78c123f191305..b4bc8cb4eb64e 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -11,6 +11,7 @@ set(LLVM_ENABLE_RUNTIMES 
"compiler-rt;libcxx;libcxxabi;libunwind" CACHE STRING "
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
+set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
 set(LLVM_ENABLE_LLD ON CACHE BOOL "")



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


[PATCH] D152057: [CMake][Fuchsia] Add LLVM_ENABLE_HTTPLIB to Stage 2 build

2023-06-03 Thread Aiden Grossman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2ff0aa207fd5: [CMake][Fuchsia] Add LLVM_ENABLE_HTTPLIB to 
Stage 2 build (authored by aidengrossman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152057

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


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -11,6 +11,7 @@
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
+set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
 set(LLVM_ENABLE_LLD ON CACHE BOOL "")


Index: clang/cmake/caches/Fuchsia-stage2.cmake
===
--- clang/cmake/caches/Fuchsia-stage2.cmake
+++ clang/cmake/caches/Fuchsia-stage2.cmake
@@ -11,6 +11,7 @@
 
 set(LLVM_ENABLE_BACKTRACES OFF CACHE BOOL "")
 set(LLVM_ENABLE_DIA_SDK OFF CACHE BOOL "")
+set(LLVM_ENABLE_HTTPLIB ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
 set(LLVM_ENABLE_LIBEDIT OFF CACHE BOOL "")
 set(LLVM_ENABLE_LLD ON CACHE BOOL "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152083: [clang] Warning for uninitialized elements in fixed-size arrays

2023-06-03 Thread Louis Burda via Phabricator via cfe-commits
Sinitax updated this revision to Diff 528162.
Sinitax added a comment.

Remove new warning from -Wuninitialized group for backwards-compatibility.


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

https://reviews.llvm.org/D152083

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaInit.cpp


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -980,6 +980,22 @@
 if (RequiresSecondPass && !hadError)
   FillInEmptyInitializations(Entity, FullyStructuredList,
  RequiresSecondPass, nullptr, 0);
+
+if (const ConstantArrayType *CAType = dyn_cast(T)) {
+  if (FullyStructuredList->getNumInits() < 
CAType->getSize().getZExtValue()) {
+S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array)
+  << IL->getSourceRange();
+  } else {
+Expr **inits = FullyStructuredList->getInits();
+for (unsigned i = 0, e = FullyStructuredList->getNumInits(); i != e; 
++i) {
+  if (inits[i] == nullptr) {
+S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array)
+  << IL->getSourceRange();
+break;
+  }
+}
+  }
+}
   }
   if (hadError && FullyStructuredList)
 FullyStructuredList->markError();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2214,6 +2214,9 @@
   "reference %0 is not yet bound to a value when used within its own"
   " initialization">,
   InGroup;
+def warn_uninit_fixed_size_array : Warning<
+  "fixed-size array contains uninitialized elements">,
+  DefaultIgnore;
 def warn_uninit_var : Warning<
   "variable %0 is uninitialized when %select{used here|captured by block}1">,
   InGroup, DefaultIgnore;


Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -980,6 +980,22 @@
 if (RequiresSecondPass && !hadError)
   FillInEmptyInitializations(Entity, FullyStructuredList,
  RequiresSecondPass, nullptr, 0);
+
+if (const ConstantArrayType *CAType = dyn_cast(T)) {
+  if (FullyStructuredList->getNumInits() < CAType->getSize().getZExtValue()) {
+S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array)
+  << IL->getSourceRange();
+  } else {
+Expr **inits = FullyStructuredList->getInits();
+for (unsigned i = 0, e = FullyStructuredList->getNumInits(); i != e; ++i) {
+  if (inits[i] == nullptr) {
+S.Diag(IL->getBeginLoc(), diag::warn_uninit_fixed_size_array)
+  << IL->getSourceRange();
+break;
+  }
+}
+  }
+}
   }
   if (hadError && FullyStructuredList)
 FullyStructuredList->markError();
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -2214,6 +2214,9 @@
   "reference %0 is not yet bound to a value when used within its own"
   " initialization">,
   InGroup;
+def warn_uninit_fixed_size_array : Warning<
+  "fixed-size array contains uninitialized elements">,
+  DefaultIgnore;
 def warn_uninit_var : Warning<
   "variable %0 is uninitialized when %select{used here|captured by block}1">,
   InGroup, DefaultIgnore;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D152090: [clang][Driver] Add -fcaret-diagnostics-max-lines as a driver option

2023-06-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder created this revision.
tbaeder added reviewers: aaron.ballman, MaskRay.
Herald added a project: All.
tbaeder requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D152090

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4109,6 +4109,12 @@
   Args.addOptOutFlag(CmdArgs, options::OPT_fdiagnostics_show_line_numbers,
  options::OPT_fno_diagnostics_show_line_numbers);
 
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_fcaret_diagnostics_max_lines_EQ)) {
+CmdArgs.push_back("-fcaret-diagnostics-max-lines");
+CmdArgs.push_back(A->getValue());
+  }
+
   if (Args.hasArg(options::OPT_fdiagnostics_absolute_paths))
 CmdArgs.push_back("-fdiagnostics-absolute-paths");
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1608,6 +1608,7 @@
   NegFlag>;
 def fencoding_EQ : Joined<["-"], "fencoding=">, Group;
 def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, 
Flags<[CoreOption]>;
+def fcaret_diagnostics_max_lines_EQ : Joined<["-"], 
"fcaret-diagnostics-max-lines=">, Group, Flags<[CoreOption]>;
 defm exceptions : BoolFOption<"exceptions",
   LangOpts<"Exceptions">, DefaultFalse,
   PosFlag, NegFlag,


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4109,6 +4109,12 @@
   Args.addOptOutFlag(CmdArgs, options::OPT_fdiagnostics_show_line_numbers,
  options::OPT_fno_diagnostics_show_line_numbers);
 
+  if (const Arg *A =
+  Args.getLastArg(options::OPT_fcaret_diagnostics_max_lines_EQ)) {
+CmdArgs.push_back("-fcaret-diagnostics-max-lines");
+CmdArgs.push_back(A->getValue());
+  }
+
   if (Args.hasArg(options::OPT_fdiagnostics_absolute_paths))
 CmdArgs.push_back("-fdiagnostics-absolute-paths");
 
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1608,6 +1608,7 @@
   NegFlag>;
 def fencoding_EQ : Joined<["-"], "fencoding=">, Group;
 def ferror_limit_EQ : Joined<["-"], "ferror-limit=">, Group, Flags<[CoreOption]>;
+def fcaret_diagnostics_max_lines_EQ : Joined<["-"], "fcaret-diagnostics-max-lines=">, Group, Flags<[CoreOption]>;
 defm exceptions : BoolFOption<"exceptions",
   LangOpts<"Exceptions">, DefaultFalse,
   PosFlag, NegFlag,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D147875: [clang][Diagnostics] Show line numbers when printing code snippets

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

@hans @dyung I've opened https://reviews.llvm.org/D152090 which should fix both 
of your concerns.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147875

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


[PATCH] D151833: Respect "-fdiagnostics-absolute-paths" on emit include location

2023-06-03 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added inline comments.



Comment at: clang/test/Frontend/absolute-paths.c:6
+// NORMAL: In file included from [[ROOT_ABSOLUTE]]:4:
+// ABSOLUTE: In file included from [[ROOT_ABSOLUTE]]:4:
 

charmitro wrote:
> tbaeder wrote:
> > charmitro wrote:
> > > tbaeder wrote:
> > > > charmitro wrote:
> > > > > tbaeder wrote:
> > > > > > This checks the same thing in both cases, but in the `NORMAL` case, 
> > > > > > it should //not// use the absolute path, shouldn't it?
> > > > > You're correct. I was constantly testing it from the same path.
> > > > > 
> > > > > Since the relative path is going to be different depending on where 
> > > > > you running from, would it be wise to accept a regular expression of 
> > > > > any string in the `NORMAL` case?
> > > > > 
> > > > > For example, 
> > > > > ```
> > > > > NORMAL: In file included from {{.*}}:
> > > > > ```
> > > > I wonder if it would make sense to just check for the filename in the 
> > > > `NORMAL` case and then do a `NORMAL-NOT: [[ROOT_ABSOLUTE]]`?
> > > Yes, that way we are testing if the warning contains the correct 
> > > filename+LOC.
> > > 
> > > Something like: `// NORMAL: In file included from 
> > > {{.*absolute-paths.c:4}}:`.
> > > 
> > > But why changefrom `ABSOLUTE:` to `NORMAL-NOT`?
> > Your regex checks if the path ends with the file name, right? That would be 
> > true in both cases.
> What else do you propose here?
> 
> Let me explain why this was the only obvious option for me.
> 
> In the case of `NORMAL`, it checks for the relative path based on the 
> location you invoke the test commands. 
> 
> Given that, if we, for example,
> 1. run `llvm-lit` from the project root, the `NORMAL` case expects:
> ```
> In file included from clang/test/Frontend/absolute-paths.c:4:
> ```
> 2. run `llvm-lit` from `$PROJECT_ROOT/clang/test/`, the `NORMAL` case expects:
> ```
> In file included from Frontend/absolute-paths.c:4:
> ```
> 
> It seems unwise to me to hard-code the path based on what the CI excepts in 
> the `NORMAL` scenario, because that way, whoever runs the test cases 
> manually, will experience test failure.
You can still keep the `ABSOLUTE: [[ROOT_ABSOLUTE]]` stuff, I was just 
proposing to add the `NORMAL-NOT` one additionally, so we can make sure we're 
not printing the absolute path in the normal case as well.


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

https://reviews.llvm.org/D151833

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


[clang] 808004f - [clang][NFC] Reformat expandTabs

2023-06-03 Thread Timm Bäder via cfe-commits

Author: Timm Bäder
Date: 2023-06-04T07:52:46+02:00
New Revision: 808004f82af7ba3d17ddaffbd809d491aa0a865e

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

LOG: [clang][NFC] Reformat expandTabs

Use the proper capitalization here as well as a init capture for better
identifiers.

Added: 


Modified: 
clang/lib/Frontend/TextDiagnostic.cpp

Removed: 




diff  --git a/clang/lib/Frontend/TextDiagnostic.cpp 
b/clang/lib/Frontend/TextDiagnostic.cpp
index ad5f1d45cb631..137001dc050d1 100644
--- a/clang/lib/Frontend/TextDiagnostic.cpp
+++ b/clang/lib/Frontend/TextDiagnostic.cpp
@@ -161,15 +161,15 @@ printableTextForNextCharacter(StringRef SourceLine, 
size_t *i,
 }
 
 static void expandTabs(std::string &SourceLine, unsigned TabStop) {
-  size_t i = SourceLine.size();
-  while (i>0) {
-i--;
-if (SourceLine[i]!='\t')
+  size_t I = SourceLine.size();
+  while (I > 0) {
+I--;
+if (SourceLine[I] != '\t')
   continue;
-size_t tmp_i = i;
-std::pair,bool> res
-  = printableTextForNextCharacter(SourceLine, &tmp_i, TabStop);
-SourceLine.replace(i, 1, res.first.c_str());
+size_t TmpI = I;
+auto [Str, Printable] =
+printableTextForNextCharacter(SourceLine, &TmpI, TabStop);
+SourceLine.replace(I, 1, Str.c_str());
   }
 }
 



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


[clang] 59048a3 - [AST] Remove unused declaration makeDeclVisibleInContextInternal

2023-06-03 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-06-03T23:36:50-07:00
New Revision: 59048a3aa3f4b2326ea4dc1abf4b9530cda50b2a

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

LOG: [AST] Remove unused declaration makeDeclVisibleInContextInternal

The corresponding function definition was removed by:

  commit f634c9006977fcbed5f55eaee831852e453fdf76
  Author: Richard Smith 
  Date:   Fri Mar 16 06:12:59 2012 +

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index f7d5b3a83141a..511afb1db5606 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -2602,14 +2602,6 @@ class DeclContext {
   void reconcileExternalVisibleStorage() const;
   bool LoadLexicalDeclsFromExternalStorage() const;
 
-  /// Makes a declaration visible within this context, but
-  /// suppresses searches for external declarations with the same
-  /// name.
-  ///
-  /// Analogous to makeDeclVisibleInContext, but for the exclusive
-  /// use of addDeclInternal().
-  void makeDeclVisibleInContextInternal(NamedDecl *D);
-
   StoredDeclsMap *CreateStoredDeclsMap(ASTContext &C) const;
 
   void loadLazyLocalLexicalLookups();



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