[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-21 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 533155.
FreddyYe added a comment.

Add missing FeatureCMOV in X8TargetParser.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -6,16 +6,24 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i586 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i686 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentiumpro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_pro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_ii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii_no_xmm_regs 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=yonah 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=prescott 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4_sse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lakemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=raptorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=meteorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -26,26 +34,39 @@
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_ssse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=penryn 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_sse4_1 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1586
 
+/**
+\brief Peeks next after next token

I don't think this style of comment is common in llvm.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1598
+  do {
+SmallVector Buf(10);
+ReadCount = getLexer().peekTokens(Buf);

Can this be a regular array instead of a SmallVector?



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1601
+for (size_t index = 0; index < ReadCount; ++index) {
+  AsmToken token = Buf[index];
+  if (token.getKind() != AsmToken::Comment) {

Capitalize variable names


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-21 Thread Freddy, Ye via Phabricator via cfe-commits
FreddyYe updated this revision to Diff 533161.
FreddyYe added a comment.

debug typo.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/test/CodeGen/attr-cpuspecific-avx-abi.c
  clang/test/CodeGen/attr-cpuspecific.c
  llvm/include/llvm/TargetParser/X86TargetParser.def
  llvm/include/llvm/TargetParser/X86TargetParser.h
  llvm/lib/Target/X86/X86.td
  llvm/lib/TargetParser/X86TargetParser.cpp
  llvm/test/CodeGen/X86/cpus-intel.ll

Index: llvm/test/CodeGen/X86/cpus-intel.ll
===
--- llvm/test/CodeGen/X86/cpus-intel.ll
+++ llvm/test/CodeGen/X86/cpus-intel.ll
@@ -6,16 +6,24 @@
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i586 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_mmx 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=i686 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentiumpro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_pro 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_ii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium3m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_iii_no_xmm_regs 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium-m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium4m 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=yonah 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=prescott 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=pentium_4_sse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=lakemont 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=raptorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=i686-unknown-unknown -mcpu=meteorlake 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
@@ -26,26 +34,39 @@
 
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=nocona 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core2 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_ssse3 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=penryn 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
+; RUN: llc < %s -o /dev/null -mtriple=x86_64-unknown-unknown -mcpu=core_2_duo_sse4_1 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ERROR --allow-empty
 ; RUN: llc < %s -o /dev/null -mtriple=x

[PATCH] D153403: [RISCV] Use unsigned types for orc_b builtins.

2023-06-21 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: Jim, asb.
Herald added subscribers: jobnoorman, luke, VincentWu, vkmr, frasercrmck, 
luismarques, apazos, sameer.abuasal, s.egerton, benna, psnobl, jocewei, PkmX, 
the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, 
shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, 
arichardson.
Herald added a project: All.
craig.topper requested review of this revision.
Herald added subscribers: cfe-commits, wangpc, eopXD, MaskRay.
Herald added a project: clang.

Inspried by D153235 , I think bit 
manipulation makes more
sense on unsigned types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153403

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
  clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -10,7 +10,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -22,7 +22,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.orc.b.i64(i64 [[TMP0]])
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long orc_b_64(long a) {
+unsigned long orc_b_64(unsigned long a) {
   return __builtin_riscv_orc_b_64(a);
 }
 
@@ -72,4 +72,4 @@
 //
 long ctz_64(long a) {
   return __builtin_riscv_ctz_64(a);
-}
\ No newline at end of file
+}
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -10,7 +10,7 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV32ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -36,4 +36,4 @@
 //
 int ctz_32(int a) {
   return __builtin_riscv_ctz_32(a);
-}
\ No newline at end of file
+}
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb-error.c
@@ -1,6 +1,6 @@
 // NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
 // RUN: %clang_cc1 -triple riscv32 -target-feature +zbb -verify %s -o -
 
-int orc_b_64(int a) {
+unsigned int orc_b_64(unsigned int a) {
   return __builtin_riscv_orc_b_64(a); // expected-error {{builtin requires: 
'RV64'}}
 }
Index: clang/include/clang/Basic/BuiltinsRISCV.def
===
--- clang/include/clang/Basic/BuiltinsRISCV.def
+++ clang/include/clang/Basic/BuiltinsRISCV.def
@@ -16,8 +16,8 @@
 #endif
 
 // Zbb extension
-TARGET_BUILTIN(__builtin_riscv_orc_b_32, "ZiZi", "nc", "zbb")
-TARGET_BUILTIN(__builtin_riscv_orc_b_64, "WiWi", "nc", "zbb,64bit")
+TARGET_BUILTIN(__builtin_riscv_orc_b_32, "UZiUZi", "nc", "zbb")
+TARGET_BUILTIN(__builtin_riscv_orc_b_64, "UWiUWi", "nc", "zbb,64bit")
 TARGET_BUILTIN(__builtin_riscv_clz_32, "ZiZi", "nc", "zbb|xtheadbb")
 TARGET_BUILTIN(__builtin_riscv_clz_64, "WiWi", "nc", "zbb|xtheadbb,64bit")
 TARGET_BUILTIN(__builtin_riscv_ctz_32, "ZiZi", "nc", "zbb")


Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv64-zbb.c
@@ -10,7 +10,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV64ZBB-NEXT:ret i32 [[TMP1]]
 //
-int orc_b_32(int a) {
+unsigned int orc_b_32(unsigned int a) {
   return __builtin_riscv_orc_b_32(a);
 }
 
@@ -22,7 +22,7 @@
 // RV64ZBB-NEXT:[[TMP1:%.*]] = call i64 @llvm.riscv.orc.b.i64(i64 [[TMP0]])
 // RV64ZBB-NEXT:ret i64 [[TMP1]]
 //
-long orc_b_64(long a) {
+unsigned long orc_b_64(unsigned long a) {
   return __builtin_riscv_orc_b_64(a);
 }
 
@@ -72,4 +72,4 @@
 //
 long ctz_64(long a) {
   return __builtin_riscv_ctz_64(a);
-}
\ No newline at end of file
+}
Index: clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
===
--- clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
+++ clang/test/CodeGen/RISCV/rvb-intrinsics/riscv32-zbb.c
@@ -10,7 +10,7 @@
 // RV32ZBB-NEXT:[[TMP1:%.*]] = call i32 @llvm.riscv.orc.b.i32(i32 [[TMP0]])
 // RV32ZBB-NE

[PATCH] D153161: [RISCV] Move Zca/Zcb/Zcd/Zcf/Zcmp/Zcmt out of experimental status.

2023-06-21 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu accepted this revision.
VincentWu added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153161

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


[PATCH] D150978: [clang][Sema] Add CodeCompletionContext::CCC_ObjCClassForwardDecl

2023-06-21 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/CodeComplete.cpp:407
+// reference the declaration.
+if (ContextKind == CodeCompletionContext::CCC_ObjCClassForwardDecl)
+  ShouldInsert = false;

rather than doing this here, can you pass `ContextKind` into 
`headerToInsertIfAllowed` ? we already have some logic there that does 
something similar (e.g. check if there's a decl in the main file). it'd be nice 
to group them together, in case we want to extend this in the future. (it'd be 
great if we can just have a `contextAllowsHeaderInsertion` helper, which can 
only return true for ObjCClassForwardDecl for now).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150978

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


[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-21 Thread Sergei Barannikov via Phabricator via cfe-commits
barannikov88 added inline comments.



Comment at: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp:1610
+}
+  } while (NonComments < 2 and ReadCount > 0);
+  return NextNextToken;

This is much more common.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

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


[PATCH] D152504: [clang][ThreadSafety] Analyze cleanup functions

2023-06-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 533175.

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

https://reviews.llvm.org/D152504

Files:
  clang/include/clang/Analysis/CFG.h
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/ThreadSafety.cpp
  clang/test/Sema/warn-thread-safety-analysis.c

Index: clang/test/Sema/warn-thread-safety-analysis.c
===
--- clang/test/Sema/warn-thread-safety-analysis.c
+++ clang/test/Sema/warn-thread-safety-analysis.c
@@ -22,6 +22,7 @@
 #define SHARED_LOCKS_REQUIRED(...) \
   __attribute__ ((shared_locks_required(__VA_ARGS__)))
 #define NO_THREAD_SAFETY_ANALYSIS  __attribute__ ((no_thread_safety_analysis))
+#define CLEANUP(A) __attribute__ ((cleanup(A)))
 
 // Define the mutex struct.
 // Simplified only for test purpose.
@@ -72,6 +73,11 @@
   return *p;
 }
 
+void cleanup_int(int *unused) __attribute__((release_capability(mu1))) {
+  (void)unused;
+  mutex_exclusive_unlock(&mu1);
+}
+
 int main(void) {
 
   Foo_fun1(1); // expected-warning{{calling function 'Foo_fun1' requires holding mutex 'mu2'}} \
@@ -127,6 +133,15 @@
 // expected-note@-1{{mutex released here}}
   mutex_shared_unlock(&mu1);// expected-warning {{releasing mutex 'mu1' that was not held}}
 
+
+  {
+mutex_exclusive_lock(&mu1);
+int CLEANUP(cleanup_int) i;
+
+Bar_fun1(3);
+  }
+  Bar_fun1(4); // expected-warning {{calling function 'Bar_fun1' requires holding mutex 'mu1' exclusively}}
+
   return 0;
 }
 
Index: clang/lib/Analysis/ThreadSafety.cpp
===
--- clang/lib/Analysis/ThreadSafety.cpp
+++ clang/lib/Analysis/ThreadSafety.cpp
@@ -2427,6 +2427,15 @@
 AD.getTriggerStmt()->getEndLoc());
   break;
 }
+
+case CFGElement::CleanupFunction: {
+  const CFGCleanupFunction &CF = BI.castAs();
+
+  LocksetBuilder.handleCall(nullptr, CF.getFunctionDecl(), nullptr,
+CF.getVarDecl()->getLocation());
+  break;
+}
+
 case CFGElement::TemporaryDtor: {
   auto TD = BI.castAs();
 
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -866,6 +866,10 @@
 B->appendAutomaticObjDtor(VD, S, cfg->getBumpVectorContext());
   }
 
+  void appendCleanupFunction(CFGBlock *B, VarDecl *VD) {
+B->appendCleanupFunction(VD, cfg->getBumpVectorContext());
+  }
+
   void appendLifetimeEnds(CFGBlock *B, VarDecl *VD, Stmt *S) {
 B->appendLifetimeEnds(VD, S, cfg->getBumpVectorContext());
   }
@@ -1907,7 +1911,8 @@
 Decls.push_back(*I);
 
   for (VarDecl *VD : llvm::reverse(Decls)) {
-if (hasTrivialDestructor(VD)) {
+bool HasCleanupAttr = VD->hasAttr();
+if (hasTrivialDestructor(VD) && !HasCleanupAttr) {
   // If AddScopes is enabled and *I is a first variable in a scope, add a
   // ScopeEnd marker in a Block.
   if (BuildOpts.AddScopes && DeclsWithEndedScope.count(VD)) {
@@ -1925,7 +1930,8 @@
 }
 Ty = Context->getBaseElementType(Ty);
 
-if (Ty->getAsCXXRecordDecl()->isAnyDestructorNoReturn())
+bool IsCXXRecordType = Ty->getAsCXXRecordDecl() != nullptr;
+if (IsCXXRecordType && Ty->getAsCXXRecordDecl()->isAnyDestructorNoReturn())
   Block = createNoReturnBlock();
 else
   autoCreateBlock();
@@ -1933,7 +1939,12 @@
 // Add ScopeEnd just after automatic obj destructor.
 if (BuildOpts.AddScopes && DeclsWithEndedScope.count(VD))
   appendScopeEnd(Block, VD, S);
-appendAutomaticObjDtor(Block, VD, S);
+
+if (HasCleanupAttr)
+  appendCleanupFunction(Block, VD);
+
+if (IsCXXRecordType)
+  appendAutomaticObjDtor(Block, VD, S);
   }
 }
 
@@ -2090,7 +2101,8 @@
 return Scope;
 
   if (BuildOpts.AddImplicitDtors) {
-if (!hasTrivialDestructor(VD) || BuildOpts.AddScopes) {
+if (!hasTrivialDestructor(VD) || VD->hasAttr() ||
+BuildOpts.AddScopes) {
   // Add the variable to scope
   Scope = createOrReuseLocalScope(Scope);
   Scope->addVar(VD);
@@ -5288,8 +5300,9 @@
 case CFGElement::CXXRecordTypedCall:
 case CFGElement::ScopeBegin:
 case CFGElement::ScopeEnd:
-  llvm_unreachable("getDestructorDecl should only be used with "
-   "ImplicitDtors");
+case CFGElement::CleanupFunction:
+llvm_unreachable("getDestructorDecl should only be used with "
+ "ImplicitDtors");
 case CFGElement::AutomaticObjectDtor: {
   const VarDecl *var = castAs().getVarDecl();
   QualType ty = var->getType();
@@ -5831,6 +5844,12 @@
 break;
   }
 
+  case CFGElement::Kind::CleanupFunction: {
+OS << "CleanupFunction ("
+   << E.castAs().getFunctionDecl()->getName() << ")\n";
+break;
+  }
+
   case CFGElement::Kind::LifetimeEnds:
 Helper

[PATCH] D152504: [clang][ThreadSafety] Analyze cleanup functions

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

Added a new element for cleanup functions.




Comment at: clang/lib/Analysis/ThreadSafety.cpp:2436
+CF.getVarDecl()->getLocation());
+  break;
+}

This handles the function call, but without the instance parameter. I was 
wondering how to best do that.


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

https://reviews.llvm.org/D152504

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-21 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen updated this revision to Diff 533182.
HaohaiWen marked 10 inline comments as done.
HaohaiWen added a comment.

Address maskray's comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Driver/ToolChains/CommonArgs.cpp
  clang/test/Driver/split-debug.c
  llvm/include/llvm/MC/MCWinCOFFObjectWriter.h
  llvm/lib/DebugInfo/DWARF/DWARFContext.cpp
  llvm/lib/MC/MCAsmBackend.cpp
  llvm/lib/MC/WinCOFFObjectWriter.cpp
  llvm/test/DebugInfo/COFF/dwarf-headers.ll
  llvm/test/DebugInfo/COFF/fission-cu.ll
  llvm/test/DebugInfo/COFF/fission-sections.ll

Index: llvm/test/DebugInfo/COFF/fission-sections.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-sections.ll
@@ -0,0 +1,42 @@
+; RUN: llc -split-dwarf-file=baz.dwo -split-dwarf-output=%t.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t.dwo | FileCheck --check-prefix=DWO %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+; But it checks that the output objects have the expected sections
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+!6 = !{!0}
+!7 = !{i32 1, !"Debug Info Version", i32 3}
+
+; CHECK-LABEL: Sections:
+
+; OBJ: Idx Name
+; OBJ-NEXT:  0 .text
+; OBJ-NEXT:  1 .data
+; OBJ-NEXT:  2 .bss
+; OBJ-NEXT:  3 .debug_abbrev
+; OBJ-NEXT:  4 .debug_info
+; OBJ-NEXT:  5 .debug_str
+; OBJ-NEXT:  6 .debug_addr
+; OBJ-NEXT:  7 .debug_pubnames
+; OBJ-NEXT:  8 .debug_pubtypes
+; OBJ-NEXT:  9 .debug_line
+
+; DWO:  Idx Name
+; DWO-NEXT:   0 .debug_str.dwo
+; DWO-NEXT:   1 .debug_str_offsets.dwo
+; DWO-NEXT:   2 .debug_info.dwo
+; DWO-NEXT:   3 .debug_abbrev.dwo
Index: llvm/test/DebugInfo/COFF/fission-cu.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/COFF/fission-cu.ll
@@ -0,0 +1,120 @@
+; RUN: llc -split-dwarf-file=baz.dwo -O0 %s -mtriple=x86_64-unknown-windows-msvc -filetype=obj -o %t
+; RUN: llvm-dwarfdump -v -all %t | FileCheck %s
+; RUN: llvm-readobj --relocations %t | FileCheck --check-prefix=OBJ %s
+; RUN: llvm-objdump -h %t | FileCheck --check-prefix=HDR %s
+
+; This test is derived from test/DebugInfo/X86/fission-cu.ll
+
+source_filename = "test/DebugInfo/X86/fission-cu.ll"
+
+@a = common global i32 0, align 4, !dbg !0
+
+!llvm.dbg.cu = !{!4}
+!llvm.module.flags = !{!7}
+
+!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
+!1 = !DIGlobalVariable(name: "a", scope: null, file: !2, line: 1, type: !3, isLocal: false, isDefinition: true)
+!2 = !DIFile(filename: "baz.c", directory: "e:\\llvm-project\\tmp")
+!3 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)
+!4 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang version 3.3 (trunk 169021) (llvm/trunk 169020)", isOptimized: false, runtimeVersion: 0, splitDebugFilename: "baz.dwo", emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5)
+!5 = !{}
+; Check that the skeleton compile unit contains the proper attributes:
+; This DIE has the following attributes: DW_AT_comp_dir, DW_AT_stmt_list,
+; DW_AT_low_pc, DW_AT_high_pc, DW_AT_ranges, DW_AT_dwo_name, DW_AT_dwo_id,
+; DW_AT_ranges_base, DW_AT_addr_base.
+
+; CHECK: .debug_abbrev contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_no
+; CHECK: DW_AT_stmt_list DW_FORM_sec_offset
+; CHECK: DW_AT_comp_dir  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_strp
+; CHECK: DW_AT_GNU_dwo_idDW_FORM_data8
+
+; Check that we're using the right forms.
+; CHECK: .debug_abbrev.dwo contents:
+; CHECK: Abbrev table for offset: 0x
+; CHECK: [1] DW_TAG_compile_unit DW_CHILDREN_yes
+; CHECK: DW_AT_producer  DW_FORM_GNU_str_index
+; CHECK: DW_AT_language  DW_FORM_data2
+; CHECK: DW_AT_name  DW_FORM_GNU_str_index
+; CHECK: DW_AT_GNU_dwo_name  DW_FORM_GNU_str_index
+; CHECK-NOT: DW_AT_low_pc
+; CHECK-NOT: DW_AT_stmt_list
+; CHECK-NOT: 

[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-21 Thread Haohai, Wen via Phabricator via cfe-commits
HaohaiWen added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1167
 // GCC style -dumpdir. We intentionally don't implement the less useful 
-dumpbase{,-ext}.
-def dumpdir : Separate<["-"], "dumpdir">, Flags<[CC1Option]>,
+def dumpdir : Separate<["-"], "dumpdir">, Flags<[CC1Option, CoreOption]>,
   MetaVarName<"">,

MaskRay wrote:
> This exposes `-dumpdir ` to clang-cl which may not be useful.
clang -gdwarf -gsplit-dwarf foo.cpp -o foo.exe -### will be expanded to
clang -cc1 ... "-dumpdir" "foo.exe-"  "-split-dwarf-file" "foo.exe-foo.dwo"

dwo name will be prefixed by dumpdir if it's specified.

This dumpdir is required for clang-cl to have same dwo filename behavior as 
clang.



Comment at: clang/lib/Driver/Driver.cpp:3898
 if (!Args.hasArg(options::OPT_dumpdir)) {
+  Arg *FinalOutput = Args.getLastArg(options::OPT_o, 
options::OPT__SLASH_o);
   Arg *Arg = Args.MakeSeparateArg(

MaskRay wrote:
> Add a test to show how OPT__SLASH_o passes a `-dumpdir `to CC1.
Already tested in (-o is OPT__SLASH_o in cl mode)

```
clang/test/Driver/split-debug.c: 62
// RUN: %clang_cl -### --target=x86_64-unknown-windows-msvc -gsplit-dwarf -g %s 
-o obj/out 2>&1 | FileCheck %s --check-prefix=SPLIT_LINK
/ SPLIT_LINK:  "-dumpdir" "obj/out-"
// SPLIT_LINK:  "-debug-info-kind=constructor"
// SPLIT_LINK-SAME: "-split-dwarf-file" "obj/out-split-debug.dwo" 
"-split-dwarf-output" "obj/out-split-debug.dwo"
```



Comment at: clang/test/Driver/split-debug.c:19
 // RUN: %clang -### -c -target amdgcn-amd-amdhsa -gsplit-dwarf -g %s 2>&1 | 
FileCheck %s --check-prefix=SPLIT
+// RUN: %clang_cl -### -c -target x86_64-unknown-windows-msvc -gsplit-dwarf -g 
%s 2>&1 | FileCheck %s --check-prefix=SPLIT
 

MaskRay wrote:
> MaskRay wrote:
> > Use `--target=` for new tests. `-target ` has been deprecated since Clang 
> > 3.x
> You can use `-gno-split-dwarf -gsplit-dwarf` to test `CoreOption` on 
> `-gno-split-dwarf`.
Good suggestion.



Comment at: llvm/lib/DebugInfo/DWARF/DWARFContext.cpp:1895
+  if (RelocatedSection != Obj.section_end() && Name.contains(".dwo")) {
+// Each section in COFF can directly contain relocations.
+if (isa(&Obj) && Section.relocations().empty())

MaskRay wrote:
> skan wrote:
> > The comment is confusing according to line 1900. Could you refine it?
> I'll change this to `ends_with(".dwo")` separately.
> 
> `check-llvm check-clang` passes even if I remove `if 
> (isa(&Obj) && Section.relocations().empty()) continue`. What 
> does it do?
For ELF, if section a.dwo has relocations, it'll have a a.dwo.rela section, 
this section is RelocatedSection.
All dwo section should not have relocations, so if this is a dwo file, then 
RelocatedSection should be Obj.section_end(). Otherwise it will report warning.

For COFF, relocations of section A are directly stored in section A. 
RelocatedSection is Section itself so it will never be Obj.section_end(). Then 
this warning will always be reported. What we need to do is to check 
Section.relocations().empty() for COFF sections.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

2023-06-21 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D153294#4435767 , @rsmith wrote:

> A constant expression (including the immediate invocations generated for 
> `consteval` functions) is a full-expression, so destructors should be run at 
> the end of evaluating it, not as part of the enclosing expression. That's 
> presumably why the code is calling `MaybeCreateExprWithCleanups` -- to 
> associate cleanups for the immediate invocation with that `ConstantExpr` 
> rather than with the outer context. I think the problem is that we don't have 
> an `ExpressionEvaluationContext` wrapping the immediate invocation, so we 
> don't save and restore the enclosing cleanup state -- and we can't really 
> wrap it, because we don't find out that we're building an immediate 
> invocation until after we've already done so. Probably the best way to handle 
> that is to create the inner `ExprWithCleanups` for the constant expression, 
> but leave the cleanups flags alone so that we also create an outer 
> `ExprWithCleanups`. That'll mean we sometimes create an `ExprWithCleanups` 
> that doesn't actually run any cleanups, but that's OK, just redundant. One 
> thing we will need to be careful about is assigning any block / compound 
> literal cleanups to the right `ExprWithCleanups` node. We can figure out 
> where to put them by doing a traversal of the `ConstantExpr`'s subexpression 
> to see if it contains the `BlockDecl` / `CompoundLiteralExpr` being 
> referenced by the cleanup.

Thanks! We don't have any tests that break with this change, so I assume this 
is not tested.
What would an example of `ConstantExpression` that has to run cleanups?  I'm 
trying to come up with one, but since all types used inside immediate 
invocation must be literal types, whenever I try to plug a non-trivial 
destructor the code gets rejected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153294

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


[clang] 72ac907 - [C++20] [Modules] Use the canonical decl when getting associated constraints

2023-06-21 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2023-06-21T17:00:56+08:00
New Revision: 72ac90715876e2963af899cbb883bad1e07b67bd

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

LOG: [C++20] [Modules] Use the canonical decl when getting associated 
constraints

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

The root cause for the issue is that we think the associated constraints
from the 'same' declaration in different module units are different
incorrectly. Since the constraints doesn't know anything about decls and
modules, we should fix the problem by getting the associated constraints
from the exactly the same declarations from different modules.

Added: 
clang/test/Modules/pr62943.cppm

Modified: 
clang/lib/Sema/SemaConcept.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaConcept.cpp b/clang/lib/Sema/SemaConcept.cpp
index 25884838d632c..f562e85009282 100644
--- a/clang/lib/Sema/SemaConcept.cpp
+++ b/clang/lib/Sema/SemaConcept.cpp
@@ -1155,6 +1155,11 @@ void Sema::DiagnoseUnsatisfiedConstraint(
 const NormalizedConstraint *
 Sema::getNormalizedAssociatedConstraints(
 NamedDecl *ConstrainedDecl, ArrayRef AssociatedConstraints) {
+  // In case the ConstrainedDecl comes from modules, it is necessary to use
+  // the canonical decl to avoid 
diff erent atomic constraints with the 'same'
+  // declarations.
+  ConstrainedDecl = cast(ConstrainedDecl->getCanonicalDecl());
+
   auto CacheEntry = NormalizationCache.find(ConstrainedDecl);
   if (CacheEntry == NormalizationCache.end()) {
 auto Normalized =

diff  --git a/clang/test/Modules/pr62943.cppm b/clang/test/Modules/pr62943.cppm
new file mode 100644
index 0..27868b78220f5
--- /dev/null
+++ b/clang/test/Modules/pr62943.cppm
@@ -0,0 +1,99 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
+// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm
+// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface \
+// RUN: -fprebuilt-module-path=%t -o %t/c.pcm
+// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t \
+// RUN: -fsyntax-only -verify
+
+//--- foo.h
+#ifndef FOO_H
+#define FOO_H
+
+template
+concept __has_member_value_type = requires { typename _Tp::value_type; };
+
+template
+concept __has_member_element_type = requires { typename _Tp::element_type; };
+
+template 
+inline constexpr bool is_object_v = __is_object(_Tp);
+
+template struct __cond_value_type {};
+
+template
+requires is_object_v<_Tp>
+struct __cond_value_type<_Tp> { using value_type = bool; };
+
+template struct indirectly_readable_traits {
+static constexpr int value = false;
+};
+#endif
+
+//--- foo.member_value_type.h
+#include "foo.h"
+template<__has_member_value_type _Tp>
+struct indirectly_readable_traits<_Tp> : __cond_value_type {
+static constexpr int value = false;
+};
+
+//--- foo.memeber_element_type.h
+#include "foo.h"
+template<__has_member_element_type _Tp>
+struct indirectly_readable_traits<_Tp>  : __cond_value_type  {
+static constexpr int value = false;
+};
+
+template<__has_member_value_type _Tp>
+  requires __has_member_element_type<_Tp>
+struct indirectly_readable_traits<_Tp> {
+static constexpr int value = true;
+};
+
+//--- foo.a.h
+#include "foo.h"
+#include "foo.member_value_type.h"
+#include "foo.memeber_element_type.h"
+template 
+using AType  = indirectly_readable_traits;
+
+//--- a.cppm
+module;
+#include "foo.a.h"
+export module a;
+
+export using ::AType;
+
+//--- b.cppm
+module;
+#include "foo.h"
+#include "foo.memeber_element_type.h"
+export module b;
+
+//--- c.cppm
+export module c;
+
+export import a;
+export import b;
+
+//--- use.cpp
+// expected-no-diagnostics
+import c;
+
+template 
+class U {
+public:
+using value_type = T;
+using element_type = T;
+};
+
+template 
+class V {
+public:
+};
+
+static_assert(!AType>::value);
+static_assert(AType>::value);



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


[PATCH] D149443: [ARM] add Thumb-1 8-bit movs/adds relocations to LLVM

2023-06-21 Thread Ties Stuij via Phabricator via cfe-commits
stuij updated this revision to Diff 533190.
stuij added a comment.

address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D149443

Files:
  clang/lib/Driver/ToolChains/Arch/ARM.cpp
  llvm/include/llvm/BinaryFormat/ELFRelocs/ARM.def
  llvm/lib/Target/ARM/ARMInstrInfo.td
  llvm/lib/Target/ARM/ARMInstrThumb.td
  llvm/lib/Target/ARM/AsmParser/ARMAsmParser.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMFixupKinds.h
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCCodeEmitter.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.cpp
  llvm/lib/Target/ARM/MCTargetDesc/ARMMCExpr.h
  llvm/test/MC/ARM/negative-immediates-thumb1-fail.s
  llvm/test/MC/ARM/thumb-8-bit-relocs.s
  llvm/test/MC/ARM/thumb-diagnostics.s
  llvm/test/MC/ARM/thumb-fixups.s

Index: llvm/test/MC/ARM/thumb-fixups.s
===
--- /dev/null
+++ llvm/test/MC/ARM/thumb-fixups.s
@@ -0,0 +1,25 @@
+@ RUN: llvm-mc -triple armv6m-unknown-unknown %s --show-encoding -o - | \
+@ RUN:   FileCheck %s
+
+movs r3, :upper8_15:_foo
+adds r3, :upper0_7:_foo
+adds r3, :lower8_15:_foo
+adds r3, :lower0_7:_foo
+
+@ CHECK:  movsr3, :upper8_15:_foo @ encoding: [A,0x23]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_upper_8_15
+@ CHECK-NEXT: addsr3, :upper0_7:_foo  @ encoding: [A,0x33]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_upper_0_7
+@ CHECK-NEXT: addsr3, :lower8_15:_foo @ encoding: [A,0x33]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_lower_8_15
+@ CHECK-NEXT: addsr3, :lower0_7:_foo  @ encoding: [A,0x33]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_lower_0_7
+
+@ GNU syntax variants:
+movs r3, #:upper8_15:#_foo
+movs r3, #:upper8_15:_foo
+
+@ CHECK:  movsr3, :upper8_15:_foo @ encoding: [A,0x23]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_upper_8_15
+@ CHECK-NEXT: movsr3, :upper8_15:_foo @ encoding: [A,0x23]
+@ CHECK-NEXT: @   fixup A - offset: 0, value: _foo, kind: fixup_arm_thumb_upper_8_15
Index: llvm/test/MC/ARM/thumb-diagnostics.s
===
--- llvm/test/MC/ARM/thumb-diagnostics.s
+++ llvm/test/MC/ARM/thumb-diagnostics.s
@@ -195,6 +195,34 @@
 @ CHECK-ERRORS: note: operand must be an immediate in the range [0,31]
 @ CHECK-ERRORS: note: too many operands for instruction
 
+@ Out of range immediates for MOVS/ADDS instruction.
+movs r3, #-1
+adds r3, #256
+@ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this:
+@ CHECK-ERRORS-NEXT: movs r3, #-1
+@ CHECK-ERRORS-NEXT: ^
+@ CHECK-ERRORS: note: operand must be an immediate in the range [0,255] or a relocatable expression
+@ CHECK-ERRORS-NEXT: movs r3, #-1
+@ CHECK-ERRORS-NEXT:  ^
+@ CHECK-ERRORS: note: operand must be a register in range [r0, r7]
+@ CHECK-ERRORS-NEXT: movs r3, #-1
+@ CHECK-ERRORS-NEXT:  ^
+@ CHECK-ERRORS: error: invalid instruction, any one of the following would fix this:
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT: ^
+@ CHECK-ERRORS: note: instruction requires: thumb2
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT: ^
+@ CHECK-ERRORS: note: invalid operand for instruction
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT:  ^
+@ CHECK-ERRORS-NEXT: note: operand must be an immediate in the range [0,255] or a relocatable expression
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT:  ^
+@ CHECK-ERRORS-NEXT: note: operand must be a register in range [r0, r7]
+@ CHECK-ERRORS-NEXT: adds r3, #256
+@ CHECK-ERRORS-NEXT:  ^
+
 @ Mismatched source/destination operands for MUL instruction.
 muls r1, r2, r3
 @ CHECK-ERRORS: error: destination register must match source register
Index: llvm/test/MC/ARM/thumb-8-bit-relocs.s
===
--- /dev/null
+++ llvm/test/MC/ARM/thumb-8-bit-relocs.s
@@ -0,0 +1,35 @@
+@ RUN: llvm-mc -triple thumbv6m-eabi -o - %s | FileCheck %s
+@ RUN: llvm-mc -triple thumbv6m-eabi -filetype obj -o - %s | llvm-readobj -r - \
+@ RUN:   | FileCheck -check-prefix CHECK-RELOCATIONS %s
+@ RUN: llvm-mc -triple thumbv7m-eabi -o - %s | FileCheck %s
+@ RUN: llvm-mc -triple thumbv7m-eabi -filetype obj -o - %s | llvm-readobj -r - \
+@ RUN:   | FileCheck -check-prefix CHECK-RELOCATIONS %s
+
+.syntax unified
+
+.type function,%function
+function:
+  bx lr
+
+.global external
+.type external,%function
+
+.type test,%function
+test:
+  movs r3, :upper8_15:function
+  adds r3, :upper0_7:function
+  adds r3, :lower8_15:function
+  adds r3, :lower0_7

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-21 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 533191.
abel-bernabeu added a comment.

Addressed some review comments:

- Doxygen-style comments are not common, so using triple-slash instead.
- Using a regular C array on a place where the usage of SmallVector is not 
justified.
- Proper capitalization of a variable
- Usage of "&&" rather than "and", to blend better with the existing code style.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/comments-zdinx.ll
  llvm/test/MC/RISCV/comments.ll

Index: llvm/test/MC/RISCV/comments.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments.ll
@@ -0,0 +1,70 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments \
+# RUN:--mattr=+v,+experimental-zfa,+experimental-zcmp,+experimental-ztso %s \
+# RUN:| FileCheck %s
+
+/*c0*/ li /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: li  a0, 0   # c0# c1# c2# c3
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ ( /*c4*/ a1 /*c5*/ ) /*c6*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ nan /*c4*/
+# CHECK: fli.s   ft0, nan#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ 1.0 /*c4*/
+# CHECK: fli.s   ft0, 1.0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ auipc /*c1*/ a0 /*c2*/ , /*c3*/ %pcrel_hi /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK:  auipc   a0, %pcrel_hi(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ + /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi0)
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ - /*c5*/ 10
+# CHECK: .Lpcrel_hi1:#c0 #c1 #c2 #c3 #c4 #c5
+# CHECK: auipc   s0, %pcrel_hi(symbol-10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi1)
+
+/*c0*/ vsetivli /*c1*/ a2 /*c2*/ , /*c3*/ 31 /*c4*/ , /*c5*/ e32 /*c6*/ , /*c7*/ m1 /*c8*/ , /*c9*/ ta /*c10*/ , /*c11*/ ma /*c12*/
+# CHECK: vsetivlia2, 31, e32, m1, ta, ma #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12
+
+/*c0*/ vadd.vv /*c1*/ v1 /*c2*/ , /*c3*/ v2 /*c4*/ , /*c5*/ v3 /*c6*/ , /*c7*/ v0.t /*c8*/
+# CHECK: vadd.vv v1, v2, v3, v0.t#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8
+
+/*c0*/ cm.push /*c1*/ { /*c2*/ ra /*c3*/ , /*c4*/ s0 /*c5*/ - /*c6*/ s1 /*c7*/ } /*c8*/ , /*c9*/ - /*c10*/ 32 /*c11*/
+# CHECK: cm.push {ra, s0-s1}, -32#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11
+
+/*c0*/ cm.popret /*c0*/ { /*c1*/ x1 /*c2*/ , /*c3*/ x8 /*c4*/ - /*c5*/ x9 /*c6*/ , /*c7*/ x18 /*c8*/ - /*c9*/ x20 /*c10*/ } /*c11*/ , /*c12*/ 64 /*c13*/
+# CHECK: cm.popret   {ra, s0-s4}, 64 #c0 #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12#c13
+
+/*c0*/ fence /*c1*/ 0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: fence   0, 0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence /*c1*/ iorw /*c2*/ , /*c3*/ iorw /*c4*/
+# CHECK: fence   #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence.tso /*c1*/
+# CHECK: fence.tso   #c0 #c1
+
+/*c0*/ fence.i /*c1*/
+# CHECK: fence.i #c0 #c1
+
+/*c0*/ nop /*c1*/
+# CHECK: nop #c0 #c1
+
+/*c0*/ .option /*c1*/ arch /*c2*/ , /*c3*/ rv64gc /*c4*/
+# CHECK: #c0 #c1 #c2 #c3 #c4
+# CHECK-NEXT: .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0
+
+/*c0*/ .attribute /*c1*/ priv_spec /*c2*/ , /*c3*/ 2 /*c4*/
+# CHECK: .attribute  8, 2
+# CHECK-NEXT: #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ .attribute /*c1*/ arch /*c2*/ , /*c3*/ "rv32i_zvfbfmin0p6" /*c4*/
+# CHECK: .attribute  5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin0p6_zvl32b1p0"
+# CHECK-NEXT: #c0 #c1 #c2 #c3 #c4
\ No newline at end of file
Index: llvm/test/MC/RISCV/comments-zdinx.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments-zdinx.ll
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments --mattr=+zdinx  %s | FileCheck %s
+
+/*c0*/ fmadd.d /*c1*/ x10 /*c2*/ , /*c3*/ x12 /*c4*/ , /*c5*/ x14 /*c6*/ , /*c7*/ x16 /*c8*/ , /*c9*/ dyn /*c10*/
+// CHECK: fmadd.d a0, a2, a4, a6  #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10
\ No newline at end of file
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
=

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-21 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 533193.
abel-bernabeu added a comment.

Reduced the commit message verbosity by one half, without losing anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/comments-zdinx.ll
  llvm/test/MC/RISCV/comments.ll

Index: llvm/test/MC/RISCV/comments.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments.ll
@@ -0,0 +1,70 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments \
+# RUN:--mattr=+v,+experimental-zfa,+experimental-zcmp,+experimental-ztso %s \
+# RUN:| FileCheck %s
+
+/*c0*/ li /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: li  a0, 0   # c0# c1# c2# c3
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ ( /*c4*/ a1 /*c5*/ ) /*c6*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ nan /*c4*/
+# CHECK: fli.s   ft0, nan#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ 1.0 /*c4*/
+# CHECK: fli.s   ft0, 1.0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ auipc /*c1*/ a0 /*c2*/ , /*c3*/ %pcrel_hi /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK:  auipc   a0, %pcrel_hi(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ + /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi0)
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ - /*c5*/ 10
+# CHECK: .Lpcrel_hi1:#c0 #c1 #c2 #c3 #c4 #c5
+# CHECK: auipc   s0, %pcrel_hi(symbol-10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi1)
+
+/*c0*/ vsetivli /*c1*/ a2 /*c2*/ , /*c3*/ 31 /*c4*/ , /*c5*/ e32 /*c6*/ , /*c7*/ m1 /*c8*/ , /*c9*/ ta /*c10*/ , /*c11*/ ma /*c12*/
+# CHECK: vsetivlia2, 31, e32, m1, ta, ma #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12
+
+/*c0*/ vadd.vv /*c1*/ v1 /*c2*/ , /*c3*/ v2 /*c4*/ , /*c5*/ v3 /*c6*/ , /*c7*/ v0.t /*c8*/
+# CHECK: vadd.vv v1, v2, v3, v0.t#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8
+
+/*c0*/ cm.push /*c1*/ { /*c2*/ ra /*c3*/ , /*c4*/ s0 /*c5*/ - /*c6*/ s1 /*c7*/ } /*c8*/ , /*c9*/ - /*c10*/ 32 /*c11*/
+# CHECK: cm.push {ra, s0-s1}, -32#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11
+
+/*c0*/ cm.popret /*c0*/ { /*c1*/ x1 /*c2*/ , /*c3*/ x8 /*c4*/ - /*c5*/ x9 /*c6*/ , /*c7*/ x18 /*c8*/ - /*c9*/ x20 /*c10*/ } /*c11*/ , /*c12*/ 64 /*c13*/
+# CHECK: cm.popret   {ra, s0-s4}, 64 #c0 #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12#c13
+
+/*c0*/ fence /*c1*/ 0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: fence   0, 0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence /*c1*/ iorw /*c2*/ , /*c3*/ iorw /*c4*/
+# CHECK: fence   #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence.tso /*c1*/
+# CHECK: fence.tso   #c0 #c1
+
+/*c0*/ fence.i /*c1*/
+# CHECK: fence.i #c0 #c1
+
+/*c0*/ nop /*c1*/
+# CHECK: nop #c0 #c1
+
+/*c0*/ .option /*c1*/ arch /*c2*/ , /*c3*/ rv64gc /*c4*/
+# CHECK: #c0 #c1 #c2 #c3 #c4
+# CHECK-NEXT: .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0
+
+/*c0*/ .attribute /*c1*/ priv_spec /*c2*/ , /*c3*/ 2 /*c4*/
+# CHECK: .attribute  8, 2
+# CHECK-NEXT: #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ .attribute /*c1*/ arch /*c2*/ , /*c3*/ "rv32i_zvfbfmin0p6" /*c4*/
+# CHECK: .attribute  5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin0p6_zvl32b1p0"
+# CHECK-NEXT: #c0 #c1 #c2 #c3 #c4
\ No newline at end of file
Index: llvm/test/MC/RISCV/comments-zdinx.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments-zdinx.ll
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments --mattr=+zdinx  %s | FileCheck %s
+
+/*c0*/ fmadd.d /*c1*/ x10 /*c2*/ , /*c3*/ x12 /*c4*/ , /*c5*/ x14 /*c6*/ , /*c7*/ x16 /*c8*/ , /*c9*/ dyn /*c10*/
+// CHECK: fmadd.d a0, a2, a4, a6  #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10
\ No newline at end of file
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -107,6 +107,8 @@
uint64_t &ErrorInfo

[PATCH] D153008: [RISCV] Allow slash-star comments in instruction operands

2023-06-21 Thread Abel Bernabeu via Phabricator via cfe-commits
abel-bernabeu updated this revision to Diff 533194.
abel-bernabeu added a comment.

Even less verbosity...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153008

Files:
  llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  llvm/test/MC/RISCV/comments-zdinx.ll
  llvm/test/MC/RISCV/comments.ll

Index: llvm/test/MC/RISCV/comments.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments.ll
@@ -0,0 +1,70 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments \
+# RUN:--mattr=+v,+experimental-zfa,+experimental-zcmp,+experimental-ztso %s \
+# RUN:| FileCheck %s
+
+/*c0*/ li /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: li  a0, 0   # c0# c1# c2# c3
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ 0 /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ lw /*c1*/ a0 /*c2*/ , /*c3*/ ( /*c4*/ a1 /*c5*/ ) /*c6*/
+# CHECK: lw  a0, 0(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ nan /*c4*/
+# CHECK: fli.s   ft0, nan#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fli.s /*c1*/ ft0 /*c2*/ , /*c3*/ 1.0 /*c4*/
+# CHECK: fli.s   ft0, 1.0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ auipc /*c1*/ a0 /*c2*/ , /*c3*/ %pcrel_hi /*c4*/ ( /*c5*/ a1 /*c6*/ ) /*c7*/
+# CHECK:  auipc   a0, %pcrel_hi(a1)   #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ + /*c5*/ 10 /*c6*/
+# CHECK: .Lpcrel_hi0:#c0 #c1 #c2 #c3 #c4 #c5 #c6
+# CHECK: auipc   s0, %pcrel_hi(symbol+10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi0)
+
+/*c0*/ la /*c1*/ s0 /*c2*/ , /*c3*/ symbol /*c4*/ - /*c5*/ 10
+# CHECK: .Lpcrel_hi1:#c0 #c1 #c2 #c3 #c4 #c5
+# CHECK: auipc   s0, %pcrel_hi(symbol-10)
+# CHECK: addis0, s0, %pcrel_lo(.Lpcrel_hi1)
+
+/*c0*/ vsetivli /*c1*/ a2 /*c2*/ , /*c3*/ 31 /*c4*/ , /*c5*/ e32 /*c6*/ , /*c7*/ m1 /*c8*/ , /*c9*/ ta /*c10*/ , /*c11*/ ma /*c12*/
+# CHECK: vsetivlia2, 31, e32, m1, ta, ma #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12
+
+/*c0*/ vadd.vv /*c1*/ v1 /*c2*/ , /*c3*/ v2 /*c4*/ , /*c5*/ v3 /*c6*/ , /*c7*/ v0.t /*c8*/
+# CHECK: vadd.vv v1, v2, v3, v0.t#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8
+
+/*c0*/ cm.push /*c1*/ { /*c2*/ ra /*c3*/ , /*c4*/ s0 /*c5*/ - /*c6*/ s1 /*c7*/ } /*c8*/ , /*c9*/ - /*c10*/ 32 /*c11*/
+# CHECK: cm.push {ra, s0-s1}, -32#c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11
+
+/*c0*/ cm.popret /*c0*/ { /*c1*/ x1 /*c2*/ , /*c3*/ x8 /*c4*/ - /*c5*/ x9 /*c6*/ , /*c7*/ x18 /*c8*/ - /*c9*/ x20 /*c10*/ } /*c11*/ , /*c12*/ 64 /*c13*/
+# CHECK: cm.popret   {ra, s0-s4}, 64 #c0 #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10#c11#c12#c13
+
+/*c0*/ fence /*c1*/ 0 /*c2*/ , /*c3*/ 0 /*c4*/
+# CHECK: fence   0, 0#c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence /*c1*/ iorw /*c2*/ , /*c3*/ iorw /*c4*/
+# CHECK: fence   #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ fence.tso /*c1*/
+# CHECK: fence.tso   #c0 #c1
+
+/*c0*/ fence.i /*c1*/
+# CHECK: fence.i #c0 #c1
+
+/*c0*/ nop /*c1*/
+# CHECK: nop #c0 #c1
+
+/*c0*/ .option /*c1*/ arch /*c2*/ , /*c3*/ rv64gc /*c4*/
+# CHECK: #c0 #c1 #c2 #c3 #c4
+# CHECK-NEXT: .option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0
+
+/*c0*/ .attribute /*c1*/ priv_spec /*c2*/ , /*c3*/ 2 /*c4*/
+# CHECK: .attribute  8, 2
+# CHECK-NEXT: #c0 #c1 #c2 #c3 #c4
+
+/*c0*/ .attribute /*c1*/ arch /*c2*/ , /*c3*/ "rv32i_zvfbfmin0p6" /*c4*/
+# CHECK: .attribute  5, "rv32i2p1_f2p2_zicsr2p0_zve32f1p0_zve32x1p0_zvfbfmin0p6_zvl32b1p0"
+# CHECK-NEXT: #c0 #c1 #c2 #c3 #c4
\ No newline at end of file
Index: llvm/test/MC/RISCV/comments-zdinx.ll
===
--- /dev/null
+++ llvm/test/MC/RISCV/comments-zdinx.ll
@@ -0,0 +1,4 @@
+# RUN: llvm-mc -triple=riscv64 --preserve-comments --mattr=+zdinx  %s | FileCheck %s
+
+/*c0*/ fmadd.d /*c1*/ x10 /*c2*/ , /*c3*/ x12 /*c4*/ , /*c5*/ x14 /*c6*/ , /*c7*/ x16 /*c8*/ , /*c9*/ dyn /*c10*/
+// CHECK: fmadd.d a0, a2, a4, a6  #c0 #c1 #c2 #c3 #c4 #c5 #c6 #c7 #c8 #c9 #c10
\ No newline at end of file
Index: llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
===
--- llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
+++ llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
@@ -107,6 +107,8 @@
uint64_t &ErrorInfo,
bool MatchingInlin

[clang] dfb85c3 - [Clang][Interp] Diagnose uninitialized ctor of global record arrays

2023-06-21 Thread Takuya Shimizu via cfe-commits

Author: Takuya Shimizu
Date: 2023-06-21T19:03:01+09:00
New Revision: dfb85c3ce09a7bd1a059a3e821390b5111454f9e

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

LOG: [Clang][Interp] Diagnose uninitialized ctor of global record arrays

This patch adds a check for uninitialized subobjects of global variables that 
are record arrays.
e.g. `constexpr Foo f[2];`

Reviewed By: tbaeder

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

Added: 


Modified: 
clang/lib/AST/Interp/ByteCodeExprGen.h
clang/lib/AST/Interp/Interp.cpp
clang/test/AST/Interp/cxx20.cpp

Removed: 




diff  --git a/clang/lib/AST/Interp/ByteCodeExprGen.h 
b/clang/lib/AST/Interp/ByteCodeExprGen.h
index 8708bf99d91e7..83bafeb9aac61 100644
--- a/clang/lib/AST/Interp/ByteCodeExprGen.h
+++ b/clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -166,7 +166,8 @@ class ByteCodeExprGen : public 
ConstStmtVisitor, bool>,
 if (!visitInitializer(Init))
   return false;
 
-if (Init->getType()->isRecordType() && !this->emitCheckGlobalCtor(Init))
+if ((Init->getType()->isArrayType() || Init->getType()->isRecordType()) &&
+!this->emitCheckGlobalCtor(Init))
   return false;
 
 return this->emitPopPtr(Init);

diff  --git a/clang/lib/AST/Interp/Interp.cpp b/clang/lib/AST/Interp/Interp.cpp
index 8d7f191ebaa09..f646e876554ca 100644
--- a/clang/lib/AST/Interp/Interp.cpp
+++ b/clang/lib/AST/Interp/Interp.cpp
@@ -456,8 +456,11 @@ static bool CheckFieldsInitialized(InterpState &S, CodePtr 
OpPC,
 
 bool CheckCtorCall(InterpState &S, CodePtr OpPC, const Pointer &This) {
   assert(!This.isZero());
-  const Record *R = This.getRecord();
-  return CheckFieldsInitialized(S, OpPC, This, R);
+  if (const Record *R = This.getRecord())
+return CheckFieldsInitialized(S, OpPC, This, R);
+  const auto *CAT =
+  cast(This.getType()->getAsArrayTypeUnsafe());
+  return CheckArrayInitialized(S, OpPC, This, CAT);
 }
 
 bool CheckFloatResult(InterpState &S, CodePtr OpPC, APFloat::opStatus Status) {

diff  --git a/clang/test/AST/Interp/cxx20.cpp b/clang/test/AST/Interp/cxx20.cpp
index 5d9fa90b482ea..87c32e42d053e 100644
--- a/clang/test/AST/Interp/cxx20.cpp
+++ b/clang/test/AST/Interp/cxx20.cpp
@@ -138,14 +138,43 @@ static_assert(!b4); // ref-error {{not an integral 
constant expression}} \
 namespace UninitializedFields {
   class A {
   public:
-int a; // expected-note 3{{subobject declared here}} \
-   // ref-note 3{{subobject declared here}}
+int a; // expected-note 4{{subobject declared here}} \
+   // ref-note 4{{subobject declared here}}
 constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant 
expression}} \
  // expected-note {{subobject 'a' is not initialized}} \
  // ref-error {{must be initialized by a constant expression}} 
\
  // ref-note {{subobject 'a' is not initialized}}
+  constexpr A aarr[2]; // expected-error {{must be initialized by a constant 
expression}} \
+   // expected-note {{subobject 'a' is not initialized}} \
+   // ref-error {{must be initialized by a constant 
expression}} \
+   // ref-note {{subobject 'a' is not initialized}}
+  class F {
+public:
+  int f; // expected-note 3{{subobject declared here}} \
+ // ref-note 3{{subobject declared here}}
+
+  constexpr F() {}
+  constexpr F(bool b) {
+if (b)
+  f = 42;
+  }
+  };
+
+  constexpr F foo[2] = {true}; // expected-error {{must be initialized by a 
constant expression}} \
+   // expected-note {{subobject 'f' is not 
initialized}} \
+   // ref-error {{must be initialized by a 
constant expression}} \
+   // ref-note {{subobject 'f' is not initialized}}
+  constexpr F foo2[3] = {true, false, true}; // expected-error {{must be 
initialized by a constant expression}} \
+ // expected-note {{subobject 'f' 
is not initialized}} \
+ // ref-error {{must be 
initialized by a constant expression}} \
+ // ref-note {{subobject 'f' is 
not initialized}}
+  constexpr F foo3[3] = {true, true, F()}; // expected-error {{must be 
initialized by a constant expression}} \
+   // expected-note {{subobject 'f' is 
not initialized}} \
+   // ref-error {{must be initialized 
by a constant expression}} \
+   // ref-note {{subobject 'f' is not 
initialized}}
+
 
 
   class Base {



__

[PATCH] D152548: [Clang][Interp] Diagnose uninitialized ctor of global record arrays

2023-06-21 Thread Takuya Shimizu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGdfb85c3ce09a: [Clang][Interp] Diagnose uninitialized ctor of 
global record arrays (authored by hazohelet).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152548

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Interp.cpp
  clang/test/AST/Interp/cxx20.cpp


Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -138,14 +138,43 @@
 namespace UninitializedFields {
   class A {
   public:
-int a; // expected-note 3{{subobject declared here}} \
-   // ref-note 3{{subobject declared here}}
+int a; // expected-note 4{{subobject declared here}} \
+   // ref-note 4{{subobject declared here}}
 constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant 
expression}} \
  // expected-note {{subobject 'a' is not initialized}} \
  // ref-error {{must be initialized by a constant expression}} 
\
  // ref-note {{subobject 'a' is not initialized}}
+  constexpr A aarr[2]; // expected-error {{must be initialized by a constant 
expression}} \
+   // expected-note {{subobject 'a' is not initialized}} \
+   // ref-error {{must be initialized by a constant 
expression}} \
+   // ref-note {{subobject 'a' is not initialized}}
+  class F {
+public:
+  int f; // expected-note 3{{subobject declared here}} \
+ // ref-note 3{{subobject declared here}}
+
+  constexpr F() {}
+  constexpr F(bool b) {
+if (b)
+  f = 42;
+  }
+  };
+
+  constexpr F foo[2] = {true}; // expected-error {{must be initialized by a 
constant expression}} \
+   // expected-note {{subobject 'f' is not 
initialized}} \
+   // ref-error {{must be initialized by a 
constant expression}} \
+   // ref-note {{subobject 'f' is not initialized}}
+  constexpr F foo2[3] = {true, false, true}; // expected-error {{must be 
initialized by a constant expression}} \
+ // expected-note {{subobject 'f' 
is not initialized}} \
+ // ref-error {{must be 
initialized by a constant expression}} \
+ // ref-note {{subobject 'f' is 
not initialized}}
+  constexpr F foo3[3] = {true, true, F()}; // expected-error {{must be 
initialized by a constant expression}} \
+   // expected-note {{subobject 'f' is 
not initialized}} \
+   // ref-error {{must be initialized 
by a constant expression}} \
+   // ref-note {{subobject 'f' is not 
initialized}}
+
 
 
   class Base {
Index: clang/lib/AST/Interp/Interp.cpp
===
--- clang/lib/AST/Interp/Interp.cpp
+++ clang/lib/AST/Interp/Interp.cpp
@@ -456,8 +456,11 @@
 
 bool CheckCtorCall(InterpState &S, CodePtr OpPC, const Pointer &This) {
   assert(!This.isZero());
-  const Record *R = This.getRecord();
-  return CheckFieldsInitialized(S, OpPC, This, R);
+  if (const Record *R = This.getRecord())
+return CheckFieldsInitialized(S, OpPC, This, R);
+  const auto *CAT =
+  cast(This.getType()->getAsArrayTypeUnsafe());
+  return CheckArrayInitialized(S, OpPC, This, CAT);
 }
 
 bool CheckFloatResult(InterpState &S, CodePtr OpPC, APFloat::opStatus Status) {
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -166,7 +166,8 @@
 if (!visitInitializer(Init))
   return false;
 
-if (Init->getType()->isRecordType() && !this->emitCheckGlobalCtor(Init))
+if ((Init->getType()->isArrayType() || Init->getType()->isRecordType()) &&
+!this->emitCheckGlobalCtor(Init))
   return false;
 
 return this->emitPopPtr(Init);


Index: clang/test/AST/Interp/cxx20.cpp
===
--- clang/test/AST/Interp/cxx20.cpp
+++ clang/test/AST/Interp/cxx20.cpp
@@ -138,14 +138,43 @@
 namespace UninitializedFields {
   class A {
   public:
-int a; // expected-note 3{{subobject declared here}} \
-   // ref-note 3{{subobject declared here}}
+int a; // expected-note 4{{subobject declared here}} \
+   // ref-note 4{{subobject declared here}}
 constexpr A() {}
   };
   constexpr A a; // expected-error {{must be initialized by a constant expression}} \
  // expected-note {{subobject 'a' is

[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-21 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 533204.
massberg marked 2 inline comments as done.
massberg added a comment.

Switched the "Hover, All" test to run with C++20 instead of C++17 and moved the
RewrittenBinaryOperatorSpaceship test to it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2926,6 +2926,41 @@
  HI.Definition = "__attribute__((nonnull))";
  HI.Documentation = Attr::getDocumentation(attr::NonNull).str();
}},
+  {
+   R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  struct Foo
+  {
+int x;
+// Foo spaceship
+auto operator<=>(const Foo&) const = default;
+  };
+
+  bool x = Foo(1) [[!^=]] Foo(2);
+ )cpp",
+   [](HoverInfo &HI) {
+ HI.Type = "bool (const Foo &) const noexcept";
+ HI.Value = "true";
+ HI.Name = "operator==";
+ HI.Parameters = {{{"const Foo &"}, std::nullopt, std::nullopt}};
+ HI.ReturnType = "bool";
+ HI.Kind = index::SymbolKind::InstanceMethod;
+ HI.LocalScope = "Foo::";
+ HI.NamespaceScope = "";
+ HI.Definition =
+ "bool operator==(const Foo &) const noexcept = default";
+ HI.Documentation = "Foo spaceship";
+ }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -2941,7 +2976,7 @@
 
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
-TU.ExtraArgs.push_back("-std=c++17");
+TU.ExtraArgs.push_back("-std=c++20");
 TU.ExtraArgs.push_back("-xobjective-c++");
 
 TU.ExtraArgs.push_back("-Wno-gnu-designator");
@@ -4047,7 +4082,6 @@
   EXPECT_TRUE(H->Value);
   EXPECT_TRUE(H->Type);
 }
-
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -618,6 +618,36 @@
   EXPECT_DECLS("RecordTypeLoc", "struct executor");
 }
 
+TEST_F(TargetDeclTest, RewrittenBinaryOperator) {
+  Flags.push_back("-std=c++20");
+
+  Code = R"cpp(
+  namespace std {
+struct strong_ordering {
+  int n;
+  constexpr operator int() const { return n; }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+}
+
+struct Foo
+{
+  int x;
+  auto operator<=>(const Foo&) const = default;
+};
+
+bool x = (Foo(1) [[!=]] Foo(2));
+  )cpp";
+  EXPECT_DECLS("CXXRewrittenBinaryOperator",
+   {"std::strong_ordering operator<=>(const Foo &) const = default",
+Rel::TemplatePattern},
+   {"bool operator==(const Foo &) const noexcept = default",
+Rel::TemplateInstantiation});
+}
+
 TEST_F(TargetDeclTest, FunctionTemplate) {
   Code = R"cpp(
 // Implicit specialization.
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -347,6 +347,10 @@
   void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE) {
 Outer.add(CDE->getOperatorDelete(), Flags);
   }
+  void
+  VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *RBO) {
+Outer.add(RBO->getDecomposedForm().InnerBinOp, Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-21 Thread Jens Massberg via Phabricator via cfe-commits
massberg marked an inline comment as done.
massberg added inline comments.



Comment at: clang-tools-extra/clangd/unittests/HoverTests.cpp:4051
 
+TEST(Hover, RewrittenBinaryOperatorSpaceshipMassberg) {
+  Annotations T(R"cpp(

sammccall wrote:
> massberg wrote:
> > massberg wrote:
> > > sammccall wrote:
> > > > sammccall wrote:
> > > > > no need to sign your work :-)
> > > > can you add this to HoverTest__All instead? That way we test all 
> > > > details of the hover card
> > > Upps, sorry.
> > > can you add this to HoverTest__All instead? That way we test all details 
> > > of the hover card
> > 
> > The (Hover, All) test tests with `std=c++17` while this test tests c++20 
> > features.
> > We could add an additional field with the version to the struct in the 
> > (Hover, All) test.
> > Or add a (Hover, All_Cpp20) test for testing C++20 (what is probably not 
> > worth at the moment with just one test requiring C++20).
> Does anything break if you switch everything to C++20?
> The intention of "std=c++17" there was certainly "not 14", rather than "not 
> 20" :-)
Test test passed with C++20. I have switch it to C++20 and moved the new test 
as a new case in this test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

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


[PATCH] D153331: [clangd][c++20]Consider rewritten binary operators in TargetFinder

2023-06-21 Thread Jens Massberg via Phabricator via cfe-commits
massberg updated this revision to Diff 533211.
massberg marked an inline comment as done.
massberg added a comment.

clang-format code


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153331

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

Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -2926,6 +2926,41 @@
  HI.Definition = "__attribute__((nonnull))";
  HI.Documentation = Attr::getDocumentation(attr::NonNull).str();
}},
+  {
+  R"cpp(
+  namespace std {
+  struct strong_ordering {
+int n;
+constexpr operator int() const { return n; }
+static const strong_ordering equal, greater, less;
+  };
+  constexpr strong_ordering strong_ordering::equal = {0};
+  constexpr strong_ordering strong_ordering::greater = {1};
+  constexpr strong_ordering strong_ordering::less = {-1};
+  }
+
+  struct Foo
+  {
+int x;
+// Foo spaceship
+auto operator<=>(const Foo&) const = default;
+  };
+
+  bool x = Foo(1) [[!^=]] Foo(2);
+ )cpp",
+  [](HoverInfo &HI) {
+HI.Type = "bool (const Foo &) const noexcept";
+HI.Value = "true";
+HI.Name = "operator==";
+HI.Parameters = {{{"const Foo &"}, std::nullopt, std::nullopt}};
+HI.ReturnType = "bool";
+HI.Kind = index::SymbolKind::InstanceMethod;
+HI.LocalScope = "Foo::";
+HI.NamespaceScope = "";
+HI.Definition =
+"bool operator==(const Foo &) const noexcept = default";
+HI.Documentation = "Foo spaceship";
+  }},
   };
 
   // Create a tiny index, so tests above can verify documentation is fetched.
@@ -2941,7 +2976,7 @@
 
 Annotations T(Case.Code);
 TestTU TU = TestTU::withCode(T.code());
-TU.ExtraArgs.push_back("-std=c++17");
+TU.ExtraArgs.push_back("-std=c++20");
 TU.ExtraArgs.push_back("-xobjective-c++");
 
 TU.ExtraArgs.push_back("-Wno-gnu-designator");
@@ -4047,7 +4082,6 @@
   EXPECT_TRUE(H->Value);
   EXPECT_TRUE(H->Type);
 }
-
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -618,6 +618,36 @@
   EXPECT_DECLS("RecordTypeLoc", "struct executor");
 }
 
+TEST_F(TargetDeclTest, RewrittenBinaryOperator) {
+  Flags.push_back("-std=c++20");
+
+  Code = R"cpp(
+  namespace std {
+struct strong_ordering {
+  int n;
+  constexpr operator int() const { return n; }
+  static const strong_ordering equal, greater, less;
+};
+constexpr strong_ordering strong_ordering::equal = {0};
+constexpr strong_ordering strong_ordering::greater = {1};
+constexpr strong_ordering strong_ordering::less = {-1};
+}
+
+struct Foo
+{
+  int x;
+  auto operator<=>(const Foo&) const = default;
+};
+
+bool x = (Foo(1) [[!=]] Foo(2));
+  )cpp";
+  EXPECT_DECLS("CXXRewrittenBinaryOperator",
+   {"std::strong_ordering operator<=>(const Foo &) const = default",
+Rel::TemplatePattern},
+   {"bool operator==(const Foo &) const noexcept = default",
+Rel::TemplateInstantiation});
+}
+
 TEST_F(TargetDeclTest, FunctionTemplate) {
   Code = R"cpp(
 // Implicit specialization.
Index: clang-tools-extra/clangd/FindTarget.cpp
===
--- clang-tools-extra/clangd/FindTarget.cpp
+++ clang-tools-extra/clangd/FindTarget.cpp
@@ -347,6 +347,10 @@
   void VisitCXXDeleteExpr(const CXXDeleteExpr *CDE) {
 Outer.add(CDE->getOperatorDelete(), Flags);
   }
+  void
+  VisitCXXRewrittenBinaryOperator(const CXXRewrittenBinaryOperator *RBO) {
+Outer.add(RBO->getDecomposedForm().InnerBinOp, Flags);
+  }
 };
 Visitor(*this, Flags).Visit(S);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153409: BEGIN_PUBLIC [clang][dataflow] Treat fields of anonymous records as being part of their parent.

2023-06-21 Thread Martin Böhme via Phabricator via cfe-commits
mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

See https://en.cppreference.com/w/c/language/struct.

Adds a test that fails without the other changes in the patch.
END_PUBLIC


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153409

Files:
  clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
  clang/lib/Analysis/FlowSensitive/Transfer.cpp
  clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
  clang/unittests/Analysis/FlowSensitive/TransferTest.cpp


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5403,4 +5403,35 @@
   });
 }
 
+// Check that fields of anonymous records are modeled and treated as children
+// of the enclosing record.
+TEST(TransferTest, AnonymousStruct) {
+  std::string Code = R"(
+struct S {
+  struct {
+int i;
+  };
+};
+void target() {
+  S s;
+  (void)s.i;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnotation(Results, "p");
+const ValueDecl *SDecl = findValueDecl(ASTCtx, "s");
+const ValueDecl *IDecl = findValueDecl(ASTCtx, "i");
+
+auto *S =
+cast(Env.getStorageLocation(*SDecl));
+// If we can call getChild() without an assertion failure, it means
+// that `i` is modeled.
+S->getChild(*IDecl);
+  });
+}
+
 } // namespace
Index: clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
+++ clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
@@ -154,7 +154,8 @@
 }
 
 const ValueDecl *test::findValueDecl(ASTContext &ASTCtx, llvm::StringRef Name) 
{
-  auto TargetNodes = match(valueDecl(hasName(Name)).bind("v"), ASTCtx);
+  auto TargetNodes = match(
+  valueDecl(unless(indirectFieldDecl()), hasName(Name)).bind("v"), ASTCtx);
   assert(TargetNodes.size() == 1 && "Name must be unique");
   auto *const Result = selectFirst("v", TargetNodes);
   assert(Result != nullptr);
Index: clang/lib/Analysis/FlowSensitive/Transfer.cpp
===
--- clang/lib/Analysis/FlowSensitive/Transfer.cpp
+++ clang/lib/Analysis/FlowSensitive/Transfer.cpp
@@ -543,6 +543,16 @@
 if (BaseLoc == nullptr)
   return;
 
+// Fields on anonymous records are treated as being part of the enclosing
+// records. So if we see a member access for an anonymous record, just pass
+// through the storage location of the base object.
+if (auto *Field = dyn_cast(Member)) {
+  if (Field->isAnonymousStructOrUnion()) {
+Env.setStorageLocation(*S, *BaseLoc);
+return;
+  }
+}
+
 auto &MemberLoc = BaseLoc->getChild(*Member);
 if (MemberLoc.getType()->isReferenceType()) {
   // Based on its type, `MemberLoc` must be mapped either to nothing or to 
a
Index: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
===
--- clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp
@@ -300,8 +300,12 @@
   !Type->isRecordType())
 return;
 
-  for (const FieldDecl *Field : Type->getAsRecordDecl()->fields())
-Fields.insert(Field);
+  for (const FieldDecl *Field : Type->getAsRecordDecl()->fields()) {
+if (Field->isAnonymousStructOrUnion())
+  getFieldsFromClassHierarchy(Field->getType(), Fields);
+else
+  Fields.insert(Field);
+  }
   if (auto *CXXRecord = Type->getAsCXXRecordDecl())
 for (const CXXBaseSpecifier &Base : CXXRecord->bases())
   getFieldsFromClassHierarchy(Base.getType(), Fields);


Index: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
===
--- clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
+++ clang/unittests/Analysis/FlowSensitive/TransferTest.cpp
@@ -5403,4 +5403,35 @@
   });
 }
 
+// Check that fields of anonymous records are modeled and treated as children
+// of the enclosing record.
+TEST(TransferTest, AnonymousStruct) {
+  std::string Code = R"(
+struct S {
+  struct {
+int i;
+  };
+};
+void target() {
+  S s;
+  (void)s.i;
+  // [[p]]
+}
+  )";
+  runDataflow(
+  Code,
+  [](const llvm::StringMap> &Results,
+ ASTContext &ASTCtx) {
+const Environment &Env = getEnvironmentAtAnnot

[PATCH] D153294: [clang] Do not create ExprWithCleanups while checking immediate invocation

2023-06-21 Thread Mariya Podchishchaeva via Phabricator via cfe-commits
Fznamznon added a comment.

> Thanks! We don't have any tests that break with this change, so I assume this 
> is not tested.

I suppose it could also be that in most cases we have enough places in Sema 
adding `ExprWithCleanups`. While trying to figure out why we need 
`ExprWithCleanups` wrapping immediate invocations I came to 
https://reviews.llvm.org/D63960 . There is 
https://reviews.llvm.org/D63960#inline-613559 asking to add wrapping that with 
an example, I added this example to the test and I suppose it didn't break 
after change since there is still an `ExprWithCleanups` around, I suppose it 
was added in another place.
In fact, I can't come up with the test that this patch would break. Either 
`ExprWithCleanups` is redundant or added by different parts of Sema.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153294

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


[PATCH] D133289: [C2X] N3007 Type inference for object definitions

2023-06-21 Thread Guillot Tony via Phabricator via cfe-commits
to268 updated this revision to Diff 533214.
to268 marked 8 inline comments as done.
to268 added a comment.

I have updated and fixed all minors comments about the test cases.
I have added the diagnostic to warn users about using a Clang extension when 
declaring an explicit `auto*` in pedantic mode.
I need to debug more about the two remaining diagnostics to fix:

- Wrong diagnostic when using the `_Atomic` attribute
- Misleading diagnostic where it should say that `auto is not allowed` but says 
that `[...] requires an initializer`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133289

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/C/C2x/n3007.c
  clang/test/CodeGen/auto.c
  clang/test/Parser/c2x-auto.c
  clang/test/Sema/c2x-auto.c
  clang/www/c_status.html

Index: clang/www/c_status.html
===
--- clang/www/c_status.html
+++ clang/www/c_status.html
@@ -1190,12 +1190,12 @@
 
   Underspecified object definitions
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3006.htm";>N3006
-  Unknown
+  Unknown
 
 
   Type inference for object declarations
   https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3007.htm";>N3007
-  No
+  Clang 17
 
 
   constexpr for object definitions
Index: clang/test/Sema/c2x-auto.c
===
--- /dev/null
+++ clang/test/Sema/c2x-auto.c
@@ -0,0 +1,119 @@
+// RUN: %clang_cc1 -std=c2x -verify -pedantic -Wno-comments %s
+
+void test_basic_types(void) {
+  auto undefined; // expected-error {{declaration of variable 'undefined' with deduced type 'auto' requires an initializer}}
+  auto auto_int = 4;
+  auto auto_long = 4UL;
+
+  _Static_assert(_Generic(auto_int, int : 1, default : 0));
+  _Static_assert(_Generic(auto_long, unsigned long : 1, default : 0));
+}
+
+void test_sizeof_typeof(void) {
+  auto auto_size = sizeof(auto);  // expected-error {{expected expression}}
+  typeof(auto) tpof = 4;  // expected-error {{expected expression}}
+}
+
+void test_casts(void) {
+  auto int_cast = (int)(4 + 3);
+  auto double_cast = (double)(1 / 3);
+  auto long_cast = (long)(4UL + 3UL);
+  auto auto_cast = (auto)(4 + 3); // expected-error {{expected expression}}
+
+  _Static_assert(_Generic(int_cast, int : 1, default : 0));
+  _Static_assert(_Generic(double_cast, double : 1, default : 0));
+  _Static_assert(_Generic(long_cast, long : 1, default : 0));
+}
+
+void test_compound_literral(void) {
+  auto int_cl = (int){13};
+  auto double_cl = (double){2.5};
+  auto array[] = { 1, 2, 3 }; // expected-error {{cannot use 'auto' with initializer list in C}}
+
+  auto auto_cl = (auto){13};  // expected-error {{expected expression}}
+
+  _Static_assert(_Generic(int_cl, int : 1, default : 0));
+  _Static_assert(_Generic(double_cl, double : 1, default : 0));
+}
+
+void test_array_pointers(void) {
+  double array[3] = { 0 };
+  auto a = array;
+  auto b = &array;
+
+  _Static_assert(_Generic(array, double * : 1, default : 0));
+  _Static_assert(_Generic(a, double * : 1, default : 0));
+  _Static_assert(_Generic(b, double (*)[3] : 1, default : 0));
+}
+
+void test_typeof() {
+  int typeof_target();
+  auto result = (typeof(typeof_target())){12};
+
+  _Static_assert(_Generic(result, int : 1, default : 0));
+}
+
+void test_qualifiers(const int y) {
+  const auto a = 12;
+  auto b = y;
+  static auto c = 1UL;
+  int* pa = &a; // expected-warning {{initializing 'int *' with an expression of type 'const int *' discards qualifiers}}
+  const int* pb = &b;
+  int* pc = &c; // expected-warning {{incompatible pointer types initializing 'int *' with an expression of type 'unsigned long *'}}
+
+  _Static_assert(_Generic(a, int : 1, default : 0));
+  _Static_assert(_Generic(b, int : 1, default : 0));
+  _Static_assert(_Generic(c, unsigned long : 1, default : 0));
+  _Static_assert(_Generic(pa, int * : 1, default : 0));
+  _Static_assert(_Generic(pb, const int * : 1, default : 0));
+  _Static_assert(_Generic(pc, int * : 1, default : 0));
+}
+
+void test_strings(void) {
+  auto str = "this is a string";
+  auto str2[] = "this is a string";
+  auto (str3) = "this is a string";
+  auto (((str4))) = "this is a string";
+
+  _Static_assert(_Generic(str, char * : 1, default : 0));
+  _Static_assert(_Generic(str2, char * : 1, default : 0));
+  _Static_assert(_Generic(str3, char * : 1, default : 0));
+  _Static_assert(_Generic(str4, char * : 1, default : 0));
+}
+
+void test_pointers(void) {
+  auto a = 12;
+  auto *ptr = &a; // expected-warning {{explicit declaration of 'auto' pointers is a Clang extension}}
+  auto *str = "this is a string"; // expected-warning {{explicit declaration of 'au

[PATCH] D153409: BEGIN_PUBLIC [clang][dataflow] Treat fields of anonymous records as being part of their parent.

2023-06-21 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:5433
+// that `i` is modeled.
+S->getChild(*IDecl);
+  });

assert that the result is non-null?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153409

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


[PATCH] D153409: BEGIN_PUBLIC [clang][dataflow] Treat fields of anonymous records as being part of their parent.

2023-06-21 Thread Martin Böhme via Phabricator via cfe-commits
mboehme marked an inline comment as done.
mboehme added inline comments.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:5433
+// that `i` is modeled.
+S->getChild(*IDecl);
+  });

sammccall wrote:
> assert that the result is non-null?
`getChild()` returns a reference, so the result can't be null. It asserts 
internally that the child exists, so if the child doesn't exist, we'll get an 
assertion failure.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153409

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


[PATCH] D153379: Remove -flang-experimental-exec flag

2023-06-21 Thread Andrzej Warzynski via Phabricator via cfe-commits
awarzynski accepted this revision.
awarzynski added a comment.
This revision is now accepted and ready to land.

This is in line with the conclusions of 
https://discourse.llvm.org/t/proposal-rename-flang-new-to-flang/:

> We should remove the need for the -flang-experimental-exec flag. There’s no 
> need to hide things to this level given the evolving maturity of LLVM’s 
> flang. This will be an immediate improvement for all flang-new users.

LGTM!

Thanks a ton @everythingfunctional , great to see this flag finally being 
removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153379

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


[PATCH] D151696: [x86] Remove CPU_SPECIFIC* MACROs and add getCPUDispatchMangling

2023-06-21 Thread Simon Pilgrim via Phabricator via cfe-commits
RKSimon added a comment.

Please can you cleanup the summary, as it isn't very easy to understand at the 
moment. Possibly split into a series of bullet points describing the changes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D151696

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


[PATCH] D150803: Add a new `wasm_custom` clang attribute for marking functions.

2023-06-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:5608-5612
+Clang supports the ``__attribute__((wasm_async))``
+attribute for the WebAssembly target. This attribute may be attached to a
+function definition, which indicates the function will be used with JavaScript
+promise integration (JSPI). The attribute will cause the creation of a custom
+section named "async" that contains each wasm_async function's index value.

aaron.ballman wrote:
> This could be my ignorance of web assembly showing, but the docs don't really 
> help me understand when you'd want to use this attribute. Perhaps a link to 
> what JSPI is and a code example would help a little bit? Or is this more of a 
> low-level implementation detail kind of attribute where folks already know 
> the domain?
Based on the documentation here, I'm wondering why the `annotate` attribute 
doesn't suffice? That attribute lets you specify custom information to 
associate with a declaration that then gets lowered such that passes can do 
whatever they want with the info, which seems to be a more generalized version 
of what this attribute is.

(FWIW, I'm back to having basically no idea when you'd use this attribute or 
what it would be used for, so my thoughts above might make no sense.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150803

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


[PATCH] D153092: [Clang][CodeGen]`vtable`, `typeinfo` et al. are globals

2023-06-21 Thread Alex Voicu via Phabricator via cfe-commits
AlexVlx added a comment.

Gentle ping.


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

https://reviews.llvm.org/D153092

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


[PATCH] D153146: [CLANG] Fix potential integer overflow value in getRVVTypeSize()

2023-06-21 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/AST/ASTContext.cpp:9567
 
   unsigned EltSize = Context.getTypeSize(Info.ElementType);
   unsigned MinElts = Info.EC.getKnownMinValue();

I think  I'd suggest just changing the types of these two variables instead of 
the cast.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153146

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


[PATCH] D153236: [NFC] Fix potential dereferencing of nullptr.

2023-06-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Parse/ParseStmt.cpp:886-887
 TopLevelCase = Case;
-  else
+  else {
+assert(DeepestParsedCaseStmt && "DeepestParsedCaseStmt cannot be 
null");
 Actions.ActOnCaseStmtBody(DeepestParsedCaseStmt, Case.get());

The `assert` doesn't add much value, this seems to be a false positive in the 
analysis.

If we have no top-level case statement yet, then we get into the `if` branch on 
line 884, but that then sets `DeepestParsedCaseStmt` on line 890, and that must 
be non-null because we verified that `Case` is valid above on line 876. So by 
the time we get into the `else` branch, `DeepestParsedCaseStmt` must be nonnull.

I don't think changes are needed here at all; WDYT?



Comment at: clang/lib/Sema/SemaExprObjC.cpp:2441
 
+  assert(receiverTypeInfo && "receiverTypeInfo cannot be null");
   return BuildClassMessage(receiverTypeInfo, ReceiverType,

schittir wrote:
> Fznamznon wrote:
> > That seems to be a strange place before and after changes. With or without 
> > change, when `ReceiverType.isNull()` is true we just end up passing 
> > `nullptr`  as `receiverTypeInfo ` to the `BuildClassMessage` which doesn't 
> > seem to be checking its non-nullness before dereferencing it, even though 
> > its description says that `receiverTypeInfo` can be null. 
> > I guess it is fine to pass `nullptr` to a function whose description says 
> > so, but the non-nullness check inside of it should be probably a bit more 
> > obvious than it is right now.
> I see your point about passing `ReceiverTypeInfo` as nullptr to 
> `BuildClassMessage` method - it seems ok to do that. 
> Would it make sense to add an `assert(ReceiverTypeInfo);` inside the method 
> as way of making the non-nullness check more obvious? 
I think there's a different assertion needed here. The invariant that 
`BuildClassMessage()` has is that the first argument (the `TypeSourceInfo *` 
needs to be nonnull if the third argument (the `SourceLocation`) is invalid. So 
I think this assert should be:

```
assert(((isSuperReceiver && Loc.isValid()) || receiverTypeInfo) &&
   "Either the super receiver location needs to be valid or the receiver 
needs valid type source information");
```



Comment at: clang/lib/Sema/SemaType.cpp:2711-2712
   // Only support _BitInt elements with byte-sized power of 2 NumBits.
   if (CurType->isBitIntType()) {
-unsigned NumBits = CurType->getAs()->getNumBits();
+unsigned NumBits = CurType->castAs()->getNumBits();
 if (!llvm::isPowerOf2_32(NumBits) || NumBits < 8) {

Slightly better fix so we don't do "isa" followed by "cast".


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

https://reviews.llvm.org/D153236

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-21 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D152436#4432736 , @balazske wrote:

> From these two solutions, which one is better? (Show many unnecessary notes, 
> or show only necessary ones but lose some of the useful notes too.)

How likely are the problems with the 2nd case? I know its a hassle, but can you 
upload results for the first and the second case? Its hard to tell without 
seeing how these pan out in the real world.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D153409: [clang][dataflow] Treat fields of anonymous records as being part of their parent.

2023-06-21 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.



Comment at: clang/lib/Analysis/FlowSensitive/DataflowAnalysisContext.cpp:305
+if (Field->isAnonymousStructOrUnion())
+  getFieldsFromClassHierarchy(Field->getType(), Fields);
+else

Could we somehow take advantage of the IndirectFieldDecl instead of recursing 
ourselves? Seems like that way we would be delegating to Clang the questions of 
the name injection/lookup.



Comment at: clang/unittests/Analysis/FlowSensitive/TransferTest.cpp:5427
+const ValueDecl *SDecl = findValueDecl(ASTCtx, "s");
+const ValueDecl *IDecl = findValueDecl(ASTCtx, "i");
+

Could we make some stronger assertion to prove that the transfer function 
works? It seems to me that getChild() by itself does not prove that.

For example, store and load the value and assert that it is the same.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153409

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


[clang] 6e04287 - [SystemZ] Fix regression in test macro-prefix-map-lambda.cpp

2023-06-21 Thread Kai Nacke via cfe-commits

Author: Kai Nacke
Date: 2023-06-21T12:53:15Z
New Revision: 6e042871837b0c87e045d1a16929a7da4412e073

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

LOG: [SystemZ] Fix regression in test macro-prefix-map-lambda.cpp

The failing test comes from https://reviews.llvm.org/D152570.
Root cause of the failure is that a string constant on SystemZ
has an alignment of 2, not 1. The CSKY target has a similar problem.
The solution is to replace the fixed number with a regex.

Reviewed By: uweigand, tuliom, Zibi

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

Added: 


Modified: 
clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp 
b/clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
index e87f0ab484dc4..19b2a47a14b64 100644
--- a/clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
+++ b/clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
@@ -8,7 +8,7 @@ auto lambdatest(f&& cb) {
 
 int main() {
   auto *s = lambdatest([](){});
-// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private 
unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at 
./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:[[#@LINE-1]]:24)]\00", align 1
+// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private 
unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at 
./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:[[#@LINE-1]]:24)]\00", align 
{{[0-9]+}}
 
   return 0;
 }



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


[PATCH] D153352: [SystemZ] Fix regression in test macro-prefix-map-lambda.cpp

2023-06-21 Thread Kai Nacke via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e042871837b: [SystemZ] Fix regression in test 
macro-prefix-map-lambda.cpp (authored by Kai).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153352

Files:
  clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp


Index: clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
===
--- clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
+++ clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
@@ -8,7 +8,7 @@
 
 int main() {
   auto *s = lambdatest([](){});
-// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private 
unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at 
./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:[[#@LINE-1]]:24)]\00", align 1
+// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private 
unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at 
./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:[[#@LINE-1]]:24)]\00", align 
{{[0-9]+}}
 
   return 0;
 }


Index: clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
===
--- clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
+++ clang/test/CodeGenCXX/macro-prefix-map-lambda.cpp
@@ -8,7 +8,7 @@
 
 int main() {
   auto *s = lambdatest([](){});
-// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at ./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:[[#@LINE-1]]:24)]\00", align 1
+// CHECK: @"__PRETTY_FUNCTION__._Z10lambdatestIZ4mainE3$_0EDaOT_" = private unnamed_addr constant [{{[0-9]+}} x i8] c"auto lambdatest(f &&) [f = (lambda at ./UNLIKELY_PATH/empty{{/|}}{{.*}}.cpp:[[#@LINE-1]]:24)]\00", align {{[0-9]+}}
 
   return 0;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153276: [clang][Interp] Reject reinterpret_cast expressions

2023-06-21 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/AST/Interp/Interp.h:1854
+  S.FFDiag(Loc, diag::note_constexpr_invalid_cast)
+  << static_cast(Kind) << S.Current->getRange(OpPC);
+  return false;

Should this be doing the cast? The overloaded operator accepts an 
`interp::CastKind` already?



Comment at: clang/lib/AST/Interp/PrimType.h:48
+  Reinterpret,
+  Dynamic,
+};

Should we bother adding this right now given it's not used or tested?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153276

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


[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-21 Thread Dan Gohman via Phabricator via cfe-commits
sunfish added a comment.

This patch appears to be just the release notes and the test; is the actual 
driver change missing?




Comment at: clang/docs/ReleaseNotes.rst:706
+  limited to the Emscripten target OS and now works with other targets such as
+  wasm32-wasi.
 

We should mention that this format is not yet stable and may change between 
LLVM versions, and that WASI does not yet have any facilities for loading 
dynamic libraries.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D153276: [clang][Interp] Reject reinterpret_cast expressions

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



Comment at: clang/lib/AST/Interp/Interp.h:1854
+  S.FFDiag(Loc, diag::note_constexpr_invalid_cast)
+  << static_cast(Kind) << S.Current->getRange(OpPC);
+  return false;

aaron.ballman wrote:
> Should this be doing the cast? The overloaded operator accepts an 
> `interp::CastKind` already?
The streaming operator there is for our `dump()` support, and the 
`note_constexpr_invalid_cast` diagnostic needs an integer to select the right 
string.



Comment at: clang/lib/AST/Interp/PrimType.h:48
+  Reinterpret,
+  Dynamic,
+};

aaron.ballman wrote:
> Should we bother adding this right now given it's not used or tested?
No strong opinion from my side, I can definitely remove it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153276

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


[PATCH] D153276: [clang][Interp] Reject reinterpret_cast expressions

2023-06-21 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 with the Dynamic bit pulled.




Comment at: clang/lib/AST/Interp/Interp.h:1854
+  S.FFDiag(Loc, diag::note_constexpr_invalid_cast)
+  << static_cast(Kind) << S.Current->getRange(OpPC);
+  return false;

tbaeder wrote:
> aaron.ballman wrote:
> > Should this be doing the cast? The overloaded operator accepts an 
> > `interp::CastKind` already?
> The streaming operator there is for our `dump()` support, and the 
> `note_constexpr_invalid_cast` diagnostic needs an integer to select the right 
> string.
Ah, that's right, this isn't calling the diagnostic streaming operator. 
Nevermind. :-)



Comment at: clang/lib/AST/Interp/PrimType.h:48
+  Reinterpret,
+  Dynamic,
+};

tbaeder wrote:
> aaron.ballman wrote:
> > Should we bother adding this right now given it's not used or tested?
> No strong opinion from my side, I can definitely remove it.
Let's yank it for the moment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153276

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


[PATCH] D153417: New CharSetConverter wrapper class for ConverterEBCDIC

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added a project: All.
abhina.sreeskantharajan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch is adding a wrapper class called CharSetConverter for 
ConverterEBCDIC which was added previously here 
https://reviews.llvm.org/rGb42718dcecdd6787e0fde826ef7377f4e3cdd7bd.

This is the base for two patches, the first will add-on iconv support to this 
CharSetConverter class so we can support more charsets. The other patch is the 
implementation of fexec-charset which relies on this CharSetConverter class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153417

Files:
  clang/include/clang/Basic/CharSet.h
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/CharSet.cpp
  clang/unittests/Basic/CMakeLists.txt
  clang/unittests/Basic/CharSetTest.cpp

Index: clang/unittests/Basic/CharSetTest.cpp
===
--- /dev/null
+++ clang/unittests/Basic/CharSetTest.cpp
@@ -0,0 +1,101 @@
+//===- unittests/Support/CharSetTest.cpp - Charset conversion tests ---===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "clang/Basic/CharSet.h"
+#include "llvm/ADT/SmallString.h"
+#include "gtest/gtest.h"
+using namespace llvm;
+
+namespace {
+
+// String "Hello World!"
+static const char HelloA[] =
+"\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x21\x0a";
+static const char HelloE[] =
+"\xC8\x85\x93\x93\x96\x40\xE6\x96\x99\x93\x84\x5A\x15";
+
+// String "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
+static const char ABCStrA[] =
+"\x41\x42\x43\x44\x45\x46\x47\x48\x49\x4A\x4B\x4C\x4D\x4E\x4F\x50\x51\x52"
+"\x53\x54\x55\x56\x57\x58\x59\x5A\x61\x62\x63\x64\x65\x66\x67\x68\x69\x6A"
+"\x6B\x6C\x6D\x6E\x6F\x70\x71\x72\x73\x74\x75\x76\x77\x78\x79\x7A";
+static const char ABCStrE[] =
+"\xC1\xC2\xC3\xC4\xC5\xC6\xC7\xC8\xC9\xD1\xD2\xD3\xD4\xD5\xD6\xD7\xD8\xD9"
+"\xE2\xE3\xE4\xE5\xE6\xE7\xE8\xE9\x81\x82\x83\x84\x85\x86\x87\x88\x89\x91"
+"\x92\x93\x94\x95\x96\x97\x98\x99\xA2\xA3\xA4\xA5\xA6\xA7\xA8\xA9";
+
+// String "¡¢£AÄÅÆEÈÉÊaàáâãäeèéêë"
+static const char AccentUTF[] =
+"\xc2\xa1\xc2\xa2\xc2\xa3\x41\xc3\x84\xc3\x85\xc3\x86\x45\xc3\x88\xc3\x89"
+"\xc3\x8a\x61\xc3\xa0\xc3\xa1\xc3\xa2\xc3\xa3\xc3\xa4\x65\xc3\xa8\xc3\xa9"
+"\xc3\xaa\xc3\xab";
+static const char AccentE[] = "\xaa\x4a\xb1\xc1\x63\x67\x9e\xc5\x74\x71\x72"
+  "\x81\x44\x45\x42\x46\x43\x85\x54\x51\x52\x53";
+
+// String with Cyrillic character ya.
+static const char CyrillicUTF[] = "\xd0\xaf";
+
+TEST(CharSet, FromUTF8) {
+  // Hello string.
+  StringRef Src(HelloA);
+  SmallString<64> Dst;
+
+  CharSetConverter Conv = CharSetConverter::create(text_encoding::id::UTF8,
+   text_encoding::id::IBM1047);
+  std::error_code EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(HelloE, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // ABC string.
+  Src = ABCStrA;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(ABCStrE, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // Accent string.
+  Src = AccentUTF;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(AccentE, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // Cyrillic string. Results in error because not representable in 1047.
+  Src = CyrillicUTF;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_EQ(EC, std::errc::illegal_byte_sequence);
+}
+
+TEST(CharSet, ToUTF8) {
+  // Hello string.
+  StringRef Src(HelloE);
+  SmallString<64> Dst;
+
+  CharSetConverter Conv = CharSetConverter::create(text_encoding::id::IBM1047,
+   text_encoding::id::UTF8);
+  std::error_code EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(HelloA, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // ABC string.
+  Src = ABCStrE;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(ABCStrA, static_cast(Dst).c_str());
+  Dst.clear();
+
+  // Accent string.
+  Src = AccentE;
+  EC = Conv.convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(AccentUTF, static_cast(Dst).c_str());
+}
+
+} // namespace
Index: clang/unittests/Basic/CMakeLists.txt
===
--- clang/unittests/Basic/CMakeLists.txt
+++ clang/unittests/Basic/CMakeLists.txt
@@ -4,6 +4,7 @@
 
 add_clang_unittest(BasicTests
   CharInfoTest.cpp
+  CharSetTest.cpp
   DarwinSDKInfoTest.cpp
   DiagnosticTest.cpp
   FileEntryTest.cpp
Index: clang/lib/Basic/CharSet.cpp
=

[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added a project: All.
abhina.sreeskantharajan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds iconv support to the CharSetConverter class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153418

Files:
  clang/include/clang/Basic/CharSet.h
  clang/include/clang/Config/config.h.cmake
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/CharSet.cpp
  clang/unittests/Basic/CharSetTest.cpp

Index: clang/unittests/Basic/CharSetTest.cpp
===
--- clang/unittests/Basic/CharSetTest.cpp
+++ clang/unittests/Basic/CharSetTest.cpp
@@ -40,6 +40,29 @@
 // String with Cyrillic character ya.
 static const char CyrillicUTF[] = "\xd0\xaf";
 
+// String "Earth地球".
+// ISO-2022-JP: Sequence ESC $ B (\x1B\x24\x42) switches to JIS X 0208-1983, and
+// sequence ESC ( B (\x1B\x28\x42) switches back to ASCII.
+// IBM-939: Byte 0x0E shifts from single byte to double byte, and 0x0F shifts
+// back.
+static const char EarthUTF[] = "\x45\x61\x72\x74\x68\xe5\x9c\xb0\xe7\x90\x83";
+// Identical to above, except the final character (球) has its last byte taken
+// away from it.
+static const char EarthUTFBroken[] = "\x45\x61\x72\x74\x68\xe5\x9c\xb0\xe7\x90";
+static const char EarthISO2022[] =
+"\x45\x61\x72\x74\x68\x1B\x24\x42\x43\x4F\x35\x65\x1B\x28\x42";
+static const char EarthISO2022ShiftBack[] =
+"\x45\x61\x72\x74\x68\x1B\x24\x42\x43\x4F\x35\x65";
+static const char EarthIBM939[] =
+"\xc5\x81\x99\xa3\x88\x0e\x45\xc2\x48\xdb\x0f";
+static const char ShiftBackOnly[] = "\x1B\x28\x42";
+
+// String "地球".
+static const char EarthKanjiOnlyUTF[] = "\xe5\x9c\xb0\xe7\x90\x83";
+static const char EarthKanjiOnlyISO2022[] =
+"\x1B\x24\x42\x43\x4F\x35\x65\x1b\x28\x42";
+static const char EarthKanjiOnlyIBM939[] = "\x0e\x45\xc2\x48\xdb\x0f";
+
 TEST(CharSet, FromUTF8) {
   // Hello string.
   StringRef Src(HelloA);
@@ -98,4 +121,154 @@
   EXPECT_STREQ(AccentUTF, static_cast(Dst).c_str());
 }
 
+TEST(CharSet, RoundTrip) {
+  ErrorOr ConvToUTF16 =
+  CharSetConverter::create("IBM-1047", "UTF-16");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToUTF16) {
+ASSERT_EQ(ConvToUTF16.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+  ErrorOr ConvToUTF32 =
+  CharSetConverter::create("UTF-16", "UTF-32");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToUTF32) {
+ASSERT_EQ(ConvToUTF32.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+  ErrorOr ConvToEBCDIC =
+  CharSetConverter::create("UTF-32", "IBM-1047");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToEBCDIC) {
+ASSERT_EQ(ConvToEBCDIC.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // Setup source string.
+  char SrcStr[256];
+  for (size_t I = 0; I < 256; ++I)
+SrcStr[I] = (I + 1) % 256;
+
+  SmallString<99> Dst1Str, Dst2Str, Dst3Str;
+
+  std::error_code EC = ConvToUTF16->convert(StringRef(SrcStr), Dst1Str, true);
+  EXPECT_TRUE(!EC);
+  EC = ConvToUTF32->convert(Dst1Str, Dst2Str, true);
+  EXPECT_TRUE(!EC);
+  EC = ConvToEBCDIC->convert(Dst2Str, Dst3Str, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(SrcStr, static_cast(Dst3Str).c_str());
+}
+
+TEST(CharSet, ShiftState2022) {
+  // Earth string.
+  StringRef Src(EarthUTF);
+  SmallString<64> Dst;
+
+  ErrorOr ConvTo2022 =
+  CharSetConverter::create("UTF-8", "ISO-2022-JP");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvTo2022) {
+ASSERT_EQ(ConvTo2022.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // Check that the string is properly converted.
+  std::error_code EC = ConvTo2022->convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(EarthISO2022, static_cast(Dst).c_str());
+}
+
+TEST(CharSet, ShiftState2022Flush) {
+  StringRef Src0(EarthUTFBroken);
+  StringRef Src1(EarthKanjiOnlyUTF);
+  SmallString<64> Dst0;
+  SmallString<64> Dst1;
+  ErrorOr ConvTo2022Flush =
+  CharSetConverter::create("UTF-8", "ISO-2022-JP");
+  if (!ConvTo2022Flush) {
+ASSERT_EQ(ConvTo2022Flush.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // This should emit an error; there is a malformed multibyte character in the
+  // input string.
+  std::error_code EC0 = ConvTo2022Flush->convert(Src0, Dst0, true);
+  EXPECT_TRUE(EC0);
+  std::error_code EC1 = ConvTo2022Flush->flush();
+  EXPECT_TRUE(!EC1);
+  std::error_code EC2 = ConvTo2022Flush->convert(Src1, Dst1, true);
+  EXPECT_TRUE(!EC2);
+  EXPECT_STREQ(EarthKanjiOnlyISO2022, static_cast(Dst1).c_str());
+}
+
+TEST(CharSet, Sh

[PATCH] D153419: Enable fexec-charset option

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
abhina.sreeskantharajan requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

This patch enables the fexec-charset option to control the execution charset of 
string literals. It sets the default internal charset, system charset, and 
execution charset for z/OS and UTF-8 for all other platforms.
This patch depends on adding the CharSetConverter class 
https://reviews.llvm.org/D153417


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153419

Files:
  clang/docs/LanguageExtensions.rst
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Basic/TokenKinds.h
  clang/include/clang/Driver/Options.td
  clang/include/clang/Lex/LiteralConverter.h
  clang/include/clang/Lex/LiteralSupport.h
  clang/include/clang/Lex/Preprocessor.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInstance.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Lex/CMakeLists.txt
  clang/lib/Lex/LiteralConverter.cpp
  clang/lib/Lex/LiteralSupport.cpp
  clang/test/CodeGen/systemz-charset.c
  clang/test/CodeGen/systemz-charset.cpp
  clang/test/Driver/cl-options.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Preprocessor/init-s390x.c
  clang/test/Preprocessor/init-x86.c
  llvm/include/llvm/TargetParser/Triple.h
  llvm/lib/TargetParser/Triple.cpp

Index: llvm/lib/TargetParser/Triple.cpp
===
--- llvm/lib/TargetParser/Triple.cpp
+++ llvm/lib/TargetParser/Triple.cpp
@@ -1193,6 +1193,13 @@
   return Tmp.split('-').second;  // Strip second component
 }
 
+// System charset on z/OS is IBM-1047 and UTF-8 otherwise
+StringRef Triple::getSystemCharset() const {
+  if (getOS() == llvm::Triple::ZOS)
+return "IBM-1047";
+  return "UTF-8";
+}
+
 static VersionTuple parseVersionFromName(StringRef Name) {
   VersionTuple Version;
   Version.tryParse(Name);
Index: llvm/include/llvm/TargetParser/Triple.h
===
--- llvm/include/llvm/TargetParser/Triple.h
+++ llvm/include/llvm/TargetParser/Triple.h
@@ -436,6 +436,9 @@
   /// string (separated by a '-' if the environment component is present).
   StringRef getOSAndEnvironmentName() const;
 
+  /// getSystemCharset - Get the system charset of the triple.
+  StringRef getSystemCharset() const;
+
   /// @}
   /// @name Convenience Predicates
   /// @{
Index: clang/test/Preprocessor/init-x86.c
===
--- clang/test/Preprocessor/init-x86.c
+++ clang/test/Preprocessor/init-x86.c
@@ -1297,7 +1297,7 @@
 // X86_64-CLOUDABI:#define __amd64 1
 // X86_64-CLOUDABI:#define __amd64__ 1
 // X86_64-CLOUDABI:#define __clang__ 1
-// X86_64-CLOUDABI:#define __clang_literal_encoding__ {{.*}}
+// X86_64-CLOUDABI:#define __clang_literal_encoding__ UTF-8
 // X86_64-CLOUDABI:#define __clang_major__ {{.*}}
 // X86_64-CLOUDABI:#define __clang_minor__ {{.*}}
 // X86_64-CLOUDABI:#define __clang_patchlevel__ {{.*}}
Index: clang/test/Preprocessor/init-s390x.c
===
--- clang/test/Preprocessor/init-s390x.c
+++ clang/test/Preprocessor/init-s390x.c
@@ -201,4 +201,5 @@
 // S390X-ZOS:   #define __TOS_390__ 1
 // S390X-ZOS:   #define __TOS_MVS__ 1
 // S390X-ZOS:   #define __XPLINK__ 1
+// S390X-ZOS:   #define __clang_literal_encoding__ IBM-1047
 // S390X-ZOS-GNUXX: #define __wchar_t 1
Index: clang/test/Driver/clang_f_opts.c
===
--- clang/test/Driver/clang_f_opts.c
+++ clang/test/Driver/clang_f_opts.c
@@ -226,8 +226,14 @@
 // RUN: %clang -### -S -finput-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-CHARSET %s
 // CHECK-INVALID-CHARSET: error: invalid value 'iso-8859-1' in '-finput-charset=iso-8859-1'
 
-// RUN: %clang -### -S -fexec-charset=iso-8859-1 -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
-// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'iso-8859-1' in '-fexec-charset=iso-8859-1'
+// RUN: %clang -### -S -fexec-charset=invalid-charset -o /dev/null %s 2>&1 | FileCheck -check-prefix=CHECK-INVALID-INPUT-CHARSET %s
+// CHECK-INVALID-INPUT-CHARSET: error: invalid value 'invalid-charset' in '-fexec-charset=invalid-charset'
+
+// Test that we support the following exec charsets.
+// RUN: %clang -### -S -fexec-charset=UTF-8 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=ISO8859-1 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// RUN: %clang -### -S -fexec-charset=IBM-1047 -o /dev/null %s 2>&1 | FileCheck --check-prefix=INVALID %s
+// INVALID-NOT: error: invalid value
 
 // Test that we don't error on these.
 // RUN: %clang -###

[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-21 Thread Joel Dice via Phabricator via cfe-commits
dicej added a comment.

In D153293#4437583 , @sunfish wrote:

> This patch appears to be just the release notes and the test; is the actual 
> driver change missing?

Sorry -- this is the first time I've used `arc`, and I apparently messed up.  I 
meant to add an extra commit on top of the original, but it just replaced the 
original.  I'll combine them and expand the release notes per your comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D153276: [clang][Interp] Reject reinterpret_cast expressions

2023-06-21 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder updated this revision to Diff 533238.

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

https://reviews.llvm.org/D153276

Files:
  clang/lib/AST/Interp/ByteCodeExprGen.cpp
  clang/lib/AST/Interp/ByteCodeExprGen.h
  clang/lib/AST/Interp/Disasm.cpp
  clang/lib/AST/Interp/Interp.h
  clang/lib/AST/Interp/Opcodes.td
  clang/lib/AST/Interp/PrimType.h
  clang/test/AST/Interp/unsupported.cpp

Index: clang/test/AST/Interp/unsupported.cpp
===
--- clang/test/AST/Interp/unsupported.cpp
+++ clang/test/AST/Interp/unsupported.cpp
@@ -47,3 +47,11 @@
 return 0;
   }
 }
+
+namespace Casts {
+  constexpr int a = reinterpret_cast(12); // expected-error {{must be initialized by a constant expression}} \
+   // expected-note {{reinterpret_cast is not allowed}} \
+   // ref-error {{must be initialized by a constant expression}} \
+   // ref-note {{reinterpret_cast is not allowed}}
+
+}
Index: clang/lib/AST/Interp/PrimType.h
===
--- clang/lib/AST/Interp/PrimType.h
+++ clang/lib/AST/Interp/PrimType.h
@@ -13,6 +13,7 @@
 #ifndef LLVM_CLANG_AST_INTERP_TYPE_H
 #define LLVM_CLANG_AST_INTERP_TYPE_H
 
+#include "llvm/Support/raw_ostream.h"
 #include 
 #include 
 #include 
@@ -42,6 +43,11 @@
   PT_FnPtr,
 };
 
+enum class CastKind : uint8_t {
+  Reinterpret,
+};
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, interp::CastKind CK);
+
 constexpr bool isIntegralType(PrimType T) { return T <= PT_Uint64; }
 
 /// Mapping from primitive types to their representation.
Index: clang/lib/AST/Interp/Opcodes.td
===
--- clang/lib/AST/Interp/Opcodes.td
+++ clang/lib/AST/Interp/Opcodes.td
@@ -51,6 +51,7 @@
 def ArgFltSemantics : ArgType { let Name = "const llvm::fltSemantics *"; }
 def ArgRoundingMode : ArgType { let Name = "llvm::RoundingMode"; }
 def ArgLETD: ArgType { let Name = "const LifetimeExtendedTemporaryDecl *"; }
+def ArgCastKind : ArgType { let Name = "CastKind"; }
 
 //===--===//
 // Classes of types instructions operate on.
@@ -636,3 +637,6 @@
 
 // [] -> []
 def Invalid : Opcode {}
+def InvalidCast : Opcode {
+  let Args = [ArgCastKind];
+}
Index: clang/lib/AST/Interp/Interp.h
===
--- clang/lib/AST/Interp/Interp.h
+++ clang/lib/AST/Interp/Interp.h
@@ -1849,6 +1849,14 @@
   return false;
 }
 
+/// Same here, but only for casts.
+inline bool InvalidCast(InterpState &S, CodePtr OpPC, CastKind Kind) {
+  const SourceLocation &Loc = S.Current->getLocation(OpPC);
+  S.FFDiag(Loc, diag::note_constexpr_invalid_cast)
+  << static_cast(Kind) << S.Current->getRange(OpPC);
+  return false;
+}
+
 //===--===//
 // Read opcode arguments
 //===--===//
Index: clang/lib/AST/Interp/Disasm.cpp
===
--- clang/lib/AST/Interp/Disasm.cpp
+++ clang/lib/AST/Interp/Disasm.cpp
@@ -73,3 +73,15 @@
 Anon->dump();
   }
 }
+
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, interp::CastKind CK) {
+  switch (CK) {
+  case interp::CastKind::Reinterpret:
+OS << "reinterpret_cast";
+break;
+  case interp::CastKind::Dynamic:
+OS << "dynamic_cast";
+break;
+  }
+  return OS;
+}
Index: clang/lib/AST/Interp/ByteCodeExprGen.h
===
--- clang/lib/AST/Interp/ByteCodeExprGen.h
+++ clang/lib/AST/Interp/ByteCodeExprGen.h
@@ -98,6 +98,7 @@
   bool VisitLambdaExpr(const LambdaExpr *E);
   bool VisitPredefinedExpr(const PredefinedExpr *E);
   bool VisitCXXThrowExpr(const CXXThrowExpr *E);
+  bool VisitCXXReinterpretCastExpr(const CXXReinterpretCastExpr *E);
 
 protected:
   bool visitExpr(const Expr *E) override;
Index: clang/lib/AST/Interp/ByteCodeExprGen.cpp
===
--- clang/lib/AST/Interp/ByteCodeExprGen.cpp
+++ clang/lib/AST/Interp/ByteCodeExprGen.cpp
@@ -1113,6 +1113,15 @@
   return this->emitInvalid(E);
 }
 
+template 
+bool ByteCodeExprGen::VisitCXXReinterpretCastExpr(
+const CXXReinterpretCastExpr *E) {
+  if (!this->discard(E->getSubExpr()))
+return false;
+
+  return this->emitInvalidCast(CastKind::Reinterpret, E);
+}
+
 template  bool ByteCodeExprGen::discard(const Expr *E) {
   if (E->containsErrors())
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-21 Thread Joel Dice via Phabricator via cfe-commits
dicej added a comment.

In D153293#4436629 , @sbc100 wrote:

> I'm happy to merge it, but perhaps we should get @sunfish to lg too.
>
> Also, should we remove the `-experimental-pic` linker flag, or are you OK 
> with that warning from the linker?   If yes, I wonder if we should do that as 
> part of this CL or a followup?

Do `emscripten` users see that warning, too?  I'd like to match whatever they 
see (or don't see).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D93031: Enable fexec-charset option

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan abandoned this revision.
abhina.sreeskantharajan added a comment.

I have opened a new patch https://reviews.llvm.org/D153419 and am closing this 
revision


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D93031

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-21 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

In D152436#4432736 , @balazske wrote:

> [...]
> From these two solutions, which one is better? (Show many unnecessary notes, 
> or show only necessary ones but lose some of the useful notes too.)

I think we must avoid polluting the environment with unnecessary notes 
(especially if we'd emit "many" of them), so I strongly suggest option 2.

Later it would be possible to fix the limitations of the interestingness 
system, e.g. by introducing a "mark all symbols in this expression as 
interesting" function. Perhaps we should open a separate discussion about this 
on discourse -- but this review and the de-alpha-ing of StdCLibraryFunctions 
should not be delayed by this tangentially related engine improvement!

Personally I think it's completely acceptable if the analyzer sometimes emits 
bug reports that are true positives but lack a message like 
"expected-note{{Function returns 1}}" as I'd guess that in the majority of 
these cases it wouldn't be terribly difficult for the user to manually derive 
this information from the context. (I'd say that even the previously 
highlighted fileno report 

 is acceptable -- it's surprising at first, but all bug reports come with an 
implicit //"On a certain execution path..."// prefix and in this case it's easy 
to see that "certain" = "when fileno returns -1".)

If these issues produce //lots// of issues that are //very// confusing, then we 
should put the affected functions behind off-by-default flags, finish this 
review process, and revisit them later when the interestingness system is 
improved; but based on the available information I don't think that's necessary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-21 Thread Joel Dice via Phabricator via cfe-commits
dicej updated this revision to Diff 533243.
dicej added a comment.

update release notes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/utils/lit/lit/llvm/config.py

Index: llvm/utils/lit/lit/llvm/config.py
===
--- llvm/utils/lit/lit/llvm/config.py
+++ llvm/utils/lit/lit/llvm/config.py
@@ -328,6 +328,9 @@
 return False
 
 def make_itanium_abi_triple(self, triple):
+if triple == "wasm32-wasi":
+return triple
+
 m = re.match(r"(\w+)-(\w+)-(\w+)", triple)
 if not m:
 self.lit_config.fatal(
@@ -339,6 +342,9 @@
 return m.group(1) + "-" + m.group(2) + "-" + m.group(3) + "-gnu"
 
 def make_msabi_triple(self, triple):
+if triple == "wasm32-wasi":
+return triple
+
 m = re.match(r"(\w+)-(\w+)-(\w+)", triple)
 if not m:
 self.lit_config.fatal("Could not turn '%s' into MS ABI triple" % triple)
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -99,13 +99,6 @@
 return Reloc::Static;
   }
 
-  if (!TT.isOSEmscripten()) {
-// Relocation modes other than static are currently implemented in a way
-// that only works for Emscripten, so disable them if we aren't targeting
-// Emscripten.
-return Reloc::Static;
-  }
-
   return *RM;
 }
 
Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -33,6 +33,20 @@
 // LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// -shared should be passed through to `wasm-ld` and not include crt1.o with a known OS.
+
+// RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
+// LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
+// -shared should be passed through to `wasm-ld` and not include crt1.o with an unknown OS.
+
+// RUN: %clang -### -shared --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_UNKNOWN_SHARED %s
+// LINK_UNKNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_UNKNOWN_SHARED: wasm-ld{{.*}}" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C link command-line with optimization with known OS.
 
 // RUN: %clang -### -O2 --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
@@ -46,6 +60,18 @@
 // RUN:   | FileCheck -check-prefix=COMPILE %s
 // COMPILE: "-cc1" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
 
+// -fPIC should work on a known OS
+
+// RUN: %clang -### -fPIC --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=COMPILE_KNOWN_PIC %s
+// COMPILE_KNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
+
+// -fPIC should work on an unknown OS
+
+// RUN: %clang -### -fPIC --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=COMPILE_UNKNOWN_PIC %s
+// COMPILE_UNKNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2"
+
 // Thread-related command line tests.
 
 // '-pthread' sets +atomics, +bulk-memory, +mutable-globals, +sign-ext, and --shared-memory
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -101,13 +101,16 @@
   << CM << A->getOption().getName();
 }
   }
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, options::OPT_shared))
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
   if (Entry) {
 CmdArgs.push_back(Args.MakeArgString("--entry"));
 CmdArgs.push_back(Args.MakeArgString(Entry));
   }
 
+  if (Args.hasArg(options::OPT_shared))
+  CmdArgs.push_back(Args.MakeArgString("-shared"));
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_

[PATCH] D153423: [clang-tidy] Allow explicit throwing in bugprone-exception-escape for special functions

2023-06-21 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
PiotrZSL added reviewers: njames93, carlosgalvezp, isuckatcs, JonasToth, 
baloghadamsoftware.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

Functions declared explicitly with noexcept(false) or throw(exception)
will be excluded from the analysis, as even though it is not recommended for
functions like swap, main, move constructors and assignment operators,
and destructors, it is a clear indication of the developer's intention and
should be respected.

Fixes: https://github.com/llvm/llvm-project/issues/40583

  https://github.com/llvm/llvm-project/issues/55143


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153423

Files:
  clang-tools-extra/clang-tidy/bugprone/ExceptionEscapeCheck.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-escape.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape-coro.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -152,7 +152,7 @@
 }
 
 // FIXME: In this case 'a' is convertible to the handler and should be caught
-// but in reality it's thrown. Note that clang doesn't report a warning for 
+// but in reality it's thrown. Note that clang doesn't report a warning for
 // this either.
 void throw_catch_multi_ptr_5() noexcept {
   try {
@@ -249,7 +249,7 @@
 void throw_derived_catch_base_ptr_c() noexcept {
   try {
 derived d;
-throw &d; 
+throw &d;
   } catch(const base *) {
   }
 }
@@ -259,7 +259,7 @@
   try {
 derived d;
 const derived *p = &d;
-throw p; 
+throw p;
   } catch(base *) {
   }
 }
@@ -282,7 +282,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_private' which should not throw exceptions
   try {
 B b;
-throw b; 
+throw b;
   } catch(A) {
   }
 }
@@ -291,7 +291,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_private_ptr' which should not throw exceptions
   try {
 B b;
-throw &b; 
+throw &b;
   } catch(A *) {
   }
 }
@@ -300,7 +300,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_protected' which should not throw exceptions
   try {
 C c;
-throw c; 
+throw c;
   } catch(A) {
   }
 }
@@ -309,7 +309,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_protected_ptr' which should not throw exceptions
   try {
 C c;
-throw &c; 
+throw &c;
   } catch(A *) {
   }
 }
@@ -318,7 +318,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_ambiguous' which should not throw exceptions
   try {
 E e;
-throw e; 
+throw e;
   } catch(A) {
   }
 }
@@ -327,7 +327,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_ambiguous_ptr' which should not throw exceptions
   try {
 E e;
-throw e; 
+throw e;
   } catch(A) {
   }
 }
@@ -703,3 +703,28 @@
   throw 1;
   return 0;
 }
+
+namespace PR55143 { namespace PR40583 {
+
+struct test_explicit_throw {
+test_explicit_throw() throw(int) { throw 42; }
+test_explicit_throw(const test_explicit_throw&) throw(int) { throw 42; }
+test_explicit_throw(test_explicit_throw&&) throw(int) { throw 42; }
+test_explicit_throw& operator=(const test_explicit_throw&) throw(int) { throw 42; }
+test_explicit_throw& operator=(test_explicit_throw&&) throw(int) { throw 42; }
+~test_explicit_throw() throw(int) { throw 42; }
+};
+
+struct test_implicit_throw {
+test_implicit_throw() { throw 42; }
+test_implicit_throw(const test_implicit_throw&) { throw 42; }
+test_implicit_throw(test_implicit_throw&&) { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function 'test_implicit_throw' which should not throw exceptions
+test_implicit_throw& operator=(const test_implicit_throw&) { throw 42; }
+test_implicit_throw& operator=(test_implicit_throw&&) { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:26: warning: an exception may be thrown in function 'operator=' which should not throw exceptions
+~test_implicit_throw() { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in function '~test_implicit_throw' which should not throw exceptions
+};
+
+}}
Index: clang-too

[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-06-21 Thread Vladislav Dzhidzhoev via Phabricator via cfe-commits
dzhidzhoev added a comment.

In D144006#4435677 , @hoy wrote:

> Hello, I'm seeing a build failure that seems related to this patch. I'm 
> seeing the patch has been relanded and reverted a couple times and not sure 
> where it is right now. Can you please confirm if the failure is related and 
> fixed? Thanks.

Hello! Currently, the commit is reverted (in commit 
6bea8331f9e09ba94a225c65becd4224a1a473af 
). Does 
the build failure still occur with it?
Could you provide a reproducing code for the crash?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

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


[PATCH] D153424: [clang][ASTImporter] Add import of CXXRewrittenBinaryOperator.

2023-06-21 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: steakhal, martong, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: All.
balazske requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153424

Files:
  clang/lib/AST/ASTImporter.cpp
  clang/test/ASTMerge/cxx-rewritten-binary-operator/Inputs/rbo.cpp
  clang/test/ASTMerge/cxx-rewritten-binary-operator/Inputs/std-compare.h
  clang/test/ASTMerge/cxx-rewritten-binary-operator/test.cpp

Index: clang/test/ASTMerge/cxx-rewritten-binary-operator/test.cpp
===
--- /dev/null
+++ clang/test/ASTMerge/cxx-rewritten-binary-operator/test.cpp
@@ -0,0 +1,3 @@
+// RUN: %clang_cc1 -std=c++20 -emit-pch -o %t.1.ast %S/Inputs/rbo.cpp
+// RUN: %clang_cc1 -std=c++20 -ast-merge %t.1.ast -fsyntax-only %s 2>&1 | FileCheck --allow-empty %s
+// CHECK-NOT: unsupported AST node
Index: clang/test/ASTMerge/cxx-rewritten-binary-operator/Inputs/std-compare.h
===
--- /dev/null
+++ clang/test/ASTMerge/cxx-rewritten-binary-operator/Inputs/std-compare.h
@@ -0,0 +1,307 @@
+#ifndef STD_COMPARE_H
+#define STD_COMPARE_H
+
+namespace std {
+inline namespace __1 {
+
+// exposition only
+enum class _EqResult : unsigned char {
+  __equal = 0,
+  __equiv = __equal,
+};
+
+enum class _OrdResult : signed char {
+  __less = -1,
+  __greater = 1
+};
+
+enum class _NCmpResult : signed char {
+  __unordered = -127
+};
+
+struct _CmpUnspecifiedType;
+using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();
+
+class partial_ordering {
+  using _ValueT = signed char;
+  explicit constexpr partial_ordering(_EqResult __v) noexcept
+  : __value_(_ValueT(__v)) {}
+  explicit constexpr partial_ordering(_OrdResult __v) noexcept
+  : __value_(_ValueT(__v)) {}
+  explicit constexpr partial_ordering(_NCmpResult __v) noexcept
+  : __value_(_ValueT(__v)) {}
+
+  constexpr bool __is_ordered() const noexcept {
+return __value_ != _ValueT(_NCmpResult::__unordered);
+  }
+
+public:
+  // valid values
+  static const partial_ordering less;
+  static const partial_ordering equivalent;
+  static const partial_ordering greater;
+  static const partial_ordering unordered;
+
+  // comparisons
+  friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+  friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+
+  friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
+  friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
+
+  // test helper
+  constexpr bool test_eq(partial_ordering const &other) const noexcept {
+return __value_ == other.__value_;
+  }
+
+private:
+  _ValueT __value_;
+};
+
+inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
+inline constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv);
+inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
+inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
+constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ == 0;
+}
+constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ < 0;
+}
+constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ <= 0;
+}
+constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ > 0;
+}
+constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
+  return __v.__is_ordered() && __v.__value_ >= 0;
+}
+constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) 

[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-21 Thread Balázs Benics via Phabricator via cfe-commits
steakhal resigned from this revision.
steakhal added a comment.

I resign as a reviewer as I'm not deeply connected to this checker, thus I 
won't block it or accept it.
However, my opinion is that a checker should be "released" if they have clear 
diagnostics (which includes that it doesn't flood the user with unimportant 
diagnostics either).
Consequently, if there are features missing to accomplish that, then that thing 
is a blocker.

TBH I never understood why interestingness is not transitive over the `SymExpr` 
dependencies (`symbols_begin/end`).
This was not the only case when it hindered us. Just think of how taint 
propagates 
.

In D152436#4437692 , @donat.nagy 
wrote:

> Personally I think it's completely acceptable if the analyzer sometimes emits 
> bug reports that are true positives but lack a message [...]

I must admit that I'm in the other camp.

> If these issues produce //lots// of issues that are //very// confusing, then 
> we should put the affected functions behind off-by-default flags, finish this 
> review process, and revisit them later when the interestingness system is 
> improved; but based on the available information I don't think that's 
> necessary.

I can agree with this pragmatic approach.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D153423: [clang-tidy] Allow explicit throwing in bugprone-exception-escape for special functions

2023-06-21 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/bugprone/exception-escape.rst:29
+and destructors, it is a clear indication of the developer's intention and
+should be respected..
+

Double period.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153423

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


[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-21 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added a comment.

In D153293#4437644 , @dicej wrote:

> In D153293#4436629 , @sbc100 wrote:
>
>> I'm happy to merge it, but perhaps we should get @sunfish to lg too.
>>
>> Also, should we remove the `-experimental-pic` linker flag, or are you OK 
>> with that warning from the linker?   If yes, I wonder if we should do that 
>> as part of this CL or a followup?
>
> Do `emscripten` users see that warning, too?  I'd like to match whatever they 
> see (or don't see).

No, the emscripten driver (emcc) currently adds `--experimental-pic` to the 
linker flags to avoid this warning.  We could gladly remove that if it becomes 
the default.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D153338: [clang-format] vim integration: Mention python3 variant of bindings

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

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153338

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-21 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings added inline comments.



Comment at: clang/lib/Basic/CMakeLists.txt:62
+if(Iconv_FOUND AND NOT Iconv_IS_BUILT_IN)
+  set(system_libs ${system_libs} ${Iconv_LIBRARIES})
+endif()

This doesn't look like an idomatic way to link a library. Could you use [[ 
https://cmake.org/cmake/help/latest/command/target_link_libraries.html | 
target_link_libraries ]] instead?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

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


[PATCH] D153430: Warn on invalid Arm or AArch64 baremetal target triple

2023-06-21 Thread Michael Platings via Phabricator via cfe-commits
michaelplatings created this revision.
michaelplatings added reviewers: peter.smith, DavidSpickett.
Herald added subscribers: abidh, kristof.beyls.
Herald added a project: All.
michaelplatings requested review of this revision.
Herald added subscribers: llvm-commits, cfe-commits, MaskRay.
Herald added projects: clang, LLVM.

A common user mistake is specifying a target of aarch64-none-eabi or
arm-none-elf whereas the correct names are aarch64-none-elf &
arm-none-eabi. Currently if a target of aarch64-none-eabi is specified
then the Generic_ELF toolchain is used, unlike aarch64-none-elf which
will use the BareMetal toolchain. This is unlikely to be intended by the
user so issue a warning that the target is invalid.

The target parser is liberal in what input it accepts so invalid triples
may yield behaviour that's sufficiently close to what the user intended.
Therefore invalid triples were used in many tests. This change updates
those tests to use valid triples.
One test (gnu-mcount.c) relies on the Generic_ELF toolchain behaviour so
change it to explicitly specify aarch64-unknown-none-gnu as the target.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153430

Files:
  clang/include/clang/Basic/DiagnosticCommonKinds.td
  clang/lib/Driver/Driver.cpp
  clang/test/CodeGen/aapcs64-align.cpp
  clang/test/CodeGen/aarch64-sign-return-address.c
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGenCXX/float16-declarations.cpp
  clang/test/Driver/aarch64-cssc.c
  clang/test/Driver/aarch64-d128.c
  clang/test/Driver/aarch64-hbc.c
  clang/test/Driver/aarch64-ite.c
  clang/test/Driver/aarch64-lrcpc3.c
  clang/test/Driver/aarch64-ls64.c
  clang/test/Driver/aarch64-lse128.c
  clang/test/Driver/aarch64-mops.c
  clang/test/Driver/aarch64-mte.c
  clang/test/Driver/aarch64-perfmon.c
  clang/test/Driver/aarch64-predres.c
  clang/test/Driver/aarch64-rand.c
  clang/test/Driver/aarch64-ras.c
  clang/test/Driver/aarch64-rdm.c
  clang/test/Driver/aarch64-ssbs.c
  clang/test/Driver/aarch64-the.c
  clang/test/Driver/arm-matrix-multiply.c
  clang/test/Driver/arm-sb.c
  clang/test/Driver/constructors.c
  clang/test/Driver/unsupported-target-arch.c
  clang/test/Frontend/gnu-mcount.c
  clang/test/Headers/arm-fp16-header.c
  clang/test/Headers/arm-neon-header.c
  clang/test/Preprocessor/aarch64-target-features.c
  llvm/test/CodeGen/AArch64/andcompare.ll
  llvm/test/CodeGen/AArch64/andorbrcompare.ll
  llvm/test/CodeGen/AArch64/blockaddress.ll
  llvm/test/CodeGen/AArch64/extern-weak.ll
  llvm/test/CodeGen/AArch64/init-array.ll
  llvm/test/CodeGen/AArch64/literal_pools_float.ll
  llvm/test/CodeGen/AArch64/neg-selects.ll
  llvm/test/CodeGen/AArch64/qmovn.ll
  llvm/test/CodeGen/AArch64/select-constant-xor.ll
  llvm/test/MC/AArch64/armv8.9a-clrbhb.s

Index: llvm/test/MC/AArch64/armv8.9a-clrbhb.s
===
--- llvm/test/MC/AArch64/armv8.9a-clrbhb.s
+++ llvm/test/MC/AArch64/armv8.9a-clrbhb.s
@@ -2,37 +2,37 @@
 // Assembly is always permitted for instructions in the hint space.
 
 // Optional, off by default
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi < %s | FileCheck %s --check-prefix=HINT_22
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=+v8a < %s | FileCheck %s --check-prefix=HINT_22
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=+v8.8a < %s | FileCheck %s --check-prefix=HINT_22
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=+v9a < %s | FileCheck %s --check-prefix=HINT_22
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=+v9.3a < %s | FileCheck %s --check-prefix=HINT_22
+// RUN: llvm-mc -show-encoding -triple aarch64-none-elf < %s | FileCheck %s --check-prefix=HINT_22
+// RUN: llvm-mc -show-encoding -triple aarch64-none-elf -mattr=+v8a < %s | FileCheck %s --check-prefix=HINT_22
+// RUN: llvm-mc -show-encoding -triple aarch64-none-elf -mattr=+v8.8a < %s | FileCheck %s --check-prefix=HINT_22
+// RUN: llvm-mc -show-encoding -triple aarch64-none-elf -mattr=+v9a < %s | FileCheck %s --check-prefix=HINT_22
+// RUN: llvm-mc -show-encoding -triple aarch64-none-elf -mattr=+v9.3a < %s | FileCheck %s --check-prefix=HINT_22
 
 // Optional, off by default, doubly disabled
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=-clrbhb < %s | FileCheck %s --check-prefix=HINT_22
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=+v8a,-clrbhb < %s | FileCheck %s --check-prefix=HINT_22
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=+v8.8a,-clrbhb < %s | FileCheck %s --check-prefix=HINT_22
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=+v9a,-clrbhb < %s | FileCheck %s --check-prefix=HINT_22
-// RUN: llvm-mc -show-encoding -triple aarch64-none-none-eabi -mattr=+v9.3a,-clrbhb < %s | FileCheck %s --check-prefix=HINT_22
+// RUN: llvm-mc -show-encoding -triple aarch64-none-elf -mattr=-clrbhb < %s | FileCheck %s

[PATCH] D153205: [clang-format] Add new block type ListInit

2023-06-21 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

My only concern is that this changes behaviour without someone making the 
conscious decision to make that change, now as much as I can't understand why 
someone would want to put the `}` onto the same line, it will only take on 
person to say "hey I liked it like that" to complain and call it a regression, 
or that we somehow change the defaults (which people always complain about even 
through we don't normally do that)

In the past our solution to this problem is to have an option with a "Leave" 
setting to sort of say, leave it as it currently is. In this case it feels like 
a bug, looks like a bug and is probably a bug, but I'd be interested in 
@owenpan and @HazardyKnusperkeks's view


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D152975: [clang-format] Allow break after return keyword

2023-06-21 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/Format.cpp:1484
   LLVMStyle.PenaltyBreakFirstLessLess = 120;
+  LLVMStyle.PenaltyBreakReturn = 100;
   LLVMStyle.PenaltyBreakString = 1000;

is 100 the current penalty?



Comment at: clang/unittests/Format/FormatTest.cpp:22187
+   "  
HereAVeryLongLineThatWillBeFormattedOnMultipleLineAnd"
+   "ShouldNotBeConsiderAsInline;\n"
"});",

the fails the beyonce rule doesn't it, unless you are assuming the test is a 
bug?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152975

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


[PATCH] D152741: [WPD] implement -fskip-vtable-filepaths

2023-06-21 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

In D152741#4422462 , @modimo wrote:

> In D152741#4421067 , @tejohnson 
> wrote:
>
>> In D152741#4419366 , @modimo wrote:
>>
>>> In D152741#4419324 , @tejohnson 
>>> wrote:
>>>
 In D152741#4419265 , @modimo 
 wrote:

> In D152741#4418831 , @tejohnson 
> wrote:
>
>> I think I understand the motivation, but not sure I agree this is the 
>> right approach - can you simply not pass -flto-unit and 
>> -fwhole-program-vtables for these files?
>
> For our third-party libraries, they're pre-built into native files by GCC 
> so that's unfortunately not an option.

 I'm confused - how would you pass this new option then? I was assuming you 
 were passing this option to some LLVM built files at the interface of 
 those libraries. In which case not passing -flto-unit and 
 -fwhole-program-visibility should have a similar effect (suppress the type 
 metadata).
>>>
>>> Oh I see, I misunderstood. Yes this is being passed to LLVM built files. We 
>>> want to avoid manual allowlists/blocklists because code changes make it 
>>> less flexible and scalable than an automatic option.
>>
>> It seems like you need allowlists or blocklists in either case - either it 
>> is passed as a regex via the option proposed here, or the build system 
>> modifies the options for that set of files.
>>
>>> This can also be pretty tricky to do correctly since we can get type 
>>> metadata from multiple TUs and all of them would need to be opted out for 
>>> WPD to not kick in.
>>
>> But clang is presumably compiling a single TU at a time, so your regex needs 
>> to cover them all anyway? I'm not sure I understand the distinction between 
>> doing something like -fskip-vtable-filepaths=third-party/.* vs something 
>> like applying -funknown-vtable-visibility to each third-party/*.cc compile.
>
> The blocklists need to be enforced on internal files that interact with 
> native libraries and those live in many different areas:
>
>   ; /third-party/include/boost.h
>   
>   class A {}
>   
>   ; /internal-source/a.cpp
>   #include "boost.h"
>   
>   class B : public A
>   
>   ; /third-party/lib/boost.a
>   #include "boost.h"
>   
>   class C : public A
>
> That being said, this is something the build system can detect and mark.
>
>> I really think the logic for which files to apply this option to belongs in 
>> the build system, not in the clang driver - just like any other clang 
>> option. It isn't clear to me why this particular option should be applied 
>> based on a file regex.
>
> The big advantage of doing this in the FE is that we know which types are 
> actually coming from the native headers. Blocking all types in the TU is 
> overly conservative and also less stable as header changes can effectively 
> turn on/off unrelated large chunks of WPD.

Ok what I missed is that you don't want to apply this to entire TUs, but rather 
just some paths that are header files, which may be included in many source 
files. So in your above example, you really only need to apply to the path of 
third-party/include/boost.h - is that correct? That would mark class A, and 
therefore anything derived from it won't get devirtualized. I guess in your 
example above, you are trying to prevent the devirtualization in a.cpp since 
there are hidden overrides (class C) in boost.a native objects.

The example included with the patch applies the option to the source file of 
the test case, and therefore its entire TU. It would be helpful to have a test 
case structured like your example above, where the file path is just that of 
the header.

Maybe a better option name is something like 
-funknown-vtable-visibility-filepaths= ? It seems a bit more descriptive.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152741

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


[clang] 9741ac5 - [clang-format] vim integration: Mention python3 variant of bindings

2023-06-21 Thread Jannik Silvanus via cfe-commits

Author: Jannik Silvanus
Date: 2023-06-21T17:18:36+02:00
New Revision: 9741ac5b3b3e7942e3332e37af829e58e5e2bb82

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

LOG: [clang-format] vim integration: Mention python3 variant of bindings

The instructions in the documentation only mentioned how to include
bindings for clang-format into vim using python2. Add the instructions
for python3 which were already present in the source comments.

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

Change-Id: I25fdbd36f0c7e745061908be8e26f68cb31c7dd5

Added: 


Modified: 
clang/docs/ClangFormat.rst

Removed: 




diff  --git a/clang/docs/ClangFormat.rst b/clang/docs/ClangFormat.rst
index 98350a04ccda4..129d5f101a0c4 100644
--- a/clang/docs/ClangFormat.rst
+++ b/clang/docs/ClangFormat.rst
@@ -145,8 +145,13 @@ This can be integrated by adding the following to your 
`.vimrc`:
 
 .. code-block:: vim
 
-  map  :pyf /clang-format.py
-  imap  :pyf /clang-format.py
+  if has('python')
+map  :pyf /clang-format.py
+imap  :pyf /clang-format.py
+  elseif has('python3')
+map  :py3f /clang-format.py
+imap  :py3f /clang-format.py
+  endif
 
 The first line enables :program:`clang-format` for NORMAL and VISUAL mode, the
 second line adds support for INSERT mode. Change "C-K" to another binding if



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


[PATCH] D153338: [clang-format] vim integration: Mention python3 variant of bindings

2023-06-21 Thread Jannik Silvanus via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9741ac5b3b3e: [clang-format] vim integration: Mention 
python3 variant of bindings (authored by jsilvanus).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153338

Files:
  clang/docs/ClangFormat.rst


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -145,8 +145,13 @@
 
 .. code-block:: vim
 
-  map  :pyf /clang-format.py
-  imap  :pyf /clang-format.py
+  if has('python')
+map  :pyf /clang-format.py
+imap  :pyf /clang-format.py
+  elseif has('python3')
+map  :py3f /clang-format.py
+imap  :py3f /clang-format.py
+  endif
 
 The first line enables :program:`clang-format` for NORMAL and VISUAL mode, the
 second line adds support for INSERT mode. Change "C-K" to another binding if


Index: clang/docs/ClangFormat.rst
===
--- clang/docs/ClangFormat.rst
+++ clang/docs/ClangFormat.rst
@@ -145,8 +145,13 @@
 
 .. code-block:: vim
 
-  map  :pyf /clang-format.py
-  imap  :pyf /clang-format.py
+  if has('python')
+map  :pyf /clang-format.py
+imap  :pyf /clang-format.py
+  elseif has('python3')
+map  :py3f /clang-format.py
+imap  :py3f /clang-format.py
+  endif
 
 The first line enables :program:`clang-format` for NORMAL and VISUAL mode, the
 second line adds support for INSERT mode. Change "C-K" to another binding if
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D134351: AArch64: add definitions for recent Apple CPUs

2023-06-21 Thread Moth via Phabricator via cfe-commits
tigermoth added a comment.

Now that AES, SHA2, SHA3 and SM4 features have been removed from armv8.6-a, 
these Apple CPUs can be changed again from 8.5-a to more correctly specified as 
armv8.6-a

https://reviews.llvm.org/D141606?id=488968


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

https://reviews.llvm.org/D134351

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-21 Thread Donát Nagy via Phabricator via cfe-commits
donat.nagy added a comment.

In D152436#4437822 , @steakhal wrote:

> In D152436#4437692 , @donat.nagy 
> wrote:
>
>> Personally I think it's completely acceptable if the analyzer sometimes 
>> emits bug reports that are true positives but lack a message [...]
>
> I must admit that I'm in the other camp.

To clarify my position the "sometimes" in my comment should've been "rarely" or 
something closer to that. I don't want to release confusing garbage, I'm just 
trying to optimize sum(helpfulness of checkers) and I feel that the last few 
steps towards perfect helpfulness are often disproportionately expensive. If a 
code contains two bugs, then two rough but understandable warnings are more 
valuable than one well-polished friendly warning + one completely missed bug 
(because we didn't have time to write a checker for it).

---

@balazske:

Do I understand it correctly that the "create note that's shown when the return 
value is marked as interesting" (the option 2 that I suggested) adds / will add 
clarifying notes to the fileno/fstat error reports and the ftell issue 
?
 Did you see any real-life examples where this option 2 does not provide useful 
notes? If not, then I think we can accept that option 2 is a sufficient 
solution for these issues.

In addition to this, there are these issues noted by @Szelethus:

In D152436#4408199 , @Szelethus wrote:

> In D152436#4405558 , @balazske 
> wrote:
>
>> link 
>> 
>> The function `open` is not modeled in `StdCLibraryFunctionsChecker`, it 
>> should not return less than -1 but this information is not included now.
>> link 
>> 
>> `socket` can not return less than -1 but this function is not modeled 
>> currently.
>
> These should be a rather painless fix, right?
>
> [...]
>
>> link 
>> 
>> `fwrite` with 0 buffer and 0 size should not be an error, this is not 
>> checked now.
>
> Some discussion for that: D140387#inline-1360054 
> . There is a FIXME in the 
> code for it -- not sure how common this specific issue is, but we did stumble 
> on it in an open source project... how painful would it be to fix this?

If it's not too difficult, then please upload a new version of this patch that 
implements "option 2" (i.e. produces notes when the return value of the std 
library function is marked as interesting) + handles the three requests of 
@Szelethus. I hope that you can do this and then this review can be concluded 
quickly.

If there are significant obstacles (or I misunderstood the situation), then 
please reply and discuss the next steps.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D144006: [DebugMetadata][DwarfDebug] Support function-local types in lexical block scopes (4/7)

2023-06-21 Thread Hongtao Yu via Phabricator via cfe-commits
hoy added a comment.

In D144006#4437804 , @dzhidzhoev 
wrote:

> In D144006#4435677 , @hoy wrote:
>
>> Hello, I'm seeing a build failure that seems related to this patch. I'm 
>> seeing the patch has been relanded and reverted a couple times and not sure 
>> where it is right now. Can you please confirm if the failure is related and 
>> fixed? Thanks.
>
> Hello! Currently, the commit is reverted (in commit 
> 6bea8331f9e09ba94a225c65becd4224a1a473af 
> ). Does 
> the build failure still occur with it?
> Could you provide a reproducing code for the crash?

Thanks for the information. As of today the build failure does not exist. It 
only happened yesterday.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D144006

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


[PATCH] D153379: Remove -flang-experimental-exec flag

2023-06-21 Thread Pete Steinfeld via Phabricator via cfe-commits
PeteSteinfeld accepted this revision.
PeteSteinfeld added a comment.

All builds and tests correctly and looks good.

@everythingfunctional, can you please post on Discourse about this change when 
you merge?  Since we've discussed this with the community, I think we should 
let them know that this is happening.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153379

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


[PATCH] D152741: [WPD] implement -fskip-vtable-filepaths

2023-06-21 Thread Di Mo via Phabricator via cfe-commits
modimo added a comment.

In D152741#4438007 , @tejohnson wrote:

> Ok what I missed is that you don't want to apply this to entire TUs, but 
> rather just some paths that are header files, which may be included in many 
> source files. So in your above example, you really only need to apply to the 
> path of third-party/include/boost.h - is that correct?

Yep!

> That would mark class A, and therefore anything derived from it won't get 
> devirtualized. I guess in your example above, you are trying to prevent the 
> devirtualization in a.cpp since there are hidden overrides (class C) in 
> boost.a native objects.

Exactly, we saw this scenario causing issues when enabling WPD.

> The example included with the patch applies the option to the source file of 
> the test case, and therefore its entire TU. It would be helpful to have a 
> test case structured like your example above, where the file path is just 
> that of the header.

Makes sense and yeah the test case is confusing. Changed it to apply to just 
the header file.

> Maybe a better option name is something like 
> -funknown-vtable-visibility-filepaths= ? It seems a bit more descriptive.

Sure, changed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152741

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


[PATCH] D152741: [WPD] implement -fskip-vtable-filepaths

2023-06-21 Thread Di Mo via Phabricator via cfe-commits
modimo updated this revision to Diff 533326.
modimo added a comment.

Address feedback. Allow empty string to unset the flag


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152741

Files:
  clang/include/clang/Basic/CodeGenOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CGVTables.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGenCXX/type-metadata-unknown-vtable-visibility-filepaths.cpp
  clang/test/Driver/funknown-vtable-visibility-filepaths.c
  llvm/include/llvm/IR/GlobalObject.h
  llvm/lib/IR/Metadata.cpp
  llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
  llvm/test/ThinLTO/X86/devirt.ll

Index: llvm/test/ThinLTO/X86/devirt.ll
===
--- llvm/test/ThinLTO/X86/devirt.ll
+++ llvm/test/ThinLTO/X86/devirt.ll
@@ -42,9 +42,11 @@
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1D1mEi,p \
+; RUN:   -r=%t2.o,_ZN1E1nEi,p \
 ; RUN:   -r=%t2.o,_ZTV1B,px \
 ; RUN:   -r=%t2.o,_ZTV1C,px \
-; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK
+; RUN:   -r=%t2.o,_ZTV1D,px \
+; RUN:   -r=%t2.o,_ZTV1F,px 2>&1 | FileCheck %s --check-prefix=REMARK
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; Check that we're able to prevent specific function from being
@@ -58,9 +60,11 @@
 ; RUN:   -r=%t2.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1C1fEi,p \
 ; RUN:   -r=%t2.o,_ZN1D1mEi,p \
+; RUN:   -r=%t2.o,_ZN1E1nEi,p \
 ; RUN:   -r=%t2.o,_ZTV1B,px \
 ; RUN:   -r=%t2.o,_ZTV1C,px \
-; RUN:   -r=%t2.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=SKIP
+; RUN:   -r=%t2.o,_ZTV1D,px \
+; RUN:   -r=%t2.o,_ZTV1F,px 2>&1 | FileCheck %s --check-prefix=SKIP
 
 ; RUN: llvm-lto2 run %t.o -save-temps -pass-remarks=. \
 ; RUN:   -whole-program-visibility \
@@ -70,16 +74,20 @@
 ; RUN:   -r=%t.o,_ZN1B1fEi,p \
 ; RUN:   -r=%t.o,_ZN1C1fEi,p \
 ; RUN:   -r=%t.o,_ZN1D1mEi,p \
+; RUN:   -r=%t.o,_ZN1E1nEi,p \
 ; RUN:   -r=%t.o,_ZTV1B, \
 ; RUN:   -r=%t.o,_ZTV1C, \
 ; RUN:   -r=%t.o,_ZTV1D, \
+; RUN:   -r=%t.o,_ZTV1F, \
 ; RUN:   -r=%t.o,_ZN1A1nEi, \
 ; RUN:   -r=%t.o,_ZN1B1fEi, \
 ; RUN:   -r=%t.o,_ZN1C1fEi, \
 ; RUN:   -r=%t.o,_ZN1D1mEi, \
+; RUN:   -r=%t.o,_ZN1E1nEi, \
 ; RUN:   -r=%t.o,_ZTV1B,px \
 ; RUN:   -r=%t.o,_ZTV1C,px \
-; RUN:   -r=%t.o,_ZTV1D,px 2>&1 | FileCheck %s --check-prefix=REMARK --dump-input=fail
+; RUN:   -r=%t.o,_ZTV1D,px \
+; RUN:   -r=%t.o,_ZTV1F,px 2>&1 | FileCheck %s --check-prefix=REMARK --dump-input=fail
 ; RUN: llvm-dis %t3.1.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-IR
 
 ; REMARK-DAG: single-impl: devirtualized a call to _ZN1A1nEi
@@ -95,13 +103,18 @@
 %struct.C = type { %struct.A }
 %struct.D = type { ptr }
 
+%struct.E = type { ptr }
+%struct.F = type { %struct.E }
+
 @_ZTV1B = constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr undef, ptr @_ZN1B1fEi, ptr @_ZN1A1nEi] }, !type !0, !type !1
 @_ZTV1C = constant { [4 x ptr] } { [4 x ptr] [ptr null, ptr undef, ptr @_ZN1C1fEi, ptr @_ZN1A1nEi] }, !type !0, !type !2
 @_ZTV1D = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1D1mEi] }, !type !3
 
+@_ZTV1F = constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr undef, ptr @_ZN1E1nEi] }, !type !5, !vcall_visibility !6
+
 
 ; CHECK-IR-LABEL: define i32 @test
-define i32 @test(ptr %obj, ptr %obj2, i32 %a) {
+define i32 @test(ptr %obj, ptr %obj2, ptr %obj3, i32 %a) {
 entry:
   %vtable = load ptr, ptr %obj
   %p = call i1 @llvm.type.test(ptr %vtable, metadata !"_ZTS1A")
@@ -114,7 +127,7 @@
   ; Ensure !prof and !callees metadata for indirect call promotion removed.
   ; CHECK-IR-NOT: prof
   ; CHECK-IR-NOT: callees
-  %call = tail call i32 %fptr1(ptr nonnull %obj, i32 %a), !prof !5, !callees !6
+  %call = tail call i32 %fptr1(ptr nonnull %obj, i32 %a), !prof !7, !callees !8
 
   %fptr22 = load ptr, ptr %vtable, align 8
 
@@ -131,7 +144,18 @@
   ; Check that the call was devirtualized.
   ; CHECK-IR: %call4 = tail call i32 @_ZN1D1mEi
   %call4 = tail call i32 %fptr33(ptr nonnull %obj2, i32 %call3)
-  ret i32 %call4
+
+  %vtable1 = load ptr, ptr %obj3
+  %p3 = call i1 @llvm.type.test(ptr %vtable1, metadata !"_ZTS1E")
+  call void @llvm.assume(i1 %p3)
+  %fptrptr1 = getelementptr ptr, ptr %vtable1, i32 0
+  %fptr44 = load ptr, ptr %fptrptr1, align 8
+
+  ; Check that the call was not devirtualized because of "unknown"
+  ; vcall_visibility.
+  ; CHECK-IR: %call5 = tail call i32 %fptr44
+  %call5 = tail call i32 %fptr44(ptr nonnull %obj, i32 %call4)
+  ret i32 %call5
 }
 ; CHECK-IR-LABEL: ret i32
 ; CHECK-IR-LABEL: }
@@ -155,6 +179,10 @@
ret i32 0;
 }
 
+define i32 @_ZN1E1nEi(ptr %this, i32 %a) #0 {
+   ret i32 0;
+}
+
 ; Make sure we don't inline or otherwise optimize out the direct calls.
 attributes #0 = { noinline optnone }
 
@@ -163,5 +191,7 @@
 !2 = !{i64 16, !"_ZTS1C"}
 !3 =

[PATCH] D153379: Remove -flang-experimental-exec flag

2023-06-21 Thread Brad Richardson via Phabricator via cfe-commits
everythingfunctional added a comment.

In D153379#4438419 , @PeteSteinfeld 
wrote:

> All builds and tests correctly and looks good.
>
> @everythingfunctional, can you please post on Discourse about this change 
> when you merge?  Since we've discussed this with the community, I think we 
> should let them know that this is happening.

Absolutely. Thanks for approving.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153379

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


[PATCH] D146148: Float_t and double_t types shouldn't be modified by #pragma clang fp eval_method

2023-06-21 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 54.

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

https://reviews.llvm.org/D146148

Files:
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TokenKinds.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLookup.cpp

Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -320,10 +320,11 @@
   // Compiler builtins are always visible, regardless of where they end
   // up being declared.
   if (IdentifierInfo *Id = NameInfo.getName().getAsIdentifierInfo()) {
-if (unsigned BuiltinID = Id->getBuiltinID()) {
-  if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
-AllowHidden = true;
-}
+if (!Id->getInterestingIdentifierID())
+  if (unsigned BuiltinID = Id->getBuiltinID()) {
+if (!getSema().Context.BuiltinInfo.isPredefinedLibFunction(BuiltinID))
+  AllowHidden = true;
+  }
   }
 }
 
@@ -943,6 +944,10 @@
 
   // If this is a builtin on this (or all) targets, create the decl.
   if (unsigned BuiltinID = II->getBuiltinID()) {
+if (unsigned ID = II->getInterestingIdentifierID()) {
+  // Don't think we should LazyCreate the interesting identifier?
+  return true;
+}
 // In C++ and OpenCL (spec v1.2 s6.9.f), we don't have any predefined
 // library functions like 'malloc'. Instead, we'll just error.
 if ((getLangOpts().CPlusPlus || getLangOpts().OpenCL) &&
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6763,14 +6763,22 @@
   if (IdentifierInfo *II = NewTD->getIdentifier())
 if (!NewTD->isInvalidDecl() &&
 NewTD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-  if (II->isStr("FILE"))
+  switch (II->getInterestingIdentifierID()) {
+  case tok::InterestingIdentifierKind::FILE:
 Context.setFILEDecl(NewTD);
-  else if (II->isStr("jmp_buf"))
+break;
+  case tok::InterestingIdentifierKind::jmp_buf:
 Context.setjmp_bufDecl(NewTD);
-  else if (II->isStr("sigjmp_buf"))
+break;
+  case tok::InterestingIdentifierKind::sigjmp_buf:
 Context.setsigjmp_bufDecl(NewTD);
-  else if (II->isStr("ucontext_t"))
+break;
+  case tok::InterestingIdentifierKind::ucontext_t:
 Context.setucontext_tDecl(NewTD);
+break;
+  default:
+break;
+  }
 }
 
   return NewTD;
Index: clang/lib/Basic/IdentifierTable.cpp
===
--- clang/lib/Basic/IdentifierTable.cpp
+++ clang/lib/Basic/IdentifierTable.cpp
@@ -279,6 +279,16 @@
   Table.get(Name).setObjCKeywordID(ObjCID);
 }
 
+static void AddInterestingIdentifier(StringRef Name,
+ tok::InterestingIdentifierKind BTID,
+ IdentifierTable &Table) {
+  // Don't add 'not_interesting' identifier.
+  if (BTID != tok::not_interesting) {
+IdentifierInfo &Info = Table.get(Name, tok::identifier);
+Info.setInterestingIdentifierID(BTID);
+  }
+}
+
 /// AddKeywords - Add all keywords to the symbol table.
 ///
 void IdentifierTable::AddKeywords(const LangOptions &LangOpts) {
@@ -295,6 +305,9 @@
 #define OBJC_AT_KEYWORD(NAME)  \
   if (LangOpts.ObjC)   \
 AddObjCKeyword(StringRef(#NAME), tok::objc_##NAME, *this);
+#define INTERESTING_IDENTIFIER(NAME)   \
+  AddInterestingIdentifier(StringRef(#NAME), tok::##NAME, *this);
+
 #define TESTING_KEYWORD(NAME, FLAGS)
 #include "clang/Basic/TokenKinds.def"
 
Index: clang/lib/Basic/Builtins.cpp
===
--- clang/lib/Basic/Builtins.cpp
+++ clang/lib/Basic/Builtins.cpp
@@ -151,7 +151,7 @@
   unsigned ID = NameIt->second->getBuiltinID();
   if (ID != Builtin::NotBuiltin && isPredefinedLibFunction(ID) &&
   isInStdNamespace(ID) == InStdNamespace) {
-Table.get(Name).setBuiltinID(Builtin::NotBuiltin);
+NameIt->second->clearBuiltinID();
   }
 }
   }
Index: clang/include/clang/Basic/TokenKinds.h
===
--- clang/include/clang/Basic/TokenKinds.h
+++ clang/include/clang/Basic/TokenKinds.h
@@ -44,6 +44,14 @@
   NUM_OBJC_KEYWORDS
 };
 
+/// Provides a namespace for interesting identifers such as float_t and
+/// double_t.
+enum InterestingIdentifierKind {
+#define INTERESTING_IDENTIFIER(X) X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_INTERESTING_IDENTIFIERS
+};
+
 /// Defines the possible values of an on-off-switch (C99 6.10.6p2).
 enum O

[PATCH] D146148: [clang] Add a namespace for interesting identifiers.

2023-06-21 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam marked an inline comment as done.
zahiraam added inline comments.



Comment at: clang/lib/Sema/SemaDecl.cpp:6784
+  if (II->getInterestingIdentifierID() != 0)
+NewTD->addAttr(AvailableOnlyInDefaultEvalMethodAttr::Create(Context));
 }

rjmccall wrote:
> zahiraam wrote:
> > rjmccall wrote:
> > > Please switch over the interesting identifiers here; we don't want to 
> > > assume this feature is only used for these two names.
> > > 
> > > In fact, should we go ahead and immediately apply it to the four 
> > > identifiers above this?  That would be nice, because then we could 
> > > actually do this in two patches: one patch that does the refactor to 
> > > track interesting identifiers but doesn't cause any functionality changes 
> > > and a second, very small patch that just introduces the new special 
> > > treatment for `float_t` and `double_t`.
> > > Please switch over the interesting identifiers here; we don't want to 
> > > assume this feature is only used for these two names.
> > > 
> > > In fact, should we go ahead and immediately apply it to the four 
> > > identifiers above this?  That would be nice, because then we could 
> > > actually do this in two patches: one patch that does the refactor to 
> > > track interesting identifiers but doesn't cause any functionality changes 
> > > and a second, very small patch that just introduces the new special 
> > > treatment for `float_t` and `double_t`.
> > 
> > Are you saying that "FILE", "jmp_buf"," sigjmp_buf" and "ucontext_t" are 
> > also interesting identifiers? If yes, they should be added to the list of 
> > interesting identifiers in TokenKinds.def?
> Right.  The basic idea of interesting identifiers is to replace these sorts 
> of identifier comparisons in performance-critical code.  So your first patch 
> would *only* add those four identifiers as interesting identifiers, handling 
> them here by registering the `typedef` with the ASTContext like the code is 
> already doing.  Then you'd make a follow-up patch that adds `float_t` and 
> `double_t` and handles them here by implicitly adding your new attribute.
> Right.  The basic idea of interesting identifiers is to replace these sorts 
> of identifier comparisons in performance-critical code.  So your first patch 
> would *only* add those four identifiers as interesting identifiers, handling 
> them here by registering the `typedef` with the ASTContext like the code is 
> already doing.  Then you'd make a follow-up patch that adds `float_t` and 
> `double_t` and handles them here by implicitly adding your new attribute.

I think that does it?


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

https://reviews.llvm.org/D146148

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added inline comments.
This revision now requires changes to proceed.



Comment at: clang/include/clang/Driver/Options.td:1167
 // GCC style -dumpdir. We intentionally don't implement the less useful 
-dumpbase{,-ext}.
-def dumpdir : Separate<["-"], "dumpdir">, Flags<[CC1Option]>,
+def dumpdir : Separate<["-"], "dumpdir">, Flags<[CC1Option, CoreOption]>,
   MetaVarName<"">,

HaohaiWen wrote:
> MaskRay wrote:
> > This exposes `-dumpdir ` to clang-cl which may not be useful.
> clang -gdwarf -gsplit-dwarf foo.cpp -o foo.exe -### will be expanded to
> clang -cc1 ... "-dumpdir" "foo.exe-"  "-split-dwarf-file" 
> "foo.exe-foo.dwo"
> 
> dwo name will be prefixed by dumpdir if it's specified.
> 
> This dumpdir is required for clang-cl to have same dwo filename behavior as 
> clang.
CoreOption allows `-dumpdir` to be used with clang-cl. If you do this, I expect 
a driver test case.

clang-cl passes `-dumpdir` to clang -cc1. `-dumpdir` has the CC1Option flag, so 
`-cc1` accepts the option.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D152785: [COFF] Support -gsplit-dwarf for COFF on Windows

2023-06-21 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

CodeView is the default debug info format for COFF. Perhaps `-gsplit-dwarf` 
should be rejected when the default `-gcodeview` is used, with a test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152785

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


[PATCH] D153359: [clang][Diagnostics] Fix distant source ranges in bad-conversion notes

2023-06-21 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

I like this patch, thanks for working on it 😄

In D153359#4436873 , @hazohelet wrote:

> Consider the following code. (I added another parameter to the original code 
> so that the covered range becomes clearer)
>
>   void func(int aa, int bb);
>   
>   
>   void test() { func(1, "two"); }
>
> BEFORE this patch:
>
>   source:4:15: error: no matching function for call to 'func'
>   4 | void test() { func(1, "two"); }
> |   ^~~~
>   source:1:6: note: candidate function not viable: no known conversion from 
> 'const char[4]' to 'int' for 2nd argument
>   1 | void func(int aa, int bb);
> |  ^
>   2 |
>   3 |
>   4 | void test() { func(1, "two"); }
> |   ~
>
> AFTER this patch:
>
>   source:4:15: error: no matching function for call to 'func'
>   4 | void test() { func(1, "two"); }
> |   ^~~~
>   source:1:6: note: candidate function not viable: no known conversion from 
> 'const char[4]' to 'int' for 2nd argument
>   1 | void func(int aa, int bb);
> |  ^~~

Having this in the commit message would be great, thanks!




Comment at: clang/lib/Sema/SemaOverload.cpp:10821
 
+// FIXME: No test case for this. Can we remove this block?
 if (FromQs.hasUnaligned() != ToQs.hasUnaligned()) {

Please don't commit until this is resolved (either tests added or it's removed).


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

https://reviews.llvm.org/D153359

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


[PATCH] D143241: [Clang] Reset FP options before function instantiations

2023-06-21 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143241

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


[PATCH] D143241: [Clang] Reset FP options before function instantiations

2023-06-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143241

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


[PATCH] D153267: [clang][Diagnostics] Provide parameter source range to arity-mismatch notes

2023-06-21 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb added a comment.

I think this will be a good addition because it underscores the salient part of 
why the function isn't viable.

Would it be possible for patches like this to have both examples of before and 
after this patch in their commit message please? That'll help expose why 
patches like this are desirable. Happy to LGTM afterwards.




Comment at: clang/test/Misc/diag-func-call-ranges.cpp:13
+void arity_mismatch() {
+  (void)func(2, 4);
+}

Why are you casting to void?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153267

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


[PATCH] D153419: Enable fexec-charset option

2023-06-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:6864
+  CmdArgs.push_back("-fexec-charset");
+  CmdArgs.push_back(Args.MakeArgString(Triple.getSystemCharset()));
   if (Arg *execCharset = Args.getLastArg(options::OPT_fexec_charset_EQ)) {

The default should be in the "else"?  It's confusing to pass two -fexec-charset 
arguments, even if it works.



Comment at: clang/lib/Lex/LiteralSupport.cpp:2145
+memcpy(Cp, CpConv.data(), ResultLength);
+ResultPtr = Cp + CpConv.size();
+  }

Can the code be refactored to put this repeated sequence into a helper function?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153419

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan updated this revision to Diff 533352.
abhina.sreeskantharajan added a reviewer: michaelplatings.
abhina.sreeskantharajan added a comment.

Use target_link_libraries instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

Files:
  clang/include/clang/Basic/CharSet.h
  clang/include/clang/Config/config.h.cmake
  clang/lib/Basic/CMakeLists.txt
  clang/lib/Basic/CharSet.cpp
  clang/unittests/Basic/CharSetTest.cpp

Index: clang/unittests/Basic/CharSetTest.cpp
===
--- clang/unittests/Basic/CharSetTest.cpp
+++ clang/unittests/Basic/CharSetTest.cpp
@@ -40,6 +40,29 @@
 // String with Cyrillic character ya.
 static const char CyrillicUTF[] = "\xd0\xaf";
 
+// String "Earth地球".
+// ISO-2022-JP: Sequence ESC $ B (\x1B\x24\x42) switches to JIS X 0208-1983, and
+// sequence ESC ( B (\x1B\x28\x42) switches back to ASCII.
+// IBM-939: Byte 0x0E shifts from single byte to double byte, and 0x0F shifts
+// back.
+static const char EarthUTF[] = "\x45\x61\x72\x74\x68\xe5\x9c\xb0\xe7\x90\x83";
+// Identical to above, except the final character (球) has its last byte taken
+// away from it.
+static const char EarthUTFBroken[] = "\x45\x61\x72\x74\x68\xe5\x9c\xb0\xe7\x90";
+static const char EarthISO2022[] =
+"\x45\x61\x72\x74\x68\x1B\x24\x42\x43\x4F\x35\x65\x1B\x28\x42";
+static const char EarthISO2022ShiftBack[] =
+"\x45\x61\x72\x74\x68\x1B\x24\x42\x43\x4F\x35\x65";
+static const char EarthIBM939[] =
+"\xc5\x81\x99\xa3\x88\x0e\x45\xc2\x48\xdb\x0f";
+static const char ShiftBackOnly[] = "\x1B\x28\x42";
+
+// String "地球".
+static const char EarthKanjiOnlyUTF[] = "\xe5\x9c\xb0\xe7\x90\x83";
+static const char EarthKanjiOnlyISO2022[] =
+"\x1B\x24\x42\x43\x4F\x35\x65\x1b\x28\x42";
+static const char EarthKanjiOnlyIBM939[] = "\x0e\x45\xc2\x48\xdb\x0f";
+
 TEST(CharSet, FromUTF8) {
   // Hello string.
   StringRef Src(HelloA);
@@ -98,4 +121,154 @@
   EXPECT_STREQ(AccentUTF, static_cast(Dst).c_str());
 }
 
+TEST(CharSet, RoundTrip) {
+  ErrorOr ConvToUTF16 =
+  CharSetConverter::create("IBM-1047", "UTF-16");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToUTF16) {
+ASSERT_EQ(ConvToUTF16.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+  ErrorOr ConvToUTF32 =
+  CharSetConverter::create("UTF-16", "UTF-32");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToUTF32) {
+ASSERT_EQ(ConvToUTF32.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+  ErrorOr ConvToEBCDIC =
+  CharSetConverter::create("UTF-32", "IBM-1047");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvToEBCDIC) {
+ASSERT_EQ(ConvToEBCDIC.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // Setup source string.
+  char SrcStr[256];
+  for (size_t I = 0; I < 256; ++I)
+SrcStr[I] = (I + 1) % 256;
+
+  SmallString<99> Dst1Str, Dst2Str, Dst3Str;
+
+  std::error_code EC = ConvToUTF16->convert(StringRef(SrcStr), Dst1Str, true);
+  EXPECT_TRUE(!EC);
+  EC = ConvToUTF32->convert(Dst1Str, Dst2Str, true);
+  EXPECT_TRUE(!EC);
+  EC = ConvToEBCDIC->convert(Dst2Str, Dst3Str, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(SrcStr, static_cast(Dst3Str).c_str());
+}
+
+TEST(CharSet, ShiftState2022) {
+  // Earth string.
+  StringRef Src(EarthUTF);
+  SmallString<64> Dst;
+
+  ErrorOr ConvTo2022 =
+  CharSetConverter::create("UTF-8", "ISO-2022-JP");
+  // Stop test if conversion is not supported (no underlying iconv support).
+  if (!ConvTo2022) {
+ASSERT_EQ(ConvTo2022.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // Check that the string is properly converted.
+  std::error_code EC = ConvTo2022->convert(Src, Dst, true);
+  EXPECT_TRUE(!EC);
+  EXPECT_STREQ(EarthISO2022, static_cast(Dst).c_str());
+}
+
+TEST(CharSet, ShiftState2022Flush) {
+  StringRef Src0(EarthUTFBroken);
+  StringRef Src1(EarthKanjiOnlyUTF);
+  SmallString<64> Dst0;
+  SmallString<64> Dst1;
+  ErrorOr ConvTo2022Flush =
+  CharSetConverter::create("UTF-8", "ISO-2022-JP");
+  if (!ConvTo2022Flush) {
+ASSERT_EQ(ConvTo2022Flush.getError(),
+  std::make_error_code(std::errc::invalid_argument));
+return;
+  }
+
+  // This should emit an error; there is a malformed multibyte character in the
+  // input string.
+  std::error_code EC0 = ConvTo2022Flush->convert(Src0, Dst0, true);
+  EXPECT_TRUE(EC0);
+  std::error_code EC1 = ConvTo2022Flush->flush();
+  EXPECT_TRUE(!EC1);
+  std::error_code EC2 = ConvTo2022Flush->convert(Src1, Dst1, true);
+  EXPECT_TRUE(!EC2);
+  EXPECT_STREQ(EarthKanjiOnlyISO2022, static_cast(Dst1).c_str());
+}
+
+TEST(CharSet, ShiftS

[PATCH] D143241: [Clang] Reset FP options before function instantiations

2023-06-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Parse/ParseTemplate.cpp:1736
+  // point of the template definition.
+  Actions.resetFPOptions(LPT.FPO);
+

Ah, is this bug specific to the MSVC-compatible template logic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143241

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-21 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan marked an inline comment as done.
abhina.sreeskantharajan added inline comments.



Comment at: clang/lib/Basic/CMakeLists.txt:62
+if(Iconv_FOUND AND NOT Iconv_IS_BUILT_IN)
+  set(system_libs ${system_libs} ${Iconv_LIBRARIES})
+endif()

michaelplatings wrote:
> This doesn't look like an idomatic way to link a library. Could you use [[ 
> https://cmake.org/cmake/help/latest/command/target_link_libraries.html | 
> target_link_libraries ]] instead?
Thanks, I've made this change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

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


[PATCH] D146148: [clang] Add a namespace for interesting identifiers.

2023-06-21 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Yes, this is very close, thank you.




Comment at: clang/include/clang/Basic/TokenKinds.def:805
+INTERESTING_IDENTIFIER(float_t)
+INTERESTING_IDENTIFIER(double_t)
+INTERESTING_IDENTIFIER(FILE)

I think it would be cleaner if you added these two as interesting identifiers 
in your follow-up patch.



Comment at: clang/lib/Sema/SemaLookup.cpp:950
+  return true;
+}
 // In C++ and OpenCL (spec v1.2 s6.9.f), we don't have any predefined

The two changes in this file shouldn't be necessary, since interesting 
identifiers should be disjoint from builtins.


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

https://reviews.llvm.org/D146148

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


[PATCH] D146148: [clang] Add a namespace for interesting identifiers.

2023-06-21 Thread Zahira Ammarguellat via Phabricator via cfe-commits
zahiraam updated this revision to Diff 533360.
zahiraam marked 3 inline comments as done.

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

https://reviews.llvm.org/D146148

Files:
  clang/include/clang/Basic/IdentifierTable.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Basic/TokenKinds.h
  clang/lib/Basic/Builtins.cpp
  clang/lib/Basic/IdentifierTable.cpp
  clang/lib/Sema/SemaDecl.cpp

Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -6763,14 +6763,22 @@
   if (IdentifierInfo *II = NewTD->getIdentifier())
 if (!NewTD->isInvalidDecl() &&
 NewTD->getDeclContext()->getRedeclContext()->isTranslationUnit()) {
-  if (II->isStr("FILE"))
+  switch (II->getInterestingIdentifierID()) {
+  case tok::InterestingIdentifierKind::FILE:
 Context.setFILEDecl(NewTD);
-  else if (II->isStr("jmp_buf"))
+break;
+  case tok::InterestingIdentifierKind::jmp_buf:
 Context.setjmp_bufDecl(NewTD);
-  else if (II->isStr("sigjmp_buf"))
+break;
+  case tok::InterestingIdentifierKind::sigjmp_buf:
 Context.setsigjmp_bufDecl(NewTD);
-  else if (II->isStr("ucontext_t"))
+break;
+  case tok::InterestingIdentifierKind::ucontext_t:
 Context.setucontext_tDecl(NewTD);
+break;
+  default:
+break;
+  }
 }
 
   return NewTD;
Index: clang/lib/Basic/IdentifierTable.cpp
===
--- clang/lib/Basic/IdentifierTable.cpp
+++ clang/lib/Basic/IdentifierTable.cpp
@@ -279,6 +279,16 @@
   Table.get(Name).setObjCKeywordID(ObjCID);
 }
 
+static void AddInterestingIdentifier(StringRef Name,
+ tok::InterestingIdentifierKind BTID,
+ IdentifierTable &Table) {
+  // Don't add 'not_interesting' identifier.
+  if (BTID != tok::not_interesting) {
+IdentifierInfo &Info = Table.get(Name, tok::identifier);
+Info.setInterestingIdentifierID(BTID);
+  }
+}
+
 /// AddKeywords - Add all keywords to the symbol table.
 ///
 void IdentifierTable::AddKeywords(const LangOptions &LangOpts) {
@@ -295,6 +305,9 @@
 #define OBJC_AT_KEYWORD(NAME)  \
   if (LangOpts.ObjC)   \
 AddObjCKeyword(StringRef(#NAME), tok::objc_##NAME, *this);
+#define INTERESTING_IDENTIFIER(NAME)   \
+  AddInterestingIdentifier(StringRef(#NAME), tok::##NAME, *this);
+
 #define TESTING_KEYWORD(NAME, FLAGS)
 #include "clang/Basic/TokenKinds.def"
 
Index: clang/lib/Basic/Builtins.cpp
===
--- clang/lib/Basic/Builtins.cpp
+++ clang/lib/Basic/Builtins.cpp
@@ -151,7 +151,7 @@
   unsigned ID = NameIt->second->getBuiltinID();
   if (ID != Builtin::NotBuiltin && isPredefinedLibFunction(ID) &&
   isInStdNamespace(ID) == InStdNamespace) {
-Table.get(Name).setBuiltinID(Builtin::NotBuiltin);
+NameIt->second->clearBuiltinID();
   }
 }
   }
Index: clang/include/clang/Basic/TokenKinds.h
===
--- clang/include/clang/Basic/TokenKinds.h
+++ clang/include/clang/Basic/TokenKinds.h
@@ -44,6 +44,14 @@
   NUM_OBJC_KEYWORDS
 };
 
+/// Provides a namespace for interesting identifers such as float_t and
+/// double_t.
+enum InterestingIdentifierKind {
+#define INTERESTING_IDENTIFIER(X) X,
+#include "clang/Basic/TokenKinds.def"
+  NUM_INTERESTING_IDENTIFIERS
+};
+
 /// Defines the possible values of an on-off-switch (C99 6.10.6p2).
 enum OnOffSwitch {
   OOS_ON, OOS_OFF, OOS_DEFAULT
Index: clang/include/clang/Basic/TokenKinds.def
===
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -85,6 +85,9 @@
 #ifndef PRAGMA_ANNOTATION
 #define PRAGMA_ANNOTATION(X) ANNOTATION(X)
 #endif
+#ifndef INTERESTING_IDENTIFIER
+#define INTERESTING_IDENTIFIER(X)
+#endif
 
 //===--===//
 // Preprocessor keywords.
@@ -794,6 +797,15 @@
 OBJC_AT_KEYWORD(import)
 OBJC_AT_KEYWORD(available)
 
+//===--===//
+// Interesting idenitifiers.
+//===--===//
+INTERESTING_IDENTIFIER(not_interesting)
+INTERESTING_IDENTIFIER(FILE)
+INTERESTING_IDENTIFIER(jmp_buf)
+INTERESTING_IDENTIFIER(sigjmp_buf)
+INTERESTING_IDENTIFIER(ucontext_t)
+
 // TODO: What to do about context-sensitive keywords like:
 //   bycopy/byref/in/inout/oneway/out?
 
@@ -974,3 +986,4 @@
 #undef TOK
 #undef C99_KEYWORD
 #undef C2X_KEYWORD
+#undef INTERESTING_IDENTIFIER
Index: clang/include/clang/Basic/IdentifierTable.h
===

[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-21 Thread Joel Dice via Phabricator via cfe-commits
dicej added a comment.

In D153293#4437877 , @sbc100 wrote:

> In D153293#4437644 , @dicej wrote:
>
>> In D153293#4436629 , @sbc100 wrote:
>>
>>> I'm happy to merge it, but perhaps we should get @sunfish to lg too.
>>>
>>> Also, should we remove the `-experimental-pic` linker flag, or are you OK 
>>> with that warning from the linker?   If yes, I wonder if we should do that 
>>> as part of this CL or a followup?
>>
>> Do `emscripten` users see that warning, too?  I'd like to match whatever 
>> they see (or don't see).
>
> No, the emscripten driver (emcc) currently adds `--experimental-pic` to the 
> linker flags to avoid this warning.  We could gladly remove that if it 
> becomes the default.

OK; I'd say let's leave the warning there since this feature so new for 
non-emscripten targets.  We can come back and remove it later on once things 
have settled.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D146148: [clang] Add a namespace for interesting identifiers.

2023-06-21 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Thanks, LGTM!


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

https://reviews.llvm.org/D146148

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


[PATCH] D153417: New CharSetConverter wrapper class for ConverterEBCDIC

2023-06-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

As I mentioned at 
https://discourse.llvm.org/t/rfc-enabling-fexec-charset-support-to-llvm-and-clang-reposting/71512
 , I think SimplifyLibCalls needs to be aware of encodings.  To make that work, 
this probably needs to be somewhere in llvm/ , not clang/ .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153417

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


[PATCH] D153418: Adding iconv support to CharSetConverter class

2023-06-21 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

This doesn't really address the concerns from 
https://discourse.llvm.org/t/rfc-adding-a-charset-converter-to-the-llvm-support-library/69795/17
 about consistency.  It's bad if different hosts support a different set of 
charsets/charset names, and it's really bad if a given charset name has 
different meanings on different hosts.

Can we use the existing conversion utilities in LLVM for UTF-16/UTF-32?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153418

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


[PATCH] D153205: [clang-format] Add new block type ListInit

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

In D153205#4437966 , @MyDeveloperDay 
wrote:

> My only concern is that this changes behaviour without someone making the 
> conscious decision to make that change, now as much as I can't understand why 
> someone would want to put the `}` onto the same line, it will only take on 
> person to say "hey I liked it like that" to complain and call it a 
> regression, or that we somehow change the defaults (which people always 
> complain about even through we don't normally do that)
>
> In the past our solution to this problem is to have an option with a "Leave" 
> setting to sort of say, leave it as it currently is. In this case it feels 
> like a bug, looks like a bug and is probably a bug, but I'd be interested in 
> @owenpan and @HazardyKnusperkeks's view

The github issue basically says all there's to say, if it those constructs 
should be formatted like function calls, then that's what should happen. Or we 
should adapt the documentation.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153205

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


[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-21 Thread Sam Clegg via Phabricator via cfe-commits
sbc100 added inline comments.



Comment at: llvm/utils/lit/lit/llvm/config.py:347
+return triple
+
 m = re.match(r"(\w+)-(\w+)-(\w+)", triple)

dicej wrote:
> sbc100 wrote:
> > Are the the changes to this file meant to be part of this CL?
> The `check-clang` target doesn't work at all if the target "triple" is a 
> double, e.g.:
> 
> ```
> llvm-lit: 
> /Users/dicej/p/wasi-sdk/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:459:
>  note: using clang: /Users/dicej/p/wasi-sdk/build/llvm/bin/clang
> llvm-lit: 
> /Users/dicej/p/wasi-sdk/src/llvm-project/llvm/utils/lit/lit/llvm/config.py:324:
>  fatal: Could not turn 'wasm32-wasi' into Itanium ABI triple
> ```
> 
> @sunfish had been using this patch locally to work around the issue, so I 
> figured I'd include the patch here so it stops being a stumbling block.  
> Perhaps there's a better way to address it?
Can you split this out into a separate change.. its seem unrelated.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

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


[PATCH] D143967: [DebugInfo][BPF] Add 'btf:type_tag' annotation in DWARF

2023-06-21 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

I haven't looked closely at this, but from a vague/quick reading, it sounds 
like this is creating annotations on certain type DINodes, but then moving them 
around to different types? It'd be nice if we could avoid that/create them in 
the right place in the first place.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143967

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


[PATCH] D153458: [clang-tidy] Model noexcept more properly in bugprone-exception-escape

2023-06-21 Thread Piotr Zegar via Phabricator via cfe-commits
PiotrZSL created this revision.
PiotrZSL added reviewers: njames93, carlosgalvezp, isuckatcs, JonasToth, 
baloghadamsoftware.
Herald added a subscriber: xazax.hun.
Herald added a project: All.
PiotrZSL requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

During call stack analysis skip called noexcept functions
as they wont throw exceptions, they will crash.
Check will emit warnings for those functions separately.

Fixes: #43667, #49151, #51596, #54668, #54956


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D153458

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/exception-escape.cpp
@@ -152,7 +152,7 @@
 }
 
 // FIXME: In this case 'a' is convertible to the handler and should be caught
-// but in reality it's thrown. Note that clang doesn't report a warning for 
+// but in reality it's thrown. Note that clang doesn't report a warning for
 // this either.
 void throw_catch_multi_ptr_5() noexcept {
   try {
@@ -249,7 +249,7 @@
 void throw_derived_catch_base_ptr_c() noexcept {
   try {
 derived d;
-throw &d; 
+throw &d;
   } catch(const base *) {
   }
 }
@@ -259,7 +259,7 @@
   try {
 derived d;
 const derived *p = &d;
-throw p; 
+throw p;
   } catch(base *) {
   }
 }
@@ -282,7 +282,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_private' which should not throw exceptions
   try {
 B b;
-throw b; 
+throw b;
   } catch(A) {
   }
 }
@@ -291,7 +291,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_private_ptr' which should not throw exceptions
   try {
 B b;
-throw &b; 
+throw &b;
   } catch(A *) {
   }
 }
@@ -300,7 +300,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_protected' which should not throw exceptions
   try {
 C c;
-throw c; 
+throw c;
   } catch(A) {
   }
 }
@@ -309,7 +309,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_protected_ptr' which should not throw exceptions
   try {
 C c;
-throw &c; 
+throw &c;
   } catch(A *) {
   }
 }
@@ -318,7 +318,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_ambiguous' which should not throw exceptions
   try {
 E e;
-throw e; 
+throw e;
   } catch(A) {
   }
 }
@@ -327,7 +327,7 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'throw_derived_catch_base_ambiguous_ptr' which should not throw exceptions
   try {
 E e;
-throw e; 
+throw e;
   } catch(A) {
   }
 }
@@ -703,3 +703,22 @@
   throw 1;
   return 0;
 }
+
+// The following function all incorrectly throw exceptions, *but* calling them
+// should not yield a warning because they are marked as noexcept.
+
+void test_basic_no_throw() noexcept { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'test_basic_no_throw' which should not throw exceptions
+
+void test_basic_throw() noexcept(false) { throw 42; }
+
+void only_calls_non_throwing() noexcept {
+  test_basic_no_throw();
+}
+
+void calls_non_and_throwing() noexcept {
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'calls_non_and_throwing' which should not throw exceptions
+  test_basic_no_throw();
+  test_basic_throw();
+}
+
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -254,7 +254,8 @@
 
 - Improved :doc:`bugprone-exception-escape
   ` to not emit warnings for
-  forward declarations of functions.
+  forward declarations of functions and additionally modified it to skip
+  ``noexcept`` functions during call stack analysis.
 
 - Fixed :doc:`bugprone-exception-escape`
   for coroutines where previously a warning would be emitted with coroutines
Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -316,6 +316,27 @@
 }
 } // namespace
 
+static bool cannotThrow(const FunctionDecl *Func) {
+  const auto *FunProto = Func->getType()->getAs();
+  if (!FunProto)
+re

[PATCH] D153059: [-Wunsafe-buffer-usage] Group parameter fix-its

2023-06-21 Thread Ziqing Luo via Phabricator via cfe-commits
ziqingluo-90 added inline comments.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2077
+
   for (const auto &[VD, Fixables] : FixablesForUnsafeVars.byVar) {
 FixItsForVariable[VD] =

NoQ wrote:
> There's a bug in variable naming: `FixablesForUnsafeVars`actually contains 
> fixables for *all* variables. Rashmi correctly renames it in D150489 to 
> reflect its actual behavior. So IIUC you're generating fixits for all 
> variables here, which is probably not what you want.
Thanks for pointing out the incorrectness of the variable name.   Actually, 
whether a variable is unsafe is irrelevant to this function.  The function only 
cares about all variables that need fixes.  So I think the incorrect name of 
the variable does not affect the functionality of my changes here.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2278-2281
+  if (isParameterOf(Impl.first, D))
+ParmsNeedFix.insert(Impl.first);
+  if (isParameterOf(Impl.second, D))
+ParmsNeedFix.insert(Impl.second);

NoQ wrote:
> Does this really go in both directions? Shouldn't it be just one direction?
> 
> ```lang=c++
> void foo(int *p) {
>   int *q = new int[10];
>   p = q;
>   q[5] = 7;
> }
> ```
> In this case `q` is an unsafe local buffer, but `p` is a (mostly) safe 
> single-object pointer that doesn't need fixing, despite implication from `q` 
> to `p`. Of course this example is somewhat unrealistic (people don't usually 
> overwrite their parameters), but it is also the only situation where the 
> other direction matters.
You are right!  It should be one-direction.



Comment at: clang/lib/Analysis/UnsafeBufferUsage.cpp:2293
+//  search of connected components.
+if (!ParmsNeedFix.empty()) {
+  auto First = ParmsNeedFix.begin(), Last = First;

NoQ wrote:
> What about the situation where params aren't seen as unsafe yet, but they're 
> discovered to be unsafe later? Eg.
> ```
> void foo(int *p, int *q) {
>   int *p2 = p;
>   p2[5] = 7;
>   int *q2 = q;
>   q2[5] = 7;
> }
> ```
> Will we notice that `p` and `q` need to be fixed simultaneously?
> 
> ---
> 
> I suspect that the problem of parameter grouping can't be solved by 
> pre-populating strategy implications between all parameters. It'll either 
> cause you to implicate all parameters (even the ones that will never need 
> fixing), or cause you to miss connections between parameters that do need 
> fixing (as the connection is discovered later).
> 
> Connection between parameters needs to be added *after* the implications 
> algorithm has finished. And once it's there (might be already there if I 
> missed something), then this part of code probably becomes unnecessary.
Yes.  They will be noticed.  Here is why:

The code here first forms a ring over `p` and  `q` in the assignment (directed) 
graph:  
```
p <--> q
```
Then the two initialization statements (implemented in [[ 
https://reviews.llvm.org/D150489 | D150489 ]]) add two more edges to the graph:
```
p2 --> p <--> q <-- q2
```
The algorithm later searches the graph starting from unsafe variables `p2` and 
`q2`, respectively,  Starting from `p2`, the algorithm discovers that `p2` and 
`p`, as well as `p` and `q` depend on each other.  Starting from `q2`,  the 
algorithm discovers that `q2` and `q`, as well as `p` and `q` depend on each 
other.   The dependency graph is sort of undirected. So eventually, the four 
variables `p2`, `p`, `q`, `q2` are in the same group.




Comment at: 
clang/test/SemaCXX/warn-unsafe-buffer-usage-fixits-multi-parm-span.cpp:13-15
+   expected-note{{change type of 'p' to 'std::span' to preserve bounds 
information, and change 'q' and 'a' to 'std::span' to propagate bounds 
information between them}} \
+   expected-note{{change type of 'q' to 'std::span' to preserve bounds 
information, and change 'p' and 'a' to 'std::span' to propagate bounds 
information between them}} \
+   expected-note{{change type of 'a' to 'std::span' to preserve bounds 
information, and change 'p' and 'q' to 'std::span' to propagate bounds 
information between them}}

NoQ wrote:
> QoL thing: //"to propagate bounds information between them"// isn't the 
> correct reason in this case. Bounds information doesn't propagate between `p` 
> and `q` and `a`. Each of them carries its own, completely unrelated bounds 
> information.
> 
> We need to come up with a different reason. Or it might be better to combine 
> the warnings into one warning here, so that we didn't need a reason:
> ```
> warning: 'p', 'q' and 'a' are unsafe pointers used for buffer access
> note: change type of 'p', 'q' and 'a' to 'std::span' to preserve bounds 
> information
> ```
> 
> This gets a bit worse when parameters are implicated indirectly, but it still 
> mostly works fine, for example:
> ```
> void foo(int *p, int *q) {
>   int *p2 = p;
>   p2[5] = 7;
>   int *q2 

[PATCH] D152946: [C++20][Modules] Implement P2615R1 revised export diagnostics.

2023-06-21 Thread Iain Sandoe via Phabricator via cfe-commits
iains added a comment.

In D152946#4431974 , @h-vetinari 
wrote:

> Mark P2615  as implemented in 
> https://github.com/llvm/llvm-project/blame/main/clang/www/cxx_status.html?



In D152946#4431974 , @h-vetinari 
wrote:

> Mark P2615  as implemented in 
> https://github.com/llvm/llvm-project/blame/main/clang/www/cxx_status.html?

I did not do that yet since this patch only implements the removal of unnamed 
export diagnostics.  There will be a follow-on patch shortly that implements 
the addition of the export specialisation diagnostics and then we can claim 
P2615R1.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152946

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


[PATCH] D153462: [Headers][doc] Add various arith/logical intrinsic descriptions to avx2intrin.h

2023-06-21 Thread Paul Robinson via Phabricator via cfe-commits
probinson created this revision.
probinson added reviewers: pengfei, RKSimon, goldstein.w.n, craig.topper.
Herald added a project: All.
probinson requested review of this revision.

https://reviews.llvm.org/D153462

Files:
  clang/lib/Headers/avx2intrin.h

Index: clang/lib/Headers/avx2intrin.h
===
--- clang/lib/Headers/avx2intrin.h
+++ clang/lib/Headers/avx2intrin.h
@@ -19,22 +19,112 @@
 #define __DEFAULT_FN_ATTRS128 __attribute__((__always_inline__, __nodebug__, __target__("avx2"), __min_vector_width__(128)))
 
 /* SSE4 Multiple Packed Sums of Absolute Difference.  */
+/// Computes sixteen sum of absolute difference (SAD) operations on sets of
+///four unsigned 8-bit integers from the 256-bit integer vectors \a X and
+///\a Y.
+///
+///Eight SAD results are computed using the lower half of the input
+///vectors, and another eight using the upper half. These 16-bit values
+///are returned in the lower and upper halves of the 256-bit result,
+///respectively.
+///
+///A single SAD operation selects four bytes from \a X and four bytes from
+///\a Y as input. It computes the differences between each \a X byte and
+///the corresponding \a Y byte, takes the absolute value of each
+///difference, and sums these four values to form one 16-bit result. The
+///intrinsic computes 16 of these results with different sets of input
+///bytes.
+///
+///For each set of eight results, the SAD operations use the same four
+///bytes from \a Y; the starting bit position for these four bytes is
+///specified by \a M[1:0] times 32. The eight operations use successive
+///sets of four bytes from \a X; the starting bit position for the first
+///set of four bytes is specified by \a M[2] times 32. These bit positions
+///are all relative to the 128-bit lane for each set of eight operations.
+///
+/// \code{.operation}
+/// r := 0
+/// FOR i := 0 TO 1
+///   j := i*3
+///   Ybase := M[j+1:j]*32 + i*128
+///   Xbase := M[j+2]*32 + i*128
+///   FOR k := 0 TO 3
+/// temp0 := ABS(X[Xbase+7:Xbase] - Y[Ybase+7:Ybase])
+/// temp1 := ABS(X[Xbase+15:Xbase+8] - Y[Ybase+15:Ybase+8])
+/// temp2 := ABS(X[Xbase+23:Xbase+16] - Y[Ybase+23:Ybase+16])
+/// temp3 := ABS(X[Xbase+31:Xbase+24] - Y[Ybase+31:Ybase+24])
+/// result[r+15:r] := temp0 + temp1 + temp2 + temp3
+/// Xbase := Xbase + 8
+/// r := r + 16
+///   ENDFOR
+/// ENDFOR
+/// \endcode
+///
+/// \headerfile 
+///
+/// \code
+/// __m256i _mm256_mpsadbw_epu8(__m256i X, __m256i Y, const int M);
+/// \endcode
+///
+/// This intrinsic corresponds to the \c VMPSADBW instruction.
+///
+/// \param X
+///A 256-bit integer vector containing one of the inputs.
+/// \param Y
+///A 256-bit integer vector containing one of the inputs.
+/// \param M
+/// An unsigned immediate value specifying the starting positions of the
+/// bytes to operate on.
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 #define _mm256_mpsadbw_epu8(X, Y, M) \
   ((__m256i)__builtin_ia32_mpsadbw256((__v32qi)(__m256i)(X), \
   (__v32qi)(__m256i)(Y), (int)(M)))
 
+/// Computes the absolute value of each signed byte in the 256-bit integer
+///vector \a __a and returns each value in the corresponding byte of
+///the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPABSB instruction.
+///
+/// \param __a
+///A 256-bit integer vector.
+/// \returns A 256-bit integer vector containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_abs_epi8(__m256i __a)
 {
 return (__m256i)__builtin_elementwise_abs((__v32qs)__a);
 }
 
+/// Computes the absolute value of each signed 16-bit element in the 256-bit
+///vector of [16 x i16] in \a __a and returns each value in the
+///corresponding element of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPABSW instruction.
+///
+/// \param __a
+///A 256-bit vector of [16 x i16].
+/// \returns A 256-bit vector of [16 x i16] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_abs_epi16(__m256i __a)
 {
 return (__m256i)__builtin_elementwise_abs((__v16hi)__a);
 }
 
+/// Computes the absolute value of each signed 32-bit element in the 256-bit
+///vector of [8 x i32] in \a __a and returns each value in the
+///corresponding element of the result.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the \c VPABSD instruction.
+///
+/// \param __a
+///A 256-bit vector of [8 x i32].
+/// \returns A 256-bit vector of [8 x i32] containing the result.
 static __inline__ __m256i __DEFAULT_FN_ATTRS256
 _mm256_abs_epi32(__m256i __a)
 {
@@ -345,24 +435,88 @@
   ((__m256i)__builtin_ia32_palignr256((__v32qi)(__m256i)(a), \
   (__v32qi)(__m256i)(b), (n)))
 
+/// Computes the bitwise AND of the 25

[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Uh-oh, looks like I'm not paying nearly enough attention to this discussion 
(sorry about that!!)

I'm somewhat skeptical of the decision made in D151225 
 because the entire reason I originally 
implemented `StdCLibraryFunctions` was to deal with false positives I was 
seeing. It was really valuable even without the bug-finding part. So I really 
wish we could find some way to keep bug-finding and modeling separate.

I haven't read the entire discussion though, I need to catch up 😓


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


[PATCH] D153293: [clang][WebAssembly] support wasm32-wasi shared libraries

2023-06-21 Thread Joel Dice via Phabricator via cfe-commits
dicej updated this revision to Diff 533375.
dicej added a comment.

remove config.py changes per review feedback


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D153293

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/WebAssembly.cpp
  clang/test/Driver/wasm-toolchain.c
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp

Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -99,13 +99,6 @@
 return Reloc::Static;
   }
 
-  if (!TT.isOSEmscripten()) {
-// Relocation modes other than static are currently implemented in a way
-// that only works for Emscripten, so disable them if we aren't targeting
-// Emscripten.
-return Reloc::Static;
-  }
-
   return *RM;
 }
 
Index: clang/test/Driver/wasm-toolchain.c
===
--- clang/test/Driver/wasm-toolchain.c
+++ clang/test/Driver/wasm-toolchain.c
@@ -33,6 +33,20 @@
 // LINK_KNOWN: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
 // LINK_KNOWN: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "crt1.o" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
 
+// -shared should be passed through to `wasm-ld` and not include crt1.o with a known OS.
+
+// RUN: %clang -### -shared --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_KNOWN_SHARED %s
+// LINK_KNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_KNOWN_SHARED: wasm-ld{{.*}}" "-L/foo/lib/wasm32-wasi" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
+// -shared should be passed through to `wasm-ld` and not include crt1.o with an unknown OS.
+
+// RUN: %clang -### -shared --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=LINK_UNKNOWN_SHARED %s
+// LINK_UNKNOWN_SHARED: "-cc1" {{.*}} "-o" "[[temp:[^"]*]]"
+// LINK_UNKNOWN_SHARED: wasm-ld{{.*}}" "-shared" "[[temp]]" "-lc" "{{.*[/\\]}}libclang_rt.builtins-wasm32.a" "-o" "a.out"
+
 // A basic C link command-line with optimization with known OS.
 
 // RUN: %clang -### -O2 --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
@@ -46,6 +60,18 @@
 // RUN:   | FileCheck -check-prefix=COMPILE %s
 // COMPILE: "-cc1" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
 
+// -fPIC should work on a known OS
+
+// RUN: %clang -### -fPIC --target=wasm32-wasi --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=COMPILE_KNOWN_PIC %s
+// COMPILE_KNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2" {{.*}} "-internal-isystem" "/foo/include/wasm32-wasi" "-internal-isystem" "/foo/include"
+
+// -fPIC should work on an unknown OS
+
+// RUN: %clang -### -fPIC --target=wasm32-unknown-unknown --sysroot=/foo %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=COMPILE_UNKNOWN_PIC %s
+// COMPILE_UNKNOWN_PIC: "-cc1" {{.*}} "-mrelocation-model" "pic" "-pic-level" "2"
+
 // Thread-related command line tests.
 
 // '-pthread' sets +atomics, +bulk-memory, +mutable-globals, +sign-ext, and --shared-memory
Index: clang/lib/Driver/ToolChains/WebAssembly.cpp
===
--- clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -101,13 +101,16 @@
   << CM << A->getOption().getName();
 }
   }
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles))
+  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles, options::OPT_shared))
 CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(Crt1)));
   if (Entry) {
 CmdArgs.push_back(Args.MakeArgString("--entry"));
 CmdArgs.push_back(Args.MakeArgString(Entry));
   }
 
+  if (Args.hasArg(options::OPT_shared))
+  CmdArgs.push_back(Args.MakeArgString("-shared"));
+
   AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs, JA);
 
   if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -701,6 +701,12 @@
 
 WebAssembly Support
 ^^^
+- Shared library support (and PIC code generation) for WebAssembly is no longer
+  limited to the Emscripten target OS and now works with other targets such as
+  wasm32-wasi.  Note that the `format
+  `_
+  is not yet stable and may change between LLVM versions.  Also, WASI does not
+  yet have facilities to load dynamic libraries.
 
 AVR Support
 ^^^
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://l

[PATCH] D129635: [OpenMP] Update the default version of OpenMP to 5.1

2023-06-21 Thread H. Vetinari via Phabricator via cfe-commits
h-vetinari added a comment.

Does https://clang.llvm.org/docs/OpenMPSupport.html need an update? It still 
says "Clang fully supports OpenMP 4.5" (with many 5.0/5.1 features marked as 
"worked on" / "unclaimed"), which would make it unusual to put the default on a 
version that's (according to that status page) only ~30% implemented.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D129635

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


[PATCH] D152436: [clang][analyzer] Move checker alpha.unix.StdCLibraryFunctions out of alpha.

2023-06-21 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> In this case function `fileno` returns -1 because of failure, but this is not 
> indicated in a `NoteTag`. This is a correct result, only the note is missing. 
> This problem can be solved if a note is displayed on every branch ("case") of 
> the standard C functions. But this leads to many notes at un-interesting 
> places. If the note is displayed only at "interesting" values another 
> difficulty shows up: The note disappears from places where it should be shown 
> because the "interestingness" is not set, for example at conditions of `if` 
> statement. So the solution may require more work. This case with function 
> `fileno` occurs 13 times in all the tested projects.

Extra notes along the path are fine as long as their `isPrunable()` flag is 
correctly set. It's perfectly ok to say //"(15) Hey btw we've just ran over 
this statement and here's what we assume it did"// in a section of a path 
that's already displayed to the user. Even if you say that on every line, it's 
probably ok.

But if the note causes a new nested stack frame to be displayed (which was 
otherwise pruned from the report), there better be a good reason for this, 
because this can easily increase the complexity of the bug report by a factor 
of 100.

It's definitely a requirement for a non-alpha checker to make sure that there 
are enough non-prunable pieces in the report for the user to understand the 
report. A lot of our existing on-by-default checkers (and even some `core` 
checkers) don't really hold up to this expectation (looking at you null 
dereference), but almost every time they don't, that's a false positive. If you 
need to pass `-analyzer-config prune-paths=false` in order to see a key step in 
the bug report, that's a false positive even if your path simulation was 
perfect.

So if any of these notes are essential to understanding any bug report (by this 
checker or by another checker, eg. like `getenv()` returning null is essential 
for null dereference checker), there needs to be a way for the note tag to 
learn that (eg., the `getenv()` should be able to ask whether the return value 
is being tracked by `trackExpressionValue()`) and if so, the note has to be 
marked as unprunable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152436

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


  1   2   >