[PATCH] D133436: Ground work for cuda-related checks in clang-tidy

2022-09-14 Thread Nathan James via Phabricator via cfe-commits
njames93 added a comment.

What's with the .keep files. Will lit or sphinx fail if the cuda directory 
doesn't exist, if not I'd be happier removing them(they'd get removed once the 
first cuda check lands anyway).




Comment at: clang-tools-extra/clang-tidy/cuda/CudaTidyModule.cpp:1
+//===--- GoogleTidyModule.cpp - clang-tidy 
===//
+//

Google...

It may be easier/safer to use the add_new_check script to generate this, then 
just remove all the new check specific files.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:98
 --
 
 New checks

Put it in here.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:152
 
+- Introduced first checks specifically for CUDA.
+

This line doesn't belong in the new checks portion of the release notes, just 
stick it in the general clang-tidy section.
Also maybe just say "Introduce the cuda module for checks specific to cuda 
code" and remove all the documentation below, That will be filled in when the 
first check lands.



Comment at: clang-tools-extra/docs/clang-tidy/index.rst:143
  each source file in its parent 
directories.
---config-file= - 
+--config-file= -
 Specify the path of .clang-tidy or custom 
config file:

Unnecessary edit can be removed.



Comment at: clang-tools-extra/docs/clang-tidy/index.rst:241
 --system-headers   - Display the errors from system headers.
---use-color- 
+--use-color-
 Use colors in diagnostics. If not set, 
colors

Ditto.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda-initializers.h:1
+// CUDA struct types with interesting initialization properties.
+// Keep in sync with clang/test/SemaCUDA/Inputs/cuda-initializers.h.

What's the purpose of this file here, do you envision many checks requiring to 
include this?



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda.h:3
+
+#include 
+

This looks worrying as test cases don't run with a standard library 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133436

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


[PATCH] D122078: [clang-tidy] Ignore concepts in `misc-redundant-expression`

2022-09-14 Thread Nathan James via Phabricator via cfe-commits
njames93 requested changes to this revision.
njames93 added a comment.
This revision now requires changes to proceed.

Just address that test issue then it'll be good




Comment at: 
clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp:1
-// RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- 
-fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s misc-redundant-expression -std=c++20 %t -- -- 
-fno-delayed-template-parsing
 

This is removing test coverage for previous language versions unnecessarily. 
Can you create a new test file redundant-expression-cxx20 instead and move this 
new test case into there.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122078

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-09-14 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

I reverted this commit while I fix the failing tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D132608: [CMake] Clean up CMake binary dir handling

2022-09-14 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added a comment.

@tianshilei1992 that is a fair point. I would be open to calling them something 
else.

I just don't want to call them `LLVM_*` because that would be confusing since 
there is (a) LLVM in particular (b) the monorepo / project as a whole, and this 
variable are about *neither* of them, being scoped to the current build.

I mainly named this way to match the`GNUInstallDirs` naming scheme, where 
`CMAKE_INSTALL_PREFIX` goes with` CMAKE_INSTALL_*DIR`; here `CMAKE_BINARY_DIR` 
goes with `CMAKE_BINARY_*DIR`. I admit relative vs absolute paths, in addition 
to `_PREFIX` vs `_DIR`, do not make the analogy exact though.

I also was hoping something like this could be upstreamed into CMake itself, 
but using different names now doesn't prevent upstream from adopting `CMAKE_*` 
were this to become official.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132608

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


[PATCH] D131799: [HLSL] clang codeGen for HLSLNumThreadsAttr

2022-09-14 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 460288.
python3kgae added a comment.

Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131799

Files:
  clang/lib/CodeGen/CGHLSLRuntime.cpp
  clang/test/CodeGenHLSL/entry.hlsl


Index: clang/test/CodeGenHLSL/entry.hlsl
===
--- clang/test/CodeGenHLSL/entry.hlsl
+++ clang/test/CodeGenHLSL/entry.hlsl
@@ -2,9 +2,10 @@
 
 // Make sure not mangle entry.
 // CHECK:define void @foo()
-// Make sure add function attribute.
+// Make sure add function attribute and numthreads attribute.
+// CHECK:"hlsl.numthreads"="16,8,1"
 // CHECK:"hlsl.shader"="compute"
-[numthreads(1,1,1)]
+[numthreads(16,8,1)]
 void foo() {
 
 }
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -19,6 +19,7 @@
 #include "llvm/IR/IntrinsicsDirectX.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/FormatVariadic.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -107,6 +108,13 @@
   const StringRef ShaderAttrKindStr = "hlsl.shader";
   Fn->addFnAttr(ShaderAttrKindStr,
 ShaderAttr->ConvertShaderTypeToStr(ShaderAttr->getType()));
+  if (HLSLNumThreadsAttr *NumThreadsAttr = FD->getAttr()) {
+const StringRef NumThreadsKindStr = "hlsl.numthreads";
+std::string NumThreadsStr =
+formatv("{0},{1},{2}", NumThreadsAttr->getX(), NumThreadsAttr->getY(),
+NumThreadsAttr->getZ());
+Fn->addFnAttr(NumThreadsKindStr, NumThreadsStr);
+  }
 }
 
 llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> ,


Index: clang/test/CodeGenHLSL/entry.hlsl
===
--- clang/test/CodeGenHLSL/entry.hlsl
+++ clang/test/CodeGenHLSL/entry.hlsl
@@ -2,9 +2,10 @@
 
 // Make sure not mangle entry.
 // CHECK:define void @foo()
-// Make sure add function attribute.
+// Make sure add function attribute and numthreads attribute.
+// CHECK:"hlsl.numthreads"="16,8,1"
 // CHECK:"hlsl.shader"="compute"
-[numthreads(1,1,1)]
+[numthreads(16,8,1)]
 void foo() {
 
 }
Index: clang/lib/CodeGen/CGHLSLRuntime.cpp
===
--- clang/lib/CodeGen/CGHLSLRuntime.cpp
+++ clang/lib/CodeGen/CGHLSLRuntime.cpp
@@ -19,6 +19,7 @@
 #include "llvm/IR/IntrinsicsDirectX.h"
 #include "llvm/IR/Metadata.h"
 #include "llvm/IR/Module.h"
+#include "llvm/Support/FormatVariadic.h"
 
 using namespace clang;
 using namespace CodeGen;
@@ -107,6 +108,13 @@
   const StringRef ShaderAttrKindStr = "hlsl.shader";
   Fn->addFnAttr(ShaderAttrKindStr,
 ShaderAttr->ConvertShaderTypeToStr(ShaderAttr->getType()));
+  if (HLSLNumThreadsAttr *NumThreadsAttr = FD->getAttr()) {
+const StringRef NumThreadsKindStr = "hlsl.numthreads";
+std::string NumThreadsStr =
+formatv("{0},{1},{2}", NumThreadsAttr->getX(), NumThreadsAttr->getY(),
+NumThreadsAttr->getZ());
+Fn->addFnAttr(NumThreadsKindStr, NumThreadsStr);
+  }
 }
 
 llvm::Value *CGHLSLRuntime::emitInputSemantic(IRBuilder<> ,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-09-14 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak added a comment.

In D102107#3791292 , @vitalybuka 
wrote:

> check-llvm fails bunch of test for me
>
> 
>
> Failed Tests (12):
>
>   LLVM :: Transforms/OpenMP/custom_state_machines.ll
>   LLVM :: Transforms/OpenMP/custom_state_machines_remarks.ll
>   LLVM :: Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
>   LLVM :: Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
>   LLVM :: Transforms/OpenMP/is_spmd_exec_mode_fold.ll
>   LLVM :: Transforms/OpenMP/parallel_level_fold.ll
>   LLVM :: Transforms/OpenMP/spmdization.ll
>   LLVM :: Transforms/OpenMP/spmdization_assumes.ll
>   LLVM :: Transforms/OpenMP/spmdization_constant_prop.ll
>   LLVM :: Transforms/OpenMP/spmdization_guarding.ll
>   LLVM :: Transforms/OpenMP/spmdization_guarding_two_reaching_kernels.ll
>   LLVM :: Transforms/OpenMP/spmdization_remarks.ll

Thanks for reporting them. I need to update them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

check-llvm fails bunch of test for me



Failed Tests (12):

  LLVM :: Transforms/OpenMP/custom_state_machines.ll
  LLVM :: Transforms/OpenMP/custom_state_machines_remarks.ll
  LLVM :: Transforms/OpenMP/get_hardware_num_threads_in_block_fold.ll
  LLVM :: Transforms/OpenMP/gpu_state_machine_function_ptr_replacement.ll
  LLVM :: Transforms/OpenMP/is_spmd_exec_mode_fold.ll
  LLVM :: Transforms/OpenMP/parallel_level_fold.ll
  LLVM :: Transforms/OpenMP/spmdization.ll
  LLVM :: Transforms/OpenMP/spmdization_assumes.ll
  LLVM :: Transforms/OpenMP/spmdization_constant_prop.ll
  LLVM :: Transforms/OpenMP/spmdization_guarding.ll
  LLVM :: Transforms/OpenMP/spmdization_guarding_two_reaching_kernels.ll
  LLVM :: Transforms/OpenMP/spmdization_remarks.ll


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

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


[PATCH] D133341: [C++] [Coroutines] Prefer aligned (de)allocation for coroutines - implement the option2 of P2014R0

2022-09-14 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

Looks great. Just a few more nits.




Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11280
+def warn_non_aligned_allocation_function : Warning <
+  "found non aligned allocation function for coroutine %0">,
+  InGroup;

"under `-fcoro-aligned-allocation`, the non-aligned allocation function for the 
promise type %0 has higher precedence than the global aligned allocation 
function"



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:11283
+def err_conflicting_aligned_options : Error <
+  "conflicting option '-fcoro-aligned-allocation' and 
'-fno-aligned-allocation'"
 >;

ChuanqiXu wrote:
> ychen wrote:
> > Since we're digressing from the usual operator new/delete look-up rules per 
> > Option 2, I think it might be easier to just *not* respect 
> > `-fno-aligned-allocation` and `-fno-sized-deallocation`. Using 
> > '-fcoro-aligned-allocation' explicitly should permit us to assume these 
> > functions could be found.
> I guess it may not be good to enable `-fsized-deallocation` automatically if 
> `-fcoro-aligned-allocation` enabled. Since it looks like there are other 
> reasons why we disabled `-fsized-deallocation` before. And it looks it will 
> block our users to use `-fcoro-aligned-allocation`. For the 
> `-faligned-allocation` flag, this is enabled by default but people could 
> disable it explicitly. So the check here is for that.
You're right. It is better to diagnose the conflicting intent.



Comment at: clang/lib/Sema/SemaCoroutine.cpp:1425
+  if (HavePlacementArgs)
+collectPlacementArgs(S, FD, Loc, PlacementArgs);
+  LookupAllocationFunction(/*NewScope*/ Sema::AFS_Class,

Micro-optimization: instead of recomputing this, add a flag `bool 
WithoutPlacementArgs` to LookupAllocationFunction to switch between an empty 
vector and `PlacementArgs`.



Comment at: clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp:94
+void return_value(int) {}
+void operator delete(void *ptr, std::align_val_t);
+  };

ChuanqiXu wrote:
> ychen wrote:
> > Please add test cases for 
> > ```
> > void operator delete  ( void* ptr, std::size_t, std::align_val_t);
> > void operator delete  ( void* ptr, std::size_t);
> > void operator delete  ( void* ptr);
> > void ::operator delete  ( void* ptr, std::size_t, std::align_val_t);
> > void ::operator delete  ( void* ptr, std::size_t);
> > void ::operator delete  ( void* ptr);
> > ```
> > in that lookup order, and makes sure the look-up order is expected.
> I've tried my best. But it looks hard to test these operator delete under 
> global namespace since they are automatically declared by the compiler.
Thanks for adding these. It looks great! I wouldn't worry about the global ones 
since this patch did not change their look-up order. 



Comment at: clang/test/SemaCXX/coroutine-alloc-4.cpp:49
+void return_value(int) {}
+void *operator new(std::size_t, std::align_val_t) noexcept;
+void *operator new(std::size_t) noexcept;

ChuanqiXu wrote:
> ychen wrote:
> > Like this test case, please add additional test cases to check the expected 
> > look-up order, one test for each consecutive pair should be good.
> > 
> > ```
> > void* T::operator new  ( std::size_t count, std::align_val_t al, 
> > user-defined-args... );
> > void* T::operator new  ( std::size_t count, std::align_val_t al);
> > void* T::operator new  ( std::size_t count, user-defined-args... );
> > void* T::operator new  ( std::size_t count);
> > void* operator new  ( std::size_t count, std::align_val_t al );
> > ```
> > 
> > 
> Yeah, I'm testing this in CodeGenCoroutines. (It is hard to test the 
> selection in Sema Test)
Thanks for adding the overload. I think the `noexcept` on operator new is not 
necessary. Strictly speaking, it is not a conforming API.


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

https://reviews.llvm.org/D133341

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


[PATCH] D133887: [Clang] Support label at end of compound statement

2022-09-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

The proposal says:

> A label at the end of a compound statement is treated as if it were followed 
> by a null statement

Does it make sense to write an AST test to verify this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133887

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


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

2022-09-14 Thread YingChi Long via Phabricator via cfe-commits
inclyc added inline comments.



Comment at: clang/test/Sema/offsetof.c:79
+int a;
+struct B // no-error, struct B is not defined within __builtin_offsetof 
directly
+{

inclyc wrote:
> aaron.ballman wrote:
> > inclyc wrote:
> > > aaron.ballman wrote:
> > > > I think this is defensible. The wording in the standard is "If the 
> > > > specified type defines a new type or if the specified member is a 
> > > > bit-field, the behavior is undefined." and the specified type in this 
> > > > case is `struct A`; that `struct A` happens to also define `struct B` 
> > > > is immaterial.
> > > > 
> > > > However, the intent behind the change to the rule is to support older 
> > > > implementations of `offsetof` to protect them from having to deal with 
> > > > a case like: `offsetof(struct S { int a, b }, b);` where `offsetof` is 
> > > > a macro and thus the comma between `a` and `b` is treated as a 
> > > > separator. So there's a part of me that wonders if we want to also 
> > > > support diagnosing this case. But then we'd have to look at the 
> > > > declarator context more recursively to see whether any of the contexts 
> > > > on the stack are an `offsetof` context and that might be tricky.
> > > > 
> > > > Thoughts?
> > > FWIW, gcc seems just rejects all definitions in this context. (Perhaps 
> > > during Parsing the statements). If we add a bool state to the Parser 
> > > (just using RAII object as before) struct B will trigger diagnostic error 
> > > because the state "ParsingOffsetof" is passed into inner declaration.
> > GCC accepts currently: https://godbolt.org/z/oEvzjW6Ee but you're correct 
> > regarding switching back to an RAII object being an easier way to address 
> > the nested declarations.
> > 
> > Let me think on this situation a bit
> > GCC accepts currently
> 
> C++: https://godbolt.org/z/fon8e7dzf 
```
: In function 'int main()':
:3:3: error: types may not be defined within '__builtin_offsetof'
3 |   {
  |   ^
:6:5: error: types may not be defined within '__builtin_offsetof'
6 | {
  | ^
Compiler returned: 1
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


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

2022-09-14 Thread YingChi Long via Phabricator via cfe-commits
inclyc added inline comments.



Comment at: clang/test/Sema/offsetof.c:79
+int a;
+struct B // no-error, struct B is not defined within __builtin_offsetof 
directly
+{

aaron.ballman wrote:
> inclyc wrote:
> > aaron.ballman wrote:
> > > I think this is defensible. The wording in the standard is "If the 
> > > specified type defines a new type or if the specified member is a 
> > > bit-field, the behavior is undefined." and the specified type in this 
> > > case is `struct A`; that `struct A` happens to also define `struct B` is 
> > > immaterial.
> > > 
> > > However, the intent behind the change to the rule is to support older 
> > > implementations of `offsetof` to protect them from having to deal with a 
> > > case like: `offsetof(struct S { int a, b }, b);` where `offsetof` is a 
> > > macro and thus the comma between `a` and `b` is treated as a separator. 
> > > So there's a part of me that wonders if we want to also support 
> > > diagnosing this case. But then we'd have to look at the declarator 
> > > context more recursively to see whether any of the contexts on the stack 
> > > are an `offsetof` context and that might be tricky.
> > > 
> > > Thoughts?
> > FWIW, gcc seems just rejects all definitions in this context. (Perhaps 
> > during Parsing the statements). If we add a bool state to the Parser (just 
> > using RAII object as before) struct B will trigger diagnostic error because 
> > the state "ParsingOffsetof" is passed into inner declaration.
> GCC accepts currently: https://godbolt.org/z/oEvzjW6Ee but you're correct 
> regarding switching back to an RAII object being an easier way to address the 
> nested declarations.
> 
> Let me think on this situation a bit
> GCC accepts currently

C++: https://godbolt.org/z/fon8e7dzf 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-09-14 Thread Dhruva Chakrabarti 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 rG7539e9cf811e: [OpenMP] Codegen aggregate for outlined 
function captures (authored by ggeorgakoudis, committed by dhruvachak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/CodeGenCXX/observe-noexcept.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/debug_threadprivate_copyin.c
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/outlined_artificial.c
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_copyin_combined_codegen.c
  

[PATCH] D102107: [OpenMP] Codegen aggregate for outlined function captures

2022-09-14 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak updated this revision to Diff 460274.
dhruvachak added a comment.

Rebased


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102107

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.h
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.h
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/AST/ast-dump-openmp-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-target-teams-distribute-parallel-for.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for-simd.c
  clang/test/AST/ast-dump-openmp-teams-distribute-parallel-for.c
  clang/test/CodeGenCXX/observe-noexcept.cpp
  clang/test/OpenMP/cancel_codegen.cpp
  clang/test/OpenMP/cancellation_point_codegen.cpp
  clang/test/OpenMP/debug-info-complex-byval.cpp
  clang/test/OpenMP/debug-info-openmp-array.cpp
  clang/test/OpenMP/debug_threadprivate_copyin.c
  clang/test/OpenMP/declare_target_codegen_globalization.cpp
  clang/test/OpenMP/declare_variant_construct_codegen_1.c
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_task_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/for_firstprivate_codegen.cpp
  clang/test/OpenMP/for_lastprivate_codegen.cpp
  clang/test/OpenMP/for_linear_codegen.cpp
  clang/test/OpenMP/for_private_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen.cpp
  clang/test/OpenMP/for_reduction_codegen_UDR.cpp
  clang/test/OpenMP/for_reduction_task_codegen.cpp
  clang/test/OpenMP/master_taskloop_in_reduction_codegen.cpp
  clang/test/OpenMP/master_taskloop_simd_in_reduction_codegen.cpp
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/nvptx_allocate_codegen.cpp
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_multi_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_nested_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/nvptx_target_teams_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
  
clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp
  clang/test/OpenMP/openmp_win_codegen.cpp
  clang/test/OpenMP/outlined_artificial.c
  clang/test/OpenMP/parallel_codegen.cpp
  clang/test/OpenMP/parallel_copyin_codegen.cpp
  clang/test/OpenMP/parallel_copyin_combined_codegen.c
  clang/test/OpenMP/parallel_firstprivate_codegen.cpp
  clang/test/OpenMP/parallel_for_codegen.cpp
  clang/test/OpenMP/parallel_for_lastprivate_conditional.cpp
  

[PATCH] D133457: Add Clang driver flags equivalent to cl's /MD, /MT, /MDd, /MTd.

2022-09-14 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 460271.
akhuang marked 3 inline comments as done.
akhuang added a comment.

more comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133457

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-runtime-flags.c

Index: clang/test/Driver/cl-runtime-flags.c
===
--- clang/test/Driver/cl-runtime-flags.c
+++ clang/test/Driver/cl-runtime-flags.c
@@ -10,6 +10,8 @@
 
 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-MT %s
 // RUN: %clang_cl -### /MT -- %s 2>&1 | FileCheck -check-prefix=CHECK-MT %s
+// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=static -- %s \
+// RUN:   2>&1 | FileCheck -check-prefix=CHECK-MT %s
 // CHECK-MT-NOT: "-D_DEBUG"
 // CHECK-MT: "-D_MT"
 // CHECK-MT-NOT: "-D_DLL"
@@ -19,6 +21,8 @@
 
 // RUN: %clang_cl -### /MTd -- %s 2>&1 | FileCheck -check-prefix=CHECK-MTd %s
 // RUN: %clang_cl -### /LD /MTd -- %s 2>&1 | FileCheck -check-prefix=CHECK-MTd %s
+// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=static_dbg \
+// RUN:   -- %s 2>&1 | FileCheck -check-prefix=CHECK-MTd %s
 // CHECK-MTd: "-D_DEBUG"
 // CHECK-MTd: "-D_MT"
 // CHECK-MTd-NOT: "-D_DLL"
@@ -27,6 +31,8 @@
 // CHECK-MTd: "--dependent-lib=oldnames"
 
 // RUN: %clang_cl -### /MD -- %s 2>&1 | FileCheck -check-prefix=CHECK-MD %s
+// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=dll -- %s \
+// RUN:   2>&1 | FileCheck -check-prefix=CHECK-MD %s
 // CHECK-MD-NOT: "-D_DEBUG"
 // CHECK-MD: "-D_MT"
 // CHECK-MD: "-D_DLL"
@@ -34,6 +40,8 @@
 // CHECK-MD: "--dependent-lib=oldnames"
 
 // RUN: %clang_cl -### /MDd -- %s 2>&1 | FileCheck -check-prefix=CHECK-MDd %s
+// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=dll_dbg -- \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=CHECK-MDd %s
 // CHECK-MDd: "-D_DEBUG"
 // CHECK-MDd: "-D_MT"
 // CHECK-MDd: "-D_DLL"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4437,6 +4437,71 @@
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
+static void ProcessVSRuntimeLibrary(const ArgList ,
+ArgStringList ) {
+  unsigned RTOptionID = options::OPT__SLASH_MT;
+
+  if (Args.hasArg(options::OPT__SLASH_LDd))
+// The /LDd option implies /MTd. The dependent lib part can be overridden,
+// but defining _DEBUG is sticky.
+RTOptionID = options::OPT__SLASH_MTd;
+
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_M_Group))
+RTOptionID = A->getOption().getID();
+
+  if (Arg *A = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
+RTOptionID = llvm::StringSwitch(A->getValue())
+  .Case("static", options::OPT__SLASH_MT)
+  .Case("static_dbg", options::OPT__SLASH_MTd)
+  .Case("dll", options::OPT__SLASH_MD)
+  .Case("dll_dbg", options::OPT__SLASH_MDd)
+  .Default(options::OPT__SLASH_MT);
+  }
+
+  StringRef FlagForCRT;
+  switch (RTOptionID) {
+  case options::OPT__SLASH_MD:
+if (Args.hasArg(options::OPT__SLASH_LDd))
+  CmdArgs.push_back("-D_DEBUG");
+CmdArgs.push_back("-D_MT");
+CmdArgs.push_back("-D_DLL");
+FlagForCRT = "--dependent-lib=msvcrt";
+break;
+  case options::OPT__SLASH_MDd:
+CmdArgs.push_back("-D_DEBUG");
+CmdArgs.push_back("-D_MT");
+CmdArgs.push_back("-D_DLL");
+FlagForCRT = "--dependent-lib=msvcrtd";
+break;
+  case options::OPT__SLASH_MT:
+if (Args.hasArg(options::OPT__SLASH_LDd))
+  CmdArgs.push_back("-D_DEBUG");
+CmdArgs.push_back("-D_MT");
+CmdArgs.push_back("-flto-visibility-public-std");
+FlagForCRT = "--dependent-lib=libcmt";
+break;
+  case options::OPT__SLASH_MTd:
+CmdArgs.push_back("-D_DEBUG");
+CmdArgs.push_back("-D_MT");
+CmdArgs.push_back("-flto-visibility-public-std");
+FlagForCRT = "--dependent-lib=libcmtd";
+break;
+  default:
+llvm_unreachable("Unexpected option ID.");
+  }
+
+  if (Args.hasArg(options::OPT__SLASH_Zl)) {
+CmdArgs.push_back("-D_VC_NODEFAULTLIB");
+  } else {
+CmdArgs.push_back(FlagForCRT.data());
+
+// This provides POSIX compatibility (maps 'open' to '_open'), which most
+// users want.  The /Za flag to cl.exe turns this off, but it's not
+// implemented in clang.
+CmdArgs.push_back("--dependent-lib=oldnames");
+  }
+}
+
 void Clang::ConstructJob(Compilation , const JobAction ,
  const InputInfo , const InputInfoList ,
  const ArgList , const char *LinkingOutput) const {
@@ -6478,6 +6543,9 @@
   if (IsMSVCCompat)
 CmdArgs.push_back("-fms-compatibility");
 
+  if (Triple.isWindowsMSVCEnvironment() && !D.IsCLMode())
+ProcessVSRuntimeLibrary(Args, 

[PATCH] D133443: [RISCV][MC] Add support for experimental Zawrs extension

2022-09-14 Thread Philip Reames via Phabricator via cfe-commits
reames added a comment.

In D133443#3790420 , @asb wrote:

> The change in set of instructions without changing the version number is 
> concerning - do you know anyone involved in that group? It would be good to 
> feedback the difficulties this can cause for us. It's also not clear if there 
> might be changes again during ratification without changing the version 
> number, which wouldn't be ideal (though probably just about livable given 
> it's marked as experimental).

I agree that the incompatible change is highly sub-optimal.  I've asked around 
a bit on the status here, but nothing I would consider "official" or would want 
to quote someone on.  My overall take is that we probably should take this as 
experimental, but only with the understanding that it may change in 
incompatible ways.

> Let's discuss briefly in the meeting tomorrow. Implementation-wise it all 
> seems straightforward.

Definitely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133443

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


[PATCH] D133659: [Clang] P1169R4: static operator()

2022-09-14 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133659

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


[PATCH] D133863: [RISCV] Add MC support of RISCV zcmt Extension

2022-09-14 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu updated this revision to Diff 460266.
VincentWu added a comment.

fix test case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133863

Files:
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/lib/Target/RISCV/RISCVSchedRocket.td
  llvm/lib/Target/RISCV/RISCVSchedSiFive7.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/lib/Target/RISCV/RISCVSystemOperands.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zcmt-Invalid.s
  llvm/test/MC/RISCV/rv32zcmt-valid.s
  llvm/test/MC/RISCV/rv64zcmt-Invalid.s
  llvm/test/MC/RISCV/rv64zcmt-valid.s

Index: llvm/test/MC/RISCV/rv64zcmt-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmt-valid.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zcmt\
+# RUN:  -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zcmt\
+# RUN:  -mattr=m < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcmt\
+# RUN:  -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.jt 1
+# CHECK-ASM: encoding: [0x06,0xa0]
+cm.jt 1
+
+# CHECK-ASM: cm.jalt 1
+# CHECK-OBJ: cm.jt 1
+# CHECK-ASM: encoding: [0x06,0xa0]
+cm.jalt 1
+
+# CHECK-ASM-AND-OBJ: cm.jalt 64
+# CHECK-ASM: encoding: [0x02,0xa1]
+cm.jalt 64
Index: llvm/test/MC/RISCV/rv64zcmt-Invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zcmt-Invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv64 -mattr=+experimental-zcmt -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: error: immediate must be an integer in the range [0, 63]
+cm.jt 64
Index: llvm/test/MC/RISCV/rv32zcmt-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zcmt-valid.s
@@ -0,0 +1,21 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zcmt\
+# RUN:  -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zcmt\
+# RUN:  -mattr=m < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zcmt\
+# RUN:  -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefixes=CHECK-OBJ,CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: cm.jt 1
+# CHECK-ASM: encoding: [0x06,0xa0]
+cm.jt 1
+
+# CHECK-ASM: cm.jalt 1
+# CHECK-OBJ: cm.jt 1
+# CHECK-ASM: encoding: [0x06,0xa0]
+cm.jalt 1
+
+# CHECK-ASM-AND-OBJ: cm.jalt 64
+# CHECK-ASM: encoding: [0x02,0xa1]
+cm.jalt 64
Index: llvm/test/MC/RISCV/rv32zcmt-Invalid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zcmt-Invalid.s
@@ -0,0 +1,5 @@
+# RUN: not llvm-mc -triple=riscv32 -mattr=+experimental-zcmt -riscv-no-aliases -show-encoding < %s 2>&1 \
+# RUN: | FileCheck -check-prefixes=CHECK-ERROR %s
+
+# CHECK-ERROR: error: immediate must be an integer in the range [0, 63]
+cm.jt 64
Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -196,3 +196,6 @@
 
 .attribute arch, "rv32izca0p70"
 # CHECK: attribute  5, "rv32i2p0_zca0p70"
+
+.attribute arch, "rv32izcmt0p70"
+# CHECK: attribute  5, "rv32i2p0_zca0p70_zcmt0p70"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -42,6 +42,7 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+zicbom %s -o - | FileCheck --check-prefix=RV32ZICBOM %s
 ; RUN: llc -mtriple=riscv32 -mattr=+zicboz %s -o - | FileCheck --check-prefix=RV32ZICBOZ %s
 ; RUN: llc -mtriple=riscv32 -mattr=+zicbop %s -o - | FileCheck --check-prefix=RV32ZICBOP %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcmt %s -o - | FileCheck --check-prefix=RV32ZCMT %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefix=RV64M %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zmmul %s -o - | FileCheck --check-prefix=RV64ZMMUL %s
 ; RUN: llc -mtriple=riscv64 -mattr=+m,+zmmul %s -o - | FileCheck --check-prefix=RV64MZMMUL %s
@@ -84,6 +85,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+zicbom %s -o - | FileCheck --check-prefix=RV64ZICBOM %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zicboz %s -o - | FileCheck --check-prefix=RV64ZICBOZ %s
 ; RUN: llc 

[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc accepted this revision.
kcc added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D133843: [clangd] Prefer definitions for gototype and implementation

2022-09-14 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

There's no test here, can you describe the cases you expect this to affect and 
why the new behavior is better?

For types this seems doubly-dubious at first glance:

- when we've decided to "prefer" a non-definition declaration, why make an 
exception here?
- I'd expect the definition to almost-always be the preferred declaration 
anyway.

For implementation, I think I there's a good argument for this behavior: the 
purpose of the command is to cut through abstractions to see what this method 
does in practice, and finding the definition fits with that. I'm happy with 
this behavior but I think it deserves a comment.
(There's also a bad argument: users think "implementation" means definition - 
just because the name is ambiguous doesn't mean we should implement both 
behaviors!)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133843

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


[PATCH] D132608: [CMake] Clean up CMake binary dir handling

2022-09-14 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added a comment.

Is it a good idea to define variables starting with `CMAKE`? That might be 
confusing for later maintenance by other developers because chances are that 
they will think those variables are CMake provided variables, try to look up 
into CMake document to see what they are, and then find out they are not at all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132608

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


[PATCH] D133804: Cuda Check for ignored return errors from api calls to cuda

2022-09-14 Thread Bartłomiej Cieślar via Phabricator via cfe-commits
barcisz updated this revision to Diff 460261.
barcisz added a comment.

Removed unneeded headers from the check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133804

Files:
  clang-tools-extra/-
  clang-tools-extra/clang-tidy/cuda/CMakeLists.txt
  clang-tools-extra/clang-tidy/cuda/CudaTidyModule.cpp
  clang-tools-extra/clang-tidy/cuda/UnsafeApiCallCheck.cpp
  clang-tools-extra/clang-tidy/cuda/UnsafeApiCallCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cuda/.keep
  clang-tools-extra/docs/clang-tidy/checks/cuda/unsafe-api-call.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda_runtime.h
  clang-tools-extra/test/clang-tidy/checkers/cuda/.keep
  
clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
  
clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu

Index: clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu
@@ -0,0 +1,96 @@
+// RUN: %check_clang_tidy %s cuda-unsafe-api-call %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: cuda-unsafe-api-call.HandlerName, \
+// RUN:   value: 'CUDA_HANDLER'}] \
+// RUN: }" \
+// RUN:   -- -isystem %clang_tidy_headers -std=c++14
+#include 
+
+class DummyContainer {
+ public:
+  int* begin();
+  int* end();
+};
+
+#define DUMMY_CUDA_HANDLER(stmt) stmt
+#define CUDA_HANDLER(stmt) do {auto err = stmt;} while(0)
+#define API_CALL() do {cudaDeviceReset();} while(0)
+
+void errorCheck();
+void errorCheck(cudaError_t error);
+
+void bad() {
+  API_CALL();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // There isn't supposed to be a fix here since it's a macro call
+
+  cudaDeviceReset();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // CHECK-FIXES:  {{^}}  CUDA_HANDLER(cudaDeviceReset());{{$}}
+  errorCheck();
+
+  if (true)
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  while (true)
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  do
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+  while(false);
+
+  switch (0) {
+case 0:
+  cudaDeviceReset();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // CHECK-FIXES:  {{^}}  CUDA_HANDLER(cudaDeviceReset());{{$}}
+  }
+
+  for(
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+;
+cudaDeviceReset()
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset()){{$}}
+  ) cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}  ) CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  for(int i : DummyContainer())
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  auto x = ({
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+true;
+  });
+}
+
+int good() {
+  DUMMY_CUDA_HANDLER(cudaDeviceReset());
+
+  if (cudaDeviceReset()) {
+return 0;
+  }
+
+  switch (cudaDeviceReset()) {
+case cudaErrorInvalidValue: return 1;
+case cudaErrorMemoryAllocation: return 2;
+default: return 3;
+  }
+
+  auto err = ({cudaDeviceReset();});
+  // NOTE: We don't check that `errorCheck()` actually handles the error; we just assume it does.
+  errorCheck(cudaDeviceReset());
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
@@ -0,0 +1,71 @@
+// RUN: %check_clang_tidy %s cuda-unsafe-api-call %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: cuda-unsafe-api-call.HandlerName, \
+// RUN:   

[PATCH] D133804: Cuda Check for ignored return errors from api calls to cuda

2022-09-14 Thread Bartłomiej Cieślar via Phabricator via cfe-commits
barcisz updated this revision to Diff 460258.
barcisz added a comment.

Removed unneeded headers from the check


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133804

Files:
  clang-tools-extra/-
  clang-tools-extra/clang-tidy/cuda/CMakeLists.txt
  clang-tools-extra/clang-tidy/cuda/CudaTidyModule.cpp
  clang-tools-extra/clang-tidy/cuda/UnsafeApiCallCheck.cpp
  clang-tools-extra/clang-tidy/cuda/UnsafeApiCallCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cuda/.keep
  clang-tools-extra/docs/clang-tidy/checks/cuda/unsafe-api-call.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda_runtime.h
  clang-tools-extra/test/clang-tidy/checkers/cuda/.keep
  
clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
  
clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu

Index: clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu
@@ -0,0 +1,96 @@
+// RUN: %check_clang_tidy %s cuda-unsafe-api-call %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: cuda-unsafe-api-call.HandlerName, \
+// RUN:   value: 'CUDA_HANDLER'}] \
+// RUN: }" \
+// RUN:   -- -isystem %clang_tidy_headers -std=c++14
+#include 
+
+class DummyContainer {
+ public:
+  int* begin();
+  int* end();
+};
+
+#define DUMMY_CUDA_HANDLER(stmt) stmt
+#define CUDA_HANDLER(stmt) do {auto err = stmt;} while(0)
+#define API_CALL() do {cudaDeviceReset();} while(0)
+
+void errorCheck();
+void errorCheck(cudaError_t error);
+
+void bad() {
+  API_CALL();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // There isn't supposed to be a fix here since it's a macro call
+
+  cudaDeviceReset();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // CHECK-FIXES:  {{^}}  CUDA_HANDLER(cudaDeviceReset());{{$}}
+  errorCheck();
+
+  if (true)
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  while (true)
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  do
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+  while(false);
+
+  switch (0) {
+case 0:
+  cudaDeviceReset();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // CHECK-FIXES:  {{^}}  CUDA_HANDLER(cudaDeviceReset());{{$}}
+  }
+
+  for(
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+;
+cudaDeviceReset()
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset()){{$}}
+  ) cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}  ) CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  for(int i : DummyContainer())
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  auto x = ({
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+true;
+  });
+}
+
+int good() {
+  DUMMY_CUDA_HANDLER(cudaDeviceReset());
+
+  if (cudaDeviceReset()) {
+return 0;
+  }
+
+  switch (cudaDeviceReset()) {
+case cudaErrorInvalidValue: return 1;
+case cudaErrorMemoryAllocation: return 2;
+default: return 3;
+  }
+
+  auto err = ({cudaDeviceReset();});
+  // NOTE: We don't check that `errorCheck()` actually handles the error; we just assume it does.
+  errorCheck(cudaDeviceReset());
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
@@ -0,0 +1,71 @@
+// RUN: %check_clang_tidy %s cuda-unsafe-api-call %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: cuda-unsafe-api-call.HandlerName, \
+// RUN:   

[PATCH] D133804: Cuda Check for ignored return errors from api calls to cuda

2022-09-14 Thread Bartłomiej Cieślar via Phabricator via cfe-commits
barcisz updated this revision to Diff 460256.
barcisz added a comment.

Brought back different message prefix for when AcceptedHandlers is set


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133804

Files:
  clang-tools-extra/-
  clang-tools-extra/clang-tidy/cuda/CMakeLists.txt
  clang-tools-extra/clang-tidy/cuda/CudaTidyModule.cpp
  clang-tools-extra/clang-tidy/cuda/UnsafeApiCallCheck.cpp
  clang-tools-extra/clang-tidy/cuda/UnsafeApiCallCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cuda/.keep
  clang-tools-extra/docs/clang-tidy/checks/cuda/unsafe-api-call.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda_runtime.h
  clang-tools-extra/test/clang-tidy/checkers/cuda/.keep
  
clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
  
clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu

Index: clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu
@@ -0,0 +1,96 @@
+// RUN: %check_clang_tidy %s cuda-unsafe-api-call %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: cuda-unsafe-api-call.HandlerName, \
+// RUN:   value: 'CUDA_HANDLER'}] \
+// RUN: }" \
+// RUN:   -- -isystem %clang_tidy_headers -std=c++14
+#include 
+
+class DummyContainer {
+ public:
+  int* begin();
+  int* end();
+};
+
+#define DUMMY_CUDA_HANDLER(stmt) stmt
+#define CUDA_HANDLER(stmt) do {auto err = stmt;} while(0)
+#define API_CALL() do {cudaDeviceReset();} while(0)
+
+void errorCheck();
+void errorCheck(cudaError_t error);
+
+void bad() {
+  API_CALL();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // There isn't supposed to be a fix here since it's a macro call
+
+  cudaDeviceReset();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // CHECK-FIXES:  {{^}}  CUDA_HANDLER(cudaDeviceReset());{{$}}
+  errorCheck();
+
+  if (true)
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  while (true)
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  do
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+  while(false);
+
+  switch (0) {
+case 0:
+  cudaDeviceReset();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // CHECK-FIXES:  {{^}}  CUDA_HANDLER(cudaDeviceReset());{{$}}
+  }
+
+  for(
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+;
+cudaDeviceReset()
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset()){{$}}
+  ) cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}  ) CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  for(int i : DummyContainer())
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  auto x = ({
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+true;
+  });
+}
+
+int good() {
+  DUMMY_CUDA_HANDLER(cudaDeviceReset());
+
+  if (cudaDeviceReset()) {
+return 0;
+  }
+
+  switch (cudaDeviceReset()) {
+case cudaErrorInvalidValue: return 1;
+case cudaErrorMemoryAllocation: return 2;
+default: return 3;
+  }
+
+  auto err = ({cudaDeviceReset();});
+  // NOTE: We don't check that `errorCheck()` actually handles the error; we just assume it does.
+  errorCheck(cudaDeviceReset());
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
@@ -0,0 +1,71 @@
+// RUN: %check_clang_tidy %s cuda-unsafe-api-call %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: 

[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem marked 3 inline comments as done.
Navidem added inline comments.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:15
+extern "C" void __sanitizer_cov_cfs_init(const uintptr_t *cfs_beg,
+ const uintptr_t *cfs_end) {
+  CFS_BEG = (uintptr_t *)cfs_beg;

vitalybuka wrote:
> Navidem wrote:
> > vitalybuka wrote:
> > > vitalybuka wrote:
> > > > would you like to add some printing function as for other coverage 
> > > > types?
> > > actually printing can be don't in follow up patch, but it may simplify 
> > > the test, you will not need iterate it in the test.
> > > actually printing can be don't in follow up patch, but it may simplify 
> > > the test, you will not need iterate it in the test.
> > 
> > I'm not sure I follow what you are suggesting.
> Check this out D108405
> then you can hook your data into DumpCoverage() 
> then you can replace entire "while (pt < CFS_END) {" loop with set of CHECK:
> Check this out D108405
> then you can hook your data into DumpCoverage() 
> then you can replace entire "while (pt < CFS_END) {" loop with set of CHECK:

I see, thanks for the pointer. I think I leave it for later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem updated this revision to Diff 460251.
Navidem added a comment.

Use CHECK-DAG and separate function for checking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
@@ -0,0 +1,22 @@
+; Test -sanitizer-coverage-control-flow.
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-control-flow -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo(ptr %a) sanitize_address {
+entry:
+  %tobool = icmp eq i32* %a, null
+  br i1 %tobool, label %if.end, label %if.then
+
+  if.then:  ; preds = %entry
+  store i32 0, i32* %a, align 4
+  call void @foo(i32* %a)
+  br label %if.end
+
+  if.end:   ; preds = %entry, %if.then
+  ret void
+}
+
+; CHECK: private constant [17 x ptr] [{{.*}}@foo{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}@foo{{.*}}null{{.*}}null], section "__sancov_cfs", comdat($foo), align 8
+; CHECK:  @__start___sancov_cfs = extern_weak hidden global
+; CHECK-NEXT: @__stop___sancov_cfs = extern_weak hidden global
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -75,11 +75,13 @@
 const char SanCov8bitCountersInitName[] = "__sanitizer_cov_8bit_counters_init";
 const char SanCovBoolFlagInitName[] = "__sanitizer_cov_bool_flag_init";
 const char SanCovPCsInitName[] = "__sanitizer_cov_pcs_init";
+const char SanCovCFsInitName[] = "__sanitizer_cov_cfs_init";
 
 const char SanCovGuardsSectionName[] = "sancov_guards";
 const char SanCovCountersSectionName[] = "sancov_cntrs";
 const char SanCovBoolFlagSectionName[] = "sancov_bools";
 const char SanCovPCsSectionName[] = "sancov_pcs";
+const char SanCovCFsSectionName[] = "sancov_cfs";
 
 const char SanCovLowestStackName[] = "__sancov_lowest_stack";
 
@@ -147,6 +149,10 @@
   cl::desc("max stack depth tracing"),
   cl::Hidden, cl::init(false));
 
+static cl::opt ClCollectCF("sanitizer-coverage-control-flow",
+  cl::desc("collect control flow for each function"),
+  cl::Hidden, cl::init(false));
+
 namespace {
 
 SanitizerCoverageOptions getOptions(int LegacyCoverageLevel) {
@@ -193,6 +199,7 @@
   !Options.Inline8bitCounters && !Options.StackDepth &&
   !Options.InlineBoolFlag && !Options.TraceLoads && !Options.TraceStores)
 Options.TracePCGuard = true; // TracePCGuard is default.
+  Options.CollectControlFlow |= ClCollectCF;
   return Options;
 }
 
@@ -212,6 +219,7 @@
 PostDomTreeCallback PDTCallback);
 
 private:
+  void createFunctionControlFlow(Function );
   void instrumentFunction(Function , DomTreeCallback DTCallback,
   PostDomTreeCallback PDTCallback);
   void InjectCoverageForIndirectCalls(Function ,
@@ -270,6 +278,7 @@
   GlobalVariable *Function8bitCounterArray;  // for inline-8bit-counters.
   GlobalVariable *FunctionBoolArray; // for inline-bool-flag.
   GlobalVariable *FunctionPCsArray;  // for pc-table.
+  GlobalVariable *FunctionCFsArray;  // for control flow table
   SmallVector GlobalsToAppendToUsed;
   SmallVector GlobalsToAppendToCompilerUsed;
 
@@ -378,6 +387,7 @@
   Function8bitCounterArray = nullptr;
   FunctionBoolArray = nullptr;
   FunctionPCsArray = nullptr;
+  FunctionCFsArray = nullptr;
   IntptrTy = Type::getIntNTy(*C, DL->getPointerSizeInBits());
   IntptrPtrTy = PointerType::getUnqual(IntptrTy);
   Type *VoidTy = Type::getVoidTy(*C);
@@ -502,6 +512,15 @@
 IRBuilder<> IRBCtor(Ctor->getEntryBlock().getTerminator());
 IRBCtor.CreateCall(InitFunction, {SecStartEnd.first, SecStartEnd.second});
   }
+
+  if (Ctor && 

[PATCH] D133444: [RISCV] Update error message to not call 'RV32' and 'RV64' an extension.

2022-09-14 Thread Craig Topper 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 rG6106a6d7fe48: [RISCV] Update error message to not call 
RV32 and RV64 an extension. (authored by craig.topper).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133444

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
@@ -3,10 +3,10 @@
 
 int zip(int rs1)
 {
-  return __builtin_riscv_zip_32(rs1); // expected-error {{builtin requires at 
least one of the following extensions to be enabled: 'RV32'}}
+  return __builtin_riscv_zip_32(rs1); // expected-error {{builtin requires: 
'RV32'}}
 }
 
 int unzip(int rs1)
 {
-  return __builtin_riscv_unzip_32(rs1); // expected-error {{builtin requires 
at least one of the following extensions to be enabled: 'RV32'}}
+  return __builtin_riscv_unzip_32(rs1); // expected-error {{builtin requires: 
'RV32'}}
 }
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
@@ -2,5 +2,5 @@
 // RUN: %clang_cc1 -triple riscv32 -target-feature +zbb -verify %s -o -
 
 int orc_b_64(int a) {
-  return __builtin_riscv_orc_b_64(a); // expected-error {{builtin requires at 
least one of the following extensions to be enabled: 'RV64'}}
+  return __builtin_riscv_orc_b_64(a); // expected-error {{builtin requires: 
'RV64'}}
 }
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -4369,13 +4369,20 @@
 if (llvm::none_of(ReqOpFeatures,
   [](StringRef OF) { return TI.hasFeature(OF); })) {
   std::string FeatureStrs;
+  bool IsExtension = true;
   for (StringRef OF : ReqOpFeatures) {
 // If the feature is 64bit, alter the string so it will print better in
 // the diagnostic.
-if (OF == "64bit")
+if (OF == "64bit") {
+  assert(ReqOpFeatures.size() == 1 && "Expected '64bit' to be alone");
   OF = "RV64";
-if (OF == "32bit")
+  IsExtension = false;
+}
+if (OF == "32bit") {
+  assert(ReqOpFeatures.size() == 1 && "Expected '32bit' to be alone");
   OF = "RV32";
+  IsExtension = false;
+}
 
 // Convert features like "zbr" and "experimental-zbr" to "Zbr".
 OF.consume_front("experimental-");
@@ -4390,6 +4397,7 @@
   // Error message
   FeatureMissing = true;
   Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_requires_extension)
+  << IsExtension
   << TheCall->getSourceRange() << StringRef(FeatureStrs);
 }
   }
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11636,7 +11636,7 @@
 
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
-  "builtin requires at least one of the following extensions to be enabled: 
%0">;
+  "builtin requires%select{| at least one of the following extensions to be 
enabled}0: %1">;
 def err_riscv_builtin_invalid_lmul : Error<
   "LMUL argument must be in the range [0,3] or [5,7]">;
 


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
@@ -3,10 +3,10 @@
 
 int zip(int rs1)
 {
-  return __builtin_riscv_zip_32(rs1); // expected-error {{builtin requires at least one of the following extensions to be enabled: 'RV32'}}
+  return __builtin_riscv_zip_32(rs1); // expected-error {{builtin requires: 'RV32'}}
 }
 
 int unzip(int rs1)
 {
-  return __builtin_riscv_unzip_32(rs1); // expected-error {{builtin requires at least one of the following extensions to be enabled: 'RV32'}}
+  return __builtin_riscv_unzip_32(rs1); // expected-error {{builtin requires: 'RV32'}}
 }
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
+++ 

[clang] 6106a6d - [RISCV] Update error message to not call 'RV32' and 'RV64' an extension.

2022-09-14 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2022-09-14T14:51:37-07:00
New Revision: 6106a6d7fe48ac26bc39621898b90766e2a10bd0

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

LOG: [RISCV] Update error message to not call 'RV32' and 'RV64' an extension.

I used RV32 so I didn't have to write RV32I and RV32E. Ideally
these builtins will be wrapped in a header someday so long term I don't
expect users to see these errors.

Reviewed By: asb

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

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Sema/SemaChecking.cpp
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 016affb1b3236..97ccc2a98c93b 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -11636,7 +11636,7 @@ def warn_tcb_enforcement_violation : Warning<
 
 // RISC-V builtin required extension warning
 def err_riscv_builtin_requires_extension : Error<
-  "builtin requires at least one of the following extensions to be enabled: 
%0">;
+  "builtin requires%select{| at least one of the following extensions to be 
enabled}0: %1">;
 def err_riscv_builtin_invalid_lmul : Error<
   "LMUL argument must be in the range [0,3] or [5,7]">;
 

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index 53c108356316e..bc9642d17d852 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -4369,13 +4369,20 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const 
TargetInfo ,
 if (llvm::none_of(ReqOpFeatures,
   [](StringRef OF) { return TI.hasFeature(OF); })) {
   std::string FeatureStrs;
+  bool IsExtension = true;
   for (StringRef OF : ReqOpFeatures) {
 // If the feature is 64bit, alter the string so it will print better in
 // the diagnostic.
-if (OF == "64bit")
+if (OF == "64bit") {
+  assert(ReqOpFeatures.size() == 1 && "Expected '64bit' to be alone");
   OF = "RV64";
-if (OF == "32bit")
+  IsExtension = false;
+}
+if (OF == "32bit") {
+  assert(ReqOpFeatures.size() == 1 && "Expected '32bit' to be alone");
   OF = "RV32";
+  IsExtension = false;
+}
 
 // Convert features like "zbr" and "experimental-zbr" to "Zbr".
 OF.consume_front("experimental-");
@@ -4390,6 +4397,7 @@ bool Sema::CheckRISCVBuiltinFunctionCall(const TargetInfo 
,
   // Error message
   FeatureMissing = true;
   Diag(TheCall->getBeginLoc(), diag::err_riscv_builtin_requires_extension)
+  << IsExtension
   << TheCall->getSourceRange() << StringRef(FeatureStrs);
 }
   }

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
index 5952443b0944a..cb90a26c3b0cd 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
@@ -2,5 +2,5 @@
 // RUN: %clang_cc1 -triple riscv32 -target-feature +zbb -verify %s -o -
 
 int orc_b_64(int a) {
-  return __builtin_riscv_orc_b_64(a); // expected-error {{builtin requires at 
least one of the following extensions to be enabled: 'RV64'}}
+  return __builtin_riscv_orc_b_64(a); // expected-error {{builtin requires: 
'RV64'}}
 }

diff  --git a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c 
b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
index b783a3546acc8..d580d70ee4d36 100644
--- a/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
+++ b/clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbkb-error.c
@@ -3,10 +3,10 @@
 
 int zip(int rs1)
 {
-  return __builtin_riscv_zip_32(rs1); // expected-error {{builtin requires at 
least one of the following extensions to be enabled: 'RV32'}}
+  return __builtin_riscv_zip_32(rs1); // expected-error {{builtin requires: 
'RV32'}}
 }
 
 int unzip(int rs1)
 {
-  return __builtin_riscv_unzip_32(rs1); // expected-error {{builtin requires 
at least one of the following extensions to be enabled: 'RV32'}}
+  return __builtin_riscv_unzip_32(rs1); // expected-error {{builtin requires: 
'RV32'}}
 }



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


[PATCH] D133711: [Sema] Reject array element types whose sizes aren't a multiple of their alignments

2022-09-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

This seems like a new error that will be pretty easy to run into, especially in 
the funky MSVC virtual base case. @aaron.ballman proposed some kind of new 
breaking change announcement mechanism. Can you add a release note and send an 
announcement following that process? I think it's just posting to Discourse 
announcements.

Overall this seems like the right thing to do.




Comment at: clang/test/Layout/ms-x86-misalignedarray.cpp:10
+#ifdef _ILP32
+// expected-error@-3 {{size of array element}}
+#endif

I think what I had in mind when I said let's not change record layout is, let's 
keep doing what we were doing if we are targeting MSVC. But, what you've done 
is principled, so if we can ship it, it would be for the best.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133711

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


[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Kostya Serebryany via Phabricator via cfe-commits
kcc added inline comments.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:24
+int main() {
+  int (*main_ptr)() = 
+  void (*foo_ptr)(int) = 

syntax nit:
  auto main_ptr = 



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:33
+
+  printf("Control Flow section boundaries: [%p %p)\n", CFS_BEG, CFS_END);
+  uintptr_t *pt = CFS_BEG;

I suggest you move this to a separate function, called from main()



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:67
+// CHECK: Control Flow section boundaries
+// CHECK: Saw the foo().
+// CHECK: Saw the main().

I don't think you are guaranteed to have main and foo in this order, and 
similarly dir vs indir call in this order. 
So, use CHECK-DAG instead of CHECK for these four lines. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:15
+extern "C" void __sanitizer_cov_cfs_init(const uintptr_t *cfs_beg,
+ const uintptr_t *cfs_end) {
+  CFS_BEG = (uintptr_t *)cfs_beg;

Navidem wrote:
> vitalybuka wrote:
> > vitalybuka wrote:
> > > would you like to add some printing function as for other coverage types?
> > actually printing can be don't in follow up patch, but it may simplify the 
> > test, you will not need iterate it in the test.
> > actually printing can be don't in follow up patch, but it may simplify the 
> > test, you will not need iterate it in the test.
> 
> I'm not sure I follow what you are suggesting.
Check this out D108405
then you can hook your data into DumpCoverage() 
then you can replace entire "while (pt < CFS_END) {" loop with set of CHECK:


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem marked an inline comment as done.
Navidem added inline comments.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:15
+extern "C" void __sanitizer_cov_cfs_init(const uintptr_t *cfs_beg,
+ const uintptr_t *cfs_end) {
+  CFS_BEG = (uintptr_t *)cfs_beg;

vitalybuka wrote:
> vitalybuka wrote:
> > would you like to add some printing function as for other coverage types?
> actually printing can be don't in follow up patch, but it may simplify the 
> test, you will not need iterate it in the test.
> actually printing can be don't in follow up patch, but it may simplify the 
> test, you will not need iterate it in the test.

I'm not sure I follow what you are suggesting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D133622: [clang][test] Disallow using the default module cache path in lit tests

2022-09-14 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir added a comment.

In D133622#3788218 , @bruno wrote:

>> I'm not sure how to deal with missing `env -u`.
>>
>> - We could do `env CLANG_MODULE_CACHE_PATH=` and change the compiler's 
>> interpretation of empty string for this variable. I'm not sure if the 
>> current behaviour (there will be no module cache in the cc1 at all) is 
>> intentional or useful.  Hesitant to change this behaviour.
>
> How about using `self.with_environment('CLANG_MODULE_CACHE_PATH', '')` so we 
> don't need to worry about using `env -u` to unset? My understand is that (1) 
> `getDefaultModuleCachePath` is the only place using 
> `CLANG_MODULE_CACHE_PATH`, and (2) `std::getenv` return nullptr if it's 
> empty, which will fallback to system provided path instead.

Where are you thinking we would call `self.with_environment` in this case? We 
explicitly do not want the system-provided path in most tests.  I think we 
would need to set it to `None`, since

> (2) `std::getenv` return nullptr if it's empty, which will fallback to system 
> provided path instead.

getenv returns empty string, not nullptr.

> Not sure it helps much but according to `option-X.test`, `system-aix` support 
> `unset`.

Heh, I'm worried we'll just hit an issue with a different platform (Windows?).  
If we can't find a better fix I guess I can at least attempt it and see what 
breaks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133622

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


[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem updated this revision to Diff 460232.
Navidem added a comment.

Enhance rt test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
@@ -0,0 +1,22 @@
+; Test -sanitizer-coverage-control-flow.
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-control-flow -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo(ptr %a) sanitize_address {
+entry:
+  %tobool = icmp eq i32* %a, null
+  br i1 %tobool, label %if.end, label %if.then
+
+  if.then:  ; preds = %entry
+  store i32 0, i32* %a, align 4
+  call void @foo(i32* %a)
+  br label %if.end
+
+  if.end:   ; preds = %entry, %if.then
+  ret void
+}
+
+; CHECK: private constant [17 x ptr] [{{.*}}@foo{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}@foo{{.*}}null{{.*}}null], section "__sancov_cfs", comdat($foo), align 8
+; CHECK:  @__start___sancov_cfs = extern_weak hidden global
+; CHECK-NEXT: @__stop___sancov_cfs = extern_weak hidden global
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -75,11 +75,13 @@
 const char SanCov8bitCountersInitName[] = "__sanitizer_cov_8bit_counters_init";
 const char SanCovBoolFlagInitName[] = "__sanitizer_cov_bool_flag_init";
 const char SanCovPCsInitName[] = "__sanitizer_cov_pcs_init";
+const char SanCovCFsInitName[] = "__sanitizer_cov_cfs_init";
 
 const char SanCovGuardsSectionName[] = "sancov_guards";
 const char SanCovCountersSectionName[] = "sancov_cntrs";
 const char SanCovBoolFlagSectionName[] = "sancov_bools";
 const char SanCovPCsSectionName[] = "sancov_pcs";
+const char SanCovCFsSectionName[] = "sancov_cfs";
 
 const char SanCovLowestStackName[] = "__sancov_lowest_stack";
 
@@ -147,6 +149,10 @@
   cl::desc("max stack depth tracing"),
   cl::Hidden, cl::init(false));
 
+static cl::opt ClCollectCF("sanitizer-coverage-control-flow",
+  cl::desc("collect control flow for each function"),
+  cl::Hidden, cl::init(false));
+
 namespace {
 
 SanitizerCoverageOptions getOptions(int LegacyCoverageLevel) {
@@ -193,6 +199,7 @@
   !Options.Inline8bitCounters && !Options.StackDepth &&
   !Options.InlineBoolFlag && !Options.TraceLoads && !Options.TraceStores)
 Options.TracePCGuard = true; // TracePCGuard is default.
+  Options.CollectControlFlow |= ClCollectCF;
   return Options;
 }
 
@@ -212,6 +219,7 @@
 PostDomTreeCallback PDTCallback);
 
 private:
+  void createFunctionControlFlow(Function );
   void instrumentFunction(Function , DomTreeCallback DTCallback,
   PostDomTreeCallback PDTCallback);
   void InjectCoverageForIndirectCalls(Function ,
@@ -270,6 +278,7 @@
   GlobalVariable *Function8bitCounterArray;  // for inline-8bit-counters.
   GlobalVariable *FunctionBoolArray; // for inline-bool-flag.
   GlobalVariable *FunctionPCsArray;  // for pc-table.
+  GlobalVariable *FunctionCFsArray;  // for control flow table
   SmallVector GlobalsToAppendToUsed;
   SmallVector GlobalsToAppendToCompilerUsed;
 
@@ -378,6 +387,7 @@
   Function8bitCounterArray = nullptr;
   FunctionBoolArray = nullptr;
   FunctionPCsArray = nullptr;
+  FunctionCFsArray = nullptr;
   IntptrTy = Type::getIntNTy(*C, DL->getPointerSizeInBits());
   IntptrPtrTy = PointerType::getUnqual(IntptrTy);
   Type *VoidTy = Type::getVoidTy(*C);
@@ -502,6 +512,15 @@
 IRBuilder<> IRBCtor(Ctor->getEntryBlock().getTerminator());
 IRBCtor.CreateCall(InitFunction, {SecStartEnd.first, SecStartEnd.second});
   }
+
+  if (Ctor && Options.CollectControlFlow) {
+auto SecStartEnd = 

[PATCH] D133875: [clang] fix generation of .debug_aranges with LTO (resubmit)

2022-09-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/test/Driver/debug-options-aranges.c:1
+// Check that lld will emit dwarf aranges.
+

The message is outdated now. This just checks how -gdwarf-aranges ias passed to 
the compiler and linker.



Comment at: clang/test/Driver/debug-options-aranges.c:3
+
+// RUN: %clang -### -target x86_64-unknown-linux -c -gdwarf-aranges %s 2>&1 | 
FileCheck -check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto -gdwarf-aranges %s 2>&1 
| FileCheck -check-prefix=PLUGIN_GARANGE %s

`--target=x86_64`



Comment at: clang/test/Driver/debug-options-aranges.c:6
+// RUN: %clang -### -target x86_64-unknown-linux -flto=thin -gdwarf-aranges %s 
2>&1 | FileCheck -check-prefix=PLUGIN_GARANGE %s
+//
+// GARANGE: -generate-arange-section

delete empty `//`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133875

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


[PATCH] D132990: [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added inline comments.



Comment at: clang/lib/Sema/SemaTemplate.cpp:1534-1538
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);

mizvekov wrote:
> aaron.ballman wrote:
> > Let's get fancy!
> You would use `getContainedDeducedType` if you expected to handle 
> DeducedTypes in general, not just AutoTypes.
> 
> So if you only want to handle AutoTypes, there is no point in using 
> `getContainedDeducedType`.
I am going to keep the `getContainedDeducedType(...)` b/c I do plan on coming 
back to this and adding the other diagnostic but I won't get fancy at this 
point but will happily consider it on the follow-up.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:310-316
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}

mizvekov wrote:
> I think the issue might not be tested in this file since we do not run it 
> with the `-Wpre-c++17-compat` flag
Good catch, I will just create a standalone `gh57362.cpp` file since this does 
not fit neatly anywhere else. 



Comment at: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx1z.cpp:3-8
+namespace GH57362 {
+template  // expected-warning {{non-type template parameters declared 
with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};
+
+template  // expected-warning {{non-type template parameters 
declared with 'decltype(auto)' are incompatible with C++ standards before 
C++17}}
+struct B{};

mizvekov wrote:
> I don't understand why these cases are grouped under GH57362 issue, they are 
> cases that worked fine without this patch, we just didn't have tests for them.
Good point. 


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

https://reviews.llvm.org/D132990

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


[PATCH] D132990: [Clang] Fix compat diagnostic to detect a nontype template parameter has a placeholder type using getContainedAutoType()

2022-09-14 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik updated this revision to Diff 460229.
shafik marked 6 inline comments as done.
shafik added a comment.

- Updating testing to reflect comments.


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

https://reviews.llvm.org/D132990

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/test/SemaTemplate/gh57362.cpp
  clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp


Index: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+
+template  // expected-warning {{non-type template parameters 
declared with 'decltype(auto)' are incompatible with C++ standards before 
C++17}}
+struct B{};
+
+template  // expected-warning {{non-type template parameters declared 
with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};
Index: clang/test/SemaTemplate/gh57362.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/gh57362.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s
+// expected-no-diagnostics
+
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1531,11 +1531,11 @@
 
   CheckValidDeclSpecifiers();
 
-  if (TInfo->getType()->isUndeducedType()) {
-Diag(D.getIdentifierLoc(),
- diag::warn_cxx14_compat_template_nontype_parm_auto_type)
-  << QualType(TInfo->getType()->getContainedAutoType(), 0);
-  }
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);
 
   assert(S->isTemplateParamScope() &&
  "Non-type template parameter not in template parameter scope!");


Index: clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/temp_arg_nontype_diagnostic_cxx17.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++17 -Wpre-c++17-compat %s
+
+template  // expected-warning {{non-type template parameters declared with 'decltype(auto)' are incompatible with C++ standards before C++17}}
+struct B{};
+
+template  // expected-warning {{non-type template parameters declared with 'auto' are incompatible with C++ standards before C++17}}
+struct A{};
Index: clang/test/SemaTemplate/gh57362.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/gh57362.cpp
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 -Wpre-c++17-compat %s
+// expected-no-diagnostics
+
+namespace GH57362 {
+template 
+class TemplateClass {};
+
+template  // ok, no diagnostic expected
+void func() {}
+}
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -1531,11 +1531,11 @@
 
   CheckValidDeclSpecifiers();
 
-  if (TInfo->getType()->isUndeducedType()) {
-Diag(D.getIdentifierLoc(),
- diag::warn_cxx14_compat_template_nontype_parm_auto_type)
-  << QualType(TInfo->getType()->getContainedAutoType(), 0);
-  }
+  if (const auto *T = TInfo->getType()->getContainedDeducedType())
+if (isa(T))
+  Diag(D.getIdentifierLoc(),
+   diag::warn_cxx14_compat_template_nontype_parm_auto_type)
+  << QualType(TInfo->getType()->getContainedAutoType(), 0);
 
   assert(S->isTemplateParamScope() &&
  "Non-type template parameter not in template parameter scope!");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D132608: [CMake] Clean up CMake binary dir handling

2022-09-14 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 added inline comments.



Comment at: libcxx/CMakeLists.txt:421
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+  set(default_install_path 
"${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+else()

ldionne wrote:
> ldionne wrote:
> > Instead, I'd do this:
> > 
> > ```
> > if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
> >   set(_include_target_dir 
> > "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
> >   set(_install_library_dir 
> > "lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}")
> > else()
> >   set(_include_target_dir "${LIBCXX_INSTALL_INCLUDE_DIR}")
> >   set(_install_library_dir "lib${LLVM_LIBDIR_SUFFIX}")
> > endif()
> > 
> > set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${_include_target_dir}" CACHE PATH
> > "Path where target-specific libc++ headers should be installed.")
> > set(LIBCXX_INSTALL_LIBRARY_DIR "${_install_library_dir}" CACHE PATH
> > "Path where built libc++ libraries should be installed.")
> > ```
> > 
> > IMO that's easier on the eye.
> Gentle ping on this.
Ah right, I have this "throw away temporary style as soon as possible" on all 
the runtimes right now. Would you prefer I do instead do "define all the 
defaults, define all the cache vars" for all of them?

I am a little partial to the current style because if it is closer to what I 
would do if cmake has proper expressions. (something like:
```
set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR
  "${
if(...)
  stuff
else()
 stuff
endif()
  }" CACHE PATH
"Path where target-specific libc++ headers should be 
```
). But if that if you are sure your want it consistently the other way I can 
switch it.

A bigger issue might be when the variables depend on each other, e.g. when I 
get the library install dir base name for the library binary dir.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132608

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


[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

LGTM as-is




Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:15
+extern "C" void __sanitizer_cov_cfs_init(const uintptr_t *cfs_beg,
+ const uintptr_t *cfs_end) {
+  CFS_BEG = (uintptr_t *)cfs_beg;

vitalybuka wrote:
> would you like to add some printing function as for other coverage types?
actually printing can be don't in follow up patch, but it may simplify the 
test, you will not need iterate it in the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D130586: [cmake] Use `CMAKE_INSTALL_LIBDIR` too

2022-09-14 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 460222.
Ericson2314 added a comment.

Rebase, fix some issues (by the looks of it)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D130586

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/Android-stage2.cmake
  clang/cmake/caches/Android.cmake
  clang/cmake/modules/AddClang.cmake
  clang/lib/Headers/CMakeLists.txt
  clang/runtime/CMakeLists.txt
  clang/tools/libclang/CMakeLists.txt
  clang/tools/scan-build-py/CMakeLists.txt
  cmake/Modules/GNUInstallPackageDir.cmake
  cmake/Modules/LLVMLibdirSuffix.cmake
  compiler-rt/cmake/Modules/CompilerRTAIXUtils.cmake
  compiler-rt/cmake/Modules/CompilerRTUtils.cmake
  compiler-rt/cmake/base-config-ix.cmake
  compiler-rt/docs/BuildingCompilerRT.rst
  flang/cmake/modules/AddFlang.cmake
  libc/CMakeLists.txt
  libc/lib/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst
  lld/cmake/modules/AddLLD.cmake
  lldb/cmake/modules/AddLLDB.cmake
  lldb/cmake/modules/LLDBGenerateConfig.cmake
  lldb/source/API/CMakeLists.txt
  lldb/tools/intel-features/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/AddOCaml.cmake
  llvm/cmake/modules/CMakeLists.txt
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/docs/CMake.rst
  llvm/tools/llvm-config/BuildVariables.inc.in
  llvm/tools/llvm-config/llvm-config.cpp
  llvm/utils/gn/secondary/llvm/tools/llvm-config/BUILD.gn
  mlir/CMakeLists.txt
  mlir/cmake/modules/AddMLIR.cmake
  mlir/cmake/modules/AddMLIRPython.cmake
  openmp/CMakeLists.txt
  openmp/README.rst
  polly/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/cmake/polly_macros.cmake
  pstl/CMakeLists.txt
  third-party/benchmark/src/CMakeLists.txt

Index: third-party/benchmark/src/CMakeLists.txt
===
--- third-party/benchmark/src/CMakeLists.txt
+++ third-party/benchmark/src/CMakeLists.txt
@@ -79,7 +79,7 @@
 configure_package_config_file (
   ${PROJECT_SOURCE_DIR}/cmake/Config.cmake.in
   ${project_config}
-  INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}
+  INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}"
   NO_SET_AND_CHECK_MACRO
   NO_CHECK_REQUIRED_COMPONENTS_MACRO
 )
@@ -100,8 +100,8 @@
   install(
 TARGETS ${targets_to_export}
 EXPORT ${targets_export_name}
-ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
 RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
 INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
 
Index: pstl/CMakeLists.txt
===
--- pstl/CMakeLists.txt
+++ pstl/CMakeLists.txt
@@ -88,10 +88,10 @@
 install(EXPORT ParallelSTLTargets
 FILE ParallelSTLTargets.cmake
 NAMESPACE pstl::
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL")
 install(FILES "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfig.cmake"
   "${CMAKE_CURRENT_BINARY_DIR}/ParallelSTLConfigVersion.cmake"
-DESTINATION lib/cmake/ParallelSTL)
+DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/ParallelSTL")
 install(DIRECTORY include/
 DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}"
 PATTERN "*.in" EXCLUDE)
Index: polly/cmake/polly_macros.cmake
===
--- polly/cmake/polly_macros.cmake
+++ polly/cmake/polly_macros.cmake
@@ -44,8 +44,8 @@
   if (NOT LLVM_INSTALL_TOOLCHAIN_ONLY OR ${name} STREQUAL "LLVMPolly")
 install(TARGETS ${name}
   EXPORT LLVMExports
-  LIBRARY DESTINATION lib${LLVM_LIBDIR_SUFFIX}
-  ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX})
+  LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
+  ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
   endif()
   set_property(GLOBAL APPEND PROPERTY LLVM_EXPORTS ${name})
 endmacro(add_polly_library)
Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -7,7 +7,7 @@
 set(POLLY_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/polly" CACHE STRING
   "Path for CMake subdirectory for Polly (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/polly')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(polly_cmake_builddir "${POLLY_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/polly")
+set(polly_cmake_builddir "${POLLY_BINARY_LIBDIR}/cmake/polly")
 
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
@@ -61,7 +61,7 @@
 set(POLLY_CONFIG_INCLUDE_DIRS
   

[PATCH] D133711: [Sema] Reject array element types whose sizes aren't a multiple of their alignments

2022-09-14 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma 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/D133711/new/

https://reviews.llvm.org/D133711

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


[PATCH] D111509: [clang] use getCommonSugar in an assortment of places

2022-09-14 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 460220.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111509

Files:
  clang-tools-extra/clangd/unittests/tweaks/ExtractVariableTests.cpp
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/narrowing-conversions-ignoreconversionfromtypes-option.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/test/AST/ast-dump-fpfeatures.cpp
  clang/test/CodeGen/compound-assign-overflow.c
  clang/test/Sema/complex-int.c
  clang/test/Sema/matrix-type-operators.c
  clang/test/Sema/nullability.c
  clang/test/Sema/sugar-common-types.c
  clang/test/SemaCXX/complex-conversion.cpp
  clang/test/SemaCXX/matrix-type-operators.cpp
  clang/test/SemaCXX/sugar-common-types.cpp
  clang/test/SemaCXX/sugared-auto.cpp
  clang/test/SemaObjC/format-strings-objc.m
  compiler-rt/test/ubsan/TestCases/Integer/add-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/no-recover.cpp
  compiler-rt/test/ubsan/TestCases/Integer/sub-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
  compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
  libcxx/DELETE.ME
  lldb/test/API/commands/expression/rdar42038760/main.c
  lldb/test/API/commands/expression/rdar44436068/main.c

Index: lldb/test/API/commands/expression/rdar44436068/main.c
===
--- lldb/test/API/commands/expression/rdar44436068/main.c
+++ lldb/test/API/commands/expression/rdar44436068/main.c
@@ -3,6 +3,6 @@
 __int128_t n = 1;
 n = n + n;
 return n; //%self.expect("p n", substrs=['(__int128_t) $0 = 2'])
-  //%self.expect("p n + 6", substrs=['(__int128) $1 = 8'])
-  //%self.expect("p n + n", substrs=['(__int128) $2 = 4'])
+  //%self.expect("p n + 6", substrs=['(__int128_t) $1 = 8'])
+  //%self.expect("p n + n", substrs=['(__int128_t) $2 = 4'])
 }
Index: lldb/test/API/commands/expression/rdar42038760/main.c
===
--- lldb/test/API/commands/expression/rdar42038760/main.c
+++ lldb/test/API/commands/expression/rdar42038760/main.c
@@ -10,7 +10,7 @@
   struct S0 l_19;
   l_19.f2 = 419;
   uint32_t l_4037 = 4294967295UL;
-  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(unsigned int) $0 = 358717883'])
+  l_19.f2 = g_463; //%self.expect("expr ((l_4037 % (-(g_463))) | l_19.f2)", substrs=['(uint32_t) $0 = 358717883'])
 }
 int main()
 {
Index: libcxx/DELETE.ME
===
--- /dev/null
+++ libcxx/DELETE.ME
@@ -0,0 +1 @@
+D111509
Index: compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/usub-overflow.cpp
@@ -12,12 +12,12 @@
 
 #ifdef SUB_I32
   (void)(uint32_t(1) - uint32_t(2));
-  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type 'unsigned int'
+  // CHECK-SUB_I32: usub-overflow.cpp:[[@LINE-1]]:22: runtime error: unsigned integer overflow: 1 - 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 #endif
 
 #ifdef SUB_I64
   (void)(uint64_t(800ll) - uint64_t(900ll));
-  // CHECK-SUB_I64: 800 - 900 cannot be represented in type 'unsigned {{long( long)?}}'
+  // CHECK-SUB_I64: 800 - 900 cannot be represented in type '{{uint64_t|unsigned long( long)?}}'
 #endif
 
 #ifdef SUB_I128
@@ -26,6 +26,6 @@
 # else
   puts("__int128 not supported\n");
 # endif
-  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type 'unsigned __int128'|__int128 not supported}}
+  // CHECK-SUB_I128: {{0x4000 - 0x8000 cannot be represented in type '__uint128_t'|__int128 not supported}}
 #endif
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
===
--- compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
+++ compiler-rt/test/ubsan/TestCases/Integer/umul-overflow.cpp
@@ -13,7 +13,7 @@
   (void)(uint16_t(0x) * uint16_t(0x8001));
 
   (void)(uint32_t(0x) * uint32_t(0x2));
-  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type 'unsigned int'
+  // CHECK: umul-overflow.cpp:15:31: runtime error: unsigned integer overflow: 4294967295 * 2 cannot be represented in type '{{uint32_t|unsigned int}}'
 
   return 0;
 }
Index: compiler-rt/test/ubsan/TestCases/Integer/uadd-overflow.cpp

[PATCH] D133261: NFC: [clang] add template AST test for make_integer_seq and type_pack_element

2022-09-14 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov updated this revision to Diff 460219.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133261

Files:
  clang/test/SemaTemplate/make_integer_seq.cpp
  clang/test/SemaTemplate/type_pack_element.cpp

Index: clang/test/SemaTemplate/type_pack_element.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/type_pack_element.cpp
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -triple x86_64-linux-gnu -ast-dump -verify -xc++ < %s | FileCheck %s
+
+using test1 = __type_pack_element<0, int>;
+//  CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}} <:3:1, col:41> col:7 test1 '__type_pack_element<0, int>':'int'
+// CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, int>' sugar
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, int>' sugar __type_pack_element
+// CHECK-NEXT:   |-TemplateArgument expr
+// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'unsigned long'
+// CHECK-NEXT:   |   |-value: Int 0
+// CHECK-NEXT:   |   `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}}  'unsigned long' 
+// CHECK-NEXT:   | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 0
+// CHECK-NEXT:   |-TemplateArgument type 'int'
+// CHECK-NEXT:   | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+// CHECK-NEXT:   `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+
+template struct A {
+  using test2 = __type_pack_element;
+//  CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:9 test2 '__type_pack_element':'__type_pack_element'
+// CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element' sugar dependent
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element' dependent __type_pack_element
+// CHECK-NEXT:   |-TemplateArgument expr
+// CHECK-NEXT:   | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}}  'unsigned long' 
+// CHECK-NEXT:   |   `-DeclRefExpr 0x{{[0-9A-Fa-f]+}}  'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
+// CHECK-NEXT:   `-TemplateArgument type 'Ts...'
+// CHECK-NEXT: `-PackExpansionType 0x{{[0-9A-Fa-f]+}} 'Ts...' dependent
+// CHECK-NEXT:   `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack
+// CHECK-NEXT: `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'Ts'
+
+  using test3 = __type_pack_element<0, Ts...>;
+//  CHECK: |-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:9 test3 '__type_pack_element<0, Ts...>':'__type_pack_element<0, Ts...>'
+// CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, Ts...>' sugar dependent
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element<0, Ts...>' dependent __type_pack_element
+// CHECK-NEXT:   |-TemplateArgument expr
+// CHECK-NEXT:   | `-ConstantExpr 0x{{[0-9A-Fa-f]+}}  'unsigned long'
+// CHECK-NEXT:   |   |-value: Int 0
+// CHECK-NEXT:   |   `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}}  'unsigned long' 
+// CHECK-NEXT:   | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 0
+// CHECK-NEXT:   `-TemplateArgument type 'Ts...'
+// CHECK-NEXT: `-PackExpansionType 0x{{[0-9A-Fa-f]+}} 'Ts...' dependent
+// CHECK-NEXT:   `-TemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'Ts' dependent contains_unexpanded_pack depth 0 index 1 pack
+// CHECK-NEXT: `-TemplateTypeParm 0x{{[0-9A-Fa-f]+}} 'Ts'
+
+  using test4 = __type_pack_element;
+//  CHECK: `-TypeAliasDecl 0x{{[0-9A-Fa-f]+}}  col:9 test4 '__type_pack_element':'__type_pack_element'
+// CHECK-NEXT:   `-ElaboratedType 0x{{[0-9A-Fa-f]+}} '__type_pack_element' sugar dependent
+// CHECK-NEXT: `-TemplateSpecializationType 0x{{[0-9A-Fa-f]+}} '__type_pack_element' dependent __type_pack_element
+// CHECK-NEXT:   |-TemplateArgument expr
+// CHECK-NEXT:   | `-ImplicitCastExpr 0x{{[0-9A-Fa-f]+}}  'unsigned long' 
+// CHECK-NEXT:   |   `-DeclRefExpr 0x{{[0-9A-Fa-f]+}}  'int' NonTypeTemplateParm 0x{{[0-9A-Fa-f]+}} 'N' 'int'
+// CHECK-NEXT:   `-TemplateArgument type 'int'
+// CHECK-NEXT: `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
+};
+
+template  struct B; // expected-note {{template is declared here}}
+template  struct B> {};
+template struct B; // expected-error {{explicit instantiation of undefined template}}
+
+template  struct C; // expected-note {{template is declared here}}
+template  struct C> {};
+template struct C; // expected-error {{explicit instantiation of undefined template}}
+
+template  struct D;
+template  struct D<__type_pack_element<0, T, U>> {};
+template  struct D<__type_pack_element<0, U, T>> {};
+
+template  struct E;
+template  struct E<__type_pack_element<0, T>> {};
+template  struct E<__type_pack_element<0, T, U>> {};
Index: clang/test/SemaTemplate/make_integer_seq.cpp
===
--- /dev/null
+++ 

[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:15
+extern "C" void __sanitizer_cov_cfs_init(const uintptr_t *cfs_beg,
+ const uintptr_t *cfs_end) {
+  CFS_BEG = (uintptr_t *)cfs_beg;

would you like to add some printing function as for other coverage types?



Comment at: 
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp:64
+// CHECK: Finished!
\ No newline at end of file


new line



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

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


[PATCH] D132608: [CMake] Clean up CMake binary dir handling

2022-09-14 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added inline comments.



Comment at: libcxx/CMakeLists.txt:421
+if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
+  set(default_install_path 
"${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
+else()

ldionne wrote:
> Instead, I'd do this:
> 
> ```
> if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
>   set(_include_target_dir 
> "${CMAKE_INSTALL_INCLUDEDIR}/${LLVM_DEFAULT_TARGET_TRIPLE}/c++/v1")
>   set(_install_library_dir 
> "lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}")
> else()
>   set(_include_target_dir "${LIBCXX_INSTALL_INCLUDE_DIR}")
>   set(_install_library_dir "lib${LLVM_LIBDIR_SUFFIX}")
> endif()
> 
> set(LIBCXX_INSTALL_INCLUDE_TARGET_DIR "${_include_target_dir}" CACHE PATH
> "Path where target-specific libc++ headers should be installed.")
> set(LIBCXX_INSTALL_LIBRARY_DIR "${_install_library_dir}" CACHE PATH
> "Path where built libc++ libraries should be installed.")
> ```
> 
> IMO that's easier on the eye.
Gentle ping on this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132608

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


[PATCH] D123630: Remove connection between 'ffast-math' and 'ffp-contract'.

2022-09-14 Thread Joshua Cranmer via Phabricator via cfe-commits
jcranmer-intel accepted this revision.
jcranmer-intel added a comment.
This revision is now accepted and ready to land.

I'm happy with these changes. I'll let Aaron have one last crack at the wording 
of the documentation, in case there's any minor editorial stuff he'd like to 
see cleaned up.


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

https://reviews.llvm.org/D123630

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


[PATCH] D133157: Add -fsanitizer-coverage=control-flow

2022-09-14 Thread Navid Emamdoost via Phabricator via cfe-commits
Navidem updated this revision to Diff 460215.
Navidem added a comment.

Update the rt test


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133157

Files:
  clang/docs/SanitizerCoverage.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/BackendUtil.cpp
  clang/lib/Driver/SanitizerArgs.cpp
  
compiler-rt/test/sanitizer_common/TestCases/sanitizer_coverage_control_flow.cpp
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
  llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll

Index: llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/SanitizerCoverage/control-flow.ll
@@ -0,0 +1,22 @@
+; Test -sanitizer-coverage-control-flow.
+; RUN: opt < %s -passes='module(sancov-module)' -sanitizer-coverage-level=3 -sanitizer-coverage-control-flow -S | FileCheck %s
+
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+define void @foo(ptr %a) sanitize_address {
+entry:
+  %tobool = icmp eq i32* %a, null
+  br i1 %tobool, label %if.end, label %if.then
+
+  if.then:  ; preds = %entry
+  store i32 0, i32* %a, align 4
+  call void @foo(i32* %a)
+  br label %if.end
+
+  if.end:   ; preds = %entry, %if.then
+  ret void
+}
+
+; CHECK: private constant [17 x ptr] [{{.*}}@foo{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}blockaddress{{.*}}@foo{{.*}}null{{.*}}null], section "__sancov_cfs", comdat($foo), align 8
+; CHECK:  @__start___sancov_cfs = extern_weak hidden global
+; CHECK-NEXT: @__stop___sancov_cfs = extern_weak hidden global
Index: llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
===
--- llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
+++ llvm/lib/Transforms/Instrumentation/SanitizerCoverage.cpp
@@ -75,11 +75,13 @@
 const char SanCov8bitCountersInitName[] = "__sanitizer_cov_8bit_counters_init";
 const char SanCovBoolFlagInitName[] = "__sanitizer_cov_bool_flag_init";
 const char SanCovPCsInitName[] = "__sanitizer_cov_pcs_init";
+const char SanCovCFsInitName[] = "__sanitizer_cov_cfs_init";
 
 const char SanCovGuardsSectionName[] = "sancov_guards";
 const char SanCovCountersSectionName[] = "sancov_cntrs";
 const char SanCovBoolFlagSectionName[] = "sancov_bools";
 const char SanCovPCsSectionName[] = "sancov_pcs";
+const char SanCovCFsSectionName[] = "sancov_cfs";
 
 const char SanCovLowestStackName[] = "__sancov_lowest_stack";
 
@@ -147,6 +149,10 @@
   cl::desc("max stack depth tracing"),
   cl::Hidden, cl::init(false));
 
+static cl::opt ClCollectCF("sanitizer-coverage-control-flow",
+  cl::desc("collect control flow for each function"),
+  cl::Hidden, cl::init(false));
+
 namespace {
 
 SanitizerCoverageOptions getOptions(int LegacyCoverageLevel) {
@@ -193,6 +199,7 @@
   !Options.Inline8bitCounters && !Options.StackDepth &&
   !Options.InlineBoolFlag && !Options.TraceLoads && !Options.TraceStores)
 Options.TracePCGuard = true; // TracePCGuard is default.
+  Options.CollectControlFlow |= ClCollectCF;
   return Options;
 }
 
@@ -212,6 +219,7 @@
 PostDomTreeCallback PDTCallback);
 
 private:
+  void createFunctionControlFlow(Function );
   void instrumentFunction(Function , DomTreeCallback DTCallback,
   PostDomTreeCallback PDTCallback);
   void InjectCoverageForIndirectCalls(Function ,
@@ -270,6 +278,7 @@
   GlobalVariable *Function8bitCounterArray;  // for inline-8bit-counters.
   GlobalVariable *FunctionBoolArray; // for inline-bool-flag.
   GlobalVariable *FunctionPCsArray;  // for pc-table.
+  GlobalVariable *FunctionCFsArray;  // for control flow table
   SmallVector GlobalsToAppendToUsed;
   SmallVector GlobalsToAppendToCompilerUsed;
 
@@ -378,6 +387,7 @@
   Function8bitCounterArray = nullptr;
   FunctionBoolArray = nullptr;
   FunctionPCsArray = nullptr;
+  FunctionCFsArray = nullptr;
   IntptrTy = Type::getIntNTy(*C, DL->getPointerSizeInBits());
   IntptrPtrTy = PointerType::getUnqual(IntptrTy);
   Type *VoidTy = Type::getVoidTy(*C);
@@ -502,6 +512,15 @@
 IRBuilder<> IRBCtor(Ctor->getEntryBlock().getTerminator());
 IRBCtor.CreateCall(InitFunction, {SecStartEnd.first, SecStartEnd.second});
   }
+
+  if (Ctor && Options.CollectControlFlow) {
+auto SecStartEnd = 

[PATCH] D133886: [clang][RecoveryExpr] Don't perform alignment check if parameter type contains errors

2022-09-14 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang/lib/Sema/SemaChecking.cpp:5779
 QualType ParamTy = Proto->getParamType(ArgIdx);
+if (ParamTy->containsErrors())
+  continue;

It looks like for the failure case the `ParamTy` for the parameter is a 
dependent array type, and it violates the "non-dependent" assumption of 
`clang::ASTContext::getTypeInfoImpl` which is called by  `getTypeAlignInChars` 
in `CheckArgAlignment`.

so I'd suggest moving the fix to `CheckArgAlignment` line 5685 (adding a 
`ParamTy->isDependentType()` to the `if` condition).



Comment at: clang/test/SemaCXX/recovery-expr-type.cpp:171
+  struct {
+void m(UC (&)[SZ]) {}
+  } S;

we can simplify it further:

```
void m(int (&)[undefined()]) {}
...


S.m(1);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133886

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


[PATCH] D133875: [clang] fix generation of .debug_aranges with LTO (resubmit)

2022-09-14 Thread Azat Khuzhin via Phabricator via cfe-commits
azat updated this revision to Diff 460212.
azat added a comment.

Use --plugin-opt=-generate-arange-section instead.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133875

Files:
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/debug-options-aranges.c


Index: clang/test/Driver/debug-options-aranges.c
===
--- /dev/null
+++ clang/test/Driver/debug-options-aranges.c
@@ -0,0 +1,8 @@
+// Check that lld will emit dwarf aranges.
+
+// RUN: %clang -### -target x86_64-unknown-linux -c -gdwarf-aranges %s 2>&1 | 
FileCheck -check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto -gdwarf-aranges %s 2>&1 
| FileCheck -check-prefix=PLUGIN_GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto=thin -gdwarf-aranges %s 
2>&1 | FileCheck -check-prefix=PLUGIN_GARANGE %s
+//
+// GARANGE: -generate-arange-section
+// PLUGIN_GARANGE: --plugin-opt=-generate-arange-section
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -508,6 +508,13 @@
 CmdArgs.push_back(Args.MakeArgString(Plugin));
   }
 
+  // Note, this solution is far from perfect, better to encode it into IR
+  // metadata, but this may not be worth it, since it looks like aranges is on
+  // the way out.
+  if (Args.hasArg(options::OPT_gdwarf_aranges)) {
+
CmdArgs.push_back(Args.MakeArgString("--plugin-opt=-generate-arange-section"));
+  }
+
   // Try to pass driver level flags relevant to LTO code generation down to
   // the plugin.
 


Index: clang/test/Driver/debug-options-aranges.c
===
--- /dev/null
+++ clang/test/Driver/debug-options-aranges.c
@@ -0,0 +1,8 @@
+// Check that lld will emit dwarf aranges.
+
+// RUN: %clang -### -target x86_64-unknown-linux -c -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=PLUGIN_GARANGE %s
+// RUN: %clang -### -target x86_64-unknown-linux -flto=thin -gdwarf-aranges %s 2>&1 | FileCheck -check-prefix=PLUGIN_GARANGE %s
+//
+// GARANGE: -generate-arange-section
+// PLUGIN_GARANGE: --plugin-opt=-generate-arange-section
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -508,6 +508,13 @@
 CmdArgs.push_back(Args.MakeArgString(Plugin));
   }
 
+  // Note, this solution is far from perfect, better to encode it into IR
+  // metadata, but this may not be worth it, since it looks like aranges is on
+  // the way out.
+  if (Args.hasArg(options::OPT_gdwarf_aranges)) {
+CmdArgs.push_back(Args.MakeArgString("--plugin-opt=-generate-arange-section"));
+  }
+
   // Try to pass driver level flags relevant to LTO code generation down to
   // the plugin.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133711: [Sema] Reject array element types whose sizes aren't a multiple of their alignments

2022-09-14 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 460207.
ahatanak retitled this revision from "[Sema] Reject array element types whose 
alignments are larger than their sizes" to "[Sema] Reject array element types 
whose sizes aren't a multiple of their alignments".
ahatanak added a comment.

Check whether the size is a multiple of the alignment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133711

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGenCXX/ubsan-new-checks.cpp
  clang/test/Layout/ms-aligned-array.c
  clang/test/Layout/ms-x86-misalignedarray.cpp
  clang/test/Sema/align-x86-64.c
  clang/test/Sema/align-x86.c
  clang/test/Sema/attr-aligned.c
  clang/test/SemaCXX/align-x86.cpp
  clang/test/SemaCXX/array-alignment.cpp
  clang/test/SemaCXX/warn-new-overaligned.cpp

Index: clang/test/SemaCXX/warn-new-overaligned.cpp
===
--- clang/test/SemaCXX/warn-new-overaligned.cpp
+++ clang/test/SemaCXX/warn-new-overaligned.cpp
@@ -19,9 +19,13 @@
 }
 
 namespace test2 {
+struct S {
+  char c[256];
+};
+
 class Test {
-  typedef int __attribute__((aligned(256))) aligned_int;
-  aligned_int high_contention_data[10];
+  typedef S __attribute__((aligned(256))) alignedS;
+  alignedS high_contention_data[10];
 };
 
 void helper() {
Index: clang/test/SemaCXX/array-alignment.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/array-alignment.cpp
@@ -0,0 +1,36 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+typedef char __attribute__((aligned(2))) AlignedChar;
+typedef AlignedChar arrayType0[4]; // expected-error {{size of array element}}
+
+struct __attribute__((aligned(8))) AlignedStruct {
+  int m0;
+};
+
+struct __attribute__((packed)) PackedStruct {
+  char m0;
+  int i0;
+};
+
+typedef PackedStruct AlignedPackedStruct __attribute__((aligned(4)));
+typedef AlignedPackedStruct arrayType1[4]; // expected-error {{(5 bytes) isn't a multiple of its alignment (4 bytes)}}
+
+AlignedChar a0[1]; // expected-error {{size of array element}}
+AlignedStruct a1[1];
+AlignedPackedStruct a2[1]; // expected-error {{size of array element}}
+
+struct S {
+  AlignedChar m0[1]; // expected-error {{size of array element}}
+  AlignedStruct m1[1];
+  AlignedPackedStruct m2[1]; // expected-error {{size of array element}}
+};
+
+void test(char *p) {
+  auto p0 = (AlignedChar(*)[1])p;// expected-error {{size of array element}}
+  auto r0 = (AlignedChar(&)[1])(*p); // expected-error {{size of array element}}
+  auto p1 = new AlignedChar[1];  // expected-error {{size of array element}}
+  auto p2 = (AlignedStruct(*)[1])p;
+  auto p3 = new AlignedStruct[1];
+  auto p4 = (AlignedPackedStruct(*)[1])p; // expected-error {{size of array element}}
+  auto p5 = new AlignedPackedStruct[1]; // expected-error {{size of array element}}
+}
Index: clang/test/SemaCXX/align-x86.cpp
===
--- clang/test/SemaCXX/align-x86.cpp
+++ clang/test/SemaCXX/align-x86.cpp
@@ -1,5 +1,4 @@
 // RUN: %clang_cc1 -std=c++11 -triple i386-apple-darwin9 -fsyntax-only -verify %s
-// expected-no-diagnostics
 
 using size_t = decltype(sizeof(0));
 
@@ -46,10 +45,10 @@
 } aligned_before_struct;
 
 static_assert(sizeof(aligned_before_struct)   == 3, "");
-static_assert(sizeof(aligned_before_struct[1])== 4, "");
-static_assert(sizeof(aligned_before_struct[2])== 6, "");
-static_assert(sizeof(aligned_before_struct[2][1]) == 8, "");
-static_assert(sizeof(aligned_before_struct[1][2]) == 6, "");
+static_assert(sizeof(aligned_before_struct[1])== 4, ""); // expected-error {{size of array element}}
+static_assert(sizeof(aligned_before_struct[2])== 6, ""); // expected-error {{size of array element}}
+static_assert(sizeof(aligned_before_struct[2][1]) == 8, ""); // expected-error {{size of array element}}
+static_assert(sizeof(aligned_before_struct[1][2]) == 6, ""); // expected-error {{size of array element}}
 
 typedef struct ALIGNED(2) {
   char a[3];
Index: clang/test/Sema/attr-aligned.c
===
--- clang/test/Sema/attr-aligned.c
+++ clang/test/Sema/attr-aligned.c
@@ -49,13 +49,14 @@
 char e1[__alignof__(e) == 2 ?: -1] = {0};
 char e2[__alignof__(e.member) == 2 ?: -1] = {0};
 
-typedef char overaligned_char __attribute__((aligned(16)));
-typedef overaligned_char array_with_overaligned_char[11];
+typedef struct { char c[16]; } S;
+typedef S overaligned_struct __attribute__((aligned(16)));
+typedef overaligned_struct array_with_overaligned_struct[11];
 typedef char array_with_align_attr[11] __attribute__((aligned(16)));
 
-char f0[__alignof__(array_with_overaligned_char) == 16 ? 1 : -1] = { 0 };
+char 

[PATCH] D111283: [clang] template / auto deduction deduces common sugar

2022-09-14 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:12367
+  case Type::Class:
\
+llvm_unreachable("Unexpected " Kind ": " #Class);
+

mizvekov wrote:
> aaronpuchert wrote:
> > mizvekov wrote:
> > > davrec wrote:
> > > > mizvekov wrote:
> > > > > davrec wrote:
> > > > > > mizvekov wrote:
> > > > > > > davrec wrote:
> > > > > > > > Could we just return `X` here? Would that just default to the 
> > > > > > > > old behavior instead of crashing whenever unforeseen cases 
> > > > > > > > arise?  
> > > > > > > No, I think we should enforce the invariants and make sure we are 
> > > > > > > handling everything that can be handled.
> > > > > > > 
> > > > > > > Classing `TemplateTypeParm`  as sugar-free was what was wrong and 
> > > > > > > we missed this on the review.
> > > > > > There might always going to be a few rare corner cases vulnerable 
> > > > > > to this though, particularly as more types are added and the people 
> > > > > > adding them don't pay strict attention to how to incorporate them 
> > > > > > here, and don't write the requisite tests (which seem very 
> > > > > > difficult to foresee and produce).  When those cases arise we will 
> > > > > > be crashing even though we could produce a perfectly good program 
> > > > > > with the intended semantics; the only thing that would suffer for 
> > > > > > most users is slightly less clear diagnostic messages for those 
> > > > > > rare cases.  I think it would be better to let those cases 
> > > > > > gradually percolate to our attention via bug reports concerning 
> > > > > > those diagnostics, rather than inconveniencing the user and 
> > > > > > demanding immediate attention via crashes.  Or am I missing 
> > > > > > something?
> > > > > I could on the same argument remove all asserts here and just let the 
> > > > > program not crash on unforeseen circumstances.
> > > > > 
> > > > > On the other hand, having these asserts here helps us catch bugs not 
> > > > > only here, but in other parts of the code. For example uniquing / 
> > > > > canonicalization bugs.
> > > > > 
> > > > > If someone changes the properties of a type so that the assumptions 
> > > > > here are not valid anymore, it's helpful to have that pointed out 
> > > > > soon.
> > > > > 
> > > > > Going for as an example this specific bug, if there werent those 
> > > > > asserts / unreachables in place and we had weakened the validation 
> > > > > here, it would take a very long time for us to figure out we were 
> > > > > making the wrong assumption with regards to TemplateTypeParmType.
> > > > > 
> > > > > I'd rather figure that out sooner on CI / internal testing rather 
> > > > > than have a bug created by a user two years from now.
> > > > Yes its nicer to developers to get stack traces and reproductions 
> > > > whenever something goes wrong, and crashing is a good way to get those, 
> > > > but users probably won't be so thrilled about it.  Especially given 
> > > > that the main selling point of this patch is that it makes diagnostics 
> > > > nicer for users: isn't it a bit absurd to crash whenever we can't 
> > > > guarantee our diagnostics will be perfect?
> > > > 
> > > > And again the real problem is future types not being properly 
> > > > incorporated here and properly tested: i.e. the worry is that this will 
> > > > be a continuing source of crashes, even if we handle all the present 
> > > > types properly.
> > > > 
> > > > How about we leave it as an unreachable for now, to help ensure all the 
> > > > present types are handled, but if months or years from now there 
> > > > continue to be crashes due to this, then just return X (while maybe 
> > > > write something to llvm::errs() to encourage users to report it), so we 
> > > > don't make the perfect the enemy of the good.
> > > It's not about crashing when it won't be perfect. We already do these 
> > > kinds of things, see the FIXMEs around the TemplateArgument and 
> > > NestedNameSpecifier, where we just return something worse than we wish 
> > > to, just because we don't have time to implement it now.
> > > 
> > > These unreachables and asserts here are about testing / documenting our 
> > > knowledge of the system and making it easier to find problems. These 
> > > should be impossible to happen in correct code, and if they do happen 
> > > because of mistakes, fixing them sooner is just going to save us 
> > > resources.
> > > 
> > > `llvm::errs` suggestion I perceive as out of line with current practice 
> > > in LLVM, we don't and have a system for producing diagnostics for results 
> > > possibly affected by FIXME and TODO situations and the like, as far as I 
> > > know, and I am not aware of any discussions in that direction. I expect a 
> > > lot of complexity and noise if we went this way.
> > > And I think this would have even less chance of working out if we started 
> > > 

[PATCH] D122078: [clang-tidy] Ignore concepts in `misc-redundant-expression`

2022-09-14 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron updated this revision to Diff 460209.
Izaron added a comment.

Add release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122078

Files:
  clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/misc/redundant-expression.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s misc-redundant-expression %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy %s misc-redundant-expression -std=c++20 %t -- -- -fno-delayed-template-parsing
 
 typedef __INT64_TYPE__ I64;
 
@@ -843,3 +843,13 @@
 
   return 2;
 }
+
+namespace concepts {
+// redundant expressions inside concepts make sense, ignore them
+template 
+concept TestConcept = requires(I i) {
+  {i - i};
+  {i && i};
+  {i ? i : i};
+};
+} // namespace concepts
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -149,6 +149,12 @@
   copy assignment operators with nonstandard return types. The check is restricted to
   c++11-or-later.
 
+- Improved :doc:`misc-redundant-expression `
+  check.
+
+  The check now skips concept definitions since redundant expressions still make sense
+  inside them.
+
 Removed checks
 ^^
 
Index: clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -10,6 +10,7 @@
 #include "../utils/Matchers.h"
 #include "../utils/OptionsUtils.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/ExprConcepts.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
@@ -440,6 +441,8 @@
   return Node.isIntegerConstantExpr(Finder->getASTContext());
 }
 
+AST_MATCHER(Expr, isRequiresExpr) { return isa(Node); }
+
 AST_MATCHER(BinaryOperator, operandsAreEquivalent) {
   return areEquivalentExpr(Node.getLHS(), Node.getRHS());
 }
@@ -858,6 +861,7 @@
 
   const auto BannedIntegerLiteral =
   integerLiteral(expandedByMacro(KnownBannedMacroNames));
+  const auto BannedAncestor = expr(isRequiresExpr());
 
   // Binary with equivalent operands, like (X != 2 && X != 2).
   Finder->addMatcher(
@@ -873,7 +877,8 @@
unless(hasType(realFloatingPointType())),
unless(hasEitherOperand(hasType(realFloatingPointType(,
unless(hasLHS(AnyLiteralExpr)),
-   unless(hasDescendant(BannedIntegerLiteral)))
+   unless(hasDescendant(BannedIntegerLiteral)),
+   unless(hasAncestor(BannedAncestor)))
.bind("binary")),
   this);
 
@@ -886,7 +891,8 @@
  unless(isInTemplateInstantiation()),
  unless(binaryOperatorIsInMacro()),
  // TODO: if the banned macros are themselves duplicated
- unless(hasDescendant(BannedIntegerLiteral)))
+ unless(hasDescendant(BannedIntegerLiteral)),
+ unless(hasAncestor(BannedAncestor)))
   .bind("nested-duplicates"),
   this);
 
@@ -896,7 +902,8 @@
conditionalOperator(expressionsAreEquivalent(),
// Filter noisy false positives.
unless(conditionalOperatorIsInMacro()),
-   unless(isInTemplateInstantiation()))
+   unless(isInTemplateInstantiation()),
+   unless(hasAncestor(BannedAncestor)))
.bind("cond")),
   this);
 
@@ -909,7 +916,8 @@
 ">=", "&&", "||", "="),
parametersAreEquivalent(),
// Filter noisy false positives.
-   unless(isMacro()), unless(isInTemplateInstantiation()))
+   unless(isMacro()), unless(isInTemplateInstantiation()),
+   unless(hasAncestor(BannedAncestor)))
.bind("call")),
   this);
 
@@ -919,7 +927,8 @@
   hasAnyOverloadedOperatorName("|", "&", "||", "&&", "^"),
   nestedParametersAreEquivalent(), argumentCountIs(2),
   // Filter noisy false positives.
-  unless(isMacro()), unless(isInTemplateInstantiation()))
+  unless(isMacro()), 

[PATCH] D128113: Clang: fix AST representation of expanded template arguments.

2022-09-14 Thread Matheus Izvekov via Phabricator via cfe-commits
mizvekov retitled this revision from "WIP: Clang: fix AST representation of 
expanded template arguments." to "Clang: fix AST representation of expanded 
template arguments.".
mizvekov edited the summary of this revision.
mizvekov updated this revision to Diff 460206.
mizvekov requested review of this revision.
This revision is now accepted and ready to land.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128113

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ASTStructuralEquivalence.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/AST/ast-dump-template-decls.cpp
  clang/test/SemaTemplate/type_pack_element.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -4793,6 +4793,44 @@
   ToD2->getDeclContext(), ToD2->getTemplateParameters()->getParam(0)));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportSubstTemplateTypeParmType) {
+  constexpr auto Code = R"(
+template  struct A {
+  using B = A1(A2...);
+};
+template struct A;
+)";
+  Decl *FromTU = getTuDecl(Code, Lang_CXX11, "input.cpp");
+  auto *FromClass = FirstDeclMatcher().match(
+  FromTU, classTemplateSpecializationDecl());
+
+  auto testType = [&](ASTContext , const char *Name,
+  llvm::Optional PackIndex) {
+const auto *Subst = selectFirst(
+"sttp", match(substTemplateTypeParmType(
+  hasReplacementType(hasCanonicalType(asString(Name
+  .bind("sttp"),
+  Ctx));
+const char *ExpectedTemplateParamName = PackIndex ? "A2" : "A1";
+ASSERT_TRUE(Subst);
+ASSERT_EQ(Subst->getReplacedParameter()->getIdentifier()->getName(),
+  ExpectedTemplateParamName);
+ASSERT_EQ(Subst->getPackIndex(), PackIndex);
+  };
+  auto tests = [&](ASTContext ) {
+testType(Ctx, "void", None);
+testType(Ctx, "char", 3);
+testType(Ctx, "float", 2);
+testType(Ctx, "int", 1);
+testType(Ctx, "short", 0);
+  };
+
+  tests(FromTU->getASTContext());
+
+  ClassTemplateSpecializationDecl *ToClass = Import(FromClass, Lang_CXX11);
+  tests(ToClass->getASTContext());
+}
+
 const AstTypeMatcher
 substTemplateTypeParmPackType;
 
Index: clang/test/SemaTemplate/type_pack_element.cpp
===
--- clang/test/SemaTemplate/type_pack_element.cpp
+++ clang/test/SemaTemplate/type_pack_element.cpp
@@ -11,7 +11,7 @@
 // CHECK-NEXT:   | `-IntegerLiteral 0x{{[0-9A-Fa-f]+}}  'int' 0
 // CHECK-NEXT:   |-TemplateArgument type 'int'
 // CHECK-NEXT:   | `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
-// CHECK-NEXT:   `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar typename depth 0 index 1 ...
+// CHECK-NEXT:   `-SubstTemplateTypeParmType 0x{{[0-9A-Fa-f]+}} 'int' sugar typename depth 0 index 1 ... pack_index 0
 // CHECK-NEXT: |-BuiltinTemplate 0x{{[0-9A-Fa-f]+}} '__type_pack_element'
 // CHECK-NEXT: `-BuiltinType 0x{{[0-9A-Fa-f]+}} 'int'
 
Index: clang/test/AST/ast-dump-template-decls.cpp
===
--- clang/test/AST/ast-dump-template-decls.cpp
+++ clang/test/AST/ast-dump-template-decls.cpp
@@ -136,13 +136,13 @@
 };
 using t1 = foo::bind;
 // CHECK:  TemplateSpecializationType 0x{{[^ ]*}} 'Y' sugar Y
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar typename depth 0 index 0 ... Bs
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'char' sugar typename depth 0 index 0 ... Bs pack_index 3
 // CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z'
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar typename depth 0 index 0 ... Bs
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'float' sugar typename depth 0 index 0 ... Bs pack_index 2
 // CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z'
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar typename depth 0 index 0 ... Bs
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'int' sugar typename depth 0 index 0 ... Bs pack_index 1
 // CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z'
-// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar typename depth 0 index 0 ... Bs
+// CHECK:  SubstTemplateTypeParmType 0x{{[^ ]*}} 'short' sugar typename depth 0 index 0 ... Bs pack_index 0
 // CHECK-NEXT: TypeAliasTemplate 0x{{[^ ]*}} 'Z'
 
 template  struct D {
@@ -152,13 

[PATCH] D133092: [clang] fix generation of .debug_aranges with LTO

2022-09-14 Thread Azat Khuzhin via Phabricator via cfe-commits
azat added a comment.

> I wasn't expecting that

Oh, I see, it wasn't the linker, but the plugin.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133092

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


[PATCH] D133092: [clang] fix generation of .debug_aranges with LTO

2022-09-14 Thread Azat Khuzhin via Phabricator via cfe-commits
azat added a comment.

> This is not correct. GNU ld and gold don't accept -mllvm. You need to use 
> -plugin-opt=-generate...

@MaskRay actually those options will be added only if the name matches 
`lld`/`lld.exe` (but I guess I need to provide more context so that it will be 
easier to understand), but you your approach is better anyway, since:

- it does not require additional condition
- it works for `gold` and `bfd` too (so they do interpret 
`--plugin-opt=-generate-arange-section` option too! I wasn't expecting that)

The new version of the patch will be available here - 
https://reviews.llvm.org/D133875


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133092

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


[PATCH] D133875: [clang] fix generation of .debug_aranges with LTO (resubmit)

2022-09-14 Thread Azat Khuzhin via Phabricator via cfe-commits
azat added a comment.

> I think @MaskRay was saying this doesn't actually work & different flags are 
> needed to pass to lld

I thought that @MaskRay was talking about more generic approach that will not 
require if for the linker name, and indeed 
`--plugin-opt=-generate-arange-section` is better, and both `gold` and `bfd` 
support it!

> have you tested this end-to-end/with a real compilation, does that work? (are 
> there other cases that already use -mllvm to pass flags down to lld?)

Sure:

  $ cat test.c
  void __attribute__((optnone)) bar()
  {
  }
  void __attribute__((optnone)) foo()
  {
  bar();
  }
  int main()
  {
  foo();
  }
  $ clang -c -flto=thin -fuse-ld=lld -gdwarf-aranges -g -O3 test.c
  $ clang -flto=thin -fuse-ld=lld -gdwarf-aranges -g -O3 test.c -### # to get 
full command
  $ /usr/bin/ld.lld ... -mllvm -generate-arange-section
  $ eu-readelf -waranges a.out  | grep -F -c -e foo -e bar
  2


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133875

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


[clang] c69b269 - [pipelines] Require GlobalsAA after sanitizers

2022-09-14 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-09-14T13:33:53-07:00
New Revision: c69b26911168cdcf49c7c7162d7b44ce4ed40c37

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

LOG: [pipelines] Require GlobalsAA after sanitizers

Restore GlobalsAA if sanitizers inserted at early optimize callback.
The analysis can be useful for the following FunctionPassManager.

Reviewed By: aeubanks

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

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 096cf5bd6610..e9f2f5d9d1c6 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -668,7 +668,7 @@ static void addSanitizers(const Triple ,
   // the logic of the original code, but operates on "shadow" values. 
It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -723,10 +723,21 @@ static void addSanitizers(const Triple ,
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[SanitizersCallback](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(



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


[PATCH] D133537: [pipelines] Require GlobalsAA after sanitizers

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
vitalybuka marked an inline comment as done.
Closed by commit rGc69b26911168: [pipelines] Require GlobalsAA after sanitizers 
(authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133537

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -668,7 +668,7 @@
   // the logic of the original code, but operates on "shadow" values. 
It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -723,10 +723,21 @@
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[SanitizersCallback](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -668,7 +668,7 @@
   // the logic of the original code, but operates on "shadow" values. It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -723,10 +723,21 @@
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[SanitizersCallback](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133537: [pipelines] Require GlobalsAA after sanitizers

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:443
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
-  Options.ExplicitEmulatedTLS = true;
+  Options.ExplicitEmulatedTLS = CodeGenOpts.ExplicitEmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();

aeubanks wrote:
> unrelated?
yes, already fixed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133537

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


[clang] 270c843 - [NFC][CodeGen] Remove empty line

2022-09-14 Thread Vitaly Buka via cfe-commits

Author: Vitaly Buka
Date: 2022-09-14T13:29:15-07:00
New Revision: 270c843005f927c878f391c9d444b48c3ce2965e

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

LOG: [NFC][CodeGen] Remove empty line

Added: 


Modified: 
clang/lib/CodeGen/BackendUtil.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index aff277f59c05..096cf5bd6610 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -641,7 +641,6 @@ static OptimizationLevel mapToLevel(const CodeGenOptions 
) {
 static void addSanitizers(const Triple ,
   const CodeGenOptions ,
   const LangOptions , PassBuilder ) {
-
   auto SanitizersCallback = [&](ModulePassManager ,
 OptimizationLevel Level) {
 if (CodeGenOpts.hasSanitizeCoverage()) {



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


[PATCH] D133537: [pipelines] RecomputeGlobalsAAPass after OptimizerEarlyEPCallbacks

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 460199.
vitalybuka added a comment.

fix capture


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133537

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -669,7 +669,7 @@
   // the logic of the original code, but operates on "shadow" values. 
It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -724,10 +724,21 @@
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[SanitizersCallback](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -669,7 +669,7 @@
   // the logic of the original code, but operates on "shadow" values. It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -724,10 +724,21 @@
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[SanitizersCallback](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133457: Add Clang driver flags equivalent to cl's /MD, /MT, /MDd, /MTd.

2022-09-14 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6546
 
+  if (Triple.isOSWindows() && !D.IsCLMode())
+ProcessVSRuntimeLibrary(Args, CmdArgs);

Should this be `Triple.isWindowsMSVCEnvironment()`? We don't want to do this at 
least for the mingw/cygwin environments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133457

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


[PATCH] D133537: [pipelines] RecomputeGlobalsAAPass after OptimizerEarlyEPCallbacks

2022-09-14 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks accepted this revision.
aeubanks added a comment.
This revision is now accepted and ready to land.

lg with comments addressed

title needs update




Comment at: clang/lib/CodeGen/BackendUtil.cpp:443
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
-  Options.ExplicitEmulatedTLS = true;
+  Options.ExplicitEmulatedTLS = CodeGenOpts.ExplicitEmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();

unrelated?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133537

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


[PATCH] D133537: [pipelines] RecomputeGlobalsAAPass after OptimizerEarlyEPCallbacks

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 460197.
vitalybuka edited the summary of this revision.
vitalybuka added a comment.

remove typo


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133537

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -669,7 +669,7 @@
   // the logic of the original code, but operates on "shadow" values. 
It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -724,10 +724,21 @@
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[&](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -669,7 +669,7 @@
   // the logic of the original code, but operates on "shadow" values. It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -724,10 +724,21 @@
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[&](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133457: Add Clang driver flags equivalent to cl's /MD, /MT, /MDd, /MTd.

2022-09-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm, nice!




Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4452
+
+  if (Arg *A = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
+StringRef Val = A->getValue();

This could use llvm::StringSwitch



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4493
+
+  if (/*IsClangCL && */Args.hasArg(options::OPT__SLASH_Zl)) {
+CmdArgs.push_back("-D_VC_NODEFAULTLIB");

leftover IsClangCL comment?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133457

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


[PATCH] D133537: [pipelines] RecomputeGlobalsAAPass after OptimizerEarlyEPCallbacks

2022-09-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 460194.
vitalybuka added a comment.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

update


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133537

Files:
  clang/lib/CodeGen/BackendUtil.cpp


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -440,7 +440,7 @@
   CodeGenOpts.UniqueBasicBlockSectionNames;
   Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
-  Options.ExplicitEmulatedTLS = true;
+  Options.ExplicitEmulatedTLS = CodeGenOpts.ExplicitEmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.StackUsageOutput = CodeGenOpts.StackUsageOutput;
@@ -669,7 +669,7 @@
   // the logic of the original code, but operates on "shadow" values. 
It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -724,10 +724,21 @@
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[&](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(


Index: clang/lib/CodeGen/BackendUtil.cpp
===
--- clang/lib/CodeGen/BackendUtil.cpp
+++ clang/lib/CodeGen/BackendUtil.cpp
@@ -440,7 +440,7 @@
   CodeGenOpts.UniqueBasicBlockSectionNames;
   Options.TLSSize = CodeGenOpts.TLSSize;
   Options.EmulatedTLS = CodeGenOpts.EmulatedTLS;
-  Options.ExplicitEmulatedTLS = true;
+  Options.ExplicitEmulatedTLS = CodeGenOpts.ExplicitEmulatedTLS;
   Options.DebuggerTuning = CodeGenOpts.getDebuggerTuning();
   Options.EmitStackSizeSection = CodeGenOpts.StackSizeSection;
   Options.StackUsageOutput = CodeGenOpts.StackUsageOutput;
@@ -669,7 +669,7 @@
   // the logic of the original code, but operates on "shadow" values. It
   // can benefit from re-running some general purpose optimization
   // passes.
-  MPM.addPass(RecomputeGlobalsAAPass());
+  MPM.addPass(RequireAnalysisPass());
   FunctionPassManager FPM;
   FPM.addPass(EarlyCSEPass(true /* Enable mem-ssa. */));
   FPM.addPass(InstCombinePass());
@@ -724,10 +724,21 @@
   MPM.addPass(DataFlowSanitizerPass(LangOpts.NoSanitizeFiles));
 }
   };
-  if (ClSanitizeOnOptimizerEarlyEP)
-PB.registerOptimizerEarlyEPCallback(SanitizersCallback);
-  else
+  if (ClSanitizeOnOptimizerEarlyEP) {
+PB.registerOptimizerEarlyEPCallback(
+[&](ModulePassManager , OptimizationLevel Level) {
+  ModulePassManager NewMPM;
+  SanitizersCallback(NewMPM, Level);
+  if (!NewMPM.isEmpty()) {
+// Sanitizers can abandon.
+NewMPM.addPass(RequireAnalysisPass());
+MPM.addPass(std::move(NewMPM));
+  }
+});
+  } else {
+// LastEP does not need GlobalsAA.
 PB.registerOptimizerLastEPCallback(SanitizersCallback);
+  }
 }
 
 void EmitAssemblyHelper::RunOptimizationPipeline(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133847: [test][clang] fix pattern for LDGARANGE-NOT in debug-options-lld test

2022-09-14 Thread Azat Khuzhin via Phabricator via cfe-commits
azat abandoned this revision.
azat added a comment.

Closed in favor of https://reviews.llvm.org/D133875


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133847

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


[PATCH] D133890: [CMake] Do these replacements to make use of D132608

2022-09-14 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 created this revision.
Ericson2314 added reviewers: phosek, ldionne, sebastian-ne, beanz.
Herald added subscribers: libc-commits, bzcheeseman, ayermolo, sdasgup3, 
abrachet, wenzhicui, wrengr, cota, teijeong, rdzhabarov, tatianashp, msifontes, 
jurahul, Kayjukh, grosul1, Joonsoo, liufengdb, aartbik, mgester, arpith-jacob, 
antiagainst, shauheen, rriddle, mehdi_amini, whisperity, mgorny.
Herald added a reviewer: sscalpone.
Herald added a reviewer: awarzynski.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a reviewer: NoQ.
Herald added projects: libc-project, Flang, All.
Ericson2314 requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: llvm-commits, libcxx-commits, openmp-commits, 
lldb-commits, cfe-commits, yota9, sstefan1, stephenneuendorffer, 
nicolasvasilache, jdoerfert.
Herald added projects: clang, LLDB, OpenMP, libc++abi, MLIR, LLVM.
Herald added a reviewer: libc++abi.

D132608  defined new `CMAKE_BINARY_*DIR` 
variables to match
`GNUInstallDirs`. Now we actually use them!

- `${CMAKE_BINARY_DIR}/lib(${CMAKE_LIBDIR_SUFFIX})?\>` -> 
`${CMAKE_BINARY_LIBDIR}`
- `${CMAKE_BINARY_DIR}/bin\>` -> `${CMAKE_BINARY_BINDIR}`

- `${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib${LLVM_LIBDIR_SUFFIX}` -> 
`${LLVM_LIBRARY_OUTPUT_INTDIR}`
- `${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin` -> 
`${LLVM_RUNTIME_OUTPUT_INTDIR}`

It is somewhat odd to me that those last two vars start with `LLVM_`
not `CMAKE_` when they are based on `CMAKE_BINARY_DIR`, but that can
be tackled some other time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133890

Files:
  bolt/tools/driver/CMakeLists.txt
  clang/CMakeLists.txt
  clang/cmake/caches/Fuchsia-stage2.cmake
  clang/cmake/modules/CMakeLists.txt
  clang/tools/scan-build-py/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  clang/tools/scan-view/CMakeLists.txt
  flang/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  flang/tools/f18/CMakeLists.txt
  libc/test/utils/tools/WrapperGen/CMakeLists.txt
  libcxxabi/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  lldb/bindings/python/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  lldb/cmake/modules/LLDBStandalone.cmake
  llvm/tools/llvm-go/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  mlir/examples/standalone/CMakeLists.txt
  mlir/test/CMakeLists.txt
  mlir/utils/mbr/CMakeLists.txt
  openmp/libomptarget/plugins/remote/CMakeLists.txt

Index: openmp/libomptarget/plugins/remote/CMakeLists.txt
===
--- openmp/libomptarget/plugins/remote/CMakeLists.txt
+++ openmp/libomptarget/plugins/remote/CMakeLists.txt
@@ -26,7 +26,7 @@
 
 if (Protobuf_FOUND AND gRPC_FOUND AND PROTOC AND GRPC_CPP_PLUGIN)
   libomptarget_say("Building remote offloading plugin.")
-  set(directory "${CMAKE_BINARY_DIR}/include/openmp/libomptarget/plugins/remote/")
+  set(directory "${CMAKE_BINARY_INCLUDEDIR}/openmp/libomptarget/plugins/remote/")
   file(MAKE_DIRECTORY ${directory})
   execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${directory})
   execute_process(
Index: mlir/utils/mbr/CMakeLists.txt
===
--- mlir/utils/mbr/CMakeLists.txt
+++ mlir/utils/mbr/CMakeLists.txt
@@ -1 +1 @@
-configure_file(mlir-mbr.in ${CMAKE_BINARY_DIR}/bin/mlir-mbr @ONLY)
+configure_file(mlir-mbr.in ${CMAKE_BINARY_BINDIR}/mlir-mbr @ONLY)
Index: mlir/test/CMakeLists.txt
===
--- mlir/test/CMakeLists.txt
+++ mlir/test/CMakeLists.txt
@@ -8,7 +8,7 @@
 # Passed to lit.site.cfg.py.so that the out of tree Standalone dialect test
 # can find MLIR's CMake configuration
 set(MLIR_CMAKE_DIR
-  "${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/mlir")
+  "${CMAKE_BINARY_LIBDIR}/cmake/mlir")
 
 # Passed to lit.site.cfg.py.in to set up the path where to find libraries.
 set(MLIR_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
Index: mlir/examples/standalone/CMakeLists.txt
===
--- mlir/examples/standalone/CMakeLists.txt
+++ mlir/examples/standalone/CMakeLists.txt
@@ -10,8 +10,8 @@
 message(STATUS "Using MLIRConfig.cmake in: ${MLIR_DIR}")
 message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
 
-set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/bin)
-set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/lib)
+set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_BINDIR})
+set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_LIBDIR})
 set(MLIR_BINARY_DIR ${CMAKE_BINARY_DIR})
 
 list(APPEND CMAKE_MODULE_PATH "${MLIR_CMAKE_DIR}")
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -9,7 +9,7 @@
 set(MLIR_INSTALL_PACKAGE_DIR 

[PATCH] D132608: [CMake] Clean up CMake binary dir handling

2022-09-14 Thread John Ericson via Phabricator via cfe-commits
Ericson2314 updated this revision to Diff 460191.
Ericson2314 added a comment.

Fix misspelled variable `CLANG_CURRENT_SOURCE_DIR` -> `CLANG_SOURCE_DIR`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132608

Files:
  bolt/CMakeLists.txt
  clang/CMakeLists.txt
  clang/tools/scan-build/CMakeLists.txt
  cmake/Modules/GNUBinaryDirs.cmake
  cmake/Modules/LLVMLibdirSuffix.cmake
  cmake/Modules/LLVMSetIntDirs.cmake
  compiler-rt/CMakeLists.txt
  compiler-rt/cmake/base-config-ix.cmake
  flang/CMakeLists.txt
  libc/CMakeLists.txt
  libcxx/CMakeLists.txt
  libcxx/docs/BuildingLibcxx.rst
  libcxxabi/CMakeLists.txt
  libunwind/CMakeLists.txt
  libunwind/docs/BuildingLibunwind.rst
  lld/CMakeLists.txt
  lldb/CMakeLists.txt
  lldb/cmake/modules/LLDBStandalone.cmake
  llvm/CMakeLists.txt
  mlir/CMakeLists.txt
  openmp/CMakeLists.txt
  polly/CMakeLists.txt

Index: polly/CMakeLists.txt
===
--- polly/CMakeLists.txt
+++ polly/CMakeLists.txt
@@ -1,12 +1,28 @@
 # Check if this is a in tree build.
+
+set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
 if (NOT DEFINED LLVM_MAIN_SRC_DIR)
   project(Polly)
   cmake_minimum_required(VERSION 3.13.4)
   set(POLLY_STANDALONE_BUILD TRUE)
 endif()
 
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${POLLY_SOURCE_DIR}/../cmake)
+endif()
+
+list(INSERT CMAKE_MODULE_PATH 0
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
+# Must go before the first `include(GNUInstallDirs)`.
+include(LLVMLibdirSuffix)
+
 # Must go below project(..)
 include(GNUInstallDirs)
+include(GNUBinaryDirs)
 
 if(POLLY_STANDALONE_BUILD)
   # Where is LLVM installed?
@@ -48,18 +64,10 @@
   set(POLLY_GTEST_AVAIL 1)
 endif ()
 
-set(POLLY_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
-set(POLLY_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
-
-if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
-  set(LLVM_COMMON_CMAKE_UTILS ${POLLY_SOURCE_DIR}/../cmake)
-endif()
-
 # Make sure that our source directory is on the current cmake module path so that
 # we can include cmake files from this directory.
 list(INSERT CMAKE_MODULE_PATH 0
   "${POLLY_SOURCE_DIR}/cmake"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
   )
 
 include("polly_macros")
Index: openmp/CMakeLists.txt
===
--- openmp/CMakeLists.txt
+++ openmp/CMakeLists.txt
@@ -1,12 +1,5 @@
 cmake_minimum_required(VERSION 3.13.4)
 
-set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
-
-# Add path for custom modules
-list(INSERT CMAKE_MODULE_PATH 0
-  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
-  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
-  )
 
 # llvm/runtimes/ will set OPENMP_STANDALONE_BUILD.
 if (OPENMP_STANDALONE_BUILD OR "${CMAKE_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_SOURCE_DIR}")
@@ -14,6 +7,18 @@
   project(openmp C CXX)
 endif()
 
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+endif()
+
+# Add path for custom modules
+list(INSERT CMAKE_MODULE_PATH 0
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
+# Must go before the first `include(GNUInstallDirs)`.
+include(LLVMLibdirSuffix)
+
 # Must go below project(..)
 include(GNUInstallDirs)
 
@@ -51,6 +56,11 @@
   endif()
 endif()
 
+# Add path for custom modules
+list(INSERT CMAKE_MODULE_PATH 0
+  "${CMAKE_CURRENT_SOURCE_DIR}/cmake"
+  )
+
 # Check and set up common compiler flags.
 include(config-ix)
 include(HandleOpenMPOptions)
Index: mlir/CMakeLists.txt
===
--- mlir/CMakeLists.txt
+++ mlir/CMakeLists.txt
@@ -1,13 +1,28 @@
 # MLIR project.
 
+set(MLIR_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
+set(MLIR_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR})
+
 # Check if MLIR is built as a standalone project.
 if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
   project(mlir)
   set(MLIR_STANDALONE_BUILD TRUE)
 endif()
 
+if(NOT DEFINED LLVM_COMMON_CMAKE_UTILS)
+  set(LLVM_COMMON_CMAKE_UTILS ${CMAKE_CURRENT_SOURCE_DIR}/../cmake)
+endif()
+
+list(INSERT CMAKE_MODULE_PATH 0
+  "${LLVM_COMMON_CMAKE_UTILS}/Modules"
+  )
+
+# Must go before the first `include(GNUInstallDirs)`.
+include(LLVMLibdirSuffix)
+
 # Must go below project(..)
 include(GNUInstallDirs)
+include(GNUBinaryDirs)
 
 if(MLIR_STANDALONE_BUILD)
   cmake_minimum_required(VERSION 3.13.4)
@@ -36,12 +51,10 @@
 "Path for binary subdirectory (defaults to '${CMAKE_INSTALL_BINDIR}')")
 mark_as_advanced(MLIR_TOOLS_INSTALL_DIR)
 
-set(MLIR_MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}  )
+set(MLIR_MAIN_SRC_DIR ${MLIR_SOURCE_DIR}   )
 set(MLIR_MAIN_INCLUDE_DIR ${MLIR_MAIN_SRC_DIR}/include )
 
-set(MLIR_SOURCE_DIR  ${CMAKE_CURRENT_SOURCE_DIR})
-set(MLIR_BINARY_DIR  ${CMAKE_CURRENT_BINARY_DIR})
-set(MLIR_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/include)
+set(MLIR_INCLUDE_DIR 

[PATCH] D132316: [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2

2022-09-14 Thread John Ericson via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3a1c81e32739: [CMake] Avoid `LLVM_BINARY_DIR` when other 
more specific variable are better… (authored by Ericson2314).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132316

Files:
  clang/cmake/modules/CMakeLists.txt
  flang/cmake/modules/CMakeLists.txt
  lld/cmake/modules/CMakeLists.txt
  lldb/cmake/modules/LLDBConfig.cmake
  llvm/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/CMakeLists.txt
  mlir/cmake/modules/CMakeLists.txt
  polly/cmake/CMakeLists.txt
  polly/test/CMakeLists.txt

Index: polly/test/CMakeLists.txt
===
--- polly/test/CMakeLists.txt
+++ polly/test/CMakeLists.txt
@@ -46,7 +46,7 @@
 
 set(LLVM_BINARY_DIR "${LLVM_BINARY_DIR}")
 set(LLVM_TOOLS_DIR "${LLVM_TOOLS_BINARY_DIR}")
-set(LLVM_LIBS_DIR "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}")
+set(LLVM_LIBS_DIR "${LLVM_LIBRARY_DIR}")
 if (CMAKE_LIBRARY_OUTPUT_DIRECTORY)
   set(POLLY_LIB_DIR ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
 else()
Index: polly/cmake/CMakeLists.txt
===
--- polly/cmake/CMakeLists.txt
+++ polly/cmake/CMakeLists.txt
@@ -12,7 +12,7 @@
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 if (CMAKE_CONFIGURATION_TYPES)
   set(POLLY_EXPORTS_FILE_NAME "PollyExports-$>.cmake")
Index: mlir/cmake/modules/CMakeLists.txt
===
--- mlir/cmake/modules/CMakeLists.txt
+++ mlir/cmake/modules/CMakeLists.txt
@@ -15,7 +15,7 @@
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to '${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 get_property(MLIR_EXPORTS GLOBAL PROPERTY MLIR_EXPORTS)
 export(TARGETS ${MLIR_EXPORTS} FILE ${mlir_cmake_builddir}/MLIRTargets.cmake)
Index: llvm/cmake/modules/CMakeLists.txt
===
--- llvm/cmake/modules/CMakeLists.txt
+++ llvm/cmake/modules/CMakeLists.txt
@@ -3,7 +3,7 @@
 include(FindPrefixFromConfig)
 
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 # First for users who use an installed LLVM, create the LLVMExports.cmake file.
 set(LLVM_EXPORTS_FILE ${llvm_cmake_builddir}/LLVMExports.cmake)
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -1093,7 +1093,7 @@
   message(FATAL_ERROR "LLVM_INSTALL_PACKAGE_DIR must be defined and writable. GEN_CONFIG should only be passe when building LLVM proper.")
   endif()
   # LLVM_INSTALL_PACKAGE_DIR might be absolute, so don't reuse below.
-  set(llvm_cmake_builddir "${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+  set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
   file(WRITE
   "${llvm_cmake_builddir}/LLVMConfigExtensions.cmake"
   "set(LLVM_STATIC_EXTENSIONS ${LLVM_STATIC_EXTENSIONS})")
Index: llvm/CMakeLists.txt
===
--- llvm/CMakeLists.txt
+++ llvm/CMakeLists.txt
@@ -940,9 +940,9 @@
   )
 
 # They are not referenced. See set_output_directory().
-set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/bin )
-set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
-set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX} )
+set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${LLVM_TOOLS_BINARY_DIR} )
+set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} )
+set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${LLVM_LIBRARY_DIR} )
 
 if(LLVM_INCLUDE_TESTS)
   include(GetErrcMessages)
Index: lldb/cmake/modules/LLDBConfig.cmake
===
--- lldb/cmake/modules/LLDBConfig.cmake
+++ lldb/cmake/modules/LLDBConfig.cmake
@@ -276,7 +276,7 @@
   # could be and pick the first that exists.
   foreach(CANDIDATE "${Clang_DIR}/../.." "${LLVM_DIR}" "${LLVM_LIBRARY_DIRS}"
 "${LLVM_BUILD_LIBRARY_DIR}"
-

[clang] 3a1c81e - [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are better-suited, part 2

2022-09-14 Thread John Ericson via cfe-commits

Author: John Ericson
Date: 2022-09-14T15:48:58-04:00
New Revision: 3a1c81e327391466f827cafef7156b164cb4c3e6

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

LOG: [CMake] Avoid `LLVM_BINARY_DIR` when other more specific variable are 
better-suited, part 2

A simple sed doing these substitutions:

- `${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}\>` -> `${LLVM_LIBRARY_DIR}`
- `${LLVM_BINARY_DIR}/bin\>` -> `${LLVM_TOOLS_BINARY_DIR}`

where `\>` means "word boundary".

The only manual modifications were reverting changes in

- `runtimes/CMakeLists.txt`

because these were "entry points" where we wanted to tread carefully not not 
introduce a "loop" which would end with an undefined variable being expanded to 
nothing.

There are some `${LLVM_BINARY_DIR}/lib` without the `${LLVM_LIBDIR_SUFFIX}`, 
but these refer to the lib subdirectory of the source (`llvm/lib`). That `lib` 
is automatically appended to make the local `CMAKE_CURRENT_BINARY_DIR` value by 
`add_subdirectory`; since the directory name in the source tree is fixed 
without any suffix, the corresponding `CMAKE_CURRENT_BINARY_DIR` will also be. 
We therefore do not replace it but leave it as-is.

This picks up where D133828 left off, getting the occurrences with*out* 
`CMAKE_CFG_INTDIR`. But this is difficult to do correctly and so not done in 
the (retroactively) previous diff.

This hopefully increases readability overall, and also decreases the usages of 
`LLVM_LIBDIR_SUFFIX`, preparing us for D130586.

Reviewed By: sebastian-ne

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

Added: 


Modified: 
clang/cmake/modules/CMakeLists.txt
flang/cmake/modules/CMakeLists.txt
lld/cmake/modules/CMakeLists.txt
lldb/cmake/modules/LLDBConfig.cmake
llvm/CMakeLists.txt
llvm/cmake/modules/AddLLVM.cmake
llvm/cmake/modules/CMakeLists.txt
mlir/cmake/modules/CMakeLists.txt
polly/cmake/CMakeLists.txt
polly/test/CMakeLists.txt

Removed: 




diff  --git a/clang/cmake/modules/CMakeLists.txt 
b/clang/cmake/modules/CMakeLists.txt
index 6a7fa2fa27ebb..880d51f5aef71 100644
--- a/clang/cmake/modules/CMakeLists.txt
+++ b/clang/cmake/modules/CMakeLists.txt
@@ -15,7 +15,7 @@ set(clang_cmake_builddir 
"${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/cla
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to 
'${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 get_property(CLANG_EXPORTS GLOBAL PROPERTY CLANG_EXPORTS)
 export(TARGETS ${CLANG_EXPORTS} FILE 
${clang_cmake_builddir}/ClangTargets.cmake)

diff  --git a/flang/cmake/modules/CMakeLists.txt 
b/flang/cmake/modules/CMakeLists.txt
index 105cc09bf8501..31a6c3c83e48b 100644
--- a/flang/cmake/modules/CMakeLists.txt
+++ b/flang/cmake/modules/CMakeLists.txt
@@ -14,7 +14,7 @@ set(flang_cmake_builddir 
"${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/fla
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to 
'${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 get_property(FLANG_EXPORTS GLOBAL PROPERTY FLANG_EXPORTS)
 export(TARGETS ${FLANG_EXPORTS} FILE 
${flang_cmake_builddir}/FlangTargets.cmake)

diff  --git a/lld/cmake/modules/CMakeLists.txt 
b/lld/cmake/modules/CMakeLists.txt
index 57195bce45c95..61e7a1fe2752f 100644
--- a/lld/cmake/modules/CMakeLists.txt
+++ b/lld/cmake/modules/CMakeLists.txt
@@ -14,7 +14,7 @@ set(lld_cmake_builddir 
"${CMAKE_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/lld")
 set(LLVM_INSTALL_PACKAGE_DIR "${CMAKE_INSTALL_PACKAGEDIR}/llvm" CACHE STRING
   "Path for CMake subdirectory for LLVM (defaults to 
'${CMAKE_INSTALL_PACKAGEDIR}/llvm')")
 # CMAKE_INSTALL_PACKAGEDIR might be absolute, so don't reuse below.
-set(llvm_cmake_builddir 
"${LLVM_BINARY_DIR}/lib${LLVM_LIBDIR_SUFFIX}/cmake/llvm")
+set(llvm_cmake_builddir "${LLVM_LIBRARY_DIR}/cmake/llvm")
 
 get_property(LLD_EXPORTS GLOBAL PROPERTY LLD_EXPORTS)
 export(TARGETS ${LLD_EXPORTS} FILE ${lld_cmake_builddir}/LLDTargets.cmake)

diff  --git a/lldb/cmake/modules/LLDBConfig.cmake 
b/lldb/cmake/modules/LLDBConfig.cmake
index 987353517d0d5..2dd14d05a92aa 100644
--- a/lldb/cmake/modules/LLDBConfig.cmake
+++ b/lldb/cmake/modules/LLDBConfig.cmake
@@ -276,7 +276,7 @@ if (NOT TARGET clang-resource-headers)
   # could be and pick the first that 

[PATCH] D133052: [clang] Avoid crash when expanding conversion templates in concepts.

2022-09-14 Thread Luke Nihlen via Phabricator via cfe-commits
luken-google added a comment.

@ilya-biryukov can you please take a look? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133052

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


[PATCH] D119651: [clang] Fix evaluation context type for consteval function calls in instantiations

2022-09-14 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

@usaxena95, thanks! It was a really tough issue =)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D119651

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


[PATCH] D133443: [RISCV][MC] Add support for experimental Zawrs extension

2022-09-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

The change in set of instructions without changing the version number is 
concerning - do you know anyone involved in that group? It would be good to 
feedback the difficulties this can cause for us. It's also not clear if there 
might be changes again during ratification without changing the version number, 
which wouldn't be ideal (though probably just about livable given it's marked 
as experimental).

Let's discuss briefly in the meeting tomorrow. Implementation-wise it all seems 
straightforward.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133443

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


[PATCH] D133887: [Clang] Support label at end of compound statement

2022-09-14 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Thanks for doing that work.

Given that this paper was touted as a C compatibility feature, I think we 
should implement the C feature at the same time
https://www.open-std.org/jtc1/sc22/wg14/www/docs/n2508.pdf

If my understanding is correct the change implemented here should just be 
allowed - without warning in C23
What do you think @aaron.ballman ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133887

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


[PATCH] D133804: Cuda Check for ignored return errors from api calls to cuda

2022-09-14 Thread Bartłomiej Cieślar via Phabricator via cfe-commits
barcisz updated this revision to Diff 460184.
barcisz added a comment.

Documentation and small check-message-related bugfixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133804

Files:
  clang-tools-extra/-
  clang-tools-extra/clang-tidy/cuda/CMakeLists.txt
  clang-tools-extra/clang-tidy/cuda/CudaTidyModule.cpp
  clang-tools-extra/clang-tidy/cuda/UnsafeApiCallCheck.cpp
  clang-tools-extra/clang-tidy/cuda/UnsafeApiCallCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cuda/.keep
  clang-tools-extra/docs/clang-tidy/checks/cuda/unsafe-api-call.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda.h
  clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/cuda/cuda_runtime.h
  clang-tools-extra/test/clang-tidy/checkers/cuda/.keep
  
clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
  
clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu

Index: clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-macro-handler.cu
@@ -0,0 +1,96 @@
+// RUN: %check_clang_tidy %s cuda-unsafe-api-call %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: cuda-unsafe-api-call.HandlerName, \
+// RUN:   value: 'CUDA_HANDLER'}] \
+// RUN: }" \
+// RUN:   -- -isystem %clang_tidy_headers -std=c++14
+#include 
+
+class DummyContainer {
+ public:
+  int* begin();
+  int* end();
+};
+
+#define DUMMY_CUDA_HANDLER(stmt) stmt
+#define CUDA_HANDLER(stmt) do {auto err = stmt;} while(0)
+#define API_CALL() do {cudaDeviceReset();} while(0)
+
+void errorCheck();
+void errorCheck(cudaError_t error);
+
+void bad() {
+  API_CALL();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // There isn't supposed to be a fix here since it's a macro call
+
+  cudaDeviceReset();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // CHECK-FIXES:  {{^}}  CUDA_HANDLER(cudaDeviceReset());{{$}}
+  errorCheck();
+
+  if (true)
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  while (true)
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  do
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+  while(false);
+
+  switch (0) {
+case 0:
+  cudaDeviceReset();
+  // CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+  // CHECK-FIXES:  {{^}}  CUDA_HANDLER(cudaDeviceReset());{{$}}
+  }
+
+  for(
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+;
+cudaDeviceReset()
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset()){{$}}
+  ) cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}  ) CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  for(int i : DummyContainer())
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+
+  auto x = ({
+cudaDeviceReset();
+// CHECK-MESSAGES: :[[@LINE-1]]:{{[0-9]+}}: warning: Unchecked CUDA API call.
+// CHECK-FIXES:  {{^}}CUDA_HANDLER(cudaDeviceReset());{{$}}
+true;
+  });
+}
+
+int good() {
+  DUMMY_CUDA_HANDLER(cudaDeviceReset());
+
+  if (cudaDeviceReset()) {
+return 0;
+  }
+
+  switch (cudaDeviceReset()) {
+case cudaErrorInvalidValue: return 1;
+case cudaErrorMemoryAllocation: return 2;
+default: return 3;
+  }
+
+  auto err = ({cudaDeviceReset();});
+  // NOTE: We don't check that `errorCheck()` actually handles the error; we just assume it does.
+  errorCheck(cudaDeviceReset());
+}
Index: clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cuda/unsafe-api-call-function-handler.cu
@@ -0,0 +1,71 @@
+// RUN: %check_clang_tidy %s cuda-unsafe-api-call %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: cuda-unsafe-api-call.HandlerName, \
+// RUN:   

[PATCH] D133887: [Clang] Support label at end of compound statement

2022-09-14 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron added a comment.

I thought it was a good idea to slightly rename 
`err_label_end_of_compound_statement` to 
`err_SWITCH_label_end_of_compound_statement` because we aren't going to support 
empty labels in switch statements. (GCC also doesn't compile it - 
https://godbolt.org/z/xabKaon8v)

So now we need to clarify that we don't support empty labels in SWITCH compound 
statements (just there).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133887

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


[PATCH] D133887: [Clang] Support label at end of compound statement

2022-09-14 Thread Evgeny Shulgin via Phabricator via cfe-commits
Izaron created this revision.
Izaron added reviewers: clang-language-wg, aaron.ballman.
Herald added a project: All.
Izaron requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Implements paper P2324R2
https://wg21.link/p2324r2
https://github.com/cplusplus/papers/issues/1006


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133887

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/lib/Parse/ParseStmt.cpp
  clang/test/Parser/cxx2b-label.cpp
  clang/test/Parser/switch-recovery.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1456,7 +1456,7 @@
 
   Labels at the end of compound statements
   https://wg21.link/P2324R2;>P2324R2
-  No
+  Clang 16
 
 
   Delimited escape sequences
Index: clang/test/Parser/switch-recovery.cpp
===
--- clang/test/Parser/switch-recovery.cpp
+++ clang/test/Parser/switch-recovery.cpp
@@ -160,14 +160,14 @@
 void missing_statement_case(int x) {
   switch (x) {
 case 1:
-case 0: // expected-error {{label at end of compound statement: expected statement}}
+case 0: // expected-error {{label at end of switch compound statement: expected statement}}
   }
 }
 
 void missing_statement_default(int x) {
   switch (x) {
 case 0:
-default: // expected-error {{label at end of compound statement: expected statement}}
+default: // expected-error {{label at end of switch compound statement: expected statement}}
   }
 }
 
@@ -179,7 +179,7 @@
 void pr19022_1a(int x) {
   switch(x) {
   case 1  // expected-error{{expected ':' after 'case'}} \
-  // expected-error{{label at end of compound statement: expected statement}}
+  // expected-error{{label at end of switch compound statement: expected statement}}
   }
 }
 
Index: clang/test/Parser/cxx2b-label.cpp
===
--- /dev/null
+++ clang/test/Parser/cxx2b-label.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx2b -std=c++2b -Wpre-c++2b-compat %s
+// RUN: %clang_cc1 -fsyntax-only -verify=expected,cxx20 -std=c++20 %s
+
+void foo() {
+label1:
+int x;
+label2:
+x = 1;
+label3: label4: label5:
+} // cxx20-warning {{label at end of compound statement is a C++2b extension}} \
+ cxx2b-warning {{label at end of compound statement is incompatible with C++ standards before C++2b}}
Index: clang/lib/Parse/ParseStmt.cpp
===
--- clang/lib/Parse/ParseStmt.cpp
+++ clang/lib/Parse/ParseStmt.cpp
@@ -679,9 +679,12 @@
 
 /// ParseLabeledStatement - We have an identifier and a ':' after it.
 ///
+///   label:
+/// identifier ':'
+/// [GNU]   identifier ':' attributes[opt]
+///
 ///   labeled-statement:
-/// identifier ':' statement
-/// [GNU]   identifier ':' attributes[opt] statement
+/// label statement
 ///
 StmtResult Parser::ParseLabeledStatement(ParsedAttributes ,
  ParsedStmtContext StmtCtx) {
@@ -725,6 +728,14 @@
 }
   }
 
+  // The label may have no statement following it
+  if (SubStmt.isUnset() && Tok.is(tok::r_brace)) {
+Diag(Tok, getLangOpts().CPlusPlus2b
+  ? diag::warn_cxx20_compat_label_end_of_compound_statement
+  : diag::ext_label_end_of_compound_statement);
+SubStmt = Actions.ActOnNullStmt(ColonLoc);
+  }
+
   // If we've not parsed a statement yet, parse one now.
   if (!SubStmt.isInvalid() && !SubStmt.isUsable())
 SubStmt = ParseStatement(nullptr, StmtCtx);
@@ -873,8 +884,8 @@
 // another parsing error, so avoid producing extra diagnostics.
 if (ColonLoc.isValid()) {
   SourceLocation AfterColonLoc = PP.getLocForEndOfToken(ColonLoc);
-  Diag(AfterColonLoc, diag::err_label_end_of_compound_statement)
-<< FixItHint::CreateInsertion(AfterColonLoc, " ;");
+  Diag(AfterColonLoc, diag::err_switch_label_end_of_compound_statement)
+  << FixItHint::CreateInsertion(AfterColonLoc, " ;");
 }
 SubStmt = StmtError();
   }
@@ -928,8 +939,8 @@
 // Diagnose the common error "switch (X) {... default: }", which is
 // not valid.
 SourceLocation AfterColonLoc = PP.getLocForEndOfToken(ColonLoc);
-Diag(AfterColonLoc, diag::err_label_end_of_compound_statement)
-  << FixItHint::CreateInsertion(AfterColonLoc, " ;");
+Diag(AfterColonLoc, diag::err_switch_label_end_of_compound_statement)
+<< FixItHint::CreateInsertion(AfterColonLoc, " ;");
 SubStmt = true;
   }
 
@@ -1096,10 +1107,10 @@
   return Actions.ActOnExprStmt(E, /*DiscardedValue=*/!IsStmtExprResult);
 }
 
-/// ParseCompoundStatementBody - Parse a sequence of statements and 

[PATCH] D133886: [clang][RecoveryExpr] Don't perform alignment check if parameter type contains errors

2022-09-14 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX added a comment.

This looks similar to the problem fixed in D103825 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133886

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


[PATCH] D133886: [clang][RecoveryExpr] Don't perform alignment check if parameter type contains errors

2022-09-14 Thread Aleksandr Platonov via Phabricator via cfe-commits
ArcsinX created this revision.
ArcsinX added reviewers: hokein, kadircet.
Herald added a project: All.
ArcsinX requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch fixes a crash which appears because of CheckArgAlignment() call with 
error type.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133886

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaCXX/recovery-expr-type.cpp


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -162,3 +162,15 @@
   b = __builtin_object_size(c, 0); // crash2
 }
 }
+
+namespace test15 {
+const UnknownType SZ = 8; // expected-error {{unknown type}}
+typedef unsigned char UC;
+void f() {
+  struct {
+void m(UC (&)[SZ]) {}
+  } S;
+  unsigned char A[8];
+  S.m(A); // no crash
+}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5776,6 +5776,8 @@
   checkAIXMemberAlignment((Arg->getExprLoc()), Arg);
 
 QualType ParamTy = Proto->getParamType(ArgIdx);
+if (ParamTy->containsErrors())
+  continue;
 QualType ArgTy = Arg->getType();
 CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),
   ArgTy, ParamTy);


Index: clang/test/SemaCXX/recovery-expr-type.cpp
===
--- clang/test/SemaCXX/recovery-expr-type.cpp
+++ clang/test/SemaCXX/recovery-expr-type.cpp
@@ -162,3 +162,15 @@
   b = __builtin_object_size(c, 0); // crash2
 }
 }
+
+namespace test15 {
+const UnknownType SZ = 8; // expected-error {{unknown type}}
+typedef unsigned char UC;
+void f() {
+  struct {
+void m(UC (&)[SZ]) {}
+  } S;
+  unsigned char A[8];
+  S.m(A); // no crash
+}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -5776,6 +5776,8 @@
   checkAIXMemberAlignment((Arg->getExprLoc()), Arg);
 
 QualType ParamTy = Proto->getParamType(ArgIdx);
+if (ParamTy->containsErrors())
+  continue;
 QualType ArgTy = Arg->getType();
 CheckArgAlignment(Arg->getExprLoc(), FDecl, std::to_string(ArgIdx + 1),
   ArgTy, ParamTy);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D133444: [RISCV] Update error message to not call 'RV32' and 'RV64' an extension.

2022-09-14 Thread Alex Bradbury via Phabricator via cfe-commits
asb accepted this revision.
asb added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133444

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


[PATCH] D123630: Remove connection between 'ffast-math' and 'ffp-contract'.

2022-09-14 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 460178.

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

https://reviews.llvm.org/D123630

Files:
  clang/docs/UsersManual.rst
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/CodeGen/ffp-contract-option.c
  clang/test/Driver/fp-contract.c

Index: clang/test/Driver/fp-contract.c
===
--- /dev/null
+++ clang/test/Driver/fp-contract.c
@@ -0,0 +1,114 @@
+// Test that -ffp-contract is set to the right value when combined with
+// the options -ffast-math and -fno-fast-math.
+
+// RUN: %clang -### -ffast-math -c %s 2>&1  \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+// CHECK-FPC-FAST: "-ffp-contract=fast"
+
+// RUN: %clang -### -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -ffast-math -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+// CHECK-FPC-ON:   "-ffp-contract=on"
+
+// RUN: %clang -### -ffast-math -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-OFF %s
+// CHECK-FPC-OFF:  "-ffp-contract=off"
+
+// RUN: %clang -### -ffast-math -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffp-contract=fast -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+// RUN: %clang -### -ffp-contract=on -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+// RUN: %clang -### -ffp-contract=off -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffp-contract=fast -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+// RUN: %clang -### -ffp-contract=on -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+// RUN: %clang -### -ffp-contract=off -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-OFF %s
+
+
+// RUN: %clang -### -ffast-math -ffp-contract=fast -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -ffast-math -ffp-contract=on -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-OFF %s
+
+// RUN: %clang -### -ffast-math -ffp-contract=on -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffast-math -ffp-contract=off -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -ffast-math -ffp-contract=off -ffp-contract=fast \
+// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffast-math -ffp-contract=on -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -ffast-math -ffp-contract=off -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-OFF %s
+
+// RUN: %clang -### -ffast-math -ffp-contract=fast -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffast-math -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -fno-fast-math -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -fno-fast-math -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -fno-fast-math -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-OFF %s
+
+// RUN: %clang -### -fno-fast-math -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffp-contract=fast -fno-fast-math -ffp-contract=on \
+// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -ffp-contract=fast -fno-fast-math -ffp-contract=off \
+// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-OFF %s
+
+// RUN: %clang -### -ffp-contract=off -fno-fast-math -ffp-contract=fast \
+// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffp-contract=off -fno-fast-math -ffp-contract=on \
+// RUN: -c %s 2>&1 | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -ffp-contract=on -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffp-contract=off -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffp-contract=fast -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-FAST %s
+
+// RUN: %clang -### -ffp-contract=on -ffast-math -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-ON %s
+
+// RUN: %clang -### -ffp-contract=off -ffast-math -fno-fast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=CHECK-FPC-OFF %s
+
+// RUN: %clang -### -ffp-contract=fast -ffast-math 

[PATCH] D132421: [HLSL] Support PCH for cc1 mode

2022-09-14 Thread Xiang Li via Phabricator via cfe-commits
python3kgae added inline comments.



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:55
+  } else
+PrevDecl = dyn_cast(Found);
+  assert(PrevDecl && "Unexpected lookup result type.");

aaron.ballman wrote:
> Is it possible that this finds a different kind of tag, like an enumeration?
No, enum with the same name will get an error when building the PCH.



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:378
+  if (S.LookupQualifiedName(Result, AST.getTranslationUnitDecl()))
+PrevDecl = Result.getAsSingle();
+  HLSLNamespace = NamespaceDecl::Create(AST, AST.getTranslationUnitDecl(),

aaron.ballman wrote:
> How certain are you that there's only one result possible here?
I cannot think of a case more than one result is here.




Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:459-461
+  ASTContext  = SemaPtr->getASTContext();
+  IdentifierInfo  = AST.Idents.get("Resource", tok::TokenKind::identifier);
+  LookupResult Result(*SemaPtr, , SourceLocation(), Sema::LookupTagName);

aaron.ballman wrote:
> We made a lookup result but then do nothing with it?
Removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132421

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


[PATCH] D132421: [HLSL] Support PCH for cc1 mode

2022-09-14 Thread Xiang Li via Phabricator via cfe-commits
python3kgae updated this revision to Diff 460175.
python3kgae marked 4 inline comments as done.
python3kgae added a comment.

Code cleanup per comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132421

Files:
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/lib/Frontend/FrontendAction.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/test/AST/HLSL/Inputs/pch.hlsl
  clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
  clang/test/AST/HLSL/pch.hlsl
  clang/test/AST/HLSL/pch_with_buf.hlsl

Index: clang/test/AST/HLSL/pch_with_buf.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/pch_with_buf.hlsl
@@ -0,0 +1,18 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -finclude-default-header -emit-pch -o %t %S/Inputs/pch_with_buf.hlsl
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s | FileCheck  %s
+
+// Make sure PCH works by using function declared in PCH header.
+// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
+// Make sure buffer defined in PCH works.
+// CHECK:VarDecl 0x{{[0-9a-f]+}}  col:17 imported Buf 'RWBuffer':'hlsl::RWBuffer<>'
+// Make sure declare a RWBuffer in current file works.
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:11:1, col:23> col:23 Buf2 'hlsl::RWBuffer':'hlsl::RWBuffer<>'
+hlsl::RWBuffer Buf2;
+
+float2 bar(float2 a, float2 b) {
+// CHECK:CallExpr 0x{{[0-9a-f]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}}  'float2 (*)(float2, float2)' 
+// CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}}  'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)'
+  return foo(a, b);
+}
Index: clang/test/AST/HLSL/pch.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/pch.hlsl
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -emit-pch -o %t %S/Inputs/pch.hlsl
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl \
+// RUN:  -finclude-default-header -include-pch %t -fsyntax-only -ast-dump-all %s \
+// RUN: | FileCheck  %s
+
+// Make sure PCH works by using function declared in PCH header and declare a RWBuffer in current file.
+// CHECK:FunctionDecl 0x[[FOO:[0-9a-f]+]] <{{.*}}:2:1, line:4:1> line:2:8 imported used foo 'float2 (float2, float2)'
+// CHECK:VarDecl 0x{{[0-9a-f]+}} <{{.*}}:10:1, col:23> col:23 Buffer 'hlsl::RWBuffer':'hlsl::RWBuffer<>'
+hlsl::RWBuffer Buffer;
+
+float2 bar(float2 a, float2 b) {
+// CHECK:CallExpr 0x{{[0-9a-f]+}}  'float2':'float __attribute__((ext_vector_type(2)))'
+// CHECK-NEXT:ImplicitCastExpr 0x{{[0-9a-f]+}}  'float2 (*)(float2, float2)' 
+// CHECK-NEXT:`-DeclRefExpr 0x{{[0-9a-f]+}}  'float2 (float2, float2)' lvalue Function 0x[[FOO]] 'foo' 'float2 (float2, float2)'
+  return foo(a, b);
+}
Index: clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/Inputs/pch_with_buf.hlsl
@@ -0,0 +1,6 @@
+
+float2 foo(float2 a, float2 b) {
+  return a + b;
+}
+
+RWBuffer Buf;
Index: clang/test/AST/HLSL/Inputs/pch.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/Inputs/pch.hlsl
@@ -0,0 +1,4 @@
+
+float2 foo(float2 a, float2 b) {
+  return a + b;
+}
Index: clang/lib/Sema/HLSLExternalSemaSource.cpp
===
--- clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -30,6 +30,7 @@
 struct BuiltinTypeDeclBuilder {
   CXXRecordDecl *Record = nullptr;
   ClassTemplateDecl *Template = nullptr;
+  ClassTemplateDecl *PrevTemplate = nullptr;
   NamespaceDecl *HLSLNamespace = nullptr;
   llvm::StringMap Fields;
 
@@ -43,48 +44,46 @@
 ASTContext  = S.getASTContext();
 IdentifierInfo  = AST.Idents.get(Name, tok::TokenKind::identifier);
 
+LookupResult Result(S, , SourceLocation(), Sema::LookupTagName);
+CXXRecordDecl *PrevDecl = nullptr;
+if (S.LookupQualifiedName(Result, HLSLNamespace)) {
+  NamedDecl *Found = Result.getFoundDecl();
+  if (auto *TD = dyn_cast(Found)) {
+PrevDecl = TD->getTemplatedDecl();
+PrevTemplate = TD;
+  } else
+PrevDecl = dyn_cast(Found);
+  assert(PrevDecl && "Unexpected lookup result type.");
+}
+
+if (PrevDecl && PrevDecl->isCompleteDefinition()) {
+  Record = PrevDecl;
+  return;
+}
+
 Record = CXXRecordDecl::Create(AST, TagDecl::TagKind::TTK_Class,
HLSLNamespace, SourceLocation(),
-   SourceLocation(), , nullptr, 

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

2022-09-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Parse/Parser.h:2311
 case DeclSpecContext::DSC_association:
+case DeclSpecContext::DSC_offsetof:
   return true;

inclyc wrote:
> aaron.ballman wrote:
> > Is this correct? I don't think we can deduce the type from `offsetof` 
> > through CTAD, can we?
> > 
> > https://godbolt.org/z/Kab6ahYe7
> > 
> > (This might be a good test case to add assuming we don't already have that 
> > coverage.)
> Emm, these checks just return as the same as "type_specifier". Because that's 
> what we passed into "ParsingTypename" before.
Hmmm, that's certainly reasonable. Can you add the test case and make sure the 
behavior doesn't change?



Comment at: clang/test/Sema/offsetof.c:79
+int a;
+struct B // no-error, struct B is not defined within __builtin_offsetof 
directly
+{

inclyc wrote:
> aaron.ballman wrote:
> > I think this is defensible. The wording in the standard is "If the 
> > specified type defines a new type or if the specified member is a 
> > bit-field, the behavior is undefined." and the specified type in this case 
> > is `struct A`; that `struct A` happens to also define `struct B` is 
> > immaterial.
> > 
> > However, the intent behind the change to the rule is to support older 
> > implementations of `offsetof` to protect them from having to deal with a 
> > case like: `offsetof(struct S { int a, b }, b);` where `offsetof` is a 
> > macro and thus the comma between `a` and `b` is treated as a separator. So 
> > there's a part of me that wonders if we want to also support diagnosing 
> > this case. But then we'd have to look at the declarator context more 
> > recursively to see whether any of the contexts on the stack are an 
> > `offsetof` context and that might be tricky.
> > 
> > Thoughts?
> FWIW, gcc seems just rejects all definitions in this context. (Perhaps during 
> Parsing the statements). If we add a bool state to the Parser (just using 
> RAII object as before) struct B will trigger diagnostic error because the 
> state "ParsingOffsetof" is passed into inner declaration.
GCC accepts currently: https://godbolt.org/z/oEvzjW6Ee but you're correct 
regarding switching back to an RAII object being an easier way to address the 
nested declarations.

Let me think on this situation a bit


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133574

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


[PATCH] D133664: [clangd] Fix hover on symbol introduced by using declaration

2022-09-14 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

In D133664#3790144 , @tom-anders 
wrote:

> Yeah I do have commit access now, so I'll land this by myself.
>
> I don't think I have the permissions to close the corresponding issue on 
> Github though, so someone else would need to do that.

It happens automatically if the commit message includes "fixes ", which it looks like this one does.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133664

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


[PATCH] D133875: [clang] fix generation of .debug_aranges with LTO (resubmit)

2022-09-14 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I think @maskray was saying this doesn't actually work & different flags are 
needed to pass to lld - have you tested this end-to-end/with a real 
compilation, does that work? (are there other cases that already use `-mllvm` 
to pass flags down to lld?)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133875

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


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Julius via Phabricator via cfe-commits
ningvin added a comment.

In D133354#3790064 , @hans wrote:

> Ah, thanks for letting me know. I've committed on your behalf as 
> https://github.com/llvm/llvm-project/commit/49e7ef2c09facd722a29a5ad96a7f8f16e362b28

Sweet, thanks a lot :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133354

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


[PATCH] D133668: [HLSL] Use _BitInt(16) for int16_t to avoid promote to int.

2022-09-14 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/lib/Basic/Targets/DirectX.h:66
 
+  bool hasBitIntType() const override { return true; }
   bool hasFeature(StringRef Feature) const override {

aaron.ballman wrote:
> This change requires more testing/thought, IMO -- do you support 128-bit 
> operations? When we bump that limit to be arbitrarily high, should DX have 
> the arbitrary limits or do you need to enforce something lower? Have you 
> considered how you want to pack these into structures or other data layout 
> considerations?
Yea, we definitely need to set the max width to 64 for DirectX.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133668

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


[PATCH] D133664: [clangd] Fix hover on symbol introduced by using declaration

2022-09-14 Thread Tom Praschan via Phabricator via cfe-commits
tom-anders added a comment.

Yeah I do have commit access now, so I'll land this by myself.

I don't think I have the permissions to close the corresponding issue on Github 
though, so someone else would need to do that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133664

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


[PATCH] D133659: [Clang] P1169R4: static operator()

2022-09-14 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 460155.
royjacobson added a comment.

Add tests required by reviewerd.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133659

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/OperatorKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Parse/ParseExprCXX.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/CXX/over/over.match/over.match.best/over.best.ics/p6.cpp
  clang/test/CXX/over/over.oper/p7.cpp
  clang/test/CodeGenCXX/cxx2b-static-call-operator.cpp
  clang/test/Parser/cxx2b-lambdas-ext-warns.cpp
  clang/test/Parser/cxx2b-lambdas.cpp
  clang/test/SemaCXX/lambda-unevaluated.cpp
  clang/test/SemaCXX/overloaded-operator-decl.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1481,7 +1481,7 @@
 
   static operator()
   https://wg21.link/P1169R4;>P1169R4
-  No
+  Clang 16
 
 
   Extended floating-point types and standard names
Index: clang/test/SemaCXX/overloaded-operator-decl.cpp
===
--- clang/test/SemaCXX/overloaded-operator-decl.cpp
+++ clang/test/SemaCXX/overloaded-operator-decl.cpp
@@ -51,7 +51,7 @@
 
 namespace PR14120 {
   struct A {
-static void operator()(int& i) { ++i; } // expected-error{{overloaded 'operator()' cannot be a static member function}}
+static void operator()(int& i) { ++i; } // expected-error{{overloaded 'operator()' cannot be declared static}}
   };
   void f() {
 int i = 0;
Index: clang/test/SemaCXX/lambda-unevaluated.cpp
===
--- clang/test/SemaCXX/lambda-unevaluated.cpp
+++ clang/test/SemaCXX/lambda-unevaluated.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++20 %s -verify
+// RUN: %clang_cc1 -std=c++2b %s -verify
 
 
 template  struct Nothing {};
@@ -120,3 +121,28 @@
 void foo(decltype(+[](T) {}) lambda, T param);
 static_assert(!__is_same(decltype(foo), void));
 } // namespace GH51641
+
+#if __cplusplus > 202002L
+namespace StaticLambdas {
+template  struct Nothing {};
+Nothing<[]() static { return 0; }()> nothing;
+
+template  struct NothingT {};
+Nothing<[]() static { return 0; }> nothingT;
+
+template 
+concept True = [] static { return true; }();
+static_assert(True);
+
+static_assert(sizeof([] static { return 0; }));
+static_assert(sizeof([] static { return 0; }()));
+
+void f()  noexcept(noexcept([] static { return 0; }()));
+
+using a = decltype([] static { return 0; });
+using b = decltype([] static { return 0; }());
+using c = decltype([]() static noexcept(noexcept([] { return 0; }())) { return 0; });
+using d = decltype(sizeof([] static { return 0; }));
+
+}
+#endif
Index: clang/test/Parser/cxx2b-lambdas.cpp
===
--- clang/test/Parser/cxx2b-lambdas.cpp
+++ clang/test/Parser/cxx2b-lambdas.cpp
@@ -38,3 +38,25 @@
 auto XL4 = [] requires true {}; // expected-error{{expected body}}
 auto XL5 = [] requires true requires true {}; // expected-error{{expected body}}
 auto XL6 = [] requires true noexcept requires true {}; // expected-error{{expected body}}
+
+auto XL7 = []() static static {}; // expected-error {{cannot appear multiple times}}
+auto XL8 = []() static mutable {}; // expected-error {{cannot be both mutable and static}}
+auto XL9 = []() static consteval {};
+auto XL10 = []() static constexpr {};
+
+auto XL11 = [] static {};
+auto XL12 = []() static {};
+auto XL13 = []() static extern {};  // expected-error {{expected body of lambda expression}}
+auto XL14 = []() extern {};  // expected-error {{expected body of lambda expression}}
+
+
+void static_captures() {
+  int x;
+  auto SC1 = [&]() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note {{captures declared here}}
+  auto SC4 = [x]() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note {{captures declared here}}
+  auto SC2 = []() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note {{captures declared here}}
+  auto SC3 = [y=x]() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note {{captures declared here}}
+  auto SC5 = [ = x]() static {}; // expected-error {{a static lambda cannot have any captures}} // expected-note {{captures declared here}}
+  auto SC6 = [=]() static {}; // expected-error {{a static lambda cannot have any 

[PATCH] D128465: [llvm] add zstd to `llvm::compression` namespace

2022-09-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: llvm/include/llvm/Support/Compression.h:48
+
+constexpr int NoCompression = -5;
+constexpr int BestSpeedCompression = 1;

MaskRay wrote:
> I missed the values here. Why is -5 picked for NoCompression? What does it 
> mean?
> 
> zstd.h says ZSTD_maxCLevel() is currently 22. The CLI program mentions 19. 
> Why is BestSizeCompression 12?
> 
> ZSTD_CLEVEL_DEFAULT/the CLI CLI uses 3 for the default level. Why is 
> DefaultCompression 5?
Ping @ckissane about the choice.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128465

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


[PATCH] D133773: [clang] fix linker executable path in test

2022-09-14 Thread Alvin Wong via Phabricator via cfe-commits
alvinhochun added a comment.

The literal dots have not been escaped as `\.`, but the current change works 
anyway and the chance of false positives here should be very low. I guess this 
is acceptable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133773

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


[PATCH] D133457: Add Clang driver flags equivalent to cl's /MD, /MT, /MDd, /MTd.

2022-09-14 Thread Amy Huang via Phabricator via cfe-commits
akhuang updated this revision to Diff 460154.
akhuang marked an inline comment as done.
akhuang added a comment.

Address comments, more cleanup


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133457

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/cl-runtime-flags.c

Index: clang/test/Driver/cl-runtime-flags.c
===
--- clang/test/Driver/cl-runtime-flags.c
+++ clang/test/Driver/cl-runtime-flags.c
@@ -10,6 +10,8 @@
 
 // RUN: %clang_cl -### -- %s 2>&1 | FileCheck -check-prefix=CHECK-MT %s
 // RUN: %clang_cl -### /MT -- %s 2>&1 | FileCheck -check-prefix=CHECK-MT %s
+// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=static -- %s \
+// RUN:   2>&1 | FileCheck -check-prefix=CHECK-MT %s
 // CHECK-MT-NOT: "-D_DEBUG"
 // CHECK-MT: "-D_MT"
 // CHECK-MT-NOT: "-D_DLL"
@@ -19,6 +21,8 @@
 
 // RUN: %clang_cl -### /MTd -- %s 2>&1 | FileCheck -check-prefix=CHECK-MTd %s
 // RUN: %clang_cl -### /LD /MTd -- %s 2>&1 | FileCheck -check-prefix=CHECK-MTd %s
+// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=static_dbg \
+// RUN:   -- %s 2>&1 | FileCheck -check-prefix=CHECK-MTd %s
 // CHECK-MTd: "-D_DEBUG"
 // CHECK-MTd: "-D_MT"
 // CHECK-MTd-NOT: "-D_DLL"
@@ -27,6 +31,8 @@
 // CHECK-MTd: "--dependent-lib=oldnames"
 
 // RUN: %clang_cl -### /MD -- %s 2>&1 | FileCheck -check-prefix=CHECK-MD %s
+// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=dll -- %s \
+// RUN:   2>&1 | FileCheck -check-prefix=CHECK-MD %s
 // CHECK-MD-NOT: "-D_DEBUG"
 // CHECK-MD: "-D_MT"
 // CHECK-MD: "-D_DLL"
@@ -34,6 +40,8 @@
 // CHECK-MD: "--dependent-lib=oldnames"
 
 // RUN: %clang_cl -### /MDd -- %s 2>&1 | FileCheck -check-prefix=CHECK-MDd %s
+// RUN: %clang -### --target=x86_64-windows-msvc -fms-runtime-lib=dll_dbg -- \
+// RUN:   %s 2>&1 | FileCheck -check-prefix=CHECK-MDd %s
 // CHECK-MDd: "-D_DEBUG"
 // CHECK-MDd: "-D_MT"
 // CHECK-MDd: "-D_DLL"
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4437,6 +4437,71 @@
   RenderDebugInfoCompressionArgs(Args, CmdArgs, D, TC);
 }
 
+static void ProcessVSRuntimeLibrary(const ArgList ,
+ArgStringList ) {
+  unsigned RTOptionID = options::OPT__SLASH_MT;
+
+  if (Args.hasArg(options::OPT__SLASH_LDd))
+// The /LDd option implies /MTd. The dependent lib part can be overridden,
+// but defining _DEBUG is sticky.
+RTOptionID = options::OPT__SLASH_MTd;
+
+  if (Arg *A = Args.getLastArg(options::OPT__SLASH_M_Group))
+RTOptionID = A->getOption().getID();
+
+  if (Arg *A = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
+StringRef Val = A->getValue();
+if (Val == "static")  RTOptionID = options::OPT__SLASH_MT;
+else if (Val == "static_dbg") RTOptionID = options::OPT__SLASH_MTd;
+else if (Val == "dll")RTOptionID = options::OPT__SLASH_MD;
+else if (Val == "dll_dbg")RTOptionID = options::OPT__SLASH_MDd;
+else llvm_unreachable("Unexpected option ID.");
+  }
+
+  StringRef FlagForCRT;
+  switch (RTOptionID) {
+  case options::OPT__SLASH_MD:
+if (Args.hasArg(options::OPT__SLASH_LDd))
+  CmdArgs.push_back("-D_DEBUG");
+CmdArgs.push_back("-D_MT");
+CmdArgs.push_back("-D_DLL");
+FlagForCRT = "--dependent-lib=msvcrt";
+break;
+  case options::OPT__SLASH_MDd:
+CmdArgs.push_back("-D_DEBUG");
+CmdArgs.push_back("-D_MT");
+CmdArgs.push_back("-D_DLL");
+FlagForCRT = "--dependent-lib=msvcrtd";
+break;
+  case options::OPT__SLASH_MT:
+if (Args.hasArg(options::OPT__SLASH_LDd))
+  CmdArgs.push_back("-D_DEBUG");
+CmdArgs.push_back("-D_MT");
+CmdArgs.push_back("-flto-visibility-public-std");
+FlagForCRT = "--dependent-lib=libcmt";
+break;
+  case options::OPT__SLASH_MTd:
+CmdArgs.push_back("-D_DEBUG");
+CmdArgs.push_back("-D_MT");
+CmdArgs.push_back("-flto-visibility-public-std");
+FlagForCRT = "--dependent-lib=libcmtd";
+break;
+  default:
+llvm_unreachable("Unexpected option ID.");
+  }
+
+  if (/*IsClangCL && */Args.hasArg(options::OPT__SLASH_Zl)) {
+CmdArgs.push_back("-D_VC_NODEFAULTLIB");
+  } else {
+CmdArgs.push_back(FlagForCRT.data());
+
+// This provides POSIX compatibility (maps 'open' to '_open'), which most
+// users want.  The /Za flag to cl.exe turns this off, but it's not
+// implemented in clang.
+CmdArgs.push_back("--dependent-lib=oldnames");
+  }
+}
+
 void Clang::ConstructJob(Compilation , const JobAction ,
  const InputInfo , const InputInfoList ,
  const ArgList , const char *LinkingOutput) const {
@@ -6478,6 +6543,9 @@
   if (IsMSVCCompat)
 

[PATCH] D133457: Add Clang driver flags equivalent to cl's /MD, /MT, /MDd, /MTd.

2022-09-14 Thread Amy Huang via Phabricator via cfe-commits
akhuang marked 3 inline comments as done.
akhuang added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4442
+bool IsClangCL) {
+  unsigned RTOptionID = 0; // MT=0, MTd=1, MD=2, MDd=3
+  bool HasLDdFlag = IsClangCL && Args.hasArg(options::OPT__SLASH_LDd);

hans wrote:
> Could this be an enum, or reuse existing values like the /Mx option ids?
Oh, right, resuing the options::OPT__SLASH_ flags makes more sense.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:4461
+  } else {
+if (Arg *A = Args.getLastArg(options::OPT_fms_runtime_lib_EQ)) {
+  StringRef Val = A->getValue();

hans wrote:
> Is there a getLastArg() variant that allows getting the last argument of 
> either the /Mx options or -fms-runtime-lib, so we don't need to check 
> IsClangCL?
Actually, I think I can just remove the IsClangCL option since this function 
now runs either in `AddClangCLArgs` or under `!IsCLMode()`. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133457

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


[PATCH] D133092: [clang] fix generation of .debug_aranges with LTO

2022-09-14 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

This is not correct. GNU ld and gold don't accept `-mllvm`. You need to use 
`-plugin-opt=-generate...`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133092

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


[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D133354#3789212 , @ningvin wrote:

> @hans just to clarify as I do not have commit access: do I still need to 
> perform some action?

Ah, thanks for letting me know. I've committed on your behalf as 
https://github.com/llvm/llvm-project/commit/49e7ef2c09facd722a29a5ad96a7f8f16e362b28


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133354

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


[clang] 49e7ef2 - [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Hans Wennborg via cfe-commits

Author: Julius
Date: 2022-09-14T19:48:08+02:00
New Revision: 49e7ef2c09facd722a29a5ad96a7f8f16e362b28

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

LOG: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility 
mode

When running in MSVC compatibility mode, previously no deprecated copy
operation warnings (enabled by -Wdeprecated-copy) were raised. This
restriction was already in place when the deprecated copy warning was
first introduced.

This patch removes said restriction so that deprecated copy warnings, if
enabled, are also raised in MSVC compatibility mode. The reasoning here
being that these warnings are still useful when running in MSVC
compatibility mode and also have to be semi-explicitly enabled in the
first place (using -Wdeprecated-copy, -Wdeprecated or -Wextra).

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

Added: 


Modified: 
clang/lib/Sema/SemaDeclCXX.cpp
clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
clang/test/SemaCXX/deprecated-copy.cpp
clang/test/SemaCXX/deprecated.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp
index ac34e42f92773..7c731131ed2f8 100644
--- a/clang/lib/Sema/SemaDeclCXX.cpp
+++ b/clang/lib/Sema/SemaDeclCXX.cpp
@@ -14429,13 +14429,10 @@ static void diagnoseDeprecatedCopyOperation(Sema , 
CXXMethodDecl *CopyOp) {
   CXXRecordDecl *RD = CopyOp->getParent();
   CXXMethodDecl *UserDeclaredOperation = nullptr;
 
-  // In Microsoft mode, assignment operations don't affect constructors and
-  // vice versa.
   if (RD->hasUserDeclaredDestructor()) {
 UserDeclaredOperation = RD->getDestructor();
   } else if (!isa(CopyOp) &&
- RD->hasUserDeclaredCopyConstructor() &&
- !S.getLangOpts().MSVCCompat) {
+ RD->hasUserDeclaredCopyConstructor()) {
 // Find any user-declared copy constructor.
 for (auto *I : RD->ctors()) {
   if (I->isCopyConstructor()) {
@@ -14445,8 +14442,7 @@ static void diagnoseDeprecatedCopyOperation(Sema , 
CXXMethodDecl *CopyOp) {
 }
 assert(UserDeclaredOperation);
   } else if (isa(CopyOp) &&
- RD->hasUserDeclaredCopyAssignment() &&
- !S.getLangOpts().MSVCCompat) {
+ RD->hasUserDeclaredCopyAssignment()) {
 // Find any user-declared move assignment operator.
 for (auto *I : RD->methods()) {
   if (I->isCopyAssignmentOperator()) {

diff  --git a/clang/test/SemaCXX/deprecated-copy-with-dtor.cpp 
b/clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
index 463b1c895009c..b274d8cb3afd1 100644
--- a/clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
+++ b/clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-dtor -verify 
-fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-dtor -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-dtor -verify 
-fms-compatibility
 
 class A {
 public:

diff  --git a/clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp 
b/clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
index 4f259ca788540..f29d65a9ced2b 100644
--- a/clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
+++ b/clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify -fms-compatibility
 
 struct A {
   A =(const A &); // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-provided copy 
assignment operator}}

diff  --git a/clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp 
b/clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
index 490ae6fbdabb9..f46e1f0961802 100644
--- a/clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
+++ b/clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify 

[PATCH] D133354: [Clang]: Diagnose deprecated copy operations also in MSVC compatibility mode

2022-09-14 Thread Hans Wennborg via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG49e7ef2c09fa: [Clang]: Diagnose deprecated copy operations 
also in MSVC compatibility mode (authored by ningvin, committed by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133354

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
  clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
  clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
  clang/test/SemaCXX/deprecated-copy.cpp
  clang/test/SemaCXX/deprecated.cpp


Index: clang/test/SemaCXX/deprecated.cpp
===
--- clang/test/SemaCXX/deprecated.cpp
+++ clang/test/SemaCXX/deprecated.cpp
@@ -1,10 +1,16 @@
 // RUN: %clang_cc1 -std=c++98 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++98 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++11 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++17 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++17 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -fms-compatibility
 // RUN: %clang_cc1 -std=c++2a %s -Wno-parentheses -Wdeprecated 
-verify=expected,cxx20 -triple x86_64-linux-gnu
+// RUN: %clang_cc1 -std=c++2a %s -Wno-parentheses -Wdeprecated 
-verify=expected,cxx20 -triple x86_64-linux-gnu -fms-compatibility
 
 // RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -Wno-deprecated-register 
-DNO_DEPRECATED_FLAGS
+// RUN: %clang_cc1 -std=c++14 %s -Wno-parentheses -Wdeprecated 
-verify=expected,not-cxx20 -triple x86_64-linux-gnu -Wno-deprecated-register 
-DNO_DEPRECATED_FLAGS -fms-compatibility
 
 #include "Inputs/register.h"
 
Index: clang/test/SemaCXX/deprecated-copy.cpp
===
--- clang/test/SemaCXX/deprecated-copy.cpp
+++ clang/test/SemaCXX/deprecated-copy.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy -verify -fms-compatibility
 
 struct A {
 A& operator=(const A&) = default; // expected-warning {{definition of 
implicit copy constructor for 'A' is deprecated because it has a user-declared 
copy assignment operator}}
Index: clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-user-provided-dtor.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-dtor 
-verify -fms-compatibility
 
 struct A {
   ~A(); // expected-warning {{definition of implicit copy constructor for 'A' 
is deprecated because it has a user-provided destructor}}
Index: clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-user-provided-copy.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated -verify -fms-compatibility
 // RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify
+// RUN: %clang_cc1 -std=c++11 %s -Wdeprecated-copy-with-user-provided-copy 
-verify -fms-compatibility
 
 struct A {
   A =(const A &); // expected-warning {{definition of implicit copy 
constructor for 'A' is deprecated because it has a user-provided copy 
assignment operator}}
Index: clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
===
--- clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
+++ clang/test/SemaCXX/deprecated-copy-with-dtor.cpp
@@ -1,6 +1,9 @@
 // RUN: 

[PATCH] D133817: MSVC ABI: Looks like even non-aarch64 uses the MSVC/14 definition for pod/aggregate passing

2022-09-14 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Thanks!

> But I had
> trouble figuring out how to exercise this functionality properly to add
> test coverage and then compare that to MSVC itself... - I got very
> confused/turned around trying to test this, so I've given up enough to
> send what I have out for review, but happy to look further into this
> with help.

I think I would take the three cases you found (protected, nsdmi, defaulted 
copy ctor), add each to this file, and check for the IR prototypes here in this 
test file. Either sret is used, or it is not.

Regarding HFAs, I believe that logic is only used on x86/x64 for the 
__vectorcall calling convention. I believe it is well-tested with respect to 
C-like structs, but the C++ aspects that you are changing are not well tested. 
I think I managed to construct a case using NSDMIs (Richard used to prefer the 
terminology "default member initializers" which is simpler): 
https://godbolt.org/z/daPzKxj3h It looks like we don't match arm64 MSVC's 
behavior exactly here, but your change to remove the "!isAArch64" test would 
probably cause us to change behavior in this case, right?




Comment at: clang/test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp:77
 
+struct SmallWithSmallWithPrivate {
+  SmallWithPrivate p;

I'm amused that this class is passed directly, but if you pass the field by 
itself, it is passed indirectly. :shrug:



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133817

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


[PATCH] D132421: [HLSL] Support PCH for cc1 mode

2022-09-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:50
+if (S.LookupQualifiedName(Result, HLSLNamespace)) {
+  NamedDecl *Found = Result.getFoundDecl();
+  if (auto *TD = dyn_cast(Found)) {

99.9% sure this is safe because we're looking up a tag name and I can't think 
of any way that might return multiple results for the same identifier, but 
bringing it up just in case anyone else knows of some obscure extension where 
that's possible.



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:55
+  } else
+PrevDecl = dyn_cast(Found);
+  assert(PrevDecl && "Unexpected lookup result type.");

Is it possible that this finds a different kind of tag, like an enumeration?



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:85-86
 AccessSpecifier Access = AccessSpecifier::AS_private) {
+if (Record->isCompleteDefinition())
+  return *this;
 assert(Record->isBeingDefined() &&

A downside to this pattern is that we need to repeat the "if it's a complete 
definition, don't do anything" predicate in basically any mutating member 
function. Getting that wrong will lead to hard-to-debug issues with PCH, as I 
understand it. But I don't think there's a cleaner way to do that without doing 
far more invasive changes.



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:378
+  if (S.LookupQualifiedName(Result, AST.getTranslationUnitDecl()))
+PrevDecl = Result.getAsSingle();
+  HLSLNamespace = NamespaceDecl::Create(AST, AST.getTranslationUnitDecl(),

How certain are you that there's only one result possible here?



Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:387
+  // Force external decls in the HLSL namespace to load from the PCH.
+  HLSLNamespace->getCanonicalDecl()->decls_begin();
   defineTrivialHLSLTypes();





Comment at: clang/lib/Sema/HLSLExternalSemaSource.cpp:459-461
+  ASTContext  = SemaPtr->getASTContext();
+  IdentifierInfo  = AST.Idents.get("Resource", tok::TokenKind::identifier);
+  LookupResult Result(*SemaPtr, , SourceLocation(), Sema::LookupTagName);

We made a lookup result but then do nothing with it?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132421

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


  1   2   3   >