[PATCH] D145843: [clangd] Add option to always insert headers with <> instead of ""

2023-03-17 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added a comment.

Thanks for the patch!

May I suggest the flag name `IncludeDelimiter`, with values `Auto` and 
`AlwaysBrackets` (with the default being `Auto`)? This leaves room for other 
styles in the future if desired.

It would mean a slight implementation change since the YAML representation 
would now be a string rather than a bool, but nothing too involved; you can use 
the existing code for parsing `IndexBlock::Background` (whose allowed values 
are `Build` and `Skip`) as a guide.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145843

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


[PATCH] D143436: [clangd] Move standard options adaptor to CommandMangler

2023-03-17 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D143436#4203525 , @dyung wrote:

> In D143436#4203394 , 
> @DmitryPolukhin wrote:
>
>> @dyung I cannot reproduce this issue on two different machines in both cases 
>> tests work fine. For clang and llvm-jitlink binaries (the only binaries used 
>> in the tests) my changes are non-functional and I didn't change anything in 
>> compiler-rt or ORC. Are you able to reproduce the crashes locally?
>
> So far I cannot on my own dev machines. I'll take the buildbot offline and 
> try to see if I can figure out what is going on this weekend.

So after deleting the build directory and clearing the ccache, the problem no 
longer seems to occur. I'm guessing it might have been corruption somewhere. 
Sorry about that!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D145401: [AMDGPU] Reserve extra SGPR blocks wth XNACK "any" TID Setting

2023-03-17 Thread Austin Kerbow via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG864a2b25beac: [AMDGPU] Reserve extra SGPR blocks wth XNACK 
any TID Setting (authored by kerbowa).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145401

Files:
  clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
  llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
  llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll
  llvm/test/CodeGen/AMDGPU/amdpal-callable.ll
  llvm/test/CodeGen/AMDGPU/occupancy-levels.ll
  llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
  llvm/test/CodeGen/AMDGPU/tid-kd-xnack-any.ll
  llvm/test/CodeGen/AMDGPU/tid-kd-xnack-off.ll
  llvm/test/CodeGen/AMDGPU/tid-kd-xnack-on.ll
  llvm/test/CodeGen/AMDGPU/trap-abis.ll

Index: llvm/test/CodeGen/AMDGPU/trap-abis.ll
===
--- llvm/test/CodeGen/AMDGPU/trap-abis.ll
+++ llvm/test/CodeGen/AMDGPU/trap-abis.ll
@@ -17,7 +17,75 @@
 
 define amdgpu_kernel void @trap(ptr addrspace(1) nocapture readonly %arg0) {
 ; NOHSA-TRAP-GFX900-V2-LABEL: trap:
-; NOHSA-TRAP-GFX900-V2:   ; %bb.0:
+; NOHSA-TRAP-GFX900-V2: .amd_kernel_code_t
+; NOHSA-TRAP-GFX900-V2-NEXT: amd_code_version_major = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: amd_code_version_minor = 2
+; NOHSA-TRAP-GFX900-V2-NEXT: amd_machine_kind = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: amd_machine_version_major = 9
+; NOHSA-TRAP-GFX900-V2-NEXT: amd_machine_version_minor = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: amd_machine_version_stepping = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: kernel_code_entry_byte_offset = 256
+; NOHSA-TRAP-GFX900-V2-NEXT: kernel_code_prefetch_byte_size = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: granulated_workitem_vgpr_count = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: granulated_wavefront_sgpr_count = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: priority = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: float_mode = 240
+; NOHSA-TRAP-GFX900-V2-NEXT: priv = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_dx10_clamp = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: debug_mode = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_ieee_mode = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_wgp_mode = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_mem_ordered = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_fwd_progress = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_private_segment_wave_byte_offset = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: user_sgpr_count = 4
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_trap_handler = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_workgroup_id_x = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_workgroup_id_y = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_workgroup_id_z = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_workgroup_info = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_vgpr_workitem_id = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_exception_msb = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: granulated_lds_size = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_exception = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_private_segment_buffer = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_dispatch_ptr = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_queue_ptr = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_kernarg_segment_ptr = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_dispatch_id = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_flat_scratch_init = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_private_segment_size = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_grid_workgroup_count_x = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_grid_workgroup_count_y = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_sgpr_grid_workgroup_count_z = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_wavefront_size32 = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: enable_ordered_append_gds = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: private_element_size = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: is_ptr64 = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: is_dynamic_callstack = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: is_debug_enabled = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: is_xnack_enabled = 1
+; NOHSA-TRAP-GFX900-V2-NEXT: workitem_private_segment_byte_size = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: workgroup_group_segment_byte_size = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: gds_segment_byte_size = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: kernarg_segment_byte_size = 44
+; NOHSA-TRAP-GFX900-V2-NEXT: workgroup_fbarrier_count = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: wavefront_sgpr_count = 8
+; NOHSA-TRAP-GFX900-V2-NEXT: workitem_vgpr_count = 2
+; NOHSA-TRAP-GFX900-V2-NEXT: reserved_vgpr_first = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: reserved_vgpr_count = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: reserved_sgpr_first = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: reserved_sgpr_count = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: debug_wavefront_private_segment_offset_sgpr = 0
+; NOHSA-TRAP-GFX900-V2-NEXT: debug_private_segment_buffer_sgpr = 0
+; 

[clang] 864a2b2 - [AMDGPU] Reserve extra SGPR blocks wth XNACK "any" TID Setting

2023-03-17 Thread Austin Kerbow via cfe-commits

Author: Austin Kerbow
Date: 2023-03-17T20:26:23-07:00
New Revision: 864a2b25beac507cc76b50030757283aae434c0c

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

LOG: [AMDGPU] Reserve extra SGPR blocks wth XNACK "any" TID Setting

ASMPrinter was relying on feature bits to setup extra SGRPs in the knerel
descriptor for the xnack_mask. This was broken for the dynamic XNACK "any" TID
setting which could cause user SGPRs to be clobbered if the number of SGPRs
reserved was near a granulated block boundary.

When XNACK was enabled this worked correctly in the ASMParser which meant some
kernels were only failing without "-save-temps".

Fixes: SWDEV-382764

Reviewed By: kzhuravl

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

Added: 
llvm/test/CodeGen/AMDGPU/tid-kd-xnack-any.ll
llvm/test/CodeGen/AMDGPU/tid-kd-xnack-off.ll
llvm/test/CodeGen/AMDGPU/tid-kd-xnack-on.ll

Modified: 
clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll
llvm/test/CodeGen/AMDGPU/amdpal-callable.ll
llvm/test/CodeGen/AMDGPU/occupancy-levels.ll
llvm/test/CodeGen/AMDGPU/resource-optimization-remarks.ll
llvm/test/CodeGen/AMDGPU/trap-abis.ll

Removed: 




diff  --git a/clang/test/Frontend/amdgcn-machine-analysis-remarks.cl 
b/clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
index cf0c15b6319f1..9403d12afa05a 100644
--- a/clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
+++ b/clang/test/Frontend/amdgcn-machine-analysis-remarks.cl
@@ -2,7 +2,7 @@
 // RUN: %clang_cc1 -triple amdgcn-amd-amdhsa -target-cpu gfx908 
-Rpass-analysis=kernel-resource-usage -S -O0 -verify %s -o /dev/null
 
 // expected-remark@+9 {{Function Name: foo}}
-// expected-remark@+8 {{SGPRs: 9}}
+// expected-remark@+8 {{SGPRs: 13}}
 // expected-remark@+7 {{VGPRs: 10}}
 // expected-remark@+6 {{AGPRs: 12}}
 // expected-remark@+5 {{ScratchSize [bytes/lane]: 0}}

diff  --git a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp 
b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
index 0883e7a5ed3a3..82c57dfcef0d8 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp
@@ -251,9 +251,9 @@ void AMDGPUAsmPrinter::emitFunctionBodyEnd() {
   STM, KernelName, getAmdhsaKernelDescriptor(*MF, CurrentProgramInfo),
   CurrentProgramInfo.NumVGPRsForWavesPerEU,
   CurrentProgramInfo.NumSGPRsForWavesPerEU -
-  IsaInfo::getNumExtraSGPRs(,
-CurrentProgramInfo.VCCUsed,
-CurrentProgramInfo.FlatUsed),
+  IsaInfo::getNumExtraSGPRs(
+  , CurrentProgramInfo.VCCUsed, CurrentProgramInfo.FlatUsed,
+  getTargetStreamer()->getTargetID()->isXnackOnOrAny()),
   CurrentProgramInfo.VCCUsed, CurrentProgramInfo.FlatUsed,
   CodeObjectVersion);
 
@@ -721,7 +721,8 @@ void AMDGPUAsmPrinter::getSIProgramInfo(SIProgramInfo 
,
   // duplicated in part in AMDGPUAsmParser::calculateGPRBlocks, and could be
   // unified.
   unsigned ExtraSGPRs = IsaInfo::getNumExtraSGPRs(
-  , ProgInfo.VCCUsed, ProgInfo.FlatUsed);
+  , ProgInfo.VCCUsed, ProgInfo.FlatUsed,
+  getTargetStreamer()->getTargetID()->isXnackOnOrAny());
 
   // Check the addressable register limit before we add ExtraSGPRs.
   if (STM.getGeneration() >= AMDGPUSubtarget::VOLCANIC_ISLANDS &&

diff  --git a/llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll 
b/llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll
index 8e558b539fa72..e639fce9d690e 100644
--- a/llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll
+++ b/llvm/test/CodeGen/AMDGPU/GlobalISel/extractelement.ll
@@ -3061,7 +3061,7 @@ define amdgpu_kernel void @dyn_extract_v5f64_s_s(ptr 
addrspace(1) %out, i32 %sel
 ; GPRIDX-NEXT: gds_segment_byte_size = 0
 ; GPRIDX-NEXT: kernarg_segment_byte_size = 12
 ; GPRIDX-NEXT: workgroup_fbarrier_count = 0
-; GPRIDX-NEXT: wavefront_sgpr_count = 9
+; GPRIDX-NEXT: wavefront_sgpr_count = 13
 ; GPRIDX-NEXT: workitem_vgpr_count = 3
 ; GPRIDX-NEXT: reserved_vgpr_first = 0
 ; GPRIDX-NEXT: reserved_vgpr_count = 0
@@ -3913,7 +3913,7 @@ define amdgpu_kernel void @dyn_extract_v4f32_s_s_s(ptr 
addrspace(1) %out, i32 %s
 ; GPRIDX-NEXT: kernel_code_entry_byte_offset = 256
 ; GPRIDX-NEXT: kernel_code_prefetch_byte_size = 0
 ; GPRIDX-NEXT: granulated_workitem_vgpr_count = 0
-; GPRIDX-NEXT: granulated_wavefront_sgpr_count = 0
+; GPRIDX-NEXT: granulated_wavefront_sgpr_count = 1
 ; GPRIDX-NEXT: priority = 0
 ; GPRIDX-NEXT: float_mode = 240
 ; GPRIDX-NEXT: priv = 0
@@ -3956,7 +3956,7 @@ define amdgpu_kernel void @dyn_extract_v4f32_s_s_s(ptr 

[PATCH] D145721: [HIP] clang should pass `-mno-amdgpu-ieee` to -cc1

2023-03-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D145721#4182834 , @tra wrote:

>> clang should pass `-mno-amdgpu-ieee` to -cc1
>
> It would be useful to have some details on why we should pass that option.

`-mamdgpu-ieee` was introduced by https://reviews.llvm.org/D77013 but I forgot 
to let clang driver pass it to clang -cc1. Recently we found that.




Comment at: clang/test/Driver/hip-options.hip:133
+// IEEE-ON-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-mamdgpu-ieee"
+// IEEE-ON-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-mno-amdgpu-ieee"
+

tra wrote:
> Nit: Both lines could be collapsed into matching `"-m{{(no-)?}}amdgpu-ieee"` 
> Either way is fine.
will do



Comment at: clang/test/Driver/hip-options.hip:137-138
+// RUN:   --cuda-gpu-arch=gfx906  %s 2>&1 | FileCheck 
-check-prefixes=IEEE-OFF,IEEE-OFF-NEG %s
+// IEEE-OFF-NEG-NOT: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-mamdgpu-ieee"
+// IEEE-OFF-DAG: clang{{.*}} "-triple" "amdgcn-amd-amdhsa" {{.*}} 
"-mno-amdgpu-ieee"

tra wrote:
> This looks odd. 
> If the DAG line matches on the first clang invocation, the NEG-NOT will 
> always succeed, because it will have nothing to check.
> 
> If clang invocation with `-no-mamdgpu-ieee` happens to be before the 
> invocation with `-mamdgpu-ieee`, then the NEG-NOT will not succeed.
> 
> Do I understand it correctly that the idea here is to make sure that only 
> `-mno-amdgpu-ieee` is ever passed to cc1?
> What's the purpose of -DAG? Do you expect to see multiple cc1 with `"-triple" 
> "amdgcn-amd-amdhsa"` ? AFAICT there should be only one for gfx906 and DAG 
> should not be needed.
> 
> The -NOT check I'd do in a separate RUN.
> 
> 
The `-NEG` check is supposed to be a separate run. I will add a separate run 
for it and remove `-DAG`


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

https://reviews.llvm.org/D145721

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


[PATCH] D140663: CUDA/HIP: Use kernel name to map to symbol

2023-03-17 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D140663#4203604 , @tra wrote:

> It appears that this patch may be causing a use-after free when we attempt to 
> generate kernel registration code. 
> The root cause is that the value we insert into `KernelHandles` by name is 
> later on replaced by a different instance of the global value with the same 
> name.
> AFAICT, the invalidation issue was present before but we accidentally avoided 
> it because we only looked up the still-valid new entries. The dangling 
> references were still in the map, but not accessed.

Agree. I think the reason is that the `F` we passed into 
`CGNVCUDARuntime::getKernelHandle` may be replaced by a new function with the 
same name. Luckily, the new function should be passed to 
`CGNVCUDARuntime::getKernelHandle` again, therefore we get a chance to update 
our maps.




Comment at: clang/lib/CodeGen/CGCUDANV.cpp:1198
+  auto Loc = KernelHandles.find(F->getName());
   if (Loc != KernelHandles.end())
 return Loc->second;

It is possible that F is replaced with a new function with the same name. In 
this case, we need to update our map, so add a condition `&& Loc->second == F` 
to the above condition.





Comment at: clang/lib/CodeGen/CGCUDANV.cpp:1207-1215
   auto *Var = new llvm::GlobalVariable(
   TheModule, F->getType(), /*isConstant=*/true, F->getLinkage(),
   /*Initializer=*/nullptr,
   CGM.getMangledName(
   GD.getWithKernelReferenceKind(KernelReferenceKind::Kernel)));
   Var->setAlignment(CGM.getPointerAlign().getAsAlign());
   Var->setDSOLocal(F->isDSOLocal());

Add a condition `if (Loc == KernelHandles.end())` to the above code for 
creating and modifying `Var`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140663

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


[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.

lgtm, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

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


[PATCH] D140663: CUDA/HIP: Use kernel name to map to symbol

2023-03-17 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

It appears that this patch may be causing a use-after free when we attempt to 
generate kernel registration code. 
The root cause is that the value we insert into `KernelHandles` by name is 
later on replaced by a different instance of the global value with the same 
name.
AFAICT, the invalidation issue was present before but we accidentally avoided 
it because we only looked up the still-valid new entries. The dangling 
references were still in the map, but not accessed.

It's reproducible on this example: https://godbolt.org/z/qGYTr3Ej5

Here's the stack trace for the call path which frees the old entry:

  #3  0x55e5564e75e2 in llvm::User::operator delete (Usr=0x55e55f6ff438) at 
/usr/local/google/home/tra/work/llvm/repo/llvm/lib/IR/User.cpp:190
  #4  0x55e5563a0a70 in 
llvm::ilist_alloc_traits::deleteNode (V=0x55e55f6ff438) at 
/usr/local/google/home/tra/work/llvm/repo/llvm/include/llvm/ADT/ilist.h:42
  #5  0x55e55639d875 in 
llvm::iplist_impl, 
llvm::SymbolTableListTraits >::erase (this=0x55e55f75a3e8, 
where=...) at 
/usr/local/google/home/tra/work/llvm/repo/llvm/include/llvm/ADT/ilist.h:269
  #6  0x55e55637c173 in llvm::Function::eraseFromParent 
(this=0x55e55f6ff438) at 
/usr/local/google/home/tra/work/llvm/repo/llvm/lib/IR/Function.cpp:367
  #7  0x55e5563a4ad5 in llvm::GlobalValue::eraseFromParent 
(this=0x55e55f6ff438) at 
/usr/local/google/home/tra/work/llvm/repo/llvm/include/llvm/IR/Value.def:76
  #8  0x55e5570dd747 in 
clang::CodeGen::CodeGenModule::applyGlobalValReplacements (this=0x55e55f7a06d0) 
at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/CodeGen/CodeGenModule.cpp:315
  #9  0x55e5570deb3a in clang::CodeGen::CodeGenModule::Release 
(this=0x55e55f7a06d0) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/CodeGen/CodeGenModule.cpp:540
  #10 0x55e5581e5ede in (anonymous 
namespace)::CodeGeneratorImpl::HandleTranslationUnit (this=0x55e55f79aa40, 
Ctx=...) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/CodeGen/ModuleBuilder.cpp:287
  #11 0x55e5581de64e in clang::BackendConsumer::HandleTranslationUnit 
(this=0x55e55f79a7a0, C=...) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/CodeGen/CodeGenAction.cpp:308
  #12 0x55e55b063273 in clang::ParseAST (S=..., PrintStats=false, 
SkipFunctionBodies=false) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/Parse/ParseAST.cpp:175
  #13 0x55e557ff26ec in clang::ASTFrontendAction::ExecuteAction 
(this=0x55e55f75aa20) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/Frontend/FrontendAction.cpp:1168
  #14 0x55e5581da604 in clang::CodeGenAction::ExecuteAction 
(this=0x55e55f75aa20) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/CodeGen/CodeGenAction.cpp:1172
  #15 0x55e557ff20ec in clang::FrontendAction::Execute 
(this=0x55e55f75aa20) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/Frontend/FrontendAction.cpp:1058
  #16 0x55e557f1b618 in clang::CompilerInstance::ExecuteAction 
(this=0x55e55f7564c0, Act=...) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/Frontend/CompilerInstance.cpp:1048
  #17 0x55e5581c35c7 in clang::ExecuteCompilerInvocation 
(Clang=0x55e55f7564c0) at 
/usr/local/google/home/tra/work/llvm/repo/clang/lib/FrontendTool/ExecuteCompilerInvocation.cpp:264
  #18 0x55e5533464b0 in cc1_main (Argv=llvm::ArrayRef of length 86 = {...}, 
Argv0=0x7ffd95ce621e 
"/usr/local/google/home/tra/work/llvm/build/debug/bin/clang-15", 
MainAddr=0x55e5533305f0 )
  at 
/usr/local/google/home/tra/work/llvm/repo/clang/tools/driver/cc1_main.cpp:251
  #19 0x55e553331dca in ExecuteCC1Tool (ArgV=llvm::SmallVector of Size 87, 
Capacity 256 = {...}, ToolContext=...) at 
/usr/local/google/home/tra/work/llvm/repo/clang/tools/driver/driver.cpp:366
  #20 0x55e553330aec in clang_main (Argc=87, Argv=0x7ffd95ce4a68, 
ToolContext=...) at 
/usr/local/google/home/tra/work/llvm/repo/clang/tools/driver/driver.cpp:407
  #21 0x55e553369d5d in main (argc=87, argv=0x7ffd95ce4a68) at 
tools/clang/tools/driver/clang-driver.cpp:15


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140663

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


[PATCH] D146278: [flang] add -flang-experimental-hlfir flag to flang-new

2023-03-17 Thread Slava Zakharin via Phabricator via cfe-commits
vzakhari added inline comments.



Comment at: flang/include/flang/Tools/CLOptions.inc:238
+  pm.addPass(mlir::createCanonicalizerPass());
+  pm.addPass(hlfir::createLowerHLFIRIntrinsicsPass());
+  pm.addPass(hlfir::createBufferizeHLFIRPass());

I would imagine we may not want to optimize MATMUL(TRANSPOSE) into 
MATMUL_TRANSPOSE at O0.  What is the best way to control this?  We may either 
disable canonicalization or let `LowerHLFIRIntrinsicsPass` lower 
MATMUL_TRANSPOSE differently based on the optimization level.  Or is it always 
okay to implement it as a combined operation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146278

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


[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 506242.
jansvoboda11 added a comment.

Improve member documentation


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp

Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -239,3 +239,130 @@
   EXPECT_EQ(convert_to_slash(DepFile),
 "test.cpp.o: /root/test.cpp /root/header.h\n");
 }
+
+// Note: We want to test caching in DependencyScanningWorkerFilesystem. To do
+// that, we need to be able to mutate the underlying file system. However,
+// InMemoryFileSystem does not allow changing the contents of a file after it's
+// been created.
+// To simulate the behavior, we create two separate in-memory file systems, each
+// containing different version of the same file. We pass those to two scanning
+// file systems that share the same cache.
+
+TEST(DependencyScanningFileSystemTest, CacheFileContentsEnabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+
+  StringRef Path = "/root/source.c";
+  auto Contents1 = llvm::MemoryBuffer::getMemBuffer("contents1");
+  auto Contents2 = llvm::MemoryBuffer::getMemBuffer("contents2");
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents1)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/source.c.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents2)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/source.c.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+}
+
+TEST(DependencyScanningFileSystemTest, CacheFileContentsDisabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+
+  StringRef Path = "/root/module.pcm";
+  auto Contents1 = llvm::MemoryBuffer::getMemBuffer("contents1");
+  auto Contents2 = llvm::MemoryBuffer::getMemBuffer("contents2");
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents1)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/module.pcm.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents2)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/module.pcm.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents2");
+  }
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureEnabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto InMemoryFS = llvm::makeIntrusiveRefCnt();
+  DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+
+  StringRef Path = "/root/source.c";
+
+  auto Stat1 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat1);
+
+  auto Contents = llvm::MemoryBuffer::getMemBuffer("contents");
+  InMemoryFS->addFile(Path, 0, std::move(Contents));
+
+  auto Stat2 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat2);
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureDisabledFile) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto InMemoryFS = llvm::makeIntrusiveRefCnt();
+  DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+
+  StringRef Path = "/root/vector";
+
+  auto Stat1 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat1);
+
+  auto Contents = llvm::MemoryBuffer::getMemBuffer("contents");
+  InMemoryFS->addFile(Path, 0, std::move(Contents));
+
+  auto Stat2 = ScanningFS.status(Path);
+  EXPECT_TRUE(Stat2);
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureDisabledDirectory) {
+  

[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 506241.
jansvoboda11 added a comment.

Disable brace initialization


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp

Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -239,3 +239,130 @@
   EXPECT_EQ(convert_to_slash(DepFile),
 "test.cpp.o: /root/test.cpp /root/header.h\n");
 }
+
+// Note: We want to test caching in DependencyScanningWorkerFilesystem. To do
+// that, we need to be able to mutate the underlying file system. However,
+// InMemoryFileSystem does not allow changing the contents of a file after it's
+// been created.
+// To simulate the behavior, we create two separate in-memory file systems, each
+// containing different version of the same file. We pass those to two scanning
+// file systems that share the same cache.
+
+TEST(DependencyScanningFileSystemTest, CacheFileContentsEnabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+
+  StringRef Path = "/root/source.c";
+  auto Contents1 = llvm::MemoryBuffer::getMemBuffer("contents1");
+  auto Contents2 = llvm::MemoryBuffer::getMemBuffer("contents2");
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents1)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/source.c.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents2)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/source.c.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+}
+
+TEST(DependencyScanningFileSystemTest, CacheFileContentsDisabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+
+  StringRef Path = "/root/module.pcm";
+  auto Contents1 = llvm::MemoryBuffer::getMemBuffer("contents1");
+  auto Contents2 = llvm::MemoryBuffer::getMemBuffer("contents2");
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents1)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/module.pcm.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents2)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/module.pcm.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents2");
+  }
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureEnabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto InMemoryFS = llvm::makeIntrusiveRefCnt();
+  DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+
+  StringRef Path = "/root/source.c";
+
+  auto Stat1 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat1);
+
+  auto Contents = llvm::MemoryBuffer::getMemBuffer("contents");
+  InMemoryFS->addFile(Path, 0, std::move(Contents));
+
+  auto Stat2 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat2);
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureDisabledFile) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto InMemoryFS = llvm::makeIntrusiveRefCnt();
+  DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+
+  StringRef Path = "/root/vector";
+
+  auto Stat1 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat1);
+
+  auto Contents = llvm::MemoryBuffer::getMemBuffer("contents");
+  InMemoryFS->addFile(Path, 0, std::move(Contents));
+
+  auto Stat2 = ScanningFS.status(Path);
+  EXPECT_TRUE(Stat2);
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureDisabledDirectory) {
+  

[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 506240.
jansvoboda11 added a comment.

Use brace initialization in named constructors


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp

Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -239,3 +239,130 @@
   EXPECT_EQ(convert_to_slash(DepFile),
 "test.cpp.o: /root/test.cpp /root/header.h\n");
 }
+
+// Note: We want to test caching in DependencyScanningWorkerFilesystem. To do
+// that, we need to be able to mutate the underlying file system. However,
+// InMemoryFileSystem does not allow changing the contents of a file after it's
+// been created.
+// To simulate the behavior, we create two separate in-memory file systems, each
+// containing different version of the same file. We pass those to two scanning
+// file systems that share the same cache.
+
+TEST(DependencyScanningFileSystemTest, CacheFileContentsEnabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+
+  StringRef Path = "/root/source.c";
+  auto Contents1 = llvm::MemoryBuffer::getMemBuffer("contents1");
+  auto Contents2 = llvm::MemoryBuffer::getMemBuffer("contents2");
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents1)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/source.c.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents2)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/source.c.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+}
+
+TEST(DependencyScanningFileSystemTest, CacheFileContentsDisabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+
+  StringRef Path = "/root/module.pcm";
+  auto Contents1 = llvm::MemoryBuffer::getMemBuffer("contents1");
+  auto Contents2 = llvm::MemoryBuffer::getMemBuffer("contents2");
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents1)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/module.pcm.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents2)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/module.pcm.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents2");
+  }
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureEnabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto InMemoryFS = llvm::makeIntrusiveRefCnt();
+  DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+
+  StringRef Path = "/root/source.c";
+
+  auto Stat1 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat1);
+
+  auto Contents = llvm::MemoryBuffer::getMemBuffer("contents");
+  InMemoryFS->addFile(Path, 0, std::move(Contents));
+
+  auto Stat2 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat2);
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureDisabledFile) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto InMemoryFS = llvm::makeIntrusiveRefCnt();
+  DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+
+  StringRef Path = "/root/vector";
+
+  auto Stat1 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat1);
+
+  auto Contents = llvm::MemoryBuffer::getMemBuffer("contents");
+  InMemoryFS->addFile(Path, 0, std::move(Contents));
+
+  auto Stat2 = ScanningFS.status(Path);
+  EXPECT_TRUE(Stat2);
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureDisabledDirectory) {
+  

[PATCH] D146342: [WIP][-Wunsafe-buffer-usage] Move the whole analysis to the end of a translation unit

2023-03-17 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 created this revision.
ziqingluo-90 added reviewers: NoQ, jkorous, t-rasmud, malavikasamak.
Herald added a subscriber: ChuanqiXu.
Herald added a project: All.
ziqingluo-90 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Our analysis requires a complete view of the translation unit to be 
conservative.  As mentioned in this patch 
,  we need to know if there is any 
function overload of a function `f` declared after `f`.   In addition, we later 
may want to make global variables safe too.  In such a case, we need to know if 
a global variable is used somewhere in the translation unit.   Moreover, the 
analysis now can ignore ill-formed code detected at the end of a TU.

A summary of the change:

1. Adds a TU traversal function in `UnsafeBufferAnalysis` to traverse and 
analyze each function definition;
2. Removes the old analysis entry in `AnalysisBasedWarnings.cpp`, which was 
called by `Sema` at the end of parsing a function;
3. Creates a new analysis entry in `AnalysisBasedWarnings.cpp` for `Sema` to 
call at the end of parsing a TU.

This patch is still work in progress as the existence of the following concerns:

1. Can we move everything in `AnalysisBasedWarnings.cpp` to `Sema`?  So far 
`AnalysisBasedWarnings` is used to bridge `Sema` and `UnsafeBufferAnalysis` so 
that the changes are minimal.
2. We probably need a more efficient TU traversal implementation.
3. Current tests are mostly fine except that some notes with message "in 
instantiation of ... " are missing.  Although these notes are not emitted by 
our analysis, we better understand why things change.
4. To test this patch on a branch with all ongoing [-Wunsafe-buffer-usage] 
patches.
5. Maybe there are better solutions?  (Looking for comments!)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146342

Files:
  clang/include/clang/Analysis/Analyses/UnsafeBufferUsage.h
  clang/include/clang/Sema/AnalysisBasedWarnings.h
  clang/lib/Analysis/UnsafeBufferUsage.cpp
  clang/lib/Sema/AnalysisBasedWarnings.cpp
  clang/lib/Sema/Sema.cpp

Index: clang/lib/Sema/Sema.cpp
===
--- clang/lib/Sema/Sema.cpp
+++ clang/lib/Sema/Sema.cpp
@@ -1426,6 +1426,8 @@
 }
   }
 
+  AnalysisWarnings.CheckUnsafeBufferUsage(Context.getTranslationUnitDecl());
+
   // Check we've noticed that we're no longer parsing the initializer for every
   // variable. If we miss cases, then at best we have a performance issue and
   // at worst a rejects-valid bug.
Index: clang/lib/Sema/AnalysisBasedWarnings.cpp
===
--- clang/lib/Sema/AnalysisBasedWarnings.cpp
+++ clang/lib/Sema/AnalysisBasedWarnings.cpp
@@ -13,6 +13,7 @@
 //===--===//
 
 #include "clang/Sema/AnalysisBasedWarnings.h"
+#include "clang/AST/Decl.h"
 #include "clang/AST/DeclCXX.h"
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/EvaluatedExprVisitor.h"
@@ -2290,6 +2291,24 @@
 S.Diag(D.Loc, D.PD);
 }
 
+void clang::sema::AnalysisBasedWarnings::CheckUnsafeBufferUsage(
+const TranslationUnitDecl *TU) {
+  if (!TU)
+return; // This is unexpected, give up quietly.
+
+  DiagnosticsEngine  = S.getDiagnostics();
+
+  // Emit unsafe buffer usage warnings and fixits.
+  if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation, SourceLocation()) ||
+  !Diags.isIgnored(diag::warn_unsafe_buffer_variable, SourceLocation())) {
+UnsafeBufferUsageReporter R(S);
+checkUnsafeBufferUsageForTU(
+TU, R, S,
+/*EmitFixits=*/S.getDiagnostics().getDiagnosticOptions().ShowFixits &&
+S.getLangOpts().CPlusPlus20);
+  }
+}
+
 void clang::sema::AnalysisBasedWarnings::IssueWarnings(
 sema::AnalysisBasedWarnings::Policy P, sema::FunctionScopeInfo *fscope,
 const Decl *D, QualType BlockType) {
@@ -2518,16 +2537,6 @@
   if (S.getLangOpts().CPlusPlus && !fscope->isCoroutine() && isNoexcept(FD))
 checkThrowInNonThrowingFunc(S, FD, AC);
 
-  // Emit unsafe buffer usage warnings and fixits.
-  if (!Diags.isIgnored(diag::warn_unsafe_buffer_operation, D->getBeginLoc()) ||
-  !Diags.isIgnored(diag::warn_unsafe_buffer_variable, D->getBeginLoc())) {
-UnsafeBufferUsageReporter R(S);
-checkUnsafeBufferUsage(
-D, R,
-/*EmitFixits=*/S.getDiagnostics().getDiagnosticOptions().ShowFixits &&
-S.getLangOpts().CPlusPlus20);
-  }
-
   // If none of the previous checks caused a CFG build, trigger one here
   // for the logical error handler.
   if (LogicalErrorHandler::hasActiveDiagnostics(Diags, D->getBeginLoc())) {
Index: clang/lib/Analysis/UnsafeBufferUsage.cpp
===
--- clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -7,10 +7,14 @@
 

[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 506237.
jansvoboda11 added a comment.
Herald added a subscriber: ormris.

Use named constructors instead of an argument to `PathPolicy`, add unit tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
  clang/unittests/Tooling/DependencyScannerTest.cpp

Index: clang/unittests/Tooling/DependencyScannerTest.cpp
===
--- clang/unittests/Tooling/DependencyScannerTest.cpp
+++ clang/unittests/Tooling/DependencyScannerTest.cpp
@@ -239,3 +239,130 @@
   EXPECT_EQ(convert_to_slash(DepFile),
 "test.cpp.o: /root/test.cpp /root/header.h\n");
 }
+
+// Note: We want to test caching in DependencyScanningWorkerFilesystem. To do
+// that, we need to be able to mutate the underlying file system. However,
+// InMemoryFileSystem does not allow changing the contents of a file after it's
+// been created.
+// To simulate the behavior, we create two separate in-memory file systems, each
+// containing different version of the same file. We pass those to two scanning
+// file systems that share the same cache.
+
+TEST(DependencyScanningFileSystemTest, CacheFileContentsEnabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+
+  StringRef Path = "/root/source.c";
+  auto Contents1 = llvm::MemoryBuffer::getMemBuffer("contents1");
+  auto Contents2 = llvm::MemoryBuffer::getMemBuffer("contents2");
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents1)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/source.c.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents2)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/source.c.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+}
+
+TEST(DependencyScanningFileSystemTest, CacheFileContentsDisabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+
+  StringRef Path = "/root/module.pcm";
+  auto Contents1 = llvm::MemoryBuffer::getMemBuffer("contents1");
+  auto Contents2 = llvm::MemoryBuffer::getMemBuffer("contents2");
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents1)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/module.pcm.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents1");
+  }
+
+  {
+auto InMemoryFS =
+llvm::makeIntrusiveRefCnt();
+ASSERT_TRUE(InMemoryFS->addFile(Path, 0, std::move(Contents2)));
+DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+auto File = ScanningFS.openFileForRead(Path);
+ASSERT_TRUE(File);
+auto Buffer = (*File)->getBuffer("Buffer for /root/module.pcm.");
+ASSERT_TRUE(Buffer);
+auto Contents = (*Buffer)->getBuffer();
+EXPECT_EQ(Contents, "contents2");
+  }
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureEnabled) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto InMemoryFS = llvm::makeIntrusiveRefCnt();
+  DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+
+  StringRef Path = "/root/source.c";
+
+  auto Stat1 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat1);
+
+  auto Contents = llvm::MemoryBuffer::getMemBuffer("contents");
+  InMemoryFS->addFile(Path, 0, std::move(Contents));
+
+  auto Stat2 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat2);
+}
+
+TEST(DependencyScanningFileSystemTest, CacheStatFailureDisabledFile) {
+  DependencyScanningFilesystemSharedCache SharedCache;
+  auto InMemoryFS = llvm::makeIntrusiveRefCnt();
+  DependencyScanningWorkerFilesystem ScanningFS(SharedCache, InMemoryFS);
+
+  StringRef Path = "/root/vector";
+
+  auto Stat1 = ScanningFS.status(Path);
+  EXPECT_FALSE(Stat1);
+
+  auto Contents = llvm::MemoryBuffer::getMemBuffer("contents");
+  InMemoryFS->addFile(Path, 0, std::move(Contents));
+
+  auto Stat2 = ScanningFS.status(Path);
+  EXPECT_TRUE(Stat2);
+}
+

[PATCH] D143436: [clangd] Move standard options adaptor to CommandMangler

2023-03-17 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

In D143436#4203394 , @DmitryPolukhin 
wrote:

> @dyung I cannot reproduce this issue on two different machines in both cases 
> tests work fine. For clang and llvm-jitlink binaries (the only binaries used 
> in the tests) my changes are non-functional and I didn't change anything in 
> compiler-rt or ORC. Are you able to reproduce the crashes locally?

So far I cannot on my own dev machines. I'll take the buildbot offline and try 
to see if I can figure out what is going on this weekend.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D146338: [MSVC compatibility][dllimport/dllexport][PS] Allow dllexport/dllimport for classes with UniqueExternalLinkage

2023-03-17 Thread Wolfgang Pieb via Phabricator via cfe-commits
wolfgangp created this revision.
wolfgangp added reviewers: hans, probinson, mstorsjo.
Herald added a project: All.
wolfgangp requested review of this revision.

This replaces D145271 .

Rather than coercing classes with UniqueExternalLInkage to ExternalLinkage as 
proposed in D145271 , this patch suggests to 
simply allow the dllexport/dllimport attributes for classes that exhibit 
UniqueExternalLinkage, which includes instantiations of template classes where 
the template parameters are local classes or classes in anonymous namespaces:

  template 
  class __declspec(dllimport) A {};
  
  void func()
  {
class B : public A {};
  }
  
  namespace {
class C : public A {};
  }

In D145271  it was suggested that we drop the 
attribute in such contexts, and this is effectively what happens. The compiler 
does not produce any exported definitions (or import any symbols) for such 
classes. The patch is simply to suppress the diagnostic for MSVC mode and 
Playstation.

I have not changed the behavior of the Windows/Itanium triple since I wasn't 
sure if this was desirable.


https://reviews.llvm.org/D146338

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/SemaCXX/dllexport.cpp
  clang/test/SemaCXX/dllimport.cpp

Index: clang/test/SemaCXX/dllimport.cpp
===
--- clang/test/SemaCXX/dllimport.cpp
+++ clang/test/SemaCXX/dllimport.cpp
@@ -5,9 +5,9 @@
 // RUN: %clang_cc1 -triple x86_64-mingw32 -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DGNU %s
 // RUN: %clang_cc1 -triple i686-windows-itanium   -fsyntax-only -fms-extensions -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI %s
 // RUN: %clang_cc1 -triple x86_64-windows-itanium -fsyntax-only -fms-extensions -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI %s
-// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++11 -Wunsupported-dll-base-class-template -DWI -DPS %s
-// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI -DPS %s
-// RUN: %clang_cc1 -triple x86_64-sie-ps5 -fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DWI -DPS %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++11 -Wunsupported-dll-base-class-template -DPS %s
+// RUN: %clang_cc1 -triple x86_64-scei-ps4-fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DPS %s
+// RUN: %clang_cc1 -triple x86_64-sie-ps5 -fsyntax-only -fdeclspec  -verify -std=c++17 -Wunsupported-dll-base-class-template -DPS %s
 
 // Helper structs to make templates more expressive.
 struct ImplicitInst_Imported {};
@@ -60,7 +60,7 @@
 // expected-note@+2{{previous attribute is here}}
 #endif
 __declspec(dllimport) extern int ExternGlobalDeclInit; // expected-note{{previous declaration is here}}
-#if defined(MS) || defined(WI)
+#if defined(MS) || defined(WI) || defined(PS)
 // expected-warning@+4{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+2{{'ExternGlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -71,7 +71,7 @@
 // expected-note@+2{{previous attribute is here}}
 #endif
 __declspec(dllimport) int GlobalDeclInit; // expected-note{{previous declaration is here}}
-#if defined(MS) || defined(WI)
+#if defined(MS) || defined(WI) || defined(PS)
 // expected-warning@+4{{'GlobalDeclInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+2{{'GlobalDeclInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -82,7 +82,7 @@
 // expected-note@+2{{previous attribute is here}}
 #endif
 int *__attribute__((dllimport)) GlobalDeclChunkAttrInit; // expected-note{{previous declaration is here}}
-#if defined(MS) || defined(WI)
+#if defined(MS) || defined(WI) || defined(PS)
 // expected-warning@+4{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+2{{'GlobalDeclChunkAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -93,7 +93,7 @@
 // expected-note@+2{{previous attribute is here}}
 #endif
 int GlobalDeclAttrInit __attribute__((dllimport)); // expected-note{{previous declaration is here}}
-#if defined(MS) || defined(WI)
+#if defined(MS) || defined(WI) || defined(PS)
 // expected-warning@+4{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: 'dllexport' attribute added}}
 #else
 // expected-warning@+2{{'GlobalDeclAttrInit' redeclared without 'dllimport' attribute: previous 'dllimport' ignored}}
@@ -184,7 +184,7 @@
 #endif
 

[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2023-03-17 Thread Oleg Skoromnik via Phabricator via cfe-commits
tupos added a comment.

Could you please also advice me what else need to be done for the ObjC, since 
there were many years since I wrote ObjC last time I'm not sure what else need 
to be done there.

Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140275

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


[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2023-03-17 Thread Oleg Skoromnik via Phabricator via cfe-commits
tupos added inline comments.



Comment at: clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp:24
+namespace clang {
+namespace clangd {
+namespace {

tschuett wrote:
> You can merge this into `namespace clang::clangd`.
I prefer not to do it, because all other files with tweaks have the same style.
However, if it is still necessary please let me know and I will change it.



Comment at: clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp:37
+//* @param bar
+//* @return
+//*/

dgoldman wrote:
> sammccall wrote:
> > I'm a bit concerned about people generating these `@param bar` and 
> > `@return` and leaving them there without filling them in - I've seen plenty 
> > of code like that and it's substantially worse than no comments at all.
> > 
> > I'm not sure we can do much though: could generate `@return TODO` or so to 
> > make it more visually obvious - WDYT?
> VS Code itself has support for snippets - 
> https://code.visualstudio.com/api/references/vscode-api#TextEditor - 
> insertSnippet - but the LSP spec doesn't yet. Once it has it I think it would 
> makes sense to use them here, but until then, TODO seems like the best we can 
> do?
I do not think that adding here TODO makes much sense, because in this case I 
can just type the whole comment automatically. Think about I added a template 
but then I need to remove part of this template because it was a placeholder.

I personally think that people who do not want to fill the template properly 
should blame themselves for not writing a proper comment and it is not a 
responsibility of the clangd to motivate them to do it.

What I'm not sure about whether we need to add to the template @pre and @post 
because this is more important as filling the parameters names.

Ideally it would be good if the template can be configurable through the 
.clangd config. What do you think?



Comment at: clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp:58
+};
+
+REGISTER_TWEAK(AddDoxygenComment)

sammccall wrote:
> tschuett wrote:
> > The LLVM coding style kindly asks you stop the anonymous namespace here. 
> > Furthermore, I believe that the `REGISTER_TWEAK` does not work in an 
> > anonymous namespace.
> The coding style is sorely outdated on this point (indentation?!), and the 
> code in this subproject doesn't follow it - happy to take this up on 
> discourse if needed but I don't think we should create a mess of mixed local 
> style here.
See the comment above.



Comment at: clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp:74
+bool AddDoxygenComment::prepare(const Selection ) {
+  if (!Inputs.AST->getLangOpts().CPlusPlus) {
+return false;

dgoldman wrote:
> sammccall wrote:
> > why? doxygen supports C AFAIK
> Would also be nice to support ObjC too, we'll just need to add support for 
> ObjCMethodDecl as well to expand support for ObjC methods.  
> (https://clang.llvm.org/doxygen/classclang_1_1ObjCMethodDecl.html vs 
> https://clang.llvm.org/doxygen/classclang_1_1FunctionDecl.html) But even if 
> that's not done in this diff, still seems fine to enable it generally?
What is the correct language option for the C language? I found only the 
enumeration of all C standards?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140275

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


[PATCH] D140275: [clangd] Tweak to add doxygen comment to the function declaration

2023-03-17 Thread Oleg Skoromnik via Phabricator via cfe-commits
tupos updated this revision to Diff 506220.
tupos marked 11 inline comments as done.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D140275

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddDoxygenComment.cpp
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/tweaks/AddDoxygenCommentTests.cpp

Index: clang-tools-extra/clangd/unittests/tweaks/AddDoxygenCommentTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/tweaks/AddDoxygenCommentTests.cpp
@@ -0,0 +1,189 @@
+//===-- AddDoxygenCommentTests.cpp *- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "TweakTesting.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+TWEAK_TEST(AddDoxygenComment);
+
+TEST_F(AddDoxygenCommentTest, AvailableUnavailable) {
+  EXPECT_AVAILABLE(R"cpp(
+void bar^(char b) { }
+[[int foo(int x)]] { }
+namespace ns1 {
+  [[int foo(int x)]] { }
+}
+  )cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+namespace ns1 {
+  /*!
+   */
+  void bar(char b) {^ }
+  // comment
+  [[int foo(int x) { }]]
+  /// comment
+  [[int meaw(int x) { }]]
+  void baz(char b) {^ }
+}
+  )cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, AvailableUnavailableOnDefinition) {
+  EXPECT_AVAILABLE(R"cpp(
+void bar^(char b);
+void bar(char b) { (void)b; }
+  )cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+void bar(char b);
+void bar^(char b) { (void)b; }
+  )cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, AvailableUnavailableOnMemberFunc) {
+  EXPECT_AVAILABLE(R"cpp(
+class Foo {
+  void foo^(){}
+  void bar^();
+};
+  )cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+class Foo {
+  void bar();
+};
+void Foo::bar^(){}
+  )cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, AvailableUnavailableOnTemplate) {
+  EXPECT_AVAILABLE(R"cpp(
+template
+class Foo {
+  void foo^(){}
+  void bar^();
+};
+  )cpp");
+  EXPECT_UNAVAILABLE(R"cpp(
+template
+class Foo {
+  void bar();
+};
+template
+void Foo::bar^(){}
+  )cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, AvailableUnavailableOnDeductionGuide) {
+  EXPECT_UNAVAILABLE(R"cpp(
+template struct A { A(); A(T); };
+A^() -> A;
+  )cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, AvailableUnavailableObjC) {
+  FileName = "TestTU.m";
+  EXPECT_AVAILABLE(R"objc(
+@interface Foo
++ (id)^fooWithValue:(int)value fooey:(unsigned int)fooey;
+@end
+  )objc");
+}
+
+TEST_F(AddDoxygenCommentTest, ApplyTemplate) {
+  EXPECT_EQ(apply(R"cpp(
+template
+void foo^(T x) {})cpp"),
+R"cpp(
+/// TODO Add description
+///
+/// @param x
+///
+template
+void foo(T x) {})cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, ApplyObjCIdReturn) {
+  FileName = "TestTU.m";
+  EXPECT_EQ(apply(R"objc(
+@interface Foo
++ (id)^fooWithValue:(int)value fooey:(unsigned int)fooey;
+@end)objc"),
+R"objc(
+@interface Foo
+/// TODO Add description
+///
+/// @param value
+/// @param fooey
+///
++ (id)fooWithValue:(int)value fooey:(unsigned int)fooey;
+@end)objc");
+}
+TEST_F(AddDoxygenCommentTest, ApplyObjCNonIdReturn) {
+  FileName = "TestTU.m";
+  EXPECT_EQ(apply(R"objc(
+@interface Foo
++ (int)^fooWithValue:(int)value fooey:(unsigned int)fooey;
+@end)objc"),
+R"objc(
+@interface Foo
+/// TODO Add description
+///
+/// @param value
+/// @param fooey
+/// @return
+///
++ (int)fooWithValue:(int)value fooey:(unsigned int)fooey;
+@end)objc");
+}
+
+TEST_F(AddDoxygenCommentTest, ApplyInsideNS) {
+  EXPECT_EQ(apply(R"cpp(
+namespace ns1 {
+  int foo^(int y, char* s) {
+int x;
+return x;
+  }
+}
+  )cpp"),
+R"cpp(
+namespace ns1 {
+  /// TODO Add description
+///
+/// @param y
+/// @param s
+/// @return
+///
+int foo(int y, char* s) {
+int x;
+return x;
+  }
+}
+  )cpp");
+}
+
+TEST_F(AddDoxygenCommentTest, ApplyInsideTU) {
+  EXPECT_EQ(apply(R"cpp(
+void foo();
+void ^bar();
+)cpp"),
+R"cpp(
+void foo();
+/// TODO Add description
+///
+///
+void bar();
+)cpp");
+}
+
+} // namespace
+} // namespace clangd
+} // namespace clang
Index: clang-tools-extra/clangd/unittests/CMakeLists.txt
===
--- clang-tools-extra/clangd/unittests/CMakeLists.txt
+++ clang-tools-extra/clangd/unittests/CMakeLists.txt
@@ -113,6 +113,7 @@
   support/ThreadingTests.cpp
   support/TraceTests.cpp
 
+  tweaks/AddDoxygenCommentTests.cpp
   tweaks/AddUsingTests.cpp
  

[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese added inline comments.



Comment at: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h:272-291
+enum class Enable { Yes, No };
+enum class ScanFile { Yes, No };
+enum class CacheStatFailure { Yes, No };
+
+struct PathPolicy {
+  unsigned Enable : 1; // Implies caching of all open and stat results.
+  unsigned ScanFile : 1;

Alternative that gets rid of the asserts as you just can't construct it 
incorrectly. I didn't compile this locally, but this should make it so you 
can't use `{}` to construct one externally, and you either use:

`PathPolicy::cache(ScanFile::Yes, CacheStatFailure::No)` or
`PathPolicy::bypassCache()`

when constructing them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

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


[PATCH] D143436: [clangd] Move standard options adaptor to CommandMangler

2023-03-17 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

@dyung I cannot reproduce this issue on two different machines in both cases 
tests work fine. For clang and llvm-jitlink binaries (the only binaries used in 
the tests) my changes are non-functional and I didn't change anything in 
compiler-rt or ORC. Are you able to reproduce the crashes locally?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 updated this revision to Diff 506205.
jansvoboda11 added a comment.

Remove configurable `CacheSuccess`, rename `CacheFailure` to `CacheStatFailure`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -42,9 +42,8 @@
 }
 
 EntryRef DependencyScanningWorkerFilesystem::scanForDirectivesIfNecessary(
-const CachedFileSystemEntry , StringRef Filename, bool Disable) {
-  if (Entry.isError() || Entry.isDirectory() || Disable ||
-  !shouldScanForDirectives(Filename))
+const CachedFileSystemEntry , StringRef Filename, PathPolicy Policy) {
+  if (Entry.isError() || Entry.isDirectory() || !Policy.ScanFile)
 return EntryRef(Filename, Entry);
 
   CachedFileContents *Contents = Entry.getCachedContents();
@@ -159,39 +158,22 @@
   return *EntriesByFilename.insert({Filename, }).first->getValue();
 }
 
-/// Whitelist file extensions that should be minimized, treating no extension as
-/// a source file that should be minimized.
-///
-/// This is kinda hacky, it would be better if we knew what kind of file Clang
-/// was expecting instead.
-static bool shouldScanForDirectivesBasedOnExtension(StringRef Filename) {
+PathPolicy clang::tooling::dependencies::getPolicy(StringRef Filename) {
   StringRef Ext = llvm::sys::path::extension(Filename);
   if (Ext.empty())
-return true; // C++ standard library
-  return llvm::StringSwitch(Ext)
-  .CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", true)
-  .CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", true)
-  .CasesLower(".m", ".mm", true)
-  .CasesLower(".i", ".ii", ".mi", ".mmi", true)
-  .CasesLower(".def", ".inc", true)
-  .Default(false);
-}
-
-static bool shouldCacheStatFailures(StringRef Filename) {
-  StringRef Ext = llvm::sys::path::extension(Filename);
-  if (Ext.empty())
-return false; // This may be the module cache directory.
-  // Only cache stat failures on files that are not expected to change during
-  // the build.
-  StringRef FName = llvm::sys::path::filename(Filename);
-  if (FName == "module.modulemap" || FName == "module.map")
-return true;
-  return shouldScanForDirectivesBasedOnExtension(Filename);
-}
-
-bool DependencyScanningWorkerFilesystem::shouldScanForDirectives(
-StringRef Filename) {
-  return shouldScanForDirectivesBasedOnExtension(Filename);
+return {Enable::Yes, ScanFile::Yes, CacheStatFailure::No};
+  // clang-format off
+  return llvm::StringSwitch(Ext)
+  .CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", {Enable::Yes, ScanFile::Yes})
+  .CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", {Enable::Yes, ScanFile::Yes})
+  .CasesLower(".m", ".mm", {Enable::Yes, ScanFile::Yes})
+  .CasesLower(".i", ".ii", ".mi", ".mmi",  {Enable::Yes, ScanFile::Yes})
+  .CasesLower(".def", ".inc",  {Enable::Yes, ScanFile::Yes})
+  .CasesLower(".modulemap", ".map",  {Enable::Yes, ScanFile::No})
+  .CasesLower(".framework", ".apinotes", {Enable::Yes, ScanFile::No})
+  .CasesLower(".yaml", ".json", ".hmap", {Enable::Yes, ScanFile::No})
+  .Default({Enable::No});
+  // clang-format on
 }
 
 const CachedFileSystemEntry &
@@ -215,10 +197,11 @@
 }
 
 llvm::ErrorOr
-DependencyScanningWorkerFilesystem::computeAndStoreResult(StringRef Filename) {
+DependencyScanningWorkerFilesystem::computeAndStoreResult(StringRef Filename,
+  PathPolicy Policy) {
   llvm::ErrorOr Stat = getUnderlyingFS().status(Filename);
   if (!Stat) {
-if (!shouldCacheStatFailures(Filename))
+if (!Policy.CacheStatFailure)
   return Stat.getError();
 const auto  =
 getOrEmplaceSharedEntryForFilename(Filename, Stat.getError());
@@ -244,16 +227,13 @@
 
 llvm::ErrorOr
 DependencyScanningWorkerFilesystem::getOrCreateFileSystemEntry(
-StringRef Filename, bool DisableDirectivesScanning) {
+StringRef Filename, PathPolicy Policy) {
   if (const auto *Entry = findEntryByFilenameWithWriteThrough(Filename))
-return scanForDirectivesIfNecessary(*Entry, Filename,
-DisableDirectivesScanning)
-.unwrapError();
-  auto MaybeEntry = computeAndStoreResult(Filename);
+return scanForDirectivesIfNecessary(*Entry, Filename, Policy).unwrapError();
+  auto MaybeEntry = computeAndStoreResult(Filename, Policy);
   if (!MaybeEntry)
 return MaybeEntry.getError();
-  return 

[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Michael Spencer via Phabricator via cfe-commits
Bigcheese accepted this revision.
Bigcheese added a comment.
This revision is now accepted and ready to land.

This doesn't appear to behave as expected for `PP_CacheFailure` or 
`PP_ScanFile` without `PP_CacheSuccess`. Looks like that will still cache. 
Should probably just assert that's not the computed policy.

Looks good with those changes.




Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp:161
 
-/// Whitelist file extensions that should be minimized, treating no extension 
as
-/// a source file that should be minimized.
+/// Whitelist file extensions that should be cached/scanned.
 ///

ributzka wrote:
> s/Whitelist/Allowlist
I think we can just change this comment to something like:

> Determine caching and scanning behavior based on file extension.



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp:168
   if (Ext.empty())
-return true; // C++ standard library
-  return llvm::StringSwitch(Ext)
-  .CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", true)
-  .CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", true)
-  .CasesLower(".m", ".mm", true)
-  .CasesLower(".i", ".ii", ".mi", ".mmi", true)
-  .CasesLower(".def", ".inc", true)
-  .Default(false);
-}
-
-static bool shouldCacheStatFailures(StringRef Filename) {
-  StringRef Ext = llvm::sys::path::extension(Filename);
-  if (Ext.empty())
-return false; // This may be the module cache directory.
-  // Only cache stat failures on files that are not expected to change during
-  // the build.
-  StringRef FName = llvm::sys::path::filename(Filename);
-  if (FName == "module.modulemap" || FName == "module.map")
-return true;
-  return shouldScanForDirectivesBasedOnExtension(Filename);
-}
-
-bool DependencyScanningWorkerFilesystem::shouldScanForDirectives(
-StringRef Filename) {
-  return shouldScanForDirectivesBasedOnExtension(Filename);
+return (PathPolicy)(PP_CacheSuccess | PP_ScanFile);
+  return (PathPolicy)llvm::StringSwitch(Ext)

If you use `LLVM_MARK_AS_BITMASK_ENUM` I think you can remove these casts.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

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


[PATCH] D146329: [Clang] Fix defaulted equality operator so that it does not attempt to compare unnamed bit-fields

2023-03-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I would have loved to test the case from 
https://github.com/llvm/llvm-project/issues/61335 directly but I think in order 
to do it nicely I need `__builtin_memset` to be usable in a constant expression 
context. I will add this to my todo list. I am open to other alternatives for 
testing this.


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

https://reviews.llvm.org/D146329

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


[PATCH] D146329: [Clang] Fix defaulted equality operator so that it does not attempt to compare unnamed bit-fields

2023-03-17 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik created this revision.
shafik added reviewers: aaron.ballman, erichkeane, rsmith.
Herald added a project: All.
shafik requested review of this revision.

If we look at class.bit p2  it 
tells us that that unnamed bit-fields are not members and class.compare.default 
p5  tells us that 
we should only non-static data members of the class.

This fixes: https://github.com/llvm/llvm-project/issues/61335 and 
https://github.com/llvm/llvm-project/issues/61417


https://reviews.llvm.org/D146329

Files:
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/class/class.compare/class.compare.default/p1.cpp


Index: clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -226,3 +226,26 @@
   (void)(b == 0);
 }
 } // namespace p2085_2
+
+namespace GH61417 {
+struct A {
+  unsigned x : 1;
+  unsigned   : 0;
+  unsigned y : 1;
+
+  constexpr A() : x(0), y(0) {}
+  bool operator==(const A& rhs) const noexcept = default;
+};
+
+void f1() {
+  constexpr A a, b;
+  constexpr bool c = (a == b); // no diagnostic, we should not be comparing the
+   // unnamed bit-field which is indeterminate
+}
+
+void f2() {
+A a, b;
+bool c = (a == b); // no diagnostic nor crash during codegen attempting to
+   // access info for unnamed bit-field
+}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7755,6 +7755,10 @@
 
 //   followed by the non-static data members of C
 for (FieldDecl *Field : Record->fields()) {
+  // C++23 [class.bit]p2:
+  //   Unnamed bit-fields are not members ...
+  if (Field->isUnnamedBitfield())
+continue;
   // Recursively expand anonymous structs.
   if (Field->isAnonymousStructOrUnion()) {
 if (visitSubobjects(Results, Field->getType()->getAsCXXRecordDecl(),


Index: clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
===
--- clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
+++ clang/test/CXX/class/class.compare/class.compare.default/p1.cpp
@@ -226,3 +226,26 @@
   (void)(b == 0);
 }
 } // namespace p2085_2
+
+namespace GH61417 {
+struct A {
+  unsigned x : 1;
+  unsigned   : 0;
+  unsigned y : 1;
+
+  constexpr A() : x(0), y(0) {}
+  bool operator==(const A& rhs) const noexcept = default;
+};
+
+void f1() {
+  constexpr A a, b;
+  constexpr bool c = (a == b); // no diagnostic, we should not be comparing the
+   // unnamed bit-field which is indeterminate
+}
+
+void f2() {
+A a, b;
+bool c = (a == b); // no diagnostic nor crash during codegen attempting to
+   // access info for unnamed bit-field
+}
+}
Index: clang/lib/Sema/SemaDeclCXX.cpp
===
--- clang/lib/Sema/SemaDeclCXX.cpp
+++ clang/lib/Sema/SemaDeclCXX.cpp
@@ -7755,6 +7755,10 @@
 
 //   followed by the non-static data members of C
 for (FieldDecl *Field : Record->fields()) {
+  // C++23 [class.bit]p2:
+  //   Unnamed bit-fields are not members ...
+  if (Field->isUnnamedBitfield())
+continue;
   // Recursively expand anonymous structs.
   if (Field->isAnonymousStructOrUnion()) {
 if (visitSubobjects(Results, Field->getType()->getAsCXXRecordDecl(),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145820: [Clang][OpenMP] Insert alloca for kernel args at function entry block instead of the launch point.

2023-03-17 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1c9ec74e3f2a: [Clang][OpenMP] Insert alloca for kernel args 
at function entry block instead… (authored by dhruvachak).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145820

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/align_clause_codegen.cpp
  clang/test/OpenMP/atomic_compare_codegen.cpp
  clang/test/OpenMP/bug60602.cpp
  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_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_non_rectangular_codegen.c
  clang/test/OpenMP/irbuilder_nested_openmp_parallel_empty.c
  clang/test/OpenMP/nested_loop_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/reduction_compound_op.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_has_device_addr_codegen.cpp
  clang/test/OpenMP/target_has_device_addr_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_map_deref_array_codegen.cpp
  clang/test/OpenMP/target_map_member_expr_codegen.cpp
  clang/test/OpenMP/target_offload_mandatory_codegen.cpp
  clang/test/OpenMP/target_ompx_dyn_cgroup_mem_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_task_affinity_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp
  

[PATCH] D146326: [LinkerWrapper] Do not extract globals with no offloading language

2023-03-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 506190.
jhuber6 added a comment.

Remove whitespace


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146326

Files:
  clang/test/Driver/linker-wrapper-libs.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1162,7 +1162,8 @@
 
 /// Scan the symbols from a BitcodeFile \p Buffer and record if we need to
 /// extract any symbols from it.
-Expected getSymbolsFromBitcode(MemoryBufferRef Buffer, StringSaver ,
+Expected getSymbolsFromBitcode(MemoryBufferRef Buffer, OffloadKind Kind,
+ StringSaver ,
  DenseMap ) {
   Expected IRSymtabOrErr = readIRSymtab(Buffer);
   if (!IRSymtabOrErr)
@@ -1182,9 +1183,10 @@
   ((OldSym & Sym_Undefined && !(OldSym & Sym_Weak)) &&
!Sym.isUndefined());
   // We will extract if it defines a new global symbol visible to the host.
+  // This is only necessary for code targeting an offloading language.
   bool NewGlobalSymbol =
   ((NewSymbol || (OldSym & Sym_Undefined)) && !Sym.isUndefined() &&
-   !Sym.canBeOmittedFromSymbolTable() &&
+   !Sym.canBeOmittedFromSymbolTable() && Kind != object::OFK_None &&
(Sym.getVisibility() != GlobalValue::HiddenVisibility));
   ShouldExtract |= ResolvesStrongReference | NewGlobalSymbol;
 
@@ -1203,7 +1205,8 @@
 
 /// Scan the symbols from an ObjectFile \p Obj and record if we need to extract
 /// any symbols from it.
-Expected getSymbolsFromObject(const ObjectFile , StringSaver ,
+Expected getSymbolsFromObject(const ObjectFile , OffloadKind Kind,
+StringSaver ,
 DenseMap ) {
   bool ShouldExtract = false;
   for (SymbolRef Sym : Obj.symbols()) {
@@ -1228,9 +1231,11 @@
!(*FlagsOrErr & SymbolRef::SF_Undefined);
 
 // We will extract if it defines a new global symbol visible to the host.
-bool NewGlobalSymbol = ((NewSymbol || (OldSym & Sym_Undefined)) &&
-!(*FlagsOrErr & SymbolRef::SF_Undefined) &&
-!(*FlagsOrErr & SymbolRef::SF_Hidden));
+// This is only necessary for code targeting an offloading language.
+bool NewGlobalSymbol =
+((NewSymbol || (OldSym & Sym_Undefined)) &&
+ !(*FlagsOrErr & SymbolRef::SF_Undefined) && Kind != object::OFK_None &&
+ !(*FlagsOrErr & SymbolRef::SF_Hidden));
 ShouldExtract |= ResolvesStrongReference | NewGlobalSymbol;
 
 // Update this symbol in the "table" with the new information.
@@ -1250,18 +1255,18 @@
 ///   1) It defines an undefined symbol in a regular object filie.
 ///   2) It defines a global symbol without hidden visibility that has not
 ///  yet been defined.
-Expected getSymbols(StringRef Image, StringSaver ,
+Expected getSymbols(StringRef Image, OffloadKind Kind, StringSaver ,
   DenseMap ) {
   MemoryBufferRef Buffer = MemoryBufferRef(Image, "");
   switch (identify_magic(Image)) {
   case file_magic::bitcode:
-return getSymbolsFromBitcode(Buffer, Saver, Syms);
+return getSymbolsFromBitcode(Buffer, Kind, Saver, Syms);
   case file_magic::elf_relocatable: {
 Expected> ObjFile =
 ObjectFile::createObjectFile(Buffer);
 if (!ObjFile)
   return ObjFile.takeError();
-return getSymbolsFromObject(**ObjFile, Saver, Syms);
+return getSymbolsFromObject(**ObjFile, Kind, Saver, Syms);
   }
   default:
 return false;
@@ -1336,8 +1341,9 @@
 if (IsArchive && !WholeArchive && !Syms.count(Binary))
   continue;
 
-Expected ExtractOrErr =
-getSymbols(Binary.getBinary()->getImage(), Saver, Syms[Binary]);
+Expected ExtractOrErr = getSymbols(
+Binary.getBinary()->getImage(),
+Binary.getBinary()->getOffloadKind(), Saver, Syms[Binary]);
 if (!ExtractOrErr)
   return ExtractOrErr.takeError();
 
Index: clang/test/Driver/linker-wrapper-libs.c
===
--- clang/test/Driver/linker-wrapper-libs.c
+++ clang/test/Driver/linker-wrapper-libs.c
@@ -64,6 +64,29 @@
 // LIBRARY-GLOBAL: clang{{.*}} -o {{.*}}.img --target=amdgcn-amd-amdhsa -mcpu=gfx1030 {{.*}}.o {{.*}}.o
 // LIBRARY-GLOBAL: clang{{.*}} -o {{.*}}.img --target=nvptx64-nvidia-cuda -march=sm_70 {{.*}}.s {{.*}}.o
 
+//
+// Check that we do not extract a global symbol if the source file was not
+// created by an offloading language that expects there to be a host version of
+// the symbol.
+//
+// RUN: %clang -cc1 %s -triple nvptx64-nvidia-cuda 

[PATCH] D146140: [clang] Properly parse variable template requires clause in lambda

2023-03-17 Thread Emilia Dreamer 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 rG6acdf58919d5: [clang] Properly parse variable template 
requires clause in lambda (authored by rymiel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146140

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaConcept.cpp
  clang/test/SemaTemplate/concepts.cpp


Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -55,10 +55,15 @@
 }
 
 namespace P0857R0 {
+  template  static constexpr bool V = true;
+
   void f() {
 auto x = [] requires B {}; // expected-note {{constraints not 
satisfied}} expected-note {{false}}
 x.operator()();
 x.operator()(); // expected-error {{no matching member function}}
+
+auto y = [] requires V () {};
+y.operator()(); // OK
   }
 
   template concept C = true;
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -105,27 +105,35 @@
   QualType Type = ConstraintExpression->getType();
 
   auto CheckForNonPrimary = [&] {
-if (PossibleNonPrimary)
-  *PossibleNonPrimary =
-  // We have the following case:
-  // template requires func(0) struct S { };
-  // The user probably isn't aware of the parentheses required around
-  // the function call, and we're only going to parse 'func' as the
-  // primary-expression, and complain that it is of non-bool type.
-  (NextToken.is(tok::l_paren) &&
-   (IsTrailingRequiresClause ||
-(Type->isDependentType() &&
- isa(ConstraintExpression)) ||
-Type->isFunctionType() ||
-Type->isSpecificBuiltinType(BuiltinType::Overload))) ||
-  // We have the following case:
-  // template requires size_ == 0 struct S { };
-  // The user probably isn't aware of the parentheses required around
-  // the binary operator, and we're only going to parse 'func' as the
-  // first operand, and complain that it is of non-bool type.
-  getBinOpPrecedence(NextToken.getKind(),
- /*GreaterThanIsOperator=*/true,
- getLangOpts().CPlusPlus11) > prec::LogicalAnd;
+if (!PossibleNonPrimary)
+  return;
+
+*PossibleNonPrimary =
+// We have the following case:
+// template requires func(0) struct S { };
+// The user probably isn't aware of the parentheses required around
+// the function call, and we're only going to parse 'func' as the
+// primary-expression, and complain that it is of non-bool type.
+//
+// However, if we're in a lambda, this might also be:
+// [] requires var () {};
+// Which also looks like a function call due to the lambda parentheses,
+// but unlike the first case, isn't an error, so this check is skipped.
+(NextToken.is(tok::l_paren) &&
+ (IsTrailingRequiresClause ||
+  (Type->isDependentType() &&
+   isa(ConstraintExpression) &&
+   !dyn_cast_if_present(getCurFunction())) ||
+  Type->isFunctionType() ||
+  Type->isSpecificBuiltinType(BuiltinType::Overload))) ||
+// We have the following case:
+// template requires size_ == 0 struct S { };
+// The user probably isn't aware of the parentheses required around
+// the binary operator, and we're only going to parse 'func' as the
+// first operand, and complain that it is of non-bool type.
+getBinOpPrecedence(NextToken.getKind(),
+   /*GreaterThanIsOperator=*/true,
+   getLangOpts().CPlusPlus11) > prec::LogicalAnd;
   };
 
   // An atomic constraint!
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -80,6 +80,9 @@
 ^
 - Support for out-of-line definitions of constrained templates has been 
improved.
   This partially fixes `#49620 
`_.
+- Lambda templates with a requires clause directly after the template 
parameters now parse
+  correctly if the requires clause consists of a variable with a dependent 
type.
+  (`#61278 `_)
 
 C++2b Feature Support
 ^


Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -55,10 +55,15 @@
 }
 
 namespace 

[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Juergen Ributzka via Phabricator via cfe-commits
ributzka added inline comments.



Comment at: 
clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp:161
 
-/// Whitelist file extensions that should be minimized, treating no extension 
as
-/// a source file that should be minimized.
+/// Whitelist file extensions that should be cached/scanned.
 ///

s/Whitelist/Allowlist


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146328

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


[clang] 6acdf58 - [clang] Properly parse variable template requires clause in lambda

2023-03-17 Thread Emilia Dreamer via cfe-commits

Author: Emilia Dreamer
Date: 2023-03-17T22:29:48+02:00
New Revision: 6acdf58919d5e66809555acf5809b12c54ba79dd

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

LOG: [clang] Properly parse variable template requires clause in lambda

Since P0857, part of C++20, a *lambda-expression* can contain a
*requires-clause* after its *template-parameter-list*.

While support for this was added as part of
eccc734a69c0c012ae3160887b65a535b35ead3e, one specific case isn't
handled properly, where the *requires-clause* consists of an
instantiation of a boolean variable template. This is due to a
diagnostic check which was written with the assumption that a
*requires-clause* can never be followed by a left parenthesis. This
assumption no longer holds for lambdas.

This diagnostic check would then attempt to perform a "recovery", but it
does so in a valid parse state, resulting in an invalid parse state
instead!

This patch adds a special case when parsing requires clauses of lambda
templates, to skip this diagnostic check.

Fixes https://github.com/llvm/llvm-project/issues/61278
Fixes https://github.com/llvm/llvm-project/issues/61387

Reviewed By: erichkeane

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/lib/Sema/SemaConcept.cpp
clang/test/SemaTemplate/concepts.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 24f5b622249d8..53001f651ea4b 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -80,6 +80,9 @@ C++20 Feature Support
 ^
 - Support for out-of-line definitions of constrained templates has been 
improved.
   This partially fixes `#49620 
`_.
+- Lambda templates with a requires clause directly after the template 
parameters now parse
+  correctly if the requires clause consists of a variable with a dependent 
type.
+  (`#61278 `_)
 
 C++2b Feature Support
 ^

diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 4a795227e6293..4ff86843dacc1 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -105,27 +105,35 @@ bool Sema::CheckConstraintExpression(const Expr 
*ConstraintExpression,
   QualType Type = ConstraintExpression->getType();
 
   auto CheckForNonPrimary = [&] {
-if (PossibleNonPrimary)
-  *PossibleNonPrimary =
-  // We have the following case:
-  // template requires func(0) struct S { };
-  // The user probably isn't aware of the parentheses required around
-  // the function call, and we're only going to parse 'func' as the
-  // primary-expression, and complain that it is of non-bool type.
-  (NextToken.is(tok::l_paren) &&
-   (IsTrailingRequiresClause ||
-(Type->isDependentType() &&
- isa(ConstraintExpression)) ||
-Type->isFunctionType() ||
-Type->isSpecificBuiltinType(BuiltinType::Overload))) ||
-  // We have the following case:
-  // template requires size_ == 0 struct S { };
-  // The user probably isn't aware of the parentheses required around
-  // the binary operator, and we're only going to parse 'func' as the
-  // first operand, and complain that it is of non-bool type.
-  getBinOpPrecedence(NextToken.getKind(),
- /*GreaterThanIsOperator=*/true,
- getLangOpts().CPlusPlus11) > prec::LogicalAnd;
+if (!PossibleNonPrimary)
+  return;
+
+*PossibleNonPrimary =
+// We have the following case:
+// template requires func(0) struct S { };
+// The user probably isn't aware of the parentheses required around
+// the function call, and we're only going to parse 'func' as the
+// primary-expression, and complain that it is of non-bool type.
+//
+// However, if we're in a lambda, this might also be:
+// [] requires var () {};
+// Which also looks like a function call due to the lambda parentheses,
+// but unlike the first case, isn't an error, so this check is skipped.
+(NextToken.is(tok::l_paren) &&
+ (IsTrailingRequiresClause ||
+  (Type->isDependentType() &&
+   isa(ConstraintExpression) &&
+   !dyn_cast_if_present(getCurFunction())) ||
+  Type->isFunctionType() ||
+  Type->isSpecificBuiltinType(BuiltinType::Overload))) ||
+// We have the following case:
+// template requires size_ == 0 struct S { };
+// The user probably isn't aware of the parentheses 

[PATCH] D146328: [clang][deps] Only cache files with specific extension

2023-03-17 Thread Jan Svoboda via Phabricator via cfe-commits
jansvoboda11 created this revision.
jansvoboda11 added reviewers: Bigcheese, benlangmuir.
Herald added a subscriber: ributzka.
Herald added a project: All.
jansvoboda11 requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

In the scanner's VFS, we cache all files by default and only avoid caching stat 
failures for certain files. This tanks the performance of scanning with 
pre-populated module cache. When there is a stale PCM file, it gets cached by 
the scanner at the start and the rebuilt version never makes it through the VFS 
again. The TU invocation that rebuilds the PCM only sees the copy in its 
InMemoryModuleCache, which is invisible to other invocations. This means the 
PCM gets rebuilt for every TU given to the scanner.

This patch fixes the situation by flipping the default, only caching files that 
are known to be important, and letting everything else fall through to the 
underlying VFS.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146328

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp

Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -42,9 +42,8 @@
 }
 
 EntryRef DependencyScanningWorkerFilesystem::scanForDirectivesIfNecessary(
-const CachedFileSystemEntry , StringRef Filename, bool Disable) {
-  if (Entry.isError() || Entry.isDirectory() || Disable ||
-  !shouldScanForDirectives(Filename))
+const CachedFileSystemEntry , StringRef Filename, PathPolicy Policy) {
+  if (Entry.isError() || Entry.isDirectory() || !(Policy & PP_ScanFile))
 return EntryRef(Filename, Entry);
 
   CachedFileContents *Contents = Entry.getCachedContents();
@@ -159,39 +158,29 @@
   return *EntriesByFilename.insert({Filename, }).first->getValue();
 }
 
-/// Whitelist file extensions that should be minimized, treating no extension as
-/// a source file that should be minimized.
+/// Whitelist file extensions that should be cached/scanned.
 ///
 /// This is kinda hacky, it would be better if we knew what kind of file Clang
 /// was expecting instead.
-static bool shouldScanForDirectivesBasedOnExtension(StringRef Filename) {
+PathPolicy clang::tooling::dependencies::getPolicy(StringRef Filename) {
   StringRef Ext = llvm::sys::path::extension(Filename);
   if (Ext.empty())
-return true; // C++ standard library
-  return llvm::StringSwitch(Ext)
-  .CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", true)
-  .CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", true)
-  .CasesLower(".m", ".mm", true)
-  .CasesLower(".i", ".ii", ".mi", ".mmi", true)
-  .CasesLower(".def", ".inc", true)
-  .Default(false);
-}
-
-static bool shouldCacheStatFailures(StringRef Filename) {
-  StringRef Ext = llvm::sys::path::extension(Filename);
-  if (Ext.empty())
-return false; // This may be the module cache directory.
-  // Only cache stat failures on files that are not expected to change during
-  // the build.
-  StringRef FName = llvm::sys::path::filename(Filename);
-  if (FName == "module.modulemap" || FName == "module.map")
-return true;
-  return shouldScanForDirectivesBasedOnExtension(Filename);
-}
-
-bool DependencyScanningWorkerFilesystem::shouldScanForDirectives(
-StringRef Filename) {
-  return shouldScanForDirectivesBasedOnExtension(Filename);
+return (PathPolicy)(PP_CacheSuccess | PP_ScanFile);
+  return (PathPolicy)llvm::StringSwitch(Ext)
+  // Sources:
+  .CasesLower(".c", ".cc", ".cpp", ".c++", ".cxx", PP_Cache | PP_ScanFile)
+  .CasesLower(".h", ".hh", ".hpp", ".h++", ".hxx", PP_Cache | PP_ScanFile)
+  .CasesLower(".m", ".mm", PP_Cache | PP_ScanFile)
+  .CasesLower(".i", ".ii", ".mi", ".mmi", PP_Cache | PP_ScanFile)
+  .CasesLower(".def", ".inc", PP_Cache | PP_ScanFile)
+  // Module maps:
+  .CasesLower(".modulemap", ".map", PP_Cache)
+  // Frameworks:
+  .CaseLower(".framework", PP_Cache)
+  // VFS overlays, header maps:
+  .CasesLower(".yaml", ".json", ".hmap", PP_Cache)
+  // Everything else (PCM, binary files, ".noindex" module cache, ...):
+  .Default(PP_FallThrough);
 }
 
 const CachedFileSystemEntry &
@@ -215,10 +204,11 @@
 }
 
 llvm::ErrorOr
-DependencyScanningWorkerFilesystem::computeAndStoreResult(StringRef Filename) {
+DependencyScanningWorkerFilesystem::computeAndStoreResult(StringRef Filename,
+  PathPolicy Policy) {
   llvm::ErrorOr Stat = getUnderlyingFS().status(Filename);
   if (!Stat) {
-if (!shouldCacheStatFailures(Filename))
+if (!(Policy & PP_CacheFailure))
   return Stat.getError();
 const auto  =
 

[PATCH] D146326: [LinkerWrapper] Do not extract globals with no offloading language

2023-03-17 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, JonChesterfield, tra, yaxunl, 
tianshilei1992.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, jplehr, sstefan1.
Herald added a project: clang.

The linker wrapper needs to reinvent its own special static library
handling for static libraries containing fatbinaries. This is primarily
because offloading languages expect certain global symbols to be visible
to the host so we must consider them used symbols. However we should be
able to remove this requirement if we are linking in "freestanding" code
that was not created by an offloading language.

The motivation for this is to support the work-in-progress `libc` for
GPUs. It is provided as a static library with no offloading language
set. This logic will let us only import used `libc` symbols always.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146326

Files:
  clang/test/Driver/linker-wrapper-libs.c
  clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp

Index: clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
===
--- clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1162,7 +1162,8 @@
 
 /// Scan the symbols from a BitcodeFile \p Buffer and record if we need to
 /// extract any symbols from it.
-Expected getSymbolsFromBitcode(MemoryBufferRef Buffer, StringSaver ,
+Expected getSymbolsFromBitcode(MemoryBufferRef Buffer, OffloadKind Kind,
+ StringSaver ,
  DenseMap ) {
   Expected IRSymtabOrErr = readIRSymtab(Buffer);
   if (!IRSymtabOrErr)
@@ -1182,9 +1183,10 @@
   ((OldSym & Sym_Undefined && !(OldSym & Sym_Weak)) &&
!Sym.isUndefined());
   // We will extract if it defines a new global symbol visible to the host.
+  // This is only necessary for code targeting an offloading language.
   bool NewGlobalSymbol =
   ((NewSymbol || (OldSym & Sym_Undefined)) && !Sym.isUndefined() &&
-   !Sym.canBeOmittedFromSymbolTable() &&
+   !Sym.canBeOmittedFromSymbolTable() && Kind != object::OFK_None &&
(Sym.getVisibility() != GlobalValue::HiddenVisibility));
   ShouldExtract |= ResolvesStrongReference | NewGlobalSymbol;
 
@@ -1203,7 +1205,8 @@
 
 /// Scan the symbols from an ObjectFile \p Obj and record if we need to extract
 /// any symbols from it.
-Expected getSymbolsFromObject(const ObjectFile , StringSaver ,
+Expected getSymbolsFromObject(const ObjectFile , OffloadKind Kind,
+StringSaver ,
 DenseMap ) {
   bool ShouldExtract = false;
   for (SymbolRef Sym : Obj.symbols()) {
@@ -1225,12 +1228,15 @@
 // We will extract if it defines a currenlty undefined non-weak symbol.
 bool ResolvesStrongReference = (OldSym & Sym_Undefined) &&
!(OldSym & Sym_Weak) &&
+
!(*FlagsOrErr & SymbolRef::SF_Undefined);
 
 // We will extract if it defines a new global symbol visible to the host.
-bool NewGlobalSymbol = ((NewSymbol || (OldSym & Sym_Undefined)) &&
-!(*FlagsOrErr & SymbolRef::SF_Undefined) &&
-!(*FlagsOrErr & SymbolRef::SF_Hidden));
+// This is only necessary for code targeting an offloading language.
+bool NewGlobalSymbol =
+((NewSymbol || (OldSym & Sym_Undefined)) &&
+ !(*FlagsOrErr & SymbolRef::SF_Undefined) && Kind != object::OFK_None &&
+ !(*FlagsOrErr & SymbolRef::SF_Hidden));
 ShouldExtract |= ResolvesStrongReference | NewGlobalSymbol;
 
 // Update this symbol in the "table" with the new information.
@@ -1250,18 +1256,18 @@
 ///   1) It defines an undefined symbol in a regular object filie.
 ///   2) It defines a global symbol without hidden visibility that has not
 ///  yet been defined.
-Expected getSymbols(StringRef Image, StringSaver ,
+Expected getSymbols(StringRef Image, OffloadKind Kind, StringSaver ,
   DenseMap ) {
   MemoryBufferRef Buffer = MemoryBufferRef(Image, "");
   switch (identify_magic(Image)) {
   case file_magic::bitcode:
-return getSymbolsFromBitcode(Buffer, Saver, Syms);
+return getSymbolsFromBitcode(Buffer, Kind, Saver, Syms);
   case file_magic::elf_relocatable: {
 Expected> ObjFile =
 ObjectFile::createObjectFile(Buffer);
 if (!ObjFile)
   return ObjFile.takeError();
-return getSymbolsFromObject(**ObjFile, Saver, Syms);
+return getSymbolsFromObject(**ObjFile, Kind, Saver, Syms);
   }
   default:
 return false;
@@ -1336,8 +1342,9 @@
 if (IsArchive && !WholeArchive && !Syms.count(Binary))
   continue;
 
-Expected ExtractOrErr =
-

[PATCH] D143436: [clangd] Move standard options adaptor to CommandMangler

2023-03-17 Thread Dmitry Polukhin via Phabricator via cfe-commits
DmitryPolukhin added a comment.

In D143436#4203008 , @dyung wrote:

> @DmitryPolukhin your change seems to be causing a crash in 2 ORC tests on a 
> bot (trivial-cxa-atexit.S and trivial-atexit.S), can you take a look or 
> revert if you need time to investigate?

My changes haven't touched anything in compiler-rt at all but I'm looking into 
the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

I have no strong opinions on the merits of this patch in either direction; I 
think the "sorry"s in the Sema diagnostics for regrettable non-conformance make 
Clang marginally friendlier, but they do nothing to actually help people who 
encounter the diagnostic.

FWIW, the relevant guidance on Clang diagnostics is 
https://clang.llvm.org/docs/InternalsManual.html#the-format-string, and that 
would override the LLVM coding guidelines' rules in places where they conflict 
(though in this case there's no conflict).




Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:338
 def err_file_too_large : Error<
-  "sorry, unsupported: file '%0' is too large for Clang to process">;
+  "unsupported: file '%0' is too large for Clang to process">;
 def err_include_too_large : Error<

I think we could drop the "unsupported: " here too. (We're allowed to have 
implementation limits; this isn't a conformance issue.)



Comment at: clang/include/clang/Basic/DiagnosticCommonKinds.td:341
+  "this include generates a translation unit too large for"
   " Clang to process.">, DefaultFatal;
 def err_unsupported_bom : Error<"%0 byte order mark detected in '%1', but "

Please remove the trailing period while you're fixing the style of this 
diagnostic.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:9669
   "by aggregate initialization using default member initializer "
   "is not supported; lifetime of %select{temporary|backing array}0 "
   "will end at the end of the full-expression">, InGroup;

While we're fixing style: in this file we have "is not yet supported", "is not 
supported yet", and "is not supported". We should pick one and use it 
consistently; "is not supported yet" would be my preference.



Comment at: clang/test/SemaTemplate/temp_arg_nontype_cxx20.cpp:11-12
 template struct Float {};
-using F1 = Float<1.0f>; // FIXME expected-error {{sorry}}
-using F1 = Float<2.0f / 2>; // FIXME expected-error {{sorry}}
+using F1 = Float<1.0f>; // FIXME expected-error
+using F1 = Float<2.0f / 2>; // FIXME expected-error
 

You should retain a `{{...}}` here with some text from the diagnostic for 
`-verify` to match against. Likewise below.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D146187: [docs] Update the status for coroutines

2023-03-17 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

> ... I think in general we want feature testing macros to be treated as our 
> signal to the user that we think something is complete, not that we think 
> something is in progress but pretty usable.

+1


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

https://reviews.llvm.org/D146187

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


[PATCH] D143436: [clangd] Move standard options adaptor to CommandMangler

2023-03-17 Thread Douglas Yung via Phabricator via cfe-commits
dyung added a comment.

@DmitryPolukhin your change seems to be causing a crash in 2 ORC tests on a bot 
(trivial-cxa-atexit.S and trivial-atexit.S), can you take a look or revert if 
you need time to investigate?

https://lab.llvm.org/buildbot/#/builders/247/builds/2639

   TEST 'ORC-x86_64-linux :: 
TestCases/Linux/x86-64/trivial-cxa-atexit.S' FAILED 
  Script:
  --
  : 'RUN: at line 3';  
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/clang   
-m64  -c -o 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-cxa-atexit.S.tmp
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/llvm-project/compiler-rt/test/orc/TestCases/Linux/x86-64/trivial-cxa-atexit.S
  : 'RUN: at line 4';   
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/llvm-jitlink
 
-orc-runtime=/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./lib/clang/17/lib/x86_64-unknown-linux-gnu/liborc_rt.a
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-cxa-atexit.S.tmp
  --
  Exit Code: 139
  Command Output (stderr):
  --
  PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ 
and include the crash backtrace.
  Stack dump:
  0.Program arguments: 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/llvm-jitlink
 
-orc-runtime=/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./lib/clang/17/lib/x86_64-unknown-linux-gnu/liborc_rt.a
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-cxa-atexit.S.tmp
  #0 0x5654e9a19e86 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
(/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/llvm-jitlink+0x10aae86)
  #1 0x5654e9a17534 SignalHandler(int) Signals.cpp:0:0
  #2 0x7f57b6259420 __restore_rt 
(/lib/x86_64-linux-gnu/libpthread.so.0+0x14420)
  #3 0x7f57758df13a 
  #4 0x7f57758e27bc 
  #5 0x7f57758f102a 
  #6 0x7f57758e875f 
  #7 0x7f57758f4de2 
  
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-cxa-atexit.S.script:
 line 2: 3620821 Segmentation fault  (core dumped) 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./bin/llvm-jitlink
 
-orc-runtime=/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/./lib/clang/17/lib/x86_64-unknown-linux-gnu/liborc_rt.a
 
/home/buildbot/buildbot-root/llvm-clang-x86_64-gcc-ubuntu/build/projects/compiler-rt/test/orc/X86_64LinuxConfig/TestCases/Linux/x86-64/Output/trivial-cxa-atexit.S.tmp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D146323: inline stmt attribute diagnosing in templates

2023-03-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.
erichkeane added a reviewer: clang-language-wg.
Herald added a project: All.
erichkeane requested review of this revision.

D146089 's author discovered that our 
diagnostics for always/no inline
would null-dereference when used in a template. He fixed that by
skipping in the dependent case.

This patch makes sure we diagnose these after a template instantiation.
It also adds infrastructure for other statement attributes to add
checking/transformation.


https://reviews.llvm.org/D146323

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaStmtAttr.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/TreeTransform.h
  clang/test/Sema/attr-alwaysinline.cpp
  clang/test/Sema/attr-noinline.cpp

Index: clang/test/Sema/attr-noinline.cpp
===
--- clang/test/Sema/attr-noinline.cpp
+++ clang/test/Sema/attr-noinline.cpp
@@ -2,9 +2,10 @@
 
 int bar();
 
+// expected-note@+1{{conflicting attribute is here}}
 [[gnu::always_inline]] void always_inline_fn(void) { }
+// expected-note@+1{{conflicting attribute is here}}
 [[gnu::flatten]] void flatten_fn(void) { }
-
 [[gnu::noinline]] void noinline_fn(void) { }
 
 void foo() {
@@ -32,9 +33,43 @@
   [[clang::noinline]] return foo(x + 1);
 }
 
-// FIXME: This should warn that noinline statement attribute has higher
-// precedence than the always_inline function attribute.
+template
+[[clang::always_inline]]
+int dependent(int x){ return x + D;} // #DEP
+[[clang::always_inline]]
+int non_dependent(int x){return x;} // #NO_DEP
+
 template [[clang::always_inline]]
-int bar(int x) {
-  [[clang::noinline]] return bar(x + 1);
+int baz(int x) { // #BAZ
+  // expected-warning@+2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
+  // expected-note@#NO_DEP{{conflicting attribute is here}}
+  [[clang::noinline]] non_dependent(x);
+  if constexpr (D>0) {
+// expected-warning@+6{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
+// expected-note@#NO_DEP{{conflicting attribute is here}}
+// expected-warning@+4 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
+// expected-note@#BAZ 3{{conflicting attribute is here}}
+// expected-note@#BAZ_INST 3{{in instantiation}}
+// expected-note@+1 3{{in instantiation}}
+[[clang::noinline]] return non_dependent(x), baz(x + 1);
+  }
+  return x;
+}
+
+// We can't suppress if there is a variadic involved.
+template
+int variadic_baz(int x) {
+  // Diagnoses NO_DEP 2x, once during phase 1, the second during instantiation.
+  // Dianoses DEP 3x, once per variadic expansion.
+  // expected-warning@+5 2{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
+  // expected-note@#NO_DEP 2{{conflicting attribute is here}}
+  // expected-warning@+3 3{{statement attribute 'noinline' has higher precedence than function attribute 'always_inline'}}
+  // expected-note@#DEP 3{{conflicting attribute is here}}
+  // expected-note@#VARIADIC_INST{{in instantiation}}
+  [[clang::noinline]] return non_dependent(x) + (dependent(x) + ...);
+}
+
+void use() {
+  baz<3>(0); // #BAZ_INST
+  variadic_baz<0, 1, 2>(0); // #VARIADIC_INST
 }
Index: clang/test/Sema/attr-alwaysinline.cpp
===
--- clang/test/Sema/attr-alwaysinline.cpp
+++ clang/test/Sema/attr-alwaysinline.cpp
@@ -3,8 +3,9 @@
 int bar();
 
 [[gnu::always_inline]] void always_inline_fn(void) {}
+// expected-note@+1{{conflicting attribute is here}}
 [[gnu::flatten]] void flatten_fn(void) {}
-
+// expected-note@+1{{conflicting attribute is here}}
 [[gnu::noinline]] void noinline_fn(void) {}
 
 void foo() {
@@ -32,9 +33,44 @@
   [[clang::always_inline]] return foo(x + 1);
 }
 
-// FIXME: This should warn that always_inline statement attribute has higher
-// precedence than the noinline function attribute.
+template
+[[gnu::noinline]]
+int dependent(int x){ return x + D;} // #DEP
+[[gnu::noinline]]
+int non_dependent(int x){return x;} // #NO_DEP
+
 template [[gnu::noinline]]
-int bar(int x) {
-  [[clang::always_inline]] return bar(x + 1);
+int baz(int x) { // #BAZ
+  // expected-warning@+2{{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
+  // expected-note@#NO_DEP{{conflicting attribute is here}}
+  [[clang::always_inline]] non_dependent(x);
+  if constexpr (D>0) {
+// expected-warning@+6{{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
+// expected-note@#NO_DEP{{conflicting attribute is here}}
+// expected-warning@+4 3{{statement attribute 'always_inline' has higher precedence than function attribute 'noinline'}}
+// expected-note@#BAZ 3{{conflicting attribute is 

[PATCH] D146163: Experimental new python bindings for clang/llvm based on Cython

2023-03-17 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

In D146163#4202969 , @rickmark wrote:

> Began discussion in Discord to see interest for other collaborators on this 
> type of binding: 
> https://discord.com/channels/636084430946959380/700158649129238591/1086362007684513844

You want to start an RFC here:
https://discourse.llvm.org


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146163

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


[PATCH] D146163: Experimental new python bindings for clang/llvm based on Cython

2023-03-17 Thread Rick Mark via Phabricator via cfe-commits
rickmark added a comment.

Began discussion in Discord to see interest for other collaborators on this 
type of binding: 
https://discord.com/channels/636084430946959380/700158649129238591/1086362007684513844


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146163

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


[PATCH] D145737: PR60985: Fix merging of lambda closure types across modules.

2023-03-17 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D145737#4202351 , @aaron.ballman 
wrote:

> Checking: are the libc++ precommit CI failures related to these changes? It's 
> a modules-specific build config, so I figured it's worth double-checking.

I took a quick glance when I sent this out and thought it was just a change in 
Clang's diagnostic spelling that libc++ hadn't caught up with, but looking 
again it seems like there's something more serious happening there; I'll 
investigate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145737

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


[PATCH] D146247: [clang-format] Support TypeScript satisfies operator

2023-03-17 Thread Taymon A. Beal via Phabricator via cfe-commits
taymonbeal added a comment.

I don't have commit access; can someone who does commit this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146247

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


[PATCH] D146247: [clang-format] Support TypeScript satisfies operator

2023-03-17 Thread Taymon A. Beal via Phabricator via cfe-commits
taymonbeal updated this revision to Diff 506153.
taymonbeal added a comment.

Add release notes and unit test in TokenAnnotatorTest.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146247

Files:
  clang/docs/ReleaseNotes.rst
  clang/unittests/Format/TokenAnnotatorTest.cpp


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1434,6 +1434,20 @@
   EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_FunctionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsTypeScriptSatisfiesOperator) {
+  auto Tokens = annotate("let x = foo satisfies Type;",
+ getGoogleStyle(FormatStyle::LK_JavaScript));
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[1], tok::identifier, TT_StartOfName);
+  EXPECT_TOKEN(Tokens[2], tok::equal, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[3], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[4], tok::identifier, TT_StartOfName);
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[6], tok::semi, TT_Unknown);
+  EXPECT_TOKEN(Tokens[7], tok::eof, TT_Unknown);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -326,6 +326,7 @@
   Compared to ``NextLine`` style, ``NextLineOnly`` style will not try to
   put the initializers on the current line first, instead, it will try to
   put the initializers on the next line only.
+- Add support for the ``satisfies`` operator introduced in TypeScript 4.9.
 
 libclang
 


Index: clang/unittests/Format/TokenAnnotatorTest.cpp
===
--- clang/unittests/Format/TokenAnnotatorTest.cpp
+++ clang/unittests/Format/TokenAnnotatorTest.cpp
@@ -1434,6 +1434,20 @@
   EXPECT_TOKEN(Tokens[13], tok::l_brace, TT_FunctionLBrace);
 }
 
+TEST_F(TokenAnnotatorTest, UnderstandsTypeScriptSatisfiesOperator) {
+  auto Tokens = annotate("let x = foo satisfies Type;",
+ getGoogleStyle(FormatStyle::LK_JavaScript));
+  ASSERT_EQ(Tokens.size(), 8u) << Tokens;
+  EXPECT_TOKEN(Tokens[0], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[1], tok::identifier, TT_StartOfName);
+  EXPECT_TOKEN(Tokens[2], tok::equal, TT_BinaryOperator);
+  EXPECT_TOKEN(Tokens[3], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[4], tok::identifier, TT_StartOfName);
+  EXPECT_TOKEN(Tokens[5], tok::identifier, TT_Unknown);
+  EXPECT_TOKEN(Tokens[6], tok::semi, TT_Unknown);
+  EXPECT_TOKEN(Tokens[7], tok::eof, TT_Unknown);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -326,6 +326,7 @@
   Compared to ``NextLine`` style, ``NextLineOnly`` style will not try to
   put the initializers on the current line first, instead, it will try to
   put the initializers on the next line only.
+- Add support for the ``satisfies`` operator introduced in TypeScript 4.9.
 
 libclang
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145639: [Coroutines] Fix premature conversion of return object

2023-03-17 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

> @bruno, @ChuanqiXu please let us know if you have any objections, otherwise 
> we will land the revert in ~2 hours.

No sweat, I didn't see this in time. Thanks for the reduced testcase.

> What's the resolution here? Can we revert this and continue the discussions 
> independently?

Eager initialization breaks us, lack of RVO on matching types breaks others. 
Landing this + D145641  altogether seems like 
the best approach.

> We can always re-land this change if the conclusion is that the approach here 
> is the one that we want.

Once we wrap up D145641  I'll land both, as 
separated commits but in the same push.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145639

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


[PATCH] D146244: [clangd] Show used symbols on #include line hover.

2023-03-17 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 506141.
VitaNuo added a comment.

Finish the test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146244

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -10,6 +10,7 @@
 #include "Annotations.h"
 #include "Config.h"
 #include "Hover.h"
+#include "TestFS.h"
 #include "TestIndex.h"
 #include "TestTU.h"
 #include "index/MemIndex.h"
@@ -20,6 +21,7 @@
 
 #include "gtest/gtest.h"
 #include 
+#include 
 #include 
 #include 
 
@@ -2951,7 +2953,7 @@
 TU.AdditionalFiles["all.h"] = guard(R"cpp(
   #include "foo.h"
 )cpp");
-  
+
 auto AST = TU.build();
 auto H = getHover(AST, Case.Code.point(), format::getLLVMStyle(), nullptr);
 ASSERT_TRUE(H);
@@ -2980,6 +2982,74 @@
 EXPECT_EQ(Case.HI.present().asMarkdown(), Case.ExpectedMarkdown);
 }
 
+TEST(Hover, UsedSymbols) {
+  struct {
+Annotations Code;
+const std::function ExpectedBuilder;
+  } Cases[] = {{Annotations(R"cpp(
+  [[#inclu^de "foo.h"]]
+  
+  int var = foo();
+)cpp"),
+[](HoverInfo ) { HI.UsedSymbolNames = {"foo"}; }},
+   {Annotations(R"cpp(
+  [[#incl^ude "foo.h"]]
+)cpp"),
+[](HoverInfo ) { HI.UsedSymbolNames = {}; }},
+   {Annotations(R"cpp(
+  #include "foo.h"  
+  [[#include ^"bar.h"]]
+  
+int fooVar = foo();
+int barVar = bar();
+int foobarVar = foobar();
+
+X x;
+)cpp"),
+[](HoverInfo ) {
+  HI.UsedSymbolNames = {"X", "bar", "foobar"};
+}},
+   {Annotations(R"cpp(
+  [[#in^clude ]]
+
+int fooVar = foo();
+  )cpp"),
+[](HoverInfo ) { HI.UsedSymbolNames = {"foo"}; }},
+   {Annotations(R"cpp(
+  [[#in^clude "public.h"]]
+  #include "private.h"
+
+  int fooVar = foo();
+)cpp"),
+[](HoverInfo ) { HI.UsedSymbolNames = {"foo"}; }}
+
+  };
+  for (const auto  : Cases) {
+SCOPED_TRACE(Case.Code.code());
+
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Case.Code.code();
+TU.AdditionalFiles["foo.h"] = guard("int foo();");
+TU.AdditionalFiles["bar.h"] = guard("int bar(); int foobar(); class X {};");
+TU.AdditionalFiles["private.h"] = guard(R"cpp(
+  // IWYU pragma: private, include "public.h"
+  int foo(); 
+   )cpp");
+ TU.AdditionalFiles["public.h"] = guard("");
+TU.AdditionalFiles["system/foo"] = guard("int foo();");
+TU.ExtraArgs.push_back("-isystem" + testPath("system"));
+
+auto AST = TU.build();
+auto H = getHover(AST, Case.Code.point(), format::getLLVMStyle(), nullptr);
+ASSERT_TRUE(H);
+HoverInfo Expected;
+Case.ExpectedBuilder(Expected);
+SCOPED_TRACE(H->present().asMarkdown());
+EXPECT_EQ(H->UsedSymbolNames, Expected.UsedSymbolNames);
+  }
+}
+
 TEST(Hover, DocsFromIndex) {
   Annotations T(R"cpp(
   template  class X {};
Index: clang-tools-extra/clangd/IncludeCleaner.h
===
--- clang-tools-extra/clangd/IncludeCleaner.h
+++ clang-tools-extra/clangd/IncludeCleaner.h
@@ -74,6 +74,9 @@
 
 std::string spellHeader(ParsedAST , const FileEntry *MainFile,
 include_cleaner::Header Provider);
+
+std::vector
+collectMacroReferences(ParsedAST );
 } // namespace clangd
 } // namespace clang
 
Index: clang-tools-extra/clangd/IncludeCleaner.cpp
===
--- clang-tools-extra/clangd/IncludeCleaner.cpp
+++ clang-tools-extra/clangd/IncludeCleaner.cpp
@@ -124,27 +124,6 @@
   return true;
 }
 
-std::vector
-collectMacroReferences(ParsedAST ) {
-  const auto  = AST.getSourceManager();
-  //  FIXME: !!this is a hacky way to collect macro references.
-  std::vector Macros;
-  auto  = AST.getPreprocessor();
-  for (const syntax::Token  :
-   AST.getTokens().spelledTokens(SM.getMainFileID())) {
-auto Macro = locateMacroAt(Tok, PP);
-if (!Macro)
-  continue;
-if (auto DefLoc = Macro->Info->getDefinitionLoc(); DefLoc.isValid())
-  Macros.push_back(
-  {Tok.location(),
-   include_cleaner::Macro{/*Name=*/PP.getIdentifierInfo(Tok.text(SM)),
-  DefLoc},
-   include_cleaner::RefType::Explicit});
-  }
-  return Macros;
-}
-
 llvm::StringRef getResolvedPath(const include_cleaner::Header ) {
   switch (SymProvider.kind()) {
   case 

[PATCH] D146278: [flang] add -flang-experimental-hlfir flag to flang-new

2023-03-17 Thread Slava Zakharin via Phabricator via cfe-commits
vzakhari added a comment.

Thank you for working on this!




Comment at: flang/include/flang/Tools/CLOptions.inc:235
+///   passes pipeline
+inline void createHLFIRToFIRPassPipeline(mlir::PassManager ,
+llvm::OptimizationLevel optLevel = defaultOptLevel) {

Would you mind also calling this in `bbc`  driver?



Comment at: flang/include/flang/Tools/CLOptions.inc:251
+bool stackArrays = false, bool underscoring = true, bool useHLFIR = false) 
{
+  if (useHLFIR)
+fir::createHLFIRToFIRPassPipeline(pm, optLevel);

Is this check and the option really needed?  Except for the extra canonicalizer 
pass the newly added passes will be no-ops, so maybe we should just run them 
unconditionally.

It may be too much to ask for, but will it make sense not to bundle these 
passes into `MLIRToLLVM` pipeline and have the possibility to let driver emit 
post-HLFIR-lowering MLIR (under `-emit-fir`) and pre-HLFIR-lowering (under some 
new option)?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146278

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


[PATCH] D143704: [flang] Feature list plugin

2023-03-17 Thread Ethan Luis McDonough via Phabricator via cfe-commits
elmcdonough added a comment.

Sorry about that.  I was trying to look for a fix, and I think it has something 
to do with these recent changes 
.
  I'll have a new revision soon.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D146310: [clang-format] Fix dropped 'else' in 398cddf6acec

2023-03-17 Thread Jared Grubb via Phabricator via cfe-commits
jaredgrubb added a comment.

The difference doesn't appear to affect any unit tests (which is unfortunate), 
but I think you didn't mean to remove this else, based both on the logic of the 
original commit and the format of the patched line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146310

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


[PATCH] D146310: [clang-format] Fix dropped 'else' in 398cddf6acec

2023-03-17 Thread Jared Grubb via Phabricator via cfe-commits
jaredgrubb created this revision.
jaredgrubb added a reviewer: klimek.
jaredgrubb added a project: clang-format.
Herald added a project: All.
jaredgrubb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

A patch (398cddf6acec 
) appears 
to have inadvertently removed an `else`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D146310

Files:
  clang/lib/Format/UnwrappedLineFormatter.cpp


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -511,9 +511,9 @@
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (NextLine.First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
-  } if(TheLine->InPPDirective ||
-   !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
-tok::kw_struct)) {
+  } else if (TheLine->InPPDirective ||
+ !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
+  tok::kw_struct)) {
 // Try to merge a block with left brace unwrapped that wasn't yet
 // covered.
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||


Index: clang/lib/Format/UnwrappedLineFormatter.cpp
===
--- clang/lib/Format/UnwrappedLineFormatter.cpp
+++ clang/lib/Format/UnwrappedLineFormatter.cpp
@@ -511,9 +511,9 @@
 ShouldMerge = !Style.BraceWrapping.AfterClass ||
   (NextLine.First->is(tok::r_brace) &&
!Style.BraceWrapping.SplitEmptyRecord);
-  } if(TheLine->InPPDirective ||
-   !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
-tok::kw_struct)) {
+  } else if (TheLine->InPPDirective ||
+ !TheLine->First->isOneOf(tok::kw_class, tok::kw_enum,
+  tok::kw_struct)) {
 // Try to merge a block with left brace unwrapped that wasn't yet
 // covered.
 ShouldMerge = !Style.BraceWrapping.AfterFunction ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D144976: [clangd] Add provider info on symbol hover.

2023-03-17 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo added a comment.

Thanks for the comments and the discussions!




Comment at: clang-tools-extra/clangd/Hover.cpp:1118
+
+  for (const auto  : Headers) {
+if (H.kind() == include_cleaner::Header::Physical &&

hokein wrote:
> now the for-range loop doesn't seem necessary, we could always use the 
> `Headers.front()`, right?
Ok. It seems like I need to put an `empty` check on `Headers`, however, because 
contrary to the loop, `front()` might actually crash AFAIU.



Comment at: clang-tools-extra/clangd/Hover.cpp:1219
 maybeAddCalleeArgInfo(N, *HI, PP);
+maybeAddSymbolProviders(AST, *HI, include_cleaner::Symbol{*DeclToUse});
   } else if (const Expr *E = N->ASTNode.get()) {

hokein wrote:
> I wonder how well it works for the `NamespaceDecl`. NamespaceDecl is usually 
> declared in many files, we will basically show a random provider in hover. 
> We're not interested in `NamesapceDecl`, we probably need to ignore it. 
> 
> No action required here, but this is something we should bear in mind.
Thank you.



Comment at: clang-tools-extra/clangd/Hover.cpp:1138
+if (H.kind() == include_cleaner::Header::Physical &&
+H.physical() == SM.getFileEntryForID(SM.getMainFileID()))
+  continue;

hokein wrote:
> VitaNuo wrote:
> > hokein wrote:
> > > MainFile provider is a special case (I don't recall the details).
> > > 
> > > IIUC, the model is:
> > > 
> > > 1) a symbol usage that is satisfied (e.g. any of its providers that are 
> > > directly included in the main file), we show the one with highest rank of 
> > > these included providers
> > > 2) a symbol usage that is not satisfied (we choose the highest rank of 
> > > all providers)
> > > 3) If the provider is the main-file, we don't show it in the hover card. 
> > > 
> > > Based on 1), if the main-file provider is the highest, we will not show 
> > > it in the hover based on 3). However, the current implementation doesn't 
> > > match this behavior
> > > -- on L1123 `ConvertedIncludes.match(H)` is always false  if H is a 
> > > main-file, and we will choose a lower-rank provider if the main-file is 
> > > the first element of `Headers`
> > > -- the logic here doesn't seem to work, we should do a `break` on L1139 
> > > rather than `continue`, which means we always use the `Headers[0]` 
> > > element.
> > > 
> > > Not sure we have discussed 3), one alternative is to show the information 
> > > for main-file provider as well, it seems fine to me that the hover shows 
> > > `provided by the current file` text (not the full path).
> > > we should do a break on L1139 rather than continue
> > 
> > Ok. I'm not sure if this is of great practical importance (what are the 
> > chances that the main file is the first provider, and there are more 
> > providers for the same symbol?),
> > but you're right that we shouldn't show the lower-ranked provider for this 
> > case.
> > 
> > > one alternative is to show the information for main-file provider as well
> > 
> > Yeah, this is possible ofc, but I'm not sure what the use would be. The 
> > general intention of this feature (or feature set, even) is to help users 
> > eliminate unnecessary dependencies, and they can hardly get rid of the main 
> > file :)
> > So of the two options, I'd rather opt for not showing anything at all.
> >  I'm not sure if this is of great practical importance  
> I think the code should match our mental model, otherwise it is hard to 
> reason about whether the actual behavior is expected or a bug.
> 
> > (what are the chances that the main file is the first provider, and there 
> > are more providers for the same symbol?),
> 
> I think the pattern is not rare (especially for headers), think of the case 
> below.
> 
> ```
> #include "other.h" // other.h transitively includes the `foo.h`
> 
> class Foo;
> const Foo& createFoo();
> ```
> 
> although the main-file provider is not the top1 given the current ranking 
> implementation, we have a plan to address it, see the FIXME in 
> https://github.com/llvm/llvm-project/blob/main/clang-tools-extra/include-cleaner/lib/FindHeaders.cpp#L219.
>  After addressing the FIXME, the main-file could be the top1.
> 
> > on L1123 ConvertedIncludes.match(H) is always false if H is a main-file, 
> > and we will choose a lower-rank provider if the main-file is the first 
> > element of Headers
> 
> This comment doesn't seem to be addressed, now it is L1105.
> 
> Given the following case, if the returned providers is [main-file, `foo.h`], 
> the current code will show `foo.h` in hover.
> However, based on our mental model:
>  1) the main-file is one of the `Foo` providers, and it is the top1, we 
> choose it
>  2) we don't show main-file provider in hover
> -> we should not show any information in hover.
> 
> ```
> #include "foo.h"
> 
> class Foo;
> Foo* b;  // hover on `Foo`.
> ```
> I think the pattern is not rare (especially for 

[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-03-17 Thread Paulo Matos 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 rG8d0c88975212: [clang][WebAssembly] Initial support for 
reference type funcref in clang (authored by pmatos).

Changed prior to commit:
  https://reviews.llvm.org/D128440?vs=501081=506134#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/AddressSpaces.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/TargetInfo.cpp
  clang/lib/Basic/Targets/DirectX.h
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/Basic/Targets/SPIR.h
  clang/lib/Basic/Targets/TCE.h
  clang/lib/Basic/Targets/WebAssembly.h
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Format/FormatToken.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseTentative.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/WebAssembly/wasm-funcref.c
  clang/test/Parser/wasm-funcref.c
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-funcref.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp

Index: clang/test/SemaTemplate/address_space-dependent.cpp
===
--- clang/test/SemaTemplate/address_space-dependent.cpp
+++ clang/test/SemaTemplate/address_space-dependent.cpp
@@ -43,7 +43,7 @@
 
 template 
 void tooBig() {
-  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388587)}}
+  __attribute__((address_space(I))) int *bounds; // expected-error {{address space is larger than the maximum supported (8388586)}}
 }
 
 template 
@@ -101,7 +101,7 @@
   car<1, 2, 3>(); // expected-note {{in instantiation of function template specialization 'car<1, 2, 3>' requested here}}
   HasASTemplateFields<1> HASTF;
   neg<-1>(); // expected-note {{in instantiation of function template specialization 'neg<-1>' requested here}}
-  correct<0x7FFFEA>();
+  correct<0x7FFFE9>();
   tooBig<8388650>(); // expected-note {{in instantiation of function template specialization 'tooBig<8388650L>' requested here}}
 
   __attribute__((address_space(1))) char *x;
Index: clang/test/SemaCXX/wasm-funcref.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/wasm-funcref.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -fexceptions -fsyntax-only -verify -triple wasm32 -Wno-unused-value -target-feature +reference-types %s
+
+// Testing that funcrefs work on template aliases
+// expected-no-diagnostics
+
+using IntIntFuncref = int(*)(int) __funcref;
+using DoubleQual = IntIntFuncref __funcref;
+
+int get(int);
+
+IntIntFuncref getFuncref() {
+return get;
+}
Index: clang/test/Sema/wasm-refs.c
===
--- clang/test/Sema/wasm-refs.c
+++ clang/test/Sema/wasm-refs.c
@@ -46,6 +46,8 @@
 __externref_t ***illegal_return_2(); // expected-error {{pointer to WebAssembly reference type is not allowed}}
 
 void varargs(int, ...);
+typedef void (*__funcref funcref_t)();
+typedef void (*__funcref __funcref funcref_fail_t)(); // expected-warning {{attribute '__funcref' is already applied}}
 
 __externref_t func(__externref_t ref) {
// expected-error {{cannot take address of WebAssembly reference}}
@@ -67,5 +69,7 @@
   _Alignof(__externref_t ***);   // expected-error {{pointer to WebAssembly reference type is not allowed}};
   varargs(1, ref);   // expected-error {{cannot pass expression of type '__externref_t' to variadic function}}
 
+  funcref_t func = __builtin_wasm_ref_null_func(0); // expected-error {{too many arguments to function call, expected 0, have 1}}
+
   return ref;
 }
Index: clang/test/Parser/wasm-funcref.c
===
--- /dev/null
+++ clang/test/Parser/wasm-funcref.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 -triple powerpc-linux-gnu -fsyntax-only -verify %s
+
+// Test that we trigger an error at parse time if using keyword funcref
+// while not using a wasm triple.
+typedef void (*__funcref funcref_t)(); // expected-error {{invalid use of '__funcref' keyword outside the WebAssembly triple}}
+typedef int (*__funcref fn_funcref_t)(int);// expected-error {{invalid use of '__funcref' keyword outside the 

[clang] 8d0c889 - [clang][WebAssembly] Initial support for reference type funcref in clang

2023-03-17 Thread Paulo Matos via cfe-commits

Author: Paulo Matos
Date: 2023-03-17T18:31:44+01:00
New Revision: 8d0c889752121e62e7258570c592b905f544d36f

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

LOG: [clang][WebAssembly] Initial support for reference type funcref in clang

This is the funcref counterpart to 890146b. We introduce a new attribute
that marks a function pointer as a funcref. It also implements builtin
__builtin_wasm_ref_null_func(), that returns a null funcref value.

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

Added: 
clang/test/CodeGen/WebAssembly/wasm-funcref.c
clang/test/Parser/wasm-funcref.c
clang/test/SemaCXX/wasm-funcref.cpp

Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/AddressSpaces.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/AttrDocs.td
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Parse/Parser.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/DeclBase.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Basic/TargetInfo.cpp
clang/lib/Basic/Targets/DirectX.h
clang/lib/Basic/Targets/NVPTX.h
clang/lib/Basic/Targets/SPIR.h
clang/lib/Basic/Targets/TCE.h
clang/lib/Basic/Targets/WebAssembly.h
clang/lib/Basic/Targets/X86.h
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/CodeGen/TargetInfo.cpp
clang/lib/CodeGen/TargetInfo.h
clang/lib/Format/FormatToken.h
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseTentative.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/wasm-refs.c
clang/test/SemaTemplate/address_space-dependent.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 7c3b755a438f1..e736f827f04b4 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -1227,6 +1227,10 @@ class alignas(8) Decl {
   /// have a FunctionType.
   const FunctionType *getFunctionType(bool BlocksToo = true) const;
 
+  // Looks through the Decl's underlying type to determine if it's a
+  // function pointer type.
+  bool isFunctionPointerType() const;
+
 private:
   void setAttrsImpl(const AttrVec& Attrs, ASTContext );
   void setDeclContextsImpl(DeclContext *SemaDC, DeclContext *LexicalDC,

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index 95a5df8699afb..9ecc29bd38fd1 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -4934,6 +4934,8 @@ class AttributedType : public Type, public 
llvm::FoldingSetNode {
 
   bool isMSTypeSpec() const;
 
+  bool isWebAssemblyFuncrefSpec() const;
+
   bool isCallingConv() const;
 
   std::optional getImmediateNullability() const;

diff  --git a/clang/include/clang/Basic/AddressSpaces.h 
b/clang/include/clang/Basic/AddressSpaces.h
index 2f2c5d5826bc3..7b723d508fff1 100644
--- a/clang/include/clang/Basic/AddressSpaces.h
+++ b/clang/include/clang/Basic/AddressSpaces.h
@@ -59,6 +59,9 @@ enum class LangAS : unsigned {
   // HLSL specific address spaces.
   hlsl_groupshared,
 
+  // Wasm specific address spaces.
+  wasm_funcref,
+
   // This denotes the count of language-specific address spaces and also
   // the offset added to the target-specific address spaces, which are usually
   // specified by address space attributes __attribute__(address_space(n))).

diff  --git a/clang/include/clang/Basic/Attr.td 
b/clang/include/clang/Basic/Attr.td
index 89a62e83444a3..6c55465926bf7 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -168,6 +168,12 @@ def FunctionLike : SubsetSubjectgetFunctionType(false) != nullptr}],
  "functions, function pointers">;
 
+// Function Pointer is a stricter version of FunctionLike that only allows 
function
+// pointers.
+def FunctionPointer : SubsetSubjectisFunctionPointerType()}],
+"functions pointers">;
+
 def OpenCLKernelFunction
 : SubsetSubjecthasAttr()}],
 "kernel functions">;
@@ -4131,6 +4137,13 @@ def FunctionReturnThunks : InheritableAttr,
   let Subjects = SubjectList<[Function]>;
   let Documentation = [FunctionReturnThunksDocs];
 }
+
+def WebAssemblyFuncref : TypeAttr, TargetSpecificAttr {
+  let Spellings = [Keyword<"__funcref">];
+  let Documentation = [WebAssemblyExportNameDocs];
+  let Subjects = SubjectList<[FunctionPointer], ErrorDiag>;
+}
+
 def ReadOnlyPlacement : InheritableAttr {
   let Spellings = [Clang<"enforce_read_only_placement">];
   let Subjects = 

[PATCH] D144976: [clangd] Add provider info on symbol hover.

2023-03-17 Thread Viktoriia Bakalova via Phabricator via cfe-commits
VitaNuo updated this revision to Diff 506132.
VitaNuo marked 15 inline comments as done.
VitaNuo added a comment.

Address review comments, simplify test. 
Take care of main file as provider handling:

- provider list [main-file,foo.h] and foo.h \#include'd - not show any 
providers on hover.
- provider list [foo.h,main-file] and foo.h \#include'd - "provided by foo.h".
- provider list [main-file, bar.h] and bar.h not \#include'd - not show any 
providers on hover.
- provider list [bar.h,main-file] and bar.h not \#include'd - "provided by 
bar.h".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144976

Files:
  clang-tools-extra/clangd/Hover.cpp
  clang-tools-extra/clangd/Hover.h
  clang-tools-extra/clangd/IncludeCleaner.cpp
  clang-tools-extra/clangd/IncludeCleaner.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/unittests/HoverTests.cpp
  clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h

Index: clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
===
--- clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
+++ clang-tools-extra/include-cleaner/include/clang-include-cleaner/Analysis.h
@@ -13,9 +13,11 @@
 
 #include "clang-include-cleaner/Record.h"
 #include "clang-include-cleaner/Types.h"
+#include "clang/Basic/SourceLocation.h"
 #include "clang/Format/Format.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/STLFunctionalExtras.h"
+#include "llvm/ADT/SmallVector.h"
 #include "llvm/Support/MemoryBufferRef.h"
 #include 
 
@@ -75,6 +77,14 @@
 
 std::string spellHeader(const Header , HeaderSearch ,
 const FileEntry *Main);
+
+/// Gets all the providers for a symbol by traversing each location.
+/// Returned headers are sorted by relevance, first element is the most
+/// likely provider for the symbol.
+llvm::SmallVector headersForSymbol(const Symbol ,
+   const SourceManager ,
+   const PragmaIncludes *PI);
+
 } // namespace include_cleaner
 } // namespace clang
 
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -14,11 +14,12 @@
 #include "TestTU.h"
 #include "index/MemIndex.h"
 #include "clang/AST/Attr.h"
+#include "clang/Format/Format.h"
 #include "clang/Index/IndexSymbol.h"
 #include "llvm/ADT/StringRef.h"
 
-#include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
 #include 
 #include 
 
@@ -28,6 +29,10 @@
 
 using PassMode = HoverInfo::PassType::PassMode;
 
+std::string guard(llvm::StringRef Code) {
+  return "#pragma once\n" + Code.str();
+}
+
 TEST(Hover, Structured) {
   struct {
 const char *const Code;
@@ -2882,6 +2887,99 @@
   }
 }
 
+TEST(Hover, Providers) {
+  struct {
+Annotations Code;
+const std::function ExpectedBuilder;
+  } Cases[] = {{Annotations(R"cpp(
+  struct Foo {}; 
+  Foo F = [[Fo^o]]{};
+)cpp"),
+[](HoverInfo ) { HI.Provider = ""; }},
+   {Annotations(R"cpp(
+  #include "foo.h"   
+  Foo F = [[Fo^o]]{};
+)cpp"),
+[](HoverInfo ) { HI.Provider = "\"foo.h\""; }},
+   {Annotations(R"cpp(
+  #include "all.h"  
+  Foo F = [[Fo^o]]{};
+)cpp"),
+[](HoverInfo ) { HI.Provider = "\"foo.h\""; }},
+   {Annotations(R"cpp(
+#define FOO 5
+int F = [[^FOO]];
+  )cpp"),
+[](HoverInfo ) { HI.Provider = ""; }},
+   {Annotations(R"cpp(
+#include "foo.h"
+int F = [[^FOO]];
+  )cpp"),
+[](HoverInfo ) { HI.Provider = "\"foo.h\""; }},
+   {Annotations(R"cpp(
+  #include "all.h"
+int F = [[^FOO]];
+  )cpp"),
+[](HoverInfo ) { HI.Provider = "\"foo.h\""; }},
+   {Annotations(R"cpp(
+  #include "foo.h"
+Foo A;
+Foo B;
+Foo C = A [[^+]] B;
+  )cpp"),
+[](HoverInfo ) { HI.Provider = "\"foo.h\""; }},
+   {Annotations(R"cpp(
+  #include "foo.h"
+  namespace ns {
+using ::Foo;
+  }
+ns::[[F^oo]] d;
+  )cpp"),
+[](HoverInfo ) { HI.Provider = "\"foo.h\""; }}};
+
+  for (const auto  : Cases) {
+SCOPED_TRACE(Case.Code.code());
+
+TestTU TU;
+TU.Filename = "foo.cpp";
+TU.Code = Case.Code.code();
+TU.AdditionalFiles["foo.h"] = guard(R"cpp(
+  #define FOO 1
+  class Foo {};
+  Foo& operator+(const Foo, const Foo);
+)cpp");
+TU.AdditionalFiles["all.h"] = guard(R"cpp(
+  #include "foo.h"
+)cpp");
+  
+auto AST = TU.build();
+auto H = getHover(AST, Case.Code.point(), format::getLLVMStyle(), nullptr);
+ASSERT_TRUE(H);
+HoverInfo 

[PATCH] D141307: Add -f[no-]loop-versioning option

2023-03-17 Thread Mats Petersson via Phabricator via cfe-commits
Leporacanthicus updated this revision to Diff 506125.
Leporacanthicus added a comment.

Rebase and fix conflicts


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141307

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Flang.cpp
  flang/include/flang/Frontend/CodeGenOptions.def
  flang/include/flang/Tools/CLOptions.inc
  flang/lib/Frontend/CompilerInvocation.cpp
  flang/lib/Frontend/FrontendActions.cpp
  flang/test/Driver/driver-help-hidden.f90
  flang/test/Driver/driver-help.f90
  flang/test/Driver/frontend-forwarding.f90
  flang/test/Driver/version-loops.f90

Index: flang/test/Driver/version-loops.f90
===
--- /dev/null
+++ flang/test/Driver/version-loops.f90
@@ -0,0 +1,54 @@
+! Test that flang-new forwards the -f{no-,}version-loops-for-stride 
+! options corredly to flang-new -fc1 for different variants of optimisation
+! and explicit flags.
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O3 \
+! RUN:   | FileCheck %s
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O2 \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O2
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O2 -fversion-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O2-with
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O4 \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O4
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -Ofast \
+! RUN:   | FileCheck %s --check-prefix=CHECK-Ofast
+  
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -Ofast -fno-version-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-Ofast-no
+
+! RUN: %flang -fsyntax-only -### %s -o %t 2>&1 \
+! RUN:   -O3 -fno-version-loops-for-stride \
+! RUN:   | FileCheck %s --check-prefix=CHECK-O3-no
+  
+! CHECK: "-fversion-loops-for-stride"
+! CHECK: "-O3"
+
+! CHECK-O2-NOT: "-fversion-loops-for-stride"
+! CHECK-O2: "-O2"  
+
+! CHECK-O2-with: "-fversion-loops-for-stride"
+! CHECK-O2-with: "-O2"  
+  
+! CHECK-O4: "-fversion-loops-for-stride"
+! CHECK-O4: "-O3"
+
+! CHECK-Ofast: "-ffast-math"
+! CHECK-Ofast: "-fversion-loops-for-stride"
+! CHECK-Ofast: "-O3"
+
+! CHECK-Ofast-no: "-ffast-math"
+! CHECK-Ofast-no-NOT: "-fversion-loops-for-stride"
+! CHECK-Ofast-no: "-O3"
+
+! CHECK-O3-no-NOT: "-fversion-loops-for-stride"
+! CHECK-O3-no: "-O3"
Index: flang/test/Driver/frontend-forwarding.f90
===
--- flang/test/Driver/frontend-forwarding.f90
+++ flang/test/Driver/frontend-forwarding.f90
@@ -15,6 +15,7 @@
 ! RUN: -fassociative-math \
 ! RUN: -freciprocal-math \
 ! RUN: -fpass-plugin=Bye%pluginext \
+! RUN: -fversion-loops-for-stride \
 ! RUN: -mllvm -print-before-all\
 ! RUN: -P \
 ! RUN:   | FileCheck %s
@@ -33,4 +34,5 @@
 ! CHECK: "-freciprocal-math"
 ! CHECK: "-fconvert=little-endian"
 ! CHECK: "-fpass-plugin=Bye
+! CHECK: "-fversion-loops-for-stride"  
 ! CHECK: "-mllvm" "-print-before-all"
Index: flang/test/Driver/driver-help.f90
===
--- flang/test/Driver/driver-help.f90
+++ flang/test/Driver/driver-help.f90
@@ -48,6 +48,8 @@
 ! HELP-NEXT: -fno-integrated-as  Disable the integrated assembler
 ! HELP-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
+! HELP-NEXT: -fno-version-loops-for-stride
+! HELP-NEXT:Do not create unit-strided loops (default)
 ! HELP-NEXT: -fopenacc  Enable OpenACC
 ! HELP-NEXT: -fopenmp   Parse OpenMP pragmas and generate parallel code.
 ! HELP-NEXT: -fpass-plugin= Load pass plugin from a dynamic shared object file (only with new pass manager).
@@ -55,6 +57,8 @@
 ! HELP-NEXT: -fstack-arrays Attempt to allocate array temporaries on the stack, no matter their size
 ! HELP-NEXT: -fsyntax-only  Run the preprocessor, parser and semantic analysis stages
 ! HELP-NEXT: -funderscoring Appends one trailing underscore to external names
+! HELP-NEXT: -fversion-loops-for-stride
+! HELP-NEXT:Create unit-strided versions of loops
 ! HELP-NEXT: -fxor-operator Enable .XOR. as a synonym of .NEQV.
 ! HELP-NEXT: -help  Display available options
 ! HELP-NEXT: -IAdd directory to the end of the list of include search paths
@@ -141,6 +145,8 @@
 ! HELP-FC1-NEXT: -fno-reformat  Dump the cooked character stream in -E mode
 ! HELP-FC1-NEXT: -fno-signed-zeros  Allow optimizations that ignore the sign of floating point zeros
 ! HELP-FC1-NEXT: -fno-stack-arrays  Allocate array temporaries on the heap (default)
+! HELP-FC1-NEXT: -fno-version-loops-for-stride
+! 

[PATCH] D143704: [flang] Feature list plugin

2023-03-17 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

I reverted your patch since the buildbot was failing for couple of hours. Feel 
free to re-land it when you have a fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D146140: [clang] Properly parse variable template requires clause in lambda

2023-03-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Still LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146140

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


[PATCH] D146140: [clang] Properly parse variable template requires clause in lambda

2023-03-17 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel updated this revision to Diff 506121.
rymiel added a comment.

Add release note


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146140

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Sema/SemaConcept.cpp
  clang/test/SemaTemplate/concepts.cpp


Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -55,10 +55,15 @@
 }
 
 namespace P0857R0 {
+  template  static constexpr bool V = true;
+
   void f() {
 auto x = [] requires B {}; // expected-note {{constraints not 
satisfied}} expected-note {{false}}
 x.operator()();
 x.operator()(); // expected-error {{no matching member function}}
+
+auto y = [] requires V () {};
+y.operator()(); // OK
   }
 
   template concept C = true;
Index: clang/lib/Sema/SemaConcept.cpp
===
--- clang/lib/Sema/SemaConcept.cpp
+++ clang/lib/Sema/SemaConcept.cpp
@@ -105,27 +105,35 @@
   QualType Type = ConstraintExpression->getType();
 
   auto CheckForNonPrimary = [&] {
-if (PossibleNonPrimary)
-  *PossibleNonPrimary =
-  // We have the following case:
-  // template requires func(0) struct S { };
-  // The user probably isn't aware of the parentheses required around
-  // the function call, and we're only going to parse 'func' as the
-  // primary-expression, and complain that it is of non-bool type.
-  (NextToken.is(tok::l_paren) &&
-   (IsTrailingRequiresClause ||
-(Type->isDependentType() &&
- isa(ConstraintExpression)) ||
-Type->isFunctionType() ||
-Type->isSpecificBuiltinType(BuiltinType::Overload))) ||
-  // We have the following case:
-  // template requires size_ == 0 struct S { };
-  // The user probably isn't aware of the parentheses required around
-  // the binary operator, and we're only going to parse 'func' as the
-  // first operand, and complain that it is of non-bool type.
-  getBinOpPrecedence(NextToken.getKind(),
- /*GreaterThanIsOperator=*/true,
- getLangOpts().CPlusPlus11) > prec::LogicalAnd;
+if (!PossibleNonPrimary)
+  return;
+
+*PossibleNonPrimary =
+// We have the following case:
+// template requires func(0) struct S { };
+// The user probably isn't aware of the parentheses required around
+// the function call, and we're only going to parse 'func' as the
+// primary-expression, and complain that it is of non-bool type.
+//
+// However, if we're in a lambda, this might also be:
+// [] requires var () {};
+// Which also looks like a function call due to the lambda parentheses,
+// but unlike the first case, isn't an error, so this check is skipped.
+(NextToken.is(tok::l_paren) &&
+ (IsTrailingRequiresClause ||
+  (Type->isDependentType() &&
+   isa(ConstraintExpression) &&
+   !dyn_cast_if_present(getCurFunction())) ||
+  Type->isFunctionType() ||
+  Type->isSpecificBuiltinType(BuiltinType::Overload))) ||
+// We have the following case:
+// template requires size_ == 0 struct S { };
+// The user probably isn't aware of the parentheses required around
+// the binary operator, and we're only going to parse 'func' as the
+// first operand, and complain that it is of non-bool type.
+getBinOpPrecedence(NextToken.getKind(),
+   /*GreaterThanIsOperator=*/true,
+   getLangOpts().CPlusPlus11) > prec::LogicalAnd;
   };
 
   // An atomic constraint!
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -80,6 +80,9 @@
 ^
 - Support for out-of-line definitions of constrained templates has been 
improved.
   This partially fixes `#49620 
`_.
+- Lambda templates with a requires clause directly after the template 
parameters now parse
+  correctly if the requires clause consists of a variable with a dependent 
type.
+  (`#61278 `_)
 
 C++2b Feature Support
 ^


Index: clang/test/SemaTemplate/concepts.cpp
===
--- clang/test/SemaTemplate/concepts.cpp
+++ clang/test/SemaTemplate/concepts.cpp
@@ -55,10 +55,15 @@
 }
 
 namespace P0857R0 {
+  template  static constexpr bool V = true;
+
   void f() {
 auto x = [] requires B {}; // expected-note {{constraints not satisfied}} expected-note 

[PATCH] D145820: [Clang][OpenMP] Insert alloca for kernel args at function entry block instead of the launch point.

2023-03-17 Thread Dhruva Chakrabarti via Phabricator via cfe-commits
dhruvachak updated this revision to Diff 506107.
dhruvachak marked an inline comment as done.
dhruvachak added a comment.

Removed attributes (as original) from clang test 
OpenMP/target_map_codegen_hold.cpp.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145820

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/align_clause_codegen.cpp
  clang/test/OpenMP/atomic_compare_codegen.cpp
  clang/test/OpenMP/bug60602.cpp
  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_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_non_rectangular_codegen.c
  clang/test/OpenMP/irbuilder_nested_openmp_parallel_empty.c
  clang/test/OpenMP/nested_loop_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_target_parallel_proc_bind_codegen.cpp
  clang/test/OpenMP/nvptx_target_parallel_reduction_codegen_tbaa_PR46146.cpp
  clang/test/OpenMP/reduction_compound_op.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_has_device_addr_codegen.cpp
  clang/test/OpenMP/target_has_device_addr_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_map_deref_array_codegen.cpp
  clang/test/OpenMP/target_map_member_expr_codegen.cpp
  clang/test/OpenMP/target_offload_mandatory_codegen.cpp
  clang/test/OpenMP/target_ompx_dyn_cgroup_mem_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_if_codegen.cpp
  clang/test/OpenMP/target_parallel_num_threads_codegen.cpp
  clang/test/OpenMP/target_task_affinity_codegen.cpp
  clang/test/OpenMP/target_teams_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_collapse_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_dist_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_schedule_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_collapse_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_dist_schedule_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/target_teams_distribute_parallel_for_simd_if_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_lastprivate_codegen.cpp
  
clang/test/OpenMP/target_teams_distribute_parallel_for_simd_private_codegen.cpp
  

[clang] 807d397 - [clang] Fix two unused variable warnings from if statements. NFC

2023-03-17 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-03-17T09:18:13-07:00
New Revision: 807d397c751355ae02a89cb5178192752b832203

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

LOG: [clang] Fix two unused variable warnings from if statements. NFC

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Sema/SemaExprMember.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index c40e93b4ad13..b6d57f077e55 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -1993,7 +1993,7 @@ void Clang::AddMIPSTargetArgs(const ArgList ,
 void Clang::AddPPCTargetArgs(const ArgList ,
  ArgStringList ) const {
   const llvm::Triple  = getToolChain().getTriple();
-  if (const Arg *A = Args.getLastArg(options::OPT_mtune_EQ)) {
+  if (Args.getLastArg(options::OPT_mtune_EQ)) {
 CmdArgs.push_back("-tune-cpu");
 std::string CPU = ppc::getPPCTuneCPU(Args, T);
 CmdArgs.push_back(Args.MakeArgString(CPU));

diff  --git a/clang/lib/Sema/SemaExprMember.cpp 
b/clang/lib/Sema/SemaExprMember.cpp
index 667a17e05f93..60b9b013d3f2 100644
--- a/clang/lib/Sema/SemaExprMember.cpp
+++ b/clang/lib/Sema/SemaExprMember.cpp
@@ -164,7 +164,7 @@ static IMAKind ClassifyImplicitMemberAccess(Sema ,
   if (auto *MD = dyn_cast(DC))
 contextClass = MD->getParent()->getCanonicalDecl();
   else if (auto *RD = dyn_cast(DC))
-contextClass = cast(DC);
+contextClass = RD;
   else
 return AbstractInstanceResult ? AbstractInstanceResult
   : IMA_Error_StaticContext;



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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D146089#4202374 , @erichkeane 
wrote:

> To highlight the fix.  See the rest of our release notes.

4743c03ca8fcb61b8fa4022c38cf93cf55d7f6fd 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D145815: [Flang][Driver] Add support for fopenmp-is-device and fembed-offload-object to Flang ToolChain

2023-03-17 Thread Andrew Gozillon via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0cd31a7d3087: [Flang][Driver] Add support for 
fopenmp-is-device and fembed-offload-object to… (authored by agozillon).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145815

Files:
  clang/lib/Driver/ToolChains/Flang.cpp
  clang/lib/Driver/ToolChains/Flang.h
  flang/test/Driver/omp-frontend-forwarding.f90


Index: flang/test/Driver/omp-frontend-forwarding.f90
===
--- /dev/null
+++ flang/test/Driver/omp-frontend-forwarding.f90
@@ -0,0 +1,22 @@
+! Test that flang-new OpenMP and OpenMP offload related 
+! commands forward or expand to the appropriate commands 
+! for flang-new -fc1 as expected.
+
+! Test regular -fopenmp with no offload
+! RUN: %flang -### -fopenmp %s 2>&1 | FileCheck --check-prefixes=CHECK-OPENMP 
%s
+! CHECK-OPENMP: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}}.f90"
+! CHECK-OPENMP-NOT: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} 
"-fopenmp-is-device" {{.*}}.f90"
+
+! Test regular -fopenmp with offload for basic fopenmp-is-device flag addition 
and correct fopenmp 
+! RUN: %flang -### -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa %s 2>&1 | 
FileCheck --check-prefixes=CHECK-OPENMP-IS-DEVICE %s
+! CHECK-OPENMP-IS-DEVICE: "{{[^"]*}}flang-new" "-fc1" {{.*}} "-fopenmp" {{.*}} 
"-fopenmp-is-device" {{.*}}.f90"
+
+! Testing fembed-offload-object and fopenmp-is-device
+! RUN: %flang -S -### %s -o %t 2>&1 \
+! RUN: -fopenmp --offload-arch=gfx90a \
+! RUN: --target=aarch64-unknown-linux-gnu \
+! RUN:   | FileCheck %s --check-prefixes=CHECK-OPENMP-EMBED
+! CHECK-OPENMP-EMBED: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}}.f90"
+! CHECK-OPENMP-EMBED-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"amdgcn-amd-amdhsa" {{.*}} "-fopenmp" {{.*}} "-fopenmp-is-device" {{.*}}.f90"
+! CHECK-OPENMP-EMBED: "{{[^"]*}}clang-offload-packager" {{.*}} 
"--image=file={{.*}}.bc,triple=amdgcn-amd-amdhsa,arch=gfx90a,kind=openmp"
+! CHECK-OPENMP-EMBED-NEXT: "{{[^"]*}}flang-new" "-fc1" "-triple" 
"aarch64-unknown-linux-gnu" {{.*}} "-fopenmp" {{.*}} 
"-fembed-offload-object={{.*}}.out" {{.*}}.bc"
Index: clang/lib/Driver/ToolChains/Flang.h
===
--- clang/lib/Driver/ToolChains/Flang.h
+++ clang/lib/Driver/ToolChains/Flang.h
@@ -56,6 +56,17 @@
   void addTargetOptions(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const;
 
+  /// Extract offload options from the driver arguments and add them to
+  /// the command arguments.
+  /// \param [in] C The current compilation for the driver invocation
+  /// \param [in] Inputs The input infomration on the current file inputs
+  /// \param [in] JA The job action
+  /// \param [in] Args The list of input driver arguments
+  /// \param [out] CmdArgs The list of output command arguments
+  void addOffloadOptions(Compilation , const InputInfoList ,
+ const JobAction , const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList ) const;
+
   /// Extract other compilation options from the driver arguments and add them
   /// to the command arguments.
   ///
Index: clang/lib/Driver/ToolChains/Flang.cpp
===
--- clang/lib/Driver/ToolChains/Flang.cpp
+++ clang/lib/Driver/ToolChains/Flang.cpp
@@ -114,6 +114,35 @@
   // TODO: Add target specific flags, ABI, mtune option etc.
 }
 
+void Flang::addOffloadOptions(Compilation , const InputInfoList ,
+  const JobAction , const ArgList ,
+  ArgStringList ) const {
+  bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
+  bool IsHostOffloadingAction = JA.isHostOffloading(Action::OFK_OpenMP) ||
+JA.isHostOffloading(C.getActiveOffloadKinds());
+
+  // Skips the primary input file, which is the input file that the compilation
+  // proccess will be executed upon (e.g. the host bitcode file) and
+  // adds the other secondary input (e.g. device bitcode files for embedding)
+  // to the embed offload object. This is condensed logic from the Clang driver
+  // for embedding offload objects during HostOffloading.
+  if (IsHostOffloadingAction) {
+for (size_t i = 1; i < Inputs.size(); ++i) {
+  if (Inputs[i].getType() != types::TY_Nothing)
+CmdArgs.push_back(
+Args.MakeArgString("-fembed-offload-object=" +
+   getToolChain().getInputFilename(Inputs[i])));
+}
+  }
+
+  if (IsOpenMPDevice) {
+// -fopenmp-is-device is passed along to tell the frontend that it is
+// generating code for a device, so that only the relevant code is
+// emitted.
+CmdArgs.push_back("-fopenmp-is-device");
+  }
+}
+
 static 

[clang] 0cd31a7 - [Flang][Driver] Add support for fopenmp-is-device and fembed-offload-object to Flang ToolChain

2023-03-17 Thread Andrew Gozillon via cfe-commits

Author: Andrew Gozillon
Date: 2023-03-17T11:12:16-05:00
New Revision: 0cd31a7d308714d26f49391ac4ea9f6bce5fa324

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

LOG: [Flang][Driver] Add support for fopenmp-is-device and 
fembed-offload-object to Flang ToolChain

This allows-fembed-offload-object's and -fopenmp-is-device
compiler invocation arguments to be passed to the Flang frontend
during split compilation when offloading in OpenMP.

An example use case is when passing an offload-arch alongside
-fopenmp to embed device objects compiled for the offload-arch
within the host architecture.

This borrows from existing clangDriver+Clang.h/.cpp work and the intent
is currently to reuse as much of the existing infrastructure and design as
we can to achieve offloading for Flang+OpenMP. An overview of
Clang's offloading design can be found
here: https://clang.llvm.org/docs/OffloadingDesign.html

Reviewers:
awarzynski
jhuber6

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

Added: 
flang/test/Driver/omp-frontend-forwarding.f90

Modified: 
clang/lib/Driver/ToolChains/Flang.cpp
clang/lib/Driver/ToolChains/Flang.h

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Flang.cpp 
b/clang/lib/Driver/ToolChains/Flang.cpp
index 10a518c34351..0a4a0de99b89 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -114,6 +114,35 @@ void Flang::addTargetOptions(const ArgList ,
   // TODO: Add target specific flags, ABI, mtune option etc.
 }
 
+void Flang::addOffloadOptions(Compilation , const InputInfoList ,
+  const JobAction , const ArgList ,
+  ArgStringList ) const {
+  bool IsOpenMPDevice = JA.isDeviceOffloading(Action::OFK_OpenMP);
+  bool IsHostOffloadingAction = JA.isHostOffloading(Action::OFK_OpenMP) ||
+JA.isHostOffloading(C.getActiveOffloadKinds());
+
+  // Skips the primary input file, which is the input file that the compilation
+  // proccess will be executed upon (e.g. the host bitcode file) and
+  // adds the other secondary input (e.g. device bitcode files for embedding)
+  // to the embed offload object. This is condensed logic from the Clang driver
+  // for embedding offload objects during HostOffloading.
+  if (IsHostOffloadingAction) {
+for (size_t i = 1; i < Inputs.size(); ++i) {
+  if (Inputs[i].getType() != types::TY_Nothing)
+CmdArgs.push_back(
+Args.MakeArgString("-fembed-offload-object=" +
+   getToolChain().getInputFilename(Inputs[i])));
+}
+  }
+
+  if (IsOpenMPDevice) {
+// -fopenmp-is-device is passed along to tell the frontend that it is
+// generating code for a device, so that only the relevant code is
+// emitted.
+CmdArgs.push_back("-fopenmp-is-device");
+  }
+}
+
 static void addFloatingPointOptions(const Driver , const ArgList ,
 ArgStringList ) {
   StringRef FPContract;
@@ -327,6 +356,9 @@ void Flang::ConstructJob(Compilation , const JobAction 
,
   // Add other compile options
   addOtherOptions(Args, CmdArgs);
 
+  // Offloading related options
+  addOffloadOptions(C, Inputs, JA, Args, CmdArgs);
+
   // Forward -Xflang arguments to -fc1
   Args.AddAllArgValues(CmdArgs, options::OPT_Xflang);
 

diff  --git a/clang/lib/Driver/ToolChains/Flang.h 
b/clang/lib/Driver/ToolChains/Flang.h
index 4c85c602e267..0dc3cb7eeadc 100644
--- a/clang/lib/Driver/ToolChains/Flang.h
+++ b/clang/lib/Driver/ToolChains/Flang.h
@@ -56,6 +56,17 @@ class LLVM_LIBRARY_VISIBILITY Flang : public Tool {
   void addTargetOptions(const llvm::opt::ArgList ,
 llvm::opt::ArgStringList ) const;
 
+  /// Extract offload options from the driver arguments and add them to
+  /// the command arguments.
+  /// \param [in] C The current compilation for the driver invocation
+  /// \param [in] Inputs The input infomration on the current file inputs
+  /// \param [in] JA The job action
+  /// \param [in] Args The list of input driver arguments
+  /// \param [out] CmdArgs The list of output command arguments
+  void addOffloadOptions(Compilation , const InputInfoList ,
+ const JobAction , const llvm::opt::ArgList ,
+ llvm::opt::ArgStringList ) const;
+
   /// Extract other compilation options from the driver arguments and add them
   /// to the command arguments.
   ///

diff  --git a/flang/test/Driver/omp-frontend-forwarding.f90 
b/flang/test/Driver/omp-frontend-forwarding.f90
new file mode 100644
index ..063e20b1bee3
--- /dev/null
+++ b/flang/test/Driver/omp-frontend-forwarding.f90
@@ -0,0 +1,22 @@
+! Test that flang-new OpenMP and OpenMP offload related 
+! commands 

[PATCH] D128440: [WebAssembly] Initial support for reference type funcref in clang

2023-03-17 Thread Paulo Matos via Phabricator via cfe-commits
pmatos marked 3 inline comments as done.
pmatos added a comment.

Thanks all for the comments, fixed and will soon land after running a check-all.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128440

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


[clang] 4743c03 - [Docs] Add release notes for D146089.

2023-03-17 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-03-17T09:03:08-07:00
New Revision: 4743c03ca8fcb61b8fa4022c38cf93cf55d7f6fd

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

LOG: [Docs] Add release notes for D146089.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 8d8be6780a47..24f5b622249d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -209,6 +209,9 @@ Bug Fixes in This Version
   function context.
   (`#37792 `_) and
   (`#48405 `_)
+- Fix crash when using ``[[clang::always_inline]]`` or ``[[clang::noinline]]``
+  statement attributes on a call to a template function in the body of a
+  template function.
 
 Bug Fixes to Compiler Builtins
 ^^



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


[clang] 4361ba7 - Revert "[Coroutines] Fix premature conversion of return object"

2023-03-17 Thread Ilya Biryukov via cfe-commits

Author: Ilya Biryukov
Date: 2023-03-17T17:01:43+01:00
New Revision: 4361ba791cd6ab6e41fca4df3fd337da0c116132

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

LOG: Revert "[Coroutines] Fix premature conversion of return object"

This reverts commit 54225c457a336b1609c6d064b2b606a9238a28b9.
The lack of RVO causes compile errors in our code.
Reverting to unblock our integrate.

See D145639 for full discussion.

Added: 


Modified: 
clang/include/clang/AST/StmtCXX.h
clang/lib/AST/StmtCXX.cpp
clang/lib/CodeGen/CGCoroutine.cpp
clang/lib/Sema/SemaCoroutine.cpp
clang/lib/Sema/TreeTransform.h
clang/test/CodeGenCoroutines/coro-gro.cpp
clang/test/CodeGenCoroutines/pr59221.cpp
clang/test/SemaCXX/coroutine-no-move-ctor.cpp
clang/test/SemaCXX/coroutines.cpp
clang/test/SemaCXX/warn-throw-out-noexcept-coro.cpp

Removed: 




diff  --git a/clang/include/clang/AST/StmtCXX.h 
b/clang/include/clang/AST/StmtCXX.h
index 05dfac2b50c3f..2c71f86768963 100644
--- a/clang/include/clang/AST/StmtCXX.h
+++ b/clang/include/clang/AST/StmtCXX.h
@@ -326,7 +326,6 @@ class CoroutineBodyStmt final
 OnFallthrough, ///< Handler for control flow falling off the body.
 Allocate,  ///< Coroutine frame memory allocation.
 Deallocate,///< Coroutine frame memory deallocation.
-ResultDecl,///< Declaration holding the result of get_return_object.
 ReturnValue,   ///< Return value for thunk function: p.get_return_object().
 ReturnStmt,///< Return statement for the thunk function.
 ReturnStmtOnAllocFailure, ///< Return statement if allocation failed.
@@ -353,7 +352,6 @@ class CoroutineBodyStmt final
 Stmt *OnFallthrough = nullptr;
 Expr *Allocate = nullptr;
 Expr *Deallocate = nullptr;
-Stmt *ResultDecl = nullptr;
 Expr *ReturnValue = nullptr;
 Stmt *ReturnStmt = nullptr;
 Stmt *ReturnStmtOnAllocFailure = nullptr;
@@ -406,7 +404,6 @@ class CoroutineBodyStmt final
   Expr *getDeallocate() const {
 return cast_or_null(getStoredStmts()[SubStmt::Deallocate]);
   }
-  Stmt *getResultDecl() const { return getStoredStmts()[SubStmt::ResultDecl]; }
   Expr *getReturnValueInit() const {
 return cast(getStoredStmts()[SubStmt::ReturnValue]);
   }

diff  --git a/clang/lib/AST/StmtCXX.cpp b/clang/lib/AST/StmtCXX.cpp
index a3ae5392f54bc..33b0421ad1016 100644
--- a/clang/lib/AST/StmtCXX.cpp
+++ b/clang/lib/AST/StmtCXX.cpp
@@ -117,7 +117,6 @@ 
CoroutineBodyStmt::CoroutineBodyStmt(CoroutineBodyStmt::CtorArgs const )
   SubStmts[CoroutineBodyStmt::OnFallthrough] = Args.OnFallthrough;
   SubStmts[CoroutineBodyStmt::Allocate] = Args.Allocate;
   SubStmts[CoroutineBodyStmt::Deallocate] = Args.Deallocate;
-  SubStmts[CoroutineBodyStmt::ResultDecl] = Args.ResultDecl;
   SubStmts[CoroutineBodyStmt::ReturnValue] = Args.ReturnValue;
   SubStmts[CoroutineBodyStmt::ReturnStmt] = Args.ReturnStmt;
   SubStmts[CoroutineBodyStmt::ReturnStmtOnAllocFailure] =

diff  --git a/clang/lib/CodeGen/CGCoroutine.cpp 
b/clang/lib/CodeGen/CGCoroutine.cpp
index 38167cc74a7f3..9b233c1807cf1 100644
--- a/clang/lib/CodeGen/CGCoroutine.cpp
+++ b/clang/lib/CodeGen/CGCoroutine.cpp
@@ -467,71 +467,6 @@ struct CallCoroDelete final : public EHScopeStack::Cleanup 
{
 };
 }
 
-namespace {
-struct GetReturnObjectManager {
-  CodeGenFunction 
-  CGBuilderTy 
-  const CoroutineBodyStmt 
-
-  Address GroActiveFlag;
-  CodeGenFunction::AutoVarEmission GroEmission;
-
-  GetReturnObjectManager(CodeGenFunction , const CoroutineBodyStmt )
-  : CGF(CGF), Builder(CGF.Builder), S(S), 
GroActiveFlag(Address::invalid()),
-GroEmission(CodeGenFunction::AutoVarEmission::invalid()) {}
-
-  // The gro variable has to outlive coroutine frame and coroutine promise, 
but,
-  // it can only be initialized after coroutine promise was created, thus, we
-  // split its emission in two parts. EmitGroAlloca emits an alloca and sets up
-  // cleanups. Later when coroutine promise is available we initialize the gro
-  // and sets the flag that the cleanup is now active.
-  void EmitGroAlloca() {
-auto *GroDeclStmt = dyn_cast(S.getResultDecl());
-if (!GroDeclStmt) {
-  // If get_return_object returns void, no need to do an alloca.
-  return;
-}
-
-auto *GroVarDecl = cast(GroDeclStmt->getSingleDecl());
-
-// Set GRO flag that it is not initialized yet
-GroActiveFlag = CGF.CreateTempAlloca(Builder.getInt1Ty(), CharUnits::One(),
- "gro.active");
-Builder.CreateStore(Builder.getFalse(), GroActiveFlag);
-
-GroEmission = CGF.EmitAutoVarAlloca(*GroVarDecl);
-
-// Remember the top of EHStack before emitting the cleanup.
-auto old_top = CGF.EHStack.stable_begin();
-CGF.EmitAutoVarCleanups(GroEmission);
- 

[PATCH] D146041: Fix weirdly apologetic diagnostic messages

2023-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D146041#4198056 , @AryanGodara 
wrote:

> I will try to split this commit, and update on this asap (Sorry for the late 
> update, I have mid-sem exams going on, I haven't abandoned this issue, still 
> working on it).

No worries about the speed of updates, it's totally fine for weeks to pass 
between updates to a patch. We're usually pretty good at asking "is this 
abandoned" rather than assuming. FWIW, it looks like there's also precommit CI 
failures related to the changes that should be looked into.




Comment at: clang/unittests/Format/FormatTest.cpp:11426
   verifyFormat("[[gsl::suppress(\"clang-tidy-check-name\")]] void f() {}");
-  verifyFormat("void f() [[deprecated(\"so sorry\")]];");
   verifyFormat("aa\n"

These changes don't really do much -- it's a test case, so the wording is not 
important, but what is important is retaining the string argument that is being 
dropped. I'd roll back the changes to this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146041

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

To highlight the fix.  See the rest of our release notes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-17 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D146089#4202037 , @erichkeane 
wrote:

> Please add a release note as requested.

To highlight the fix or highlight the missing warning? Or both?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D145737: PR60985: Fix merging of lambda closure types across modules.

2023-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Checking: are the libc++ precommit CI failures related to these changes? It's a 
modules-specific build config, so I figured it's worth double-checking.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145737

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


[PATCH] D143436: [clangd] Move standard options adaptor to CommandMangler

2023-03-17 Thread Alex Bradbury via Phabricator via cfe-commits
asb added a comment.

This broke `-DBUILD_SHARED_LIBS=True` builds - I committed 
rG482d22d05a4a30a4f8594273bd359f7d311c9d4c 
 to fix it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143436

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


[PATCH] D144651: [Serialization] Place command line defines in the correct file

2023-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though you should also add a release note for the fix.




Comment at: clang/lib/Serialization/ASTReader.cpp:1593
+if (Record[3]) {
+  SrcMgr::FileInfo  =
+  const_cast(SourceMgr.getSLocEntry(FID).getFile());

No need to repeat the type.


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

https://reviews.llvm.org/D144651

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


[PATCH] D145815: [Flang][Driver] Add support for fopenmp-is-device and fembed-offload-object to Flang ToolChain

2023-03-17 Thread Andrew Gozillon via Phabricator via cfe-commits
agozillon added a comment.

May I please request a final acceptance from both @jhuber6 and @awarzynski 
before I commit this upstream! If you have no further comments to add or 
requests of course.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145815

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


[PATCH] D143704: [flang] Feature list plugin

2023-03-17 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

pre-commit ci is showing a different failure:

   TEST 'Flang :: Examples/feature-list-class.f90' FAILED 

  Script:
  --
  : 'RUN: at line 4';   
/var/lib/buildkite-agent/builds/llvm-project/build/bin/flang-new -fc1 -load 
/var/lib/buildkite-agent/builds/llvm-project/build/lib/flangFeatureList.so  
   -plugin feature-list 
/var/lib/buildkite-agent/builds/llvm-project/flang/test/Examples/feature-list-class.f90
 2>&1 | /var/lib/buildkite-agent/builds/llvm-project/build/bin/FileCheck 
/var/lib/buildkite-agent/builds/llvm-project/flang/test/Examples/feature-list-class.f90
  --
  Exit Code: 1
   
  Command Output (stderr):
  --
  
/var/lib/buildkite-agent/builds/llvm-project/flang/test/Examples/feature-list-class.f90:31:10:
 error: CHECK: expected string not found in input
  ! CHECK: Name: 32
   ^
  :1:1: note: scanning from here
  error: unable to load plugin 
'/var/lib/buildkite-agent/builds/llvm-project/build/lib/flangFeatureList.so': 
'/var/lib/buildkite-agent/builds/llvm-project/build/lib/flangFeatureList.so: 
cannot open shared object file: No such file or directory'
  ^
  :1:198: note: possible intended match here
  error: unable to load plugin 
'/var/lib/buildkite-agent/builds/llvm-project/build/lib/flangFeatureList.so': 
'/var/lib/buildkite-agent/builds/llvm-project/build/lib/flangFeatureList.so: 
cannot open shared object file: No such file or directory'


   ^
   
  Input file: 
  Check file: 
/var/lib/buildkite-agent/builds/llvm-project/flang/test/Examples/feature-list-class.f90
   
  -dump-input=help explains the following input dump.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-17 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: clang/lib/Driver/ToolChains/CommonArgs.cpp:1696
 if (TC.getTriple().isOSAIX()) {
+  if (Args.hasArg(options::OPT_r))
+break;

I think this is redundant, we guard out this whole function call in the block 
above.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

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


[PATCH] D145899: [AIX][Clang] Respect -r when invoking the linker

2023-03-17 Thread David Tenty via Phabricator via cfe-commits
daltenty added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.cpp:237
+// Add directory to library search path.
+Args.AddAllArgs(CmdArgs, options::OPT_L);
+ToolChain.AddFilePathLibArgs(Args, CmdArgs);

This mostly looks good, but I'm not sure other toolchains omit use specified 
`L` options. I think we shouldn't either.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D145899

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


[PATCH] D146288: clang-tidy: Detect use-after-move in CXXCtorInitializer

2023-03-17 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL added a comment.

I will check this more deeply during weekend.


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

https://reviews.llvm.org/D146288

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


[PATCH] D143704: [flang] Feature list plugin

2023-03-17 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D143704#4202146 , @elmcdonough 
wrote:

> Haven't been able to check this yet, but I think it might be due to the tests 
> expecting a deterministic output.  I've only ever tested on Ubuntu WSL, so 
> its possible the order is different on different platforms.  I think 
> replacing CHECK-NEXT with CHECK-DAG might fix the issue.

Please revert until you have a fix.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D143287: [Clang][X86] Change X86 cast intrinsics to use __builtin_nondeterministic_value

2023-03-17 Thread Manuel Brito via Phabricator via cfe-commits
ManuelJBrito planned changes to this revision.
ManuelJBrito added a comment.

Implementing the 128 to 512 casts by filling the rest of the vector with the 
same definition of a nondeterministic_value is not correct because  :

a = freeze poison
v = 

is not the same as

v = freeze poison

The only solution I'm seeing ,using the shufflevector, is doing the conversion 
in two steps:

- build a 256 vector with the upper half being undefined( freeze poison)
- build a 512 vector where the lower half is the previous 256 vector and the 
upper half being undefined

I think this would require two shuffles which is unfortunate.

This would ensure no miscompilations due to multiple uses of the same freeze 
undef/poison but would probably require some backend work to ensure the pattern 
is recognized to emit efficient assembly.

Would this work ? @RKSimon @craig.topper


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143287

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


[clang] 482d22d - [clang][test] Fix -DBUILD_SHARED_LIBS build by adding depency on MC from clangTesting

2023-03-17 Thread Alex Bradbury via cfe-commits

Author: Alex Bradbury
Date: 2023-03-17T14:45:48Z
New Revision: 482d22d05a4a30a4f8594273bd359f7d311c9d4c

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

LOG: [clang][test] Fix -DBUILD_SHARED_LIBS build by adding depency on MC from 
clangTesting

Commit 34de7da6246cdfa6ff6f3d3c514583cddc0a10ec (D143436) introduced a
dependency on the TargetRegistry in `getAnyTargetForTesting`. This is
part of MC, which wasn't listed in clang/lib/Testing/CMakeLists.txt.
This broke the -DBUILD_SHARED_LIBS=True builds.

Added: 


Modified: 
clang/lib/Testing/CMakeLists.txt

Removed: 




diff  --git a/clang/lib/Testing/CMakeLists.txt 
b/clang/lib/Testing/CMakeLists.txt
index 49b6787959bc1..4a2400d6a107a 100644
--- a/clang/lib/Testing/CMakeLists.txt
+++ b/clang/lib/Testing/CMakeLists.txt
@@ -11,6 +11,7 @@ add_llvm_library(clangTesting
   BUILDTREE_ONLY
 
   LINK_COMPONENTS
+  MC
   Support
   )
 



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


[PATCH] D146288: clang-tidy: Detect use-after-move in CXXCtorInitializer

2023-03-17 Thread Marco Falke via Phabricator via cfe-commits
MarcoFalke updated this revision to Diff 506081.
MarcoFalke added a comment.

sort doc


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

https://reviews.llvm.org/D146288

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
@@ -1353,6 +1353,71 @@
 }
 } // namespace UnevalContext
 
+class CtorInit {
+public:
+  CtorInit(std::string val)
+  : a{val.empty()},// fine
+s{std::move(val)},
+b{val.empty()}
+  // CHECK-NOTES: [[@LINE-1]]:11: warning: 'val' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:9: note: move occurred here
+  {}
+
+private:
+  bool a;
+  std::string s;
+  bool b;
+};
+
+class CtorInitLambda {
+public:
+  CtorInitLambda(std::string val)
+  : a{val.empty()},// fine
+s{std::move(val)},
+b{[&] { return val.empty(); }()},
+// CHECK-NOTES: [[@LINE-1]]:12: warning: 'val' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:9: note: move occurred here
+c{[] {
+  std::string str{};
+  std::move(str);
+  return str.empty();
+  // CHECK-NOTES: [[@LINE-1]]:18: warning: 'str' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:11: note: move occurred here
+}()} {
+std::move(val);
+// CHECK-NOTES: [[@LINE-1]]:15: warning: 'val' used after it was moved
+// CHECK-NOTES: [[@LINE-13]]:9: note: move occurred here
+std::string val2{};
+std::move(val2);
+val2.empty();
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'val2' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
+  }
+
+private:
+  bool a;
+  std::string s;
+  bool b;
+  bool c;
+  bool d{};
+};
+
+class CtorInitOrder {
+public:
+  CtorInitOrder(std::string val)
+  : a{val.empty()}, // fine
+b{val.empty()},
+// CHECK-NOTES: [[@LINE-1]]:11: warning: 'val' used after it was moved
+s{std::move(val)} {} // wrong order
+  // CHECK-NOTES: [[@LINE-1]]:9: note: move occurred here
+  // CHECK-NOTES: [[@LINE-4]]:11: note: the use happens in a later loop iteration than the move
+
+private:
+  bool a;
+  std::string s;
+  bool b;
+};
+
 class PR38187 {
 public:
   PR38187(std::string val) : val_(std::move(val)) {
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -162,6 +162,10 @@
   ` check.
   Global options of the same name should be used instead.
 
+- Improved :doc:`bugprone-use-after-move
+  ` check to also cover constructor
+  initializers.
+
 - Deprecated check-local options `HeaderFileExtensions`
   in :doc:`google-build-namespaces
   ` check.
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -58,11 +58,11 @@
 public:
   UseAfterMoveFinder(ASTContext *TheContext);
 
-  // Within the given function body, finds the first use of 'MovedVariable' that
+  // Within the given code block, finds the first use of 'MovedVariable' that
   // occurs after 'MovingCall' (the expression that performs the move). If a
   // use-after-move is found, writes information about it to 'TheUseAfterMove'.
   // Returns whether a use-after-move was found.
-  bool find(Stmt *FunctionBody, const Expr *MovingCall,
+  bool find(Stmt *CodeBlock, const Expr *MovingCall,
 const ValueDecl *MovedVariable, UseAfterMove *TheUseAfterMove);
 
 private:
@@ -104,7 +104,7 @@
 UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)
 : Context(TheContext) {}
 
-bool UseAfterMoveFinder::find(Stmt *FunctionBody, const Expr *MovingCall,
+bool UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
   const ValueDecl *MovedVariable,
   UseAfterMove *TheUseAfterMove) {
   // Generate the CFG manually instead of through an AnalysisDeclContext because
@@ -118,12 +118,11 @@
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
   std::unique_ptr TheCFG =
-  CFG::buildCFG(nullptr, FunctionBody, Context, Options);
+  CFG::buildCFG(nullptr, CodeBlock, Context, Options);
   if (!TheCFG)
 return false;
 
-  Sequence =
-  std::make_unique(TheCFG.get(), FunctionBody, Context);
+  Sequence = std::make_unique(TheCFG.get(), CodeBlock, Context);
   BlockMap = 

[PATCH] D146288: clang-tidy: Detect use-after-move in CXXCtorInitializer

2023-03-17 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:190
 
+- Improved :doc:`bugprone-use-after-move
+  ` check to also cover constructor

Please keep alphabetical order (by check name) in this section.


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

https://reviews.llvm.org/D146288

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


[PATCH] D143704: [flang] Feature list plugin

2023-03-17 Thread Ethan Luis McDonough via Phabricator via cfe-commits
elmcdonough added a comment.

Haven't been able to check this yet, but I think it might be due to the tests 
expecting a deterministic output.  I've only ever tested on Ubuntu WSL, so its 
possible the order is different on different platforms.  I think replacing 
CHECK-NEXT with CHECK-DAG might fix the issue.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143704

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


[PATCH] D144870: [Clang][DebugInfo] Emit zero size bitfields in the debug info to delimit bitfields in different allocation units.

2023-03-17 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

Is it possible you need to look only at the immediately preceding field, and 
not iterate? For example,

  struct zero_bitfield {
char a : 8;
char : 0;
char b : 8;
char c : 8;
  };

If processing `b` sees the zero-length bitfield and does the needful, then when 
processing `c` it's sufficient to see that `b` is a preceding bitfield and know 
that the needful has been done.

I'm now also curious whether this ABI aspect affects non-bitfields. For example:

  struct non_adjacent_bitfields {
char d;
char : 0;
char e;
char f : 8;
  };

(1) Is `e` affected by the presence of the zero-length bitfield? (2) is `f` 
affected? (3) If the answers are "no" and "yes" then you do need to iterate 
looking for the zero-length bitfield, but otherwise I think it's sufficient to 
look only at the preceding field.

(Of course it's possible that finding the preceding field can be done only by 
iterating, but I'd hope that isn't necessary.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144870

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


[PATCH] D144878: __builtin_FILE_NAME()

2023-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2147e940e8a8: Add __builtin_FILE_NAME() (authored by 
karapsinie, committed by aaron.ballman).

Changed prior to commit:
  https://reviews.llvm.org/D144878?vs=505468=506078#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144878

Files:
  clang/docs/LanguageExtensions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Expr.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/AST/Expr.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseExpr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Preprocessor/feature_tests.c
  clang/test/Preprocessor/feature_tests.cpp
  clang/test/Sema/source_location.c
  clang/test/SemaCXX/Inputs/source-location-file.h
  clang/test/SemaCXX/source_location.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -259,6 +259,10 @@
  Lang_CXX03, Verifier,
  functionDecl(hasDescendant(
  sourceLocExpr(hasBuiltinStr("__builtin_FILE");
+  testImport("void declToImport() { (void)__builtin_FILE_NAME(); }", Lang_CXX03,
+ "", Lang_CXX03, Verifier,
+ functionDecl(hasDescendant(
+ sourceLocExpr(hasBuiltinStr("__builtin_FILE_NAME");
   testImport("void declToImport() { (void)__builtin_COLUMN(); }", Lang_CXX03,
  "", Lang_CXX03, Verifier,
  functionDecl(hasDescendant(
Index: clang/test/SemaCXX/source_location.cpp
===
--- clang/test/SemaCXX/source_location.cpp
+++ clang/test/SemaCXX/source_location.cpp
@@ -84,6 +84,7 @@
 static_assert(is_same);
 static_assert(is_same);
 static_assert(is_same);
+static_assert(is_same);
 static_assert(is_same);
 static_assert(is_same);
 
@@ -91,6 +92,7 @@
 static_assert(noexcept(__builtin_LINE()));
 static_assert(noexcept(__builtin_COLUMN()));
 static_assert(noexcept(__builtin_FILE()));
+static_assert(noexcept(__builtin_FILE_NAME()));
 static_assert(noexcept(__builtin_FUNCTION()));
 static_assert(noexcept(__builtin_source_location()));
 
@@ -346,6 +348,54 @@
 
 } // namespace test_file
 
+//===--===//
+//__builtin_FILE_NAME()
+//===--===//
+
+namespace test_file_name {
+constexpr const char *test_file_name_simple(
+  const char *__f = __builtin_FILE_NAME()) {
+  return __f;
+}
+void test_function() {
+#line 900
+  static_assert(is_equal(test_file_name_simple(), __FILE_NAME__));
+  static_assert(is_equal(SLF::test_function_filename(), __FILE_NAME__), "");
+  static_assert(is_equal(SLF::test_function_filename_template(42),
+ __FILE_NAME__), "");
+
+  static_assert(is_equal(SLF::test_function_filename_indirect(),
+ SLF::global_info_filename), "");
+  static_assert(is_equal(SLF::test_function_filename_template_indirect(42),
+ SLF::global_info_filename), "");
+
+  static_assert(test_file_name_simple() != nullptr);
+  static_assert(is_equal(test_file_name_simple(), "source_location.cpp"));
+}
+
+void test_class() {
+#line 315
+  using SLF::TestClass;
+  constexpr TestClass Default;
+  constexpr TestClass InParam{42};
+  constexpr TestClass Template{42, 42};
+  constexpr auto *F = Default.info_file_name;
+  constexpr auto Char = F[0];
+  static_assert(is_equal(Default.info_file_name, SLF::FILE_NAME), "");
+  static_assert(is_equal(InParam.info_file_name, SLF::FILE_NAME), "");
+  static_assert(is_equal(InParam.ctor_info_file_name, __FILE_NAME__), "");
+}
+
+void test_aggr_class() {
+  using Agg = SLF::AggrClass<>;
+  constexpr Agg Default{};
+  constexpr Agg InitOne{42};
+  static_assert(is_equal(Default.init_info_file_name, __FILE_NAME__), "");
+  static_assert(is_equal(InitOne.init_info_file_name, __FILE_NAME__), "");
+}
+
+} // namespace test_file_name
+
 //===--===//
 //__builtin_FUNCTION()
 //===--===//
@@ -487,6 +537,7 @@
 #line 44 "test_file.c"
 static_assert(is_equal("test_file.c", __FILE__));
 static_assert(is_equal("test_file.c", __builtin_FILE()));
+static_assert(is_equal("test_file.c", __builtin_FILE_NAME()));
 static_assert(is_equal("test_file.c", SL::current().file()));
 static_assert(is_equal("test_file.c", SLF::test_function().file()));
 static_assert(is_equal(SLF::FILE, SLF::test_function_indirect().file()));
Index: 

[clang] 2147e94 - Add __builtin_FILE_NAME()

2023-03-17 Thread Aaron Ballman via cfe-commits

Author: Ilya Karapsin
Date: 2023-03-17T09:52:41-04:00
New Revision: 2147e940e8a8f85f97f28407989c628886b5cd7e

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

LOG: Add __builtin_FILE_NAME()

Add '__builtin_FILE_NAME()', which expands to the filename because the
full path is not always needed. It corresponds to the '__FILE_NAME__'
predefined macro and is consistent with the other '__builin' functions
added for predefined macros.

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

Added: 


Modified: 
clang/docs/LanguageExtensions.rst
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/Expr.h
clang/include/clang/Basic/TokenKinds.def
clang/include/clang/Lex/Preprocessor.h
clang/lib/AST/Expr.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParseExpr.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/Preprocessor/feature_tests.c
clang/test/Preprocessor/feature_tests.cpp
clang/test/Sema/source_location.c
clang/test/SemaCXX/Inputs/source-location-file.h
clang/test/SemaCXX/source_location.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/docs/LanguageExtensions.rst 
b/clang/docs/LanguageExtensions.rst
index 413ad8de3215c..f8c83d4d6d162 100644
--- a/clang/docs/LanguageExtensions.rst
+++ b/clang/docs/LanguageExtensions.rst
@@ -3611,13 +3611,15 @@ Source location builtins
 
 Clang provides builtins to support C++ standard library implementation
 of ``std::source_location`` as specified in C++20.  With the exception
-of ``__builtin_COLUMN``, these builtins are also implemented by GCC.
+of ``__builtin_COLUMN`` and ``__builtin_FILE_NAME``,
+these builtins are also implemented by GCC.
 
 **Syntax**:
 
 .. code-block:: c
 
   const char *__builtin_FILE();
+  const char *__builtin_FILE_NAME(); // Clang only
   const char *__builtin_FUNCTION();
   unsigned__builtin_LINE();
   unsigned__builtin_COLUMN(); // Clang only
@@ -3648,11 +3650,11 @@ of ``__builtin_COLUMN``, these builtins are also 
implemented by GCC.
 
 **Description**:
 
-The builtins ``__builtin_LINE``, ``__builtin_FUNCTION``, and ``__builtin_FILE``
-return the values, at the "invocation point", for ``__LINE__``,
-``__FUNCTION__``, and ``__FILE__`` respectively. ``__builtin_COLUMN`` similarly
-returns the column, though there is no corresponding macro. These builtins are
-constant expressions.
+The builtins ``__builtin_LINE``, ``__builtin_FUNCTION``, ``__builtin_FILE`` and
+``__builtin_FILE_NAME`` return the values, at the "invocation point", for
+``__LINE__``, ``__FUNCTION__``, ``__FILE__`` and ``__FILE_NAME__`` 
respectively.
+``__builtin_COLUMN`` similarly returns the column,
+though there is no corresponding macro. These builtins are constant 
expressions.
 
 When the builtins appear as part of a default function argument the invocation
 point is the location of the caller. When the builtins appear as part of a

diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 1bcdfaec15fe0..8d8be6780a476 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -116,6 +116,9 @@ Non-comprehensive list of changes in this release
   optimizations.
 - Clang now supports ``__builtin_nondeterministic_value`` that returns a
   nondeterministic value of the same type as the provided argument.
+- Clang now supports ``__builtin_FILE_NAME()`` which returns the same
+  information as the ``__FILE_NAME__`` macro (the presumed file name
+  from the invocation point, with no path components included).
 
 New Compiler Flags
 --

diff  --git a/clang/include/clang/AST/Expr.h b/clang/include/clang/AST/Expr.h
index df2573324b752..28c23c5c0be91 100644
--- a/clang/include/clang/AST/Expr.h
+++ b/clang/include/clang/AST/Expr.h
@@ -4685,13 +4685,14 @@ class VAArgExpr : public Expr {
 };
 
 /// Represents a function call to one of __builtin_LINE(), __builtin_COLUMN(),
-/// __builtin_FUNCTION(), __builtin_FILE(), or __builtin_source_location().
+/// __builtin_FUNCTION(), __builtin_FILE(), __builtin_FILE_NAME(),
+/// or __builtin_source_location().
 class SourceLocExpr final : public Expr {
   SourceLocation BuiltinLoc, RParenLoc;
   DeclContext *ParentContext;
 
 public:
-  enum IdentKind { Function, File, Line, Column, SourceLocStruct };
+  enum IdentKind { Function, File, FileName, Line, Column, SourceLocStruct };
 
   SourceLocExpr(const ASTContext , IdentKind Type, QualType ResultTy,
 SourceLocation BLoc, SourceLocation RParenLoc,
@@ -4715,6 +4716,7 @@ class SourceLocExpr final : public Expr {
   bool isIntType() const {
 switch (getIdentKind()) {
 case File:
+case FileName:
 case Function:
 case SourceLocStruct:
   return false;

diff  --git 

[PATCH] D144878: __builtin_FILE_NAME()

2023-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseExpr.cpp:805-807
+/// [C++11] simple-type-specifier braced-init-list [C++11 5.2.3]
 /// [C++]   typename-specifier '(' expression-list[opt] ')' [C++ 5.2.3]
+/// [C++11] typename-specifier braced-init-list [C++11 5.2.3]

karapsinie wrote:
> aaron.ballman wrote:
> > Formatting here also got messed up a bit.
> If these two lines are restored, "git-clang-format" will break the comments.
I'll fix it on commit. Do you still get that behavior if you use 
git-clang-format to format only the *patch* though? 
https://clang.llvm.org/docs/ClangFormat.html#script-for-patch-reformatting


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

https://reviews.llvm.org/D144878

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


[PATCH] D146089: [Sema] Fix null pointer dereference handleAlwaysInlineAttr.

2023-03-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Please add a release note as requested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146089

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


[PATCH] D146054: [RISCV] Add -print-supported-marchs and -march=help support

2023-03-17 Thread Brandon Wu via Phabricator via cfe-commits
4vtomat updated this revision to Diff 506062.
4vtomat added a comment.

Resolved Craig and Kito's comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146054

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Frontend/FrontendOptions.h
  clang/lib/Driver/Driver.cpp
  clang/test/Driver/print-supported-marchs.c
  clang/tools/driver/cc1_main.cpp
  llvm/include/llvm/Support/RISCVISAInfo.h
  llvm/lib/Support/RISCVISAInfo.cpp

Index: llvm/lib/Support/RISCVISAInfo.cpp
===
--- llvm/lib/Support/RISCVISAInfo.cpp
+++ llvm/lib/Support/RISCVISAInfo.cpp
@@ -139,6 +139,33 @@
 {"ztso", RISCVExtensionVersion{0, 1}},
 };
 
+namespace llvm {
+void RISCVMarchHelp() {
+  errs() << "All available -march extensions for RISC-V\n\n";
+  errs() << '\t' << left_justify("Name", 20) << "Version\n";
+
+  RISCVISAInfo::OrderedExtensionMap ExtMap;
+  for (const auto  : SupportedExtensions)
+ExtMap[E.Name] = { E.Name, E.Version.Major, E.Version.Minor };
+  for (const auto  : ExtMap)
+errs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
+ E.second.MinorVersion);
+
+  errs() << "\nExperimental extensions\n";
+  ExtMap.clear();
+  for (const auto  : SupportedExperimentalExtensions)
+ExtMap[E.Name] = { E.Name, E.Version.Major, E.Version.Minor };
+  for (const auto  : ExtMap)
+errs() << format("\t%-20s%d.%d\n", E.first.c_str(), E.second.MajorVersion,
+ E.second.MinorVersion);
+
+  errs() << '\n';
+
+  errs() << "Use -march to specify the target's extension.\n"
+"For example, clang -march=rv32i_v1p0\n";
+}
+}
+
 static bool stripExperimentalPrefix(StringRef ) {
   return Ext.consume_front("experimental-");
 }
Index: llvm/include/llvm/Support/RISCVISAInfo.h
===
--- llvm/include/llvm/Support/RISCVISAInfo.h
+++ llvm/include/llvm/Support/RISCVISAInfo.h
@@ -23,6 +23,8 @@
   unsigned MinorVersion;
 };
 
+void RISCVMarchHelp();
+
 class RISCVISAInfo {
 public:
   RISCVISAInfo(const RISCVISAInfo &) = delete;
Index: clang/tools/driver/cc1_main.cpp
===
--- clang/tools/driver/cc1_main.cpp
+++ clang/tools/driver/cc1_main.cpp
@@ -38,6 +38,7 @@
 #include "llvm/Support/ManagedStatic.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/Process.h"
+#include "llvm/Support/RISCVISAInfo.h"
 #include "llvm/Support/Signals.h"
 #include "llvm/Support/TargetSelect.h"
 #include "llvm/Support/TimeProfiler.h"
@@ -182,6 +183,27 @@
   return 0;
 }
 
+/// Print supported marchs of the given target.
+static int PrintSupportedMarchs(std::string TargetStr) {
+  std::string Error;
+  const llvm::Target *TheTarget =
+  llvm::TargetRegistry::lookupTarget(TargetStr, Error);
+  if (!TheTarget) {
+llvm::errs() << Error;
+return 1;
+  }
+
+  if (TargetStr.find("riscv") == std::string::npos) {
+llvm::errs() << "The -march=help only supports for RISCV target.\n";
+return 1;
+  }
+
+  llvm::RISCVMarchHelp();
+
+  return 0;
+}
+
+
 int cc1_main(ArrayRef Argv, const char *Argv0, void *MainAddr) {
   ensureSufficientStack();
 
@@ -223,6 +245,10 @@
   if (Clang->getFrontendOpts().PrintSupportedCPUs)
 return PrintSupportedCPUs(Clang->getTargetOpts().Triple);
 
+  // --print-supported-marchs takes priority over the actual compilation.
+  if (Clang->getFrontendOpts().PrintSupportedMarchs)
+return PrintSupportedMarchs(Clang->getTargetOpts().Triple);
+
   // Infer the builtin include path if unspecified.
   if (Clang->getHeaderSearchOpts().UseBuiltinIncludes &&
   Clang->getHeaderSearchOpts().ResourceDir.empty())
Index: clang/test/Driver/print-supported-marchs.c
===
--- /dev/null
+++ clang/test/Driver/print-supported-marchs.c
@@ -0,0 +1,98 @@
+// Test that --print-supported-marchs lists supported Marchs.
+
+// REQUIRES: riscv-registered-target
+
+// RUN: %clang --target=riscv64 --print-supported-marchs 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-RISCV
+
+// Test -march=help alias.
+// RUN: %clang --target=riscv64 -march=help 2>&1 | \
+// RUN:   FileCheck %s --check-prefix=CHECK-RISCV
+
+// CHECK-NOT: warning: argument unused during compilation
+// CHECK-RISCV: Target: riscv64
+// CHECK-RISCV: All available -march extensions for RISC-V
+// CHECK-RISCV: 	NameVersion
+// CHECK-RISCV: 	i   2.0
+// CHECK-RISCV: 	e   1.9
+// CHECK-RISCV: 	m   2.0
+// CHECK-RISCV: 	a   2.0
+// CHECK-RISCV: 	f   2.0
+// CHECK-RISCV: 	d   2.0
+// CHECK-RISCV: 	c   2.0
+// CHECK-RISCV: 	v   1.0
+// CHECK-RISCV: 	h   1.0
+// CHECK-RISCV: 	svinval 1.0
+// 

[PATCH] D146178: [Clang][Sema] Fix comparison of constraint expressions

2023-03-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D146178#4200821 , @rsmith wrote:

> The approach of attempting to adjust the depth here is not correct, and we 
> should rip this whole mechanism out and reimplement it.  Consider this 
> closely related testcase:
>
>   template
>   concept Concept = true;
>   
>   template
>   struct A
>   {
> template V>
> void C(V&& t);
>   };
>   
>   template<>
>   template V>
>   void A::C(V&& t)
>   {}
>
> Clang rejects this because it's trying to compare `Concept` from the 
> declaration against `Concept` from the explicit specialization.
>
> The right way to fix that and the issue being addressed here is that, rather 
> than adjusting the depths, we should substitute the outer template arguments 
> from the scope specifier (`A::`) into the constraint before performing 
> the comparison. (In the special case where none of the outer template 
> parameters are used by the inner template, that does effectively just adjust 
> the depths of any inner template parameters.)
>
> The relevant language rule was introduced by the resolution of CA104 in 
> P2103R0 
>  
> (which Clang's status page incorrectly marks as complete in Clang 10). In 
> particular, see temp.constr.decl/4 
>  for the rule that we should 
> implement, but don't:
>
>> When determining whether a given introduced constraint-expression `C1` of a 
>> declaration in an instantiated specialization of a templated class is 
>> equivalent ([temp.over.link]) to the corresponding constraint-expression 
>> `C2` of a declaration outside the class body, `C1` is instantiated. If the 
>> instantiation results in an invalid expression, the constraint-expressions 
>> are not equivalent.
>
> So, in this case, we're supposed to instantiate the constraint expression 
> `Concept`, substituting the template arguments of `A` into it (in a SFINAE 
> context).

IIRC, the original motivation for this attempt was that we frequently compare 
template arguments, even in cases where that isn't permitted?  I had sent you a 
couple of emails when I was attempting this, but you'd not gotten a chance to 
respond.  I think I came up on this as the only way to do this without 
instantiating the constraint (which I recall you'd said was not the right way 
to compare constraints at one point?).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146178

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


[PATCH] D146146: [Clang] Stop demoting ElementCount/TypeSize conversion errors to warnings.

2023-03-17 Thread Paul Walker via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG62f09d788f9f: [Clang] Stop demoting ElementCount/TypeSize 
conversion errors to warnings. (authored by paulwalker-arm).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146146

Files:
  clang/lib/Driver/ToolChains/Clang.cpp


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5560,22 +5560,6 @@
 
   RenderTargetOptions(Triple, Args, KernelOrKext, CmdArgs);
 
-  // FIXME: For now we want to demote any errors to warnings, when they have
-  // been raised for asking the wrong question of scalable vectors, such as
-  // asking for the fixed number of elements. This may happen because code that
-  // is not yet ported to work for scalable vectors uses the wrong interfaces,
-  // whereas the behaviour is actually correct. Emitting a warning helps bring
-  // up scalable vector support in an incremental way. When scalable vector
-  // support is stable enough, all uses of wrong interfaces should be 
considered
-  // as errors, but until then, we can live with a warning being emitted by the
-  // compiler. This way, Clang can be used to compile code with scalable 
vectors
-  // and identify possible issues.
-  if (isa(JA) || isa(JA) ||
-  isa(JA)) {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back("-treat-scalable-fixed-error-as-warning");
-  }
-
   // These two are potentially updated by AddClangCLArgs.
   codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo;
   bool EmitCodeView = false;


Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -5560,22 +5560,6 @@
 
   RenderTargetOptions(Triple, Args, KernelOrKext, CmdArgs);
 
-  // FIXME: For now we want to demote any errors to warnings, when they have
-  // been raised for asking the wrong question of scalable vectors, such as
-  // asking for the fixed number of elements. This may happen because code that
-  // is not yet ported to work for scalable vectors uses the wrong interfaces,
-  // whereas the behaviour is actually correct. Emitting a warning helps bring
-  // up scalable vector support in an incremental way. When scalable vector
-  // support is stable enough, all uses of wrong interfaces should be considered
-  // as errors, but until then, we can live with a warning being emitted by the
-  // compiler. This way, Clang can be used to compile code with scalable vectors
-  // and identify possible issues.
-  if (isa(JA) || isa(JA) ||
-  isa(JA)) {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back("-treat-scalable-fixed-error-as-warning");
-  }
-
   // These two are potentially updated by AddClangCLArgs.
   codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo;
   bool EmitCodeView = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 62f09d7 - [Clang] Stop demoting ElementCount/TypeSize conversion errors to warnings.

2023-03-17 Thread Paul Walker via cfe-commits

Author: Paul Walker
Date: 2023-03-17T12:49:45Z
New Revision: 62f09d788f9fc540db12f3cfa2f98760071fca96

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

LOG: [Clang] Stop demoting ElementCount/TypeSize conversion errors to warnings.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 1c62cd2ecc9d..c40e93b4ad13 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5560,22 +5560,6 @@ void Clang::ConstructJob(Compilation , const JobAction 
,
 
   RenderTargetOptions(Triple, Args, KernelOrKext, CmdArgs);
 
-  // FIXME: For now we want to demote any errors to warnings, when they have
-  // been raised for asking the wrong question of scalable vectors, such as
-  // asking for the fixed number of elements. This may happen because code that
-  // is not yet ported to work for scalable vectors uses the wrong interfaces,
-  // whereas the behaviour is actually correct. Emitting a warning helps bring
-  // up scalable vector support in an incremental way. When scalable vector
-  // support is stable enough, all uses of wrong interfaces should be 
considered
-  // as errors, but until then, we can live with a warning being emitted by the
-  // compiler. This way, Clang can be used to compile code with scalable 
vectors
-  // and identify possible issues.
-  if (isa(JA) || isa(JA) ||
-  isa(JA)) {
-CmdArgs.push_back("-mllvm");
-CmdArgs.push_back("-treat-scalable-fixed-error-as-warning");
-  }
-
   // These two are potentially updated by AddClangCLArgs.
   codegenoptions::DebugInfoKind DebugInfoKind = codegenoptions::NoDebugInfo;
   bool EmitCodeView = false;



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


[PATCH] D146288: clang-tidy: Detect use-after-move in CXXCtorInitializer

2023-03-17 Thread Marco Falke via Phabricator via cfe-commits
MarcoFalke updated this revision to Diff 506055.
MarcoFalke added a comment.

clang-format+doc


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

https://reviews.llvm.org/D146288

Files:
  clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/use-after-move.cpp
@@ -1353,6 +1353,70 @@
 }
 } // namespace UnevalContext
 
+class CtorInit {
+public:
+  CtorInit(std::string val)
+  : a{val.empty()},// fine
+s{std::move(val)},
+b{val.empty()}
+  // CHECK-NOTES: [[@LINE-1]]:11: warning: 'val' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:9: note: move occurred here
+  {}
+
+private:
+  bool a;
+  std::string s;
+  bool b;
+};
+
+class CtorInitLambda {
+public:
+  CtorInitLambda(std::string val)
+  : a{val.empty()},// fine
+s{std::move(val)},
+b{[&] { return val.empty(); }()},
+// CHECK-NOTES: [[@LINE-1]]:12: warning: 'val' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:9: note: move occurred here
+c{[] {
+  std::string str{};
+  std::move(str);
+  return str.empty();
+  // CHECK-NOTES: [[@LINE-1]]:18: warning: 'str' used after it was moved
+  // CHECK-NOTES: [[@LINE-3]]:11: note: move occurred here
+}()} {
+std::move(val);
+// CHECK-NOTES: [[@LINE-1]]:15: warning: 'val' used after it was moved
+// CHECK-NOTES: [[@LINE-13]]:9: note: move occurred here
+std::string val2{};
+std::move(val2);
+val2.empty();
+// CHECK-NOTES: [[@LINE-1]]:5: warning: 'val2' used after it was moved
+// CHECK-NOTES: [[@LINE-3]]:5: note: move occurred here
+  }
+
+private:
+  bool a;
+  std::string s;
+  bool b;
+  bool c;
+};
+
+class CtorInitOrder {
+public:
+  CtorInitOrder(std::string val)
+  : a{val.empty()}, // fine
+b{val.empty()},
+// CHECK-NOTES: [[@LINE-1]]:11: warning: 'val' used after it was moved
+s{std::move(val)} {} // wrong order
+  // CHECK-NOTES: [[@LINE-1]]:9: note: move occurred here
+  // CHECK-NOTES: [[@LINE-4]]:11: note: the use happens in a later loop iteration than the move
+
+private:
+  bool a;
+  std::string s;
+  bool b;
+};
+
 class PR38187 {
 public:
   PR38187(std::string val) : val_(std::move(val)) {
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -187,6 +187,10 @@
   ` check.
   Global options of the same name should be used instead.
 
+- Improved :doc:`bugprone-use-after-move
+  ` check to also cover constructor
+  initializers.
+
 - In :doc:`modernize-use-default-member-init
   ` count template
   constructors toward hand written constructors so that they are skipped if more
Index: clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/UseAfterMoveCheck.cpp
@@ -58,11 +58,11 @@
 public:
   UseAfterMoveFinder(ASTContext *TheContext);
 
-  // Within the given function body, finds the first use of 'MovedVariable' that
+  // Within the given code block, finds the first use of 'MovedVariable' that
   // occurs after 'MovingCall' (the expression that performs the move). If a
   // use-after-move is found, writes information about it to 'TheUseAfterMove'.
   // Returns whether a use-after-move was found.
-  bool find(Stmt *FunctionBody, const Expr *MovingCall,
+  bool find(Stmt *CodeBlock, const Expr *MovingCall,
 const ValueDecl *MovedVariable, UseAfterMove *TheUseAfterMove);
 
 private:
@@ -104,7 +104,7 @@
 UseAfterMoveFinder::UseAfterMoveFinder(ASTContext *TheContext)
 : Context(TheContext) {}
 
-bool UseAfterMoveFinder::find(Stmt *FunctionBody, const Expr *MovingCall,
+bool UseAfterMoveFinder::find(Stmt *CodeBlock, const Expr *MovingCall,
   const ValueDecl *MovedVariable,
   UseAfterMove *TheUseAfterMove) {
   // Generate the CFG manually instead of through an AnalysisDeclContext because
@@ -118,12 +118,11 @@
   Options.AddImplicitDtors = true;
   Options.AddTemporaryDtors = true;
   std::unique_ptr TheCFG =
-  CFG::buildCFG(nullptr, FunctionBody, Context, Options);
+  CFG::buildCFG(nullptr, CodeBlock, Context, Options);
   if (!TheCFG)
 return false;
 
-  Sequence =
-  std::make_unique(TheCFG.get(), FunctionBody, Context);
+  Sequence = std::make_unique(TheCFG.get(), CodeBlock, Context);
  

[PATCH] D146140: [clang] Properly parse variable template requires clause in lambda

2023-03-17 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

In D146140#4201481 , @cor3ntin wrote:

> Do we need a release note for this?

Yes, good catch!  @rymiel : can you please add one?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146140

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


[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-03-17 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis added inline comments.



Comment at: 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp:1523
+  auto bodyCB = [&](InsertPointTy allocaIP, InsertPointTy codeGenIP) {
+// DataOp has only one region associated with it.
+auto  = cast(op).getRegion();

kiranchandramohan wrote:
> Nit: I think this should be an assertion.
AFAIK the `mlir op` for this only allows for one region.



Comment at: 
mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp:1502-1510
+  llvm::OpenMPIRBuilder::LocationDescription ompLoc(builder);
+  llvm::OpenMPIRBuilder::InsertPointTy allocaIP =
+  findAllocaInsertPoint(builder, moduleTranslation);
+
+  struct llvm::OpenMPIRBuilder::MapperAllocas mapperAllocas;
+  SmallVector mapTypeFlags;
+  SmallVector mapNames;

kiranchandramohan wrote:
> TIFitis wrote:
> > kiranchandramohan wrote:
> > > Can all this go into the OpenMP IRBuilder? And be passed back if 
> > > necessary via the callback.
> > If we decide to move processMapOperand then these can be moved along with 
> > it.
> Now that we decided not to move `processMapOperand`, can this be moved to the 
> OpenMPIRBuilder?
Hi, I am working on a patch to add `use_device_ptr` and `use_deice_addr` 
clauses. As part of that I have restructured how `mapOperands` are processed 
and separated the mlir and codegen part of it. These are already moved to 
OMPIRBuilder in that patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142914

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


[PATCH] D142914: [MLIR][OpenMP] Added OMPIRBuilder support for Target Data directives.

2023-03-17 Thread Akash Banerjee via Phabricator via cfe-commits
TIFitis updated this revision to Diff 506054.
TIFitis marked 5 inline comments as done.
TIFitis added a comment.

Addresed reviewer comments. Removed flang changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142914

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
  mlir/include/mlir/Target/LLVMIR/Dialect/OpenMPCommon.h
  mlir/lib/Target/LLVMIR/CMakeLists.txt
  mlir/lib/Target/LLVMIR/Dialect/OpenACC/OpenACCToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp
  mlir/lib/Target/LLVMIR/Dialect/OpenMPCommon.cpp
  mlir/test/Target/LLVMIR/omptarget-llvm.mlir

Index: mlir/test/Target/LLVMIR/omptarget-llvm.mlir
===
--- /dev/null
+++ mlir/test/Target/LLVMIR/omptarget-llvm.mlir
@@ -0,0 +1,176 @@
+// RUN: mlir-translate -mlir-to-llvmir -split-input-file %s | FileCheck %s
+
+llvm.func @_QPopenmp_target_data() {
+  %0 = llvm.mlir.constant(1 : i64) : i64
+  %1 = llvm.alloca %0 x i32 {bindc_name = "i", in_type = i32, operand_segment_sizes = array, uniq_name = "_QFopenmp_target_dataEi"} : (i64) -> !llvm.ptr
+  omp.target_data   map((tofrom -> %1 : !llvm.ptr)) {
+%2 = llvm.mlir.constant(99 : i32) : i32
+llvm.store %2, %1 : !llvm.ptr
+omp.terminator
+  }
+  llvm.return
+}
+
+// CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 3]
+// CHECK-LABEL: define void @_QPopenmp_target_data() {
+// CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: %[[VAL_3:.*]] = alloca i32, i64 1, align 4
+// CHECK: br label %[[VAL_4:.*]]
+// CHECK:   entry:; preds = %[[VAL_5:.*]]
+// CHECK: %[[VAL_6:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_6]], align 8
+// CHECK: %[[VAL_7:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: store ptr %[[VAL_3]], ptr %[[VAL_7]], align 8
+// CHECK: %[[VAL_8:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: store i64 ptrtoint (ptr getelementptr (ptr, ptr null, i32 1) to i64), ptr %[[VAL_8]], align 4
+// CHECK: %[[VAL_9:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_10:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: %[[VAL_11:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_begin_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_9]], ptr %[[VAL_10]], ptr %[[VAL_11]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: br label %[[VAL_12:.*]]
+// CHECK:   omp.data.region:  ; preds = %[[VAL_4]]
+// CHECK: store i32 99, ptr %[[VAL_3]], align 4
+// CHECK: br label %[[VAL_13:.*]]
+// CHECK:   omp.region.cont:  ; preds = %[[VAL_12]]
+// CHECK: %[[VAL_14:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_0]], i32 0, i32 0
+// CHECK: %[[VAL_15:.*]] = getelementptr inbounds [1 x ptr], ptr %[[VAL_1]], i32 0, i32 0
+// CHECK: %[[VAL_16:.*]] = getelementptr inbounds [1 x i64], ptr %[[VAL_2]], i32 0, i32 0
+// CHECK: call void @__tgt_target_data_end_mapper(ptr @2, i64 -1, i32 1, ptr %[[VAL_14]], ptr %[[VAL_15]], ptr %[[VAL_16]], ptr @.offload_maptypes, ptr @.offload_mapnames, ptr null)
+// CHECK: ret void
+
+// -
+
+llvm.func @_QPopenmp_target_data_region(%1 : !llvm.ptr>) {
+  omp.target_data   map((from -> %1 : !llvm.ptr>)) {
+%2 = llvm.mlir.constant(99 : i32) : i32
+%3 = llvm.mlir.constant(1 : i64) : i64
+%4 = llvm.mlir.constant(1 : i64) : i64
+%5 = llvm.mlir.constant(0 : i64) : i64
+%6 = llvm.getelementptr %1[0, %5] : (!llvm.ptr>, i64) -> !llvm.ptr
+llvm.store %2, %6 : !llvm.ptr
+omp.terminator
+  }
+  llvm.return
+}
+
+// CHECK: @.offload_maptypes = private unnamed_addr constant [1 x i64] [i64 2]
+// CHECK-LABEL: define void @_QPopenmp_target_data_region
+// CHECK: (ptr %[[ARG_0:.*]]) {
+// CHECK: %[[VAL_0:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_1:.*]] = alloca [1 x ptr], align 8
+// CHECK: %[[VAL_2:.*]] = alloca [1 x i64], align 8
+// CHECK: br label %[[VAL_3:.*]]
+// CHECK:   entry:; preds = %[[VAL_4:.*]]
+// CHECK: %[[VAL_5:.*]] = getelementptr inbounds [1 x ptr], ptr 

[clang] e495eab - [clang] Include the error message in file reading error diagnostic

2023-03-17 Thread Hans Wennborg via cfe-commits

Author: Hans Wennborg
Date: 2023-03-17T13:47:02+01:00
New Revision: e495eabd326801c1e00508898dbcb04073a31014

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

LOG: [clang] Include the error message in file reading error diagnostic

in order to provide as much information as possible to the user. The
diagnostic will now look like for example:

  error: error reading '/tmp/foo.c': Permission denied

(This addresses a FIXME from 2019, 9ef6c49baf45)

Differential revision: https://reviews.llvm.org/D146280

Added: 


Modified: 
clang/include/clang/Basic/DiagnosticFrontendKinds.td
clang/lib/Frontend/CompilerInstance.cpp
clang/tools/driver/cc1as_main.cpp
flang/lib/Frontend/FrontendAction.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/DiagnosticFrontendKinds.td 
b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
index c1a71d51d91b..9f788380f433 100644
--- a/clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ b/clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -11,7 +11,7 @@ class BackendInfo : CatBackend, ShowInSystemHeader;
 let Component = "Frontend" in {
 
 def err_fe_error_opening : Error<"error opening '%0': %1">;
-def err_fe_error_reading : Error<"error reading '%0'">;
+def err_fe_error_reading : Error<"error reading '%0': %1">;
 def err_fe_error_reading_stdin : Error<"error reading stdin: %0">;
 def err_fe_error_backend : Error<"error in backend: %0">, DefaultFatal;
 

diff  --git a/clang/lib/Frontend/CompilerInstance.cpp 
b/clang/lib/Frontend/CompilerInstance.cpp
index ecf939424e56..691f779b5966 100644
--- a/clang/lib/Frontend/CompilerInstance.cpp
+++ b/clang/lib/Frontend/CompilerInstance.cpp
@@ -981,10 +981,9 @@ bool CompilerInstance::InitializeSourceManager(const 
FrontendInputFile ,
? FileMgr.getSTDIN()
: FileMgr.getFileRef(InputFile, /*OpenFile=*/true);
   if (!FileOrErr) {
-// FIXME: include the error in the diagnostic even when it's not stdin.
 auto EC = llvm::errorToErrorCode(FileOrErr.takeError());
 if (InputFile != "-")
-  Diags.Report(diag::err_fe_error_reading) << InputFile;
+  Diags.Report(diag::err_fe_error_reading) << InputFile << EC.message();
 else
   Diags.Report(diag::err_fe_error_reading_stdin) << EC.message();
 return false;

diff  --git a/clang/tools/driver/cc1as_main.cpp 
b/clang/tools/driver/cc1as_main.cpp
index 43d427b1af9b..ee54a0f7b0ea 100644
--- a/clang/tools/driver/cc1as_main.cpp
+++ b/clang/tools/driver/cc1as_main.cpp
@@ -384,8 +384,8 @@ static bool ExecuteAssemblerImpl(AssemblerInvocation ,
   MemoryBuffer::getFileOrSTDIN(Opts.InputFile, /*IsText=*/true);
 
   if (std::error_code EC = Buffer.getError()) {
-Error = EC.message();
-return Diags.Report(diag::err_fe_error_reading) << Opts.InputFile;
+return Diags.Report(diag::err_fe_error_reading)
+   << Opts.InputFile << EC.message();
   }
 
   SourceMgr SrcMgr;

diff  --git a/flang/lib/Frontend/FrontendAction.cpp 
b/flang/lib/Frontend/FrontendAction.cpp
index e6ede550092c..d9fe1232e29b 100644
--- a/flang/lib/Frontend/FrontendAction.cpp
+++ b/flang/lib/Frontend/FrontendAction.cpp
@@ -48,7 +48,7 @@ bool FrontendAction::beginSourceFile(CompilerInstance ,
   unsigned diagID;
   if (llvm::vfs::getRealFileSystem()->exists(input.getFile())) {
 ci.getDiagnostics().Report(clang::diag::err_fe_error_reading)
-<< input.getFile();
+<< input.getFile() << "not a regular file";
 diagID = ci.getDiagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "%0 is not a regular file");
   } else {



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


[PATCH] D146280: [clang] Include the error message in file reading error diagnostic

2023-03-17 Thread Hans Wennborg 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 rGe495eabd3268: [clang] Include the error message in file 
reading error diagnostic (authored by hans).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146280

Files:
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/lib/Frontend/CompilerInstance.cpp
  clang/tools/driver/cc1as_main.cpp
  flang/lib/Frontend/FrontendAction.cpp


Index: flang/lib/Frontend/FrontendAction.cpp
===
--- flang/lib/Frontend/FrontendAction.cpp
+++ flang/lib/Frontend/FrontendAction.cpp
@@ -48,7 +48,7 @@
   unsigned diagID;
   if (llvm::vfs::getRealFileSystem()->exists(input.getFile())) {
 ci.getDiagnostics().Report(clang::diag::err_fe_error_reading)
-<< input.getFile();
+<< input.getFile() << "not a regular file";
 diagID = ci.getDiagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "%0 is not a regular file");
   } else {
Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -384,8 +384,8 @@
   MemoryBuffer::getFileOrSTDIN(Opts.InputFile, /*IsText=*/true);
 
   if (std::error_code EC = Buffer.getError()) {
-Error = EC.message();
-return Diags.Report(diag::err_fe_error_reading) << Opts.InputFile;
+return Diags.Report(diag::err_fe_error_reading)
+   << Opts.InputFile << EC.message();
   }
 
   SourceMgr SrcMgr;
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -981,10 +981,9 @@
? FileMgr.getSTDIN()
: FileMgr.getFileRef(InputFile, /*OpenFile=*/true);
   if (!FileOrErr) {
-// FIXME: include the error in the diagnostic even when it's not stdin.
 auto EC = llvm::errorToErrorCode(FileOrErr.takeError());
 if (InputFile != "-")
-  Diags.Report(diag::err_fe_error_reading) << InputFile;
+  Diags.Report(diag::err_fe_error_reading) << InputFile << EC.message();
 else
   Diags.Report(diag::err_fe_error_reading_stdin) << EC.message();
 return false;
Index: clang/include/clang/Basic/DiagnosticFrontendKinds.td
===
--- clang/include/clang/Basic/DiagnosticFrontendKinds.td
+++ clang/include/clang/Basic/DiagnosticFrontendKinds.td
@@ -11,7 +11,7 @@
 let Component = "Frontend" in {
 
 def err_fe_error_opening : Error<"error opening '%0': %1">;
-def err_fe_error_reading : Error<"error reading '%0'">;
+def err_fe_error_reading : Error<"error reading '%0': %1">;
 def err_fe_error_reading_stdin : Error<"error reading stdin: %0">;
 def err_fe_error_backend : Error<"error in backend: %0">, DefaultFatal;
 


Index: flang/lib/Frontend/FrontendAction.cpp
===
--- flang/lib/Frontend/FrontendAction.cpp
+++ flang/lib/Frontend/FrontendAction.cpp
@@ -48,7 +48,7 @@
   unsigned diagID;
   if (llvm::vfs::getRealFileSystem()->exists(input.getFile())) {
 ci.getDiagnostics().Report(clang::diag::err_fe_error_reading)
-<< input.getFile();
+<< input.getFile() << "not a regular file";
 diagID = ci.getDiagnostics().getCustomDiagID(
 clang::DiagnosticsEngine::Error, "%0 is not a regular file");
   } else {
Index: clang/tools/driver/cc1as_main.cpp
===
--- clang/tools/driver/cc1as_main.cpp
+++ clang/tools/driver/cc1as_main.cpp
@@ -384,8 +384,8 @@
   MemoryBuffer::getFileOrSTDIN(Opts.InputFile, /*IsText=*/true);
 
   if (std::error_code EC = Buffer.getError()) {
-Error = EC.message();
-return Diags.Report(diag::err_fe_error_reading) << Opts.InputFile;
+return Diags.Report(diag::err_fe_error_reading)
+   << Opts.InputFile << EC.message();
   }
 
   SourceMgr SrcMgr;
Index: clang/lib/Frontend/CompilerInstance.cpp
===
--- clang/lib/Frontend/CompilerInstance.cpp
+++ clang/lib/Frontend/CompilerInstance.cpp
@@ -981,10 +981,9 @@
? FileMgr.getSTDIN()
: FileMgr.getFileRef(InputFile, /*OpenFile=*/true);
   if (!FileOrErr) {
-// FIXME: include the error in the diagnostic even when it's not stdin.
 auto EC = llvm::errorToErrorCode(FileOrErr.takeError());
 if (InputFile != "-")
-  Diags.Report(diag::err_fe_error_reading) << InputFile;
+  Diags.Report(diag::err_fe_error_reading) << InputFile << EC.message();
 else
   

[PATCH] D146280: [clang] Include the error message in file reading error diagnostic

2023-03-17 Thread Hans Wennborg via Phabricator via cfe-commits
hans added a comment.

In D146280#4201769 , @thakis wrote:

> (if the presubmit is related, maybe some flang test needs updating? Weird 
> that flang uses clang's diags.)

The presubmit errors look unrelated and the flang tests seem fine locally.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146280

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


[PATCH] D146275: [libclang] Fix documentation; NFC

2023-03-17 Thread Aaron Ballman 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 rG2d91b0dae0a9: [libclang] Fix documentation; NFC (authored by 
vedgy, committed by aaron.ballman).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146275

Files:
  clang/include/clang-c/Index.h


Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -445,7 +445,9 @@
 /**
  * Sets general options associated with a CXIndex.
  *
- * This function is DEPRECATED. Set CXIndexOptions::GlobalOptions and call
+ * This function is DEPRECATED. Set
+ * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
+ * CXIndexOptions::ThreadBackgroundPriorityForEditing and call
  * clang_createIndexWithOptions() instead.
  *
  * For example:


Index: clang/include/clang-c/Index.h
===
--- clang/include/clang-c/Index.h
+++ clang/include/clang-c/Index.h
@@ -445,7 +445,9 @@
 /**
  * Sets general options associated with a CXIndex.
  *
- * This function is DEPRECATED. Set CXIndexOptions::GlobalOptions and call
+ * This function is DEPRECATED. Set
+ * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
+ * CXIndexOptions::ThreadBackgroundPriorityForEditing and call
  * clang_createIndexWithOptions() instead.
  *
  * For example:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 2d91b0d - [libclang] Fix documentation; NFC

2023-03-17 Thread Aaron Ballman via cfe-commits

Author: Igor Kushnir
Date: 2023-03-17T08:40:08-04:00
New Revision: 2d91b0dae0a902317d384a44f588107d04c9ad3c

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

LOG: [libclang] Fix documentation; NFC

Fixes cc929590ad305f0d068709c7c7999f5fc6118dc9. The
CXIndexOptions::GlobalOptions data member has been replaced with the two
CXChoice data members during code review.

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

Added: 


Modified: 
clang/include/clang-c/Index.h

Removed: 




diff  --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h
index 1dc0cab2ea12..c7d32e6a152a 100644
--- a/clang/include/clang-c/Index.h
+++ b/clang/include/clang-c/Index.h
@@ -445,7 +445,9 @@ clang_createIndexWithOptions(const CXIndexOptions *options);
 /**
  * Sets general options associated with a CXIndex.
  *
- * This function is DEPRECATED. Set CXIndexOptions::GlobalOptions and call
+ * This function is DEPRECATED. Set
+ * CXIndexOptions::ThreadBackgroundPriorityForIndexing and/or
+ * CXIndexOptions::ThreadBackgroundPriorityForEditing and call
  * clang_createIndexWithOptions() instead.
  *
  * For example:



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


[PATCH] D146275: [libclang] Fix documentation; NFC

2023-03-17 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, good catch!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D146275

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


  1   2   >