[PATCH] D143094: [clang] Change AMX macros to match names from GCC

2023-02-03 Thread Joe Loser via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8998fa6c14f1: [clang] Change AMX macros to match names from 
GCC (authored by jloser).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143094

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Headers/immintrin.h
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_amx_target_features.c
  clang/test/Preprocessor/x86_target_features.c

Index: clang/test/Preprocessor/x86_target_features.c
===
--- clang/test/Preprocessor/x86_target_features.c
+++ clang/test/Preprocessor/x86_target_features.c
@@ -548,16 +548,16 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mamx-fp16 -x c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=AMX-FP16 %s
 
-// AMX-FP16: #define __AMXFP16__ 1
-// AMX-FP16: #define __AMXTILE__ 1
+// AMX-FP16: #define __AMX_FP16__ 1
+// AMX-FP16: #define __AMX_TILE__ 1
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mno-amx-fp16 \
 // RUN: -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-FP16 %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mamx-fp16 \
 // RUN: -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-FP16 %s
 
-// NO-AMX-FP16-NOT: #define __AMXFP16__ 1
-// NO-AMX-FP16-NOT: #define __AMXTILE__ 1
+// NO-AMX-FP16-NOT: #define __AMX_FP16__ 1
+// NO-AMX-FP16-NOT: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavxvnni -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVXVNNI %s
 
Index: clang/test/Preprocessor/x86_amx_target_features.c
===
--- clang/test/Preprocessor/x86_amx_target_features.c
+++ clang/test/Preprocessor/x86_amx_target_features.c
@@ -1,35 +1,35 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=AMX-TILE %s
 
-// AMX-TILE: #define __AMXTILE__ 1
+// AMX-TILE: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-BF16 %s
 
-// AMX-BF16: #define __AMXBF16__ 1
-// AMX-BF16: #define __AMXTILE__ 1
+// AMX-BF16: #define __AMX_BF16__ 1
+// AMX-BF16: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-INT8 %s
 
-// AMX-INT8: #define __AMXINT8__ 1
-// AMX-INT8: #define __AMXTILE__ 1
+// AMX-INT8: #define __AMX_INT8__ 1
+// AMX-INT8: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-TILE %s
 
-// NOAMX-TILE-NOT: #define __AMXTILE__ 1
+// NOAMX-TILE-NOT: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-bf16 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
-// NOAMX-BF16-NOT: #define __AMXBF16__ 1
+// NOAMX-BF16-NOT: #define __AMX_BF16__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
-// NOAMX-BF16-NOT: #define __AMXTILE__ 1
-// NOAMX-BF16-NOT: #define __AMXBF16__ 1
+// NOAMX-BF16-NOT: #define __AMX_TILE__ 1
+// NOAMX-BF16-NOT: #define __AMX_BF16__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-int8 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
-// NOAMX-INT8-NOT: #define __AMXINT8__ 1
+// NOAMX-INT8-NOT: #define __AMX_INT8__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
-// NOAMX-INT8-NOT: #define __AMXTILE__ 1
-// NOAMX-INT8-NOT: #define __AMXINT8__ 1
+// NOAMX-INT8-NOT: #define __AMX_TILE__ 1
+// NOAMX-INT8-NOT: #define __AMX_INT8__ 1
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1649,9 +1649,9 @@
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M32
 // CHECK_SPR_M32: #define __AES__ 1
-// CHECK_SPR_M32: #define __AMXBF16__ 1
-// CHECK_SPR_M32: #define __AMXINT8__ 1
-// CHECK_SPR_M32: #define __AMXTILE__ 1
+// CHECK_SPR_M32: #define __AMX_BF16__ 1
+// CHECK_SPR_M32: #define __AMX_INT8__ 1
+// CHECK_SPR_M32: #define __AMX_TILE__ 1
 // CHECK_SPR_M32: #define __AVX2__ 1
 // CHECK_SPR_M32: #define __AVX512BF16__ 1
 // CHECK_SPR_M32: #define __AVX512BITALG__ 1
@@ -1724,9 +1724,9 @@
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M64
 // CHECK_SPR_M64: #define __AES__ 1
-// 

[PATCH] D143094: [clang] Change AMX macros to match names from GCC

2023-02-02 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

In D143094#4098208 , @LuoYuanke wrote:

> LGTM, thanks

Thanks for the review.  Do I need to wait for another approver before landing 
this?  I mostly work on `libc++`, so not too familiar with expectations on 
Clang reviews, or whether one approver who's familiar/knowledgable in the area 
is sufficient.

I'm hoping to land this soon and request to cherry-pick it into LLVM 16 to 
avoid the macro value changing across 16/17 releases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143094

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


[PATCH] D143094: [clang] Change AMX macros to match names from GCC

2023-02-01 Thread Joe Loser via Phabricator via cfe-commits
jloser updated this revision to Diff 494008.
jloser added a comment.

Update commit message to properly display the #define


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D143094

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Headers/immintrin.h
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_amx_target_features.c
  clang/test/Preprocessor/x86_target_features.c

Index: clang/test/Preprocessor/x86_target_features.c
===
--- clang/test/Preprocessor/x86_target_features.c
+++ clang/test/Preprocessor/x86_target_features.c
@@ -548,16 +548,16 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mamx-fp16 -x c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=AMX-FP16 %s
 
-// AMX-FP16: #define __AMXFP16__ 1
-// AMX-FP16: #define __AMXTILE__ 1
+// AMX-FP16: #define __AMX_FP16__ 1
+// AMX-FP16: #define __AMX_TILE__ 1
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mno-amx-fp16 \
 // RUN: -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-FP16 %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mamx-fp16 \
 // RUN: -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-FP16 %s
 
-// NO-AMX-FP16-NOT: #define __AMXFP16__ 1
-// NO-AMX-FP16-NOT: #define __AMXTILE__ 1
+// NO-AMX-FP16-NOT: #define __AMX_FP16__ 1
+// NO-AMX-FP16-NOT: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavxvnni -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVXVNNI %s
 
Index: clang/test/Preprocessor/x86_amx_target_features.c
===
--- clang/test/Preprocessor/x86_amx_target_features.c
+++ clang/test/Preprocessor/x86_amx_target_features.c
@@ -1,35 +1,35 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=AMX-TILE %s
 
-// AMX-TILE: #define __AMXTILE__ 1
+// AMX-TILE: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-BF16 %s
 
-// AMX-BF16: #define __AMXBF16__ 1
-// AMX-BF16: #define __AMXTILE__ 1
+// AMX-BF16: #define __AMX_BF16__ 1
+// AMX-BF16: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-INT8 %s
 
-// AMX-INT8: #define __AMXINT8__ 1
-// AMX-INT8: #define __AMXTILE__ 1
+// AMX-INT8: #define __AMX_INT8__ 1
+// AMX-INT8: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-TILE %s
 
-// NOAMX-TILE-NOT: #define __AMXTILE__ 1
+// NOAMX-TILE-NOT: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-bf16 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
-// NOAMX-BF16-NOT: #define __AMXBF16__ 1
+// NOAMX-BF16-NOT: #define __AMX_BF16__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
-// NOAMX-BF16-NOT: #define __AMXTILE__ 1
-// NOAMX-BF16-NOT: #define __AMXBF16__ 1
+// NOAMX-BF16-NOT: #define __AMX_TILE__ 1
+// NOAMX-BF16-NOT: #define __AMX_BF16__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-int8 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
-// NOAMX-INT8-NOT: #define __AMXINT8__ 1
+// NOAMX-INT8-NOT: #define __AMX_INT8__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
-// NOAMX-INT8-NOT: #define __AMXTILE__ 1
-// NOAMX-INT8-NOT: #define __AMXINT8__ 1
+// NOAMX-INT8-NOT: #define __AMX_TILE__ 1
+// NOAMX-INT8-NOT: #define __AMX_INT8__ 1
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1649,9 +1649,9 @@
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M32
 // CHECK_SPR_M32: #define __AES__ 1
-// CHECK_SPR_M32: #define __AMXBF16__ 1
-// CHECK_SPR_M32: #define __AMXINT8__ 1
-// CHECK_SPR_M32: #define __AMXTILE__ 1
+// CHECK_SPR_M32: #define __AMX_BF16__ 1
+// CHECK_SPR_M32: #define __AMX_INT8__ 1
+// CHECK_SPR_M32: #define __AMX_TILE__ 1
 // CHECK_SPR_M32: #define __AVX2__ 1
 // CHECK_SPR_M32: #define __AVX512BF16__ 1
 // CHECK_SPR_M32: #define __AVX512BITALG__ 1
@@ -1724,9 +1724,9 @@
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M64
 // CHECK_SPR_M64: #define __AES__ 1
-// CHECK_SPR_M64: #define __AMXBF16__ 1
-// CHECK_SPR_M64: #define 

[PATCH] D143094: [clang] Change AMX macros to match names from GCC

2023-02-01 Thread Joe Loser via Phabricator via cfe-commits
jloser created this revision.
jloser added reviewers: yubing, LuoYuanke, pengfei, craig.topper.
Herald added a project: All.
jloser requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The current behavior for AMX macros is:

  gcc -march=native -dM -E - < /dev/null | grep TILE
  
  clang -march=native -dM -E - < /dev/null | grep TILE

which is not ideal.  Change `__AMXTILE__` and friends to `__AMX_TILE__` (i.e.
have an underscore in them).  This makes GCC and Clang agree on the naming of
these AMX macros to simplify downstream user code.

Fix this for `__AMXTILE__`, `__AMX_INT8__`, `__AMX_BF16__`, and `__AMX_FP16__`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D143094

Files:
  clang/lib/Basic/Targets/X86.cpp
  clang/lib/Headers/immintrin.h
  clang/test/Preprocessor/predefined-arch-macros.c
  clang/test/Preprocessor/x86_amx_target_features.c
  clang/test/Preprocessor/x86_target_features.c

Index: clang/test/Preprocessor/x86_target_features.c
===
--- clang/test/Preprocessor/x86_target_features.c
+++ clang/test/Preprocessor/x86_target_features.c
@@ -548,16 +548,16 @@
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mamx-fp16 -x c \
 // RUN: -E -dM -o - %s | FileCheck  -check-prefix=AMX-FP16 %s
 
-// AMX-FP16: #define __AMXFP16__ 1
-// AMX-FP16: #define __AMXTILE__ 1
+// AMX-FP16: #define __AMX_FP16__ 1
+// AMX-FP16: #define __AMX_TILE__ 1
 
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mno-amx-fp16 \
 // RUN: -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-FP16 %s
 // RUN: %clang -target x86_64-unknown-linux-gnu -march=atom -mamx-fp16 \
 // RUN: -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NO-AMX-FP16 %s
 
-// NO-AMX-FP16-NOT: #define __AMXFP16__ 1
-// NO-AMX-FP16-NOT: #define __AMXTILE__ 1
+// NO-AMX-FP16-NOT: #define __AMX_FP16__ 1
+// NO-AMX-FP16-NOT: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-unknown -march=atom -mavxvnni -x c -E -dM -o - %s | FileCheck -match-full-lines --check-prefix=AVXVNNI %s
 
Index: clang/test/Preprocessor/x86_amx_target_features.c
===
--- clang/test/Preprocessor/x86_amx_target_features.c
+++ clang/test/Preprocessor/x86_amx_target_features.c
@@ -1,35 +1,35 @@
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=AMX-TILE %s
 
-// AMX-TILE: #define __AMXTILE__ 1
+// AMX-TILE: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-BF16 %s
 
-// AMX-BF16: #define __AMXBF16__ 1
-// AMX-BF16: #define __AMXTILE__ 1
+// AMX-BF16: #define __AMX_BF16__ 1
+// AMX-BF16: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -x c -E -dM -o - %s | FileCheck -check-prefix=AMX-INT8 %s
 
-// AMX-INT8: #define __AMXINT8__ 1
-// AMX-INT8: #define __AMXTILE__ 1
+// AMX-INT8: #define __AMX_INT8__ 1
+// AMX-INT8: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-TILE %s
 
-// NOAMX-TILE-NOT: #define __AMXTILE__ 1
+// NOAMX-TILE-NOT: #define __AMX_TILE__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-bf16 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
-// NOAMX-BF16-NOT: #define __AMXBF16__ 1
+// NOAMX-BF16-NOT: #define __AMX_BF16__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-bf16 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-BF16 %s
 
-// NOAMX-BF16-NOT: #define __AMXTILE__ 1
-// NOAMX-BF16-NOT: #define __AMXBF16__ 1
+// NOAMX-BF16-NOT: #define __AMX_TILE__ 1
+// NOAMX-BF16-NOT: #define __AMX_BF16__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-amx-int8 -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
-// NOAMX-INT8-NOT: #define __AMXINT8__ 1
+// NOAMX-INT8-NOT: #define __AMX_INT8__ 1
 
 // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mamx-int8 -mno-amx-tile -x c -E -dM -o - %s | FileCheck  -check-prefix=NOAMX-INT8 %s
 
-// NOAMX-INT8-NOT: #define __AMXTILE__ 1
-// NOAMX-INT8-NOT: #define __AMXINT8__ 1
+// NOAMX-INT8-NOT: #define __AMX_TILE__ 1
+// NOAMX-INT8-NOT: #define __AMX_INT8__ 1
Index: clang/test/Preprocessor/predefined-arch-macros.c
===
--- clang/test/Preprocessor/predefined-arch-macros.c
+++ clang/test/Preprocessor/predefined-arch-macros.c
@@ -1649,9 +1649,9 @@
 // RUN: -target i386-unknown-linux \
 // RUN:   | FileCheck -match-full-lines %s -check-prefix=CHECK_SPR_M32
 // CHECK_SPR_M32: #define __AES__ 1
-// CHECK_SPR_M32: #define __AMXBF16__ 1
-// CHECK_SPR_M32: #define __AMXINT8__ 1
-// CHECK_SPR_M32: #define __AMXTILE__ 1
+// 

[PATCH] D141814: [llvm][ADT] Replace uses of `makeMutableArrayRef` with deduction guides

2023-01-16 Thread Joe Loser via Phabricator via cfe-commits
jloser added inline comments.



Comment at: lldb/source/Host/common/NativeProcessProtocol.cpp:652
 
   auto data =
+  llvm::MutableArrayRef(static_cast(buf), bytes_read);

serge-sans-paille wrote:
> random nit: This could be rewritten as
> 
> ```
> llvm::MutableArrayRef data(static_cast(buf), bytes_read);
> ```
> 
> now
Yep, I just changed that before landing this. Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141814

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


[PATCH] D141814: [llvm][ADT] Replace uses of `makeMutableArrayRef` with deduction guides

2023-01-16 Thread Joe Loser via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa288d7f93770: [llvm][ADT] Replace uses of 
`makeMutableArrayRef` with deduction guides (authored by jloser).

Changed prior to commit:
  https://reviews.llvm.org/D141814?vs=489419=489635#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141814

Files:
  bolt/lib/Profile/DataAggregator.cpp
  clang-tools-extra/clangd/FuzzyMatch.cpp
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
  clang/include/clang/AST/DeclOpenMP.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Lex/MacroInfo.h
  clang/lib/AST/StmtOpenMP.cpp
  lld/COFF/Chunks.cpp
  lld/COFF/DebugTypes.cpp
  lld/COFF/Writer.cpp
  lld/ELF/InputFiles.h
  lld/ELF/SyntheticSections.cpp
  lldb/source/Host/common/NativeProcessProtocol.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/Metadata.h
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/Support/Parallel.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/ExecutionEngine/ExecutionEngine.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
  llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/unittests/Support/Path.cpp
  mlir/lib/Bytecode/Writer/IRNumbering.cpp
  mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
  mlir/test/mlir-tblgen/constraint-unique.td
  mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Index: mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
===
--- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2746,7 +2746,7 @@
   ///
   /// {0}: The region's index.
   const char *const getSingleRegion =
-  "::llvm::makeMutableArrayRef((*this)->getRegion({0}))";
+  "::llvm::MutableArrayRef((*this)->getRegion({0}))";
 
   // If we have no regions, there is nothing more to do.
   const auto canSkip = [](const NamedRegion ) {
@@ -2781,7 +2781,7 @@
   /// Get a single successor.
   ///
   /// {0}: The successor's name.
-  const char *const getSingleSuccessor = "::llvm::makeMutableArrayRef({0}())";
+  const char *const getSingleSuccessor = "::llvm::MutableArrayRef({0}())";
 
   // If we have no successors, there is nothing more to do.
   const auto canSkip = [](const NamedSuccessor ) {
Index: mlir/test/mlir-tblgen/constraint-unique.td
===
--- mlir/test/mlir-tblgen/constraint-unique.td
+++ mlir/test/mlir-tblgen/constraint-unique.td
@@ -127,10 +127,10 @@
 // CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:  if (::mlir::failed([[$A_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto  : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK: for (auto  : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:  if (::mlir::failed([[$A_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK: for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:  if (::mlir::failed([[$A_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:return ::mlir::failure();
 
@@ -148,9 +148,9 @@
 // CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:  if (::mlir::failed([[$O_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto  : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK: for (auto  : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:  if (::mlir::failed([[$O_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK: for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:  if (::mlir::failed([[$O_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:return ::mlir::failure();
Index: mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
===
--- mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
+++ mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
@@ -80,8 +80,7 @@
 LLVM_DEBUG(llvm::dbgs() << "  found coalesceable band from " << start
   

[PATCH] D141814: [llvm][ADT] Replace uses of `makeMutableArrayRef` with deduction guides

2023-01-15 Thread Joe Loser via Phabricator via cfe-commits
jloser created this revision.
jloser added reviewers: MaskRay, serge-sans-paille, dblaikie.
Herald added subscribers: Moerafaat, zero9178, bzcheeseman, kosarev, ayermolo, 
sdasgup3, wenzhicui, wrengr, foad, cota, teijeong, rdzhabarov, tatianashp, 
msifontes, jurahul, Kayjukh, grosul1, Joonsoo, kerbowa, liufengdb, aartbik, 
mgester, arpith-jacob, csigg, antiagainst, shauheen, rriddle, mehdi_amini, 
kadircet, arphaman, hiraditya, arichardson, jvesely, emaste, arsenm.
Herald added a reviewer: aartbik.
Herald added a reviewer: bondhugula.
Herald added a reviewer: rafauler.
Herald added a reviewer: Amir.
Herald added a reviewer: maksfb.
Herald added a project: All.
jloser requested review of this revision.
Herald added a reviewer: nicolasvasilache.
Herald added subscribers: cfe-commits, llvm-commits, lldb-commits, 
pcwang-thead, yota9, stephenneuendorffer, nicolasvasilache.
Herald added a reviewer: dcaballe.
Herald added projects: clang, LLDB, MLIR, LLVM, clang-tools-extra.

Similar to how `makeArrayRef` is deprecated in favor of deduction guides, do the
same for `makeMutableArrayRef`.

Once all of the places in-tree are using the deduction guides for
`MutableArrayRef`, we can mark `makeMutableArrayRef` as deprecated.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D141814

Files:
  bolt/lib/Profile/DataAggregator.cpp
  clang-tools-extra/clangd/FuzzyMatch.cpp
  clang-tools-extra/clangd/SemanticSelection.cpp
  clang-tools-extra/clangd/index/dex/Trigram.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/Forest.h
  clang/include/clang/AST/DeclOpenMP.h
  clang/include/clang/AST/OpenMPClause.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Lex/MacroInfo.h
  clang/lib/AST/StmtOpenMP.cpp
  lld/COFF/Chunks.cpp
  lld/COFF/DebugTypes.cpp
  lld/COFF/Writer.cpp
  lld/ELF/InputFiles.h
  lld/ELF/SyntheticSections.cpp
  lldb/source/Host/common/NativeProcessProtocol.cpp
  llvm/include/llvm/DebugInfo/DWARF/DWARFUnitIndex.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/Metadata.h
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/Support/Parallel.h
  llvm/lib/Analysis/ConstantFolding.cpp
  llvm/lib/ExecutionEngine/ExecutionEngine.cpp
  llvm/lib/Support/Path.cpp
  llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
  llvm/lib/Transforms/Scalar/IndVarSimplify.cpp
  llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
  llvm/unittests/Support/Path.cpp
  mlir/lib/Bytecode/Writer/IRNumbering.cpp
  mlir/lib/Dialect/Affine/Transforms/LoopCoalescing.cpp
  mlir/test/mlir-tblgen/constraint-unique.td
  mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Index: mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
===
--- mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
+++ mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp
@@ -2746,7 +2746,7 @@
   ///
   /// {0}: The region's index.
   const char *const getSingleRegion =
-  "::llvm::makeMutableArrayRef((*this)->getRegion({0}))";
+  "::llvm::MutableArrayRef((*this)->getRegion({0}))";
 
   // If we have no regions, there is nothing more to do.
   const auto canSkip = [](const NamedRegion ) {
@@ -2781,7 +2781,7 @@
   /// Get a single successor.
   ///
   /// {0}: The successor's name.
-  const char *const getSingleSuccessor = "::llvm::makeMutableArrayRef({0}())";
+  const char *const getSingleSuccessor = "::llvm::MutableArrayRef({0}())";
 
   // If we have no successors, there is nothing more to do.
   const auto canSkip = [](const NamedSuccessor ) {
Index: mlir/test/mlir-tblgen/constraint-unique.td
===
--- mlir/test/mlir-tblgen/constraint-unique.td
+++ mlir/test/mlir-tblgen/constraint-unique.td
@@ -127,10 +127,10 @@
 // CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:  if (::mlir::failed([[$A_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto  : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK: for (auto  : ::llvm::MutableArrayRef((*this)->getRegion(0)))
 // CHECK-NEXT:  if (::mlir::failed([[$A_REGION_CONSTRAINT]](*this, region, "d", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto *successor : ::llvm::makeMutableArrayRef(c()))
+// CHECK: for (auto *successor : ::llvm::MutableArrayRef(c()))
 // CHECK-NEXT:  if (::mlir::failed([[$A_SUCCESSOR_CONSTRAINT]](*this, successor, "c", index++)))
 // CHECK-NEXT:return ::mlir::failure();
 
@@ -148,9 +148,9 @@
 // CHECK: for (auto [[$RET_VALUE:.*]] : [[$RET_VALUE_GROUP]])
 // CHECK-NEXT:  if (::mlir::failed([[$O_TYPE_CONSTRAINT]](*this, [[$RET_VALUE]].getType(), "result", index++)))
 // CHECK-NEXT:return ::mlir::failure();
-// CHECK: for (auto  : ::llvm::makeMutableArrayRef((*this)->getRegion(0)))
+// CHECK: for (auto  : 

[PATCH] D139973: [llvm] Make llvm::Any similar to std::any

2022-12-20 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

Sorry for the delay here; this patch LGTM!  Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139973

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


[PATCH] D139973: [llvm] Make llvm::Any similar to std::any

2022-12-17 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

I'm +1 for the direction here; I took a brief look but will look closely either 
later tonight or tomorrow before I approve.  Thanks for doing this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139973

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


[PATCH] D136549: [clang] Fix time profile in "isIntegerConstantExpr"

2022-10-23 Thread Joe Loser via Phabricator via cfe-commits
jloser added inline comments.



Comment at: clang/lib/AST/ExprConstant.cpp:15908
 
-  llvm::TimeTraceScope TimeScope("isIntegerConstantExpr", [&] {
-return Loc->printToString(Ctx.getSourceManager());
-  });
+  ExprTimeTraceScope TimeScope(this, Ctx, "isIntegerConstantExpr");
 

Izaron wrote:
> jloser wrote:
> > **Question** This looks like the right fix for this call site.  Are the 
> > other two uses of `llvm::TimeTraceScope` as a local variable subject to 
> > similar problems? I don't think so since we don't try to get the location 
> > explicitly, but want to confirm.
> That's a good question! We use custom `llvm::TimeTraceScope` in three places:
> 
> ```
> isPotentialConstantExpr
> EvaluateAsInitializer
> EvaluateWithSubstitution
> ```
> 
> The problem with `isIntegerConstantExpr` (which I fixed in this patch) was 
> that the `Loc` was `nullptr` (and there were no tests that would catch it).
> 
> The three functions with custom time traces use either `const VarDecl *VD` or 
> `const FunctionDecl *FD`. These variables are surely not `nullptr` because 
> the methods bravely use them (`VD->doSmth()`/`FD->doSmth()`).
> 
> Also our unit test covers `isPotentialConstantExpr` and 
> `EvaluateAsInitializer` (you can see them in `ASSERT_TRUE`).
> So I think there is no obvious problems that I can think of =)
That was my takeaway as well — no obvious lingering bugs. :)



Comment at: clang/unittests/Support/TimeProfilerTest.cpp:209
+  setupProfiler();
+  ASSERT_TRUE(compileFromString(Code, "-std=c99", "test.c"));
+  std::string Json = teardownProfiler();

Izaron wrote:
> jloser wrote:
> > **Question** Is adding the ability to plumb the standards mode just useful 
> > for this bug fix in the sense of reducing the trace graph output of the AST?
> This is useful for bug fix, because some `ExprConstant.cpp` methods are 
> called only for C code (not for C++ code). C and C++ have a somewhat 
> different constant evaluations.
> 
> The segfault in `Expr::isIntegerConstantExpr` was only discoverable when 
> compiling C code, because there is a explicit condition for calling this 
> method only for C code:
> https://github.com/llvm/llvm-project/blob/08d1c43c7023a2e955c43fbf4c3f1635f91521e0/clang/lib/Sema/SemaExpr.cpp#L17318
Makes sense — thanks for pointing out the relevant code block in Sema!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136549

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


[PATCH] D136549: [clang] Fix time profile in "isIntegerConstantExpr"

2022-10-23 Thread Joe Loser via Phabricator via cfe-commits
jloser accepted this revision.
jloser added a comment.
This revision is now accepted and ready to land.

LGTM.  Thanks for the fix.

I did leave an open question or two though, but it is non-blocking.




Comment at: clang/lib/AST/ExprConstant.cpp:15908
 
-  llvm::TimeTraceScope TimeScope("isIntegerConstantExpr", [&] {
-return Loc->printToString(Ctx.getSourceManager());
-  });
+  ExprTimeTraceScope TimeScope(this, Ctx, "isIntegerConstantExpr");
 

**Question** This looks like the right fix for this call site.  Are the other 
two uses of `llvm::TimeTraceScope` as a local variable subject to similar 
problems? I don't think so since we don't try to get the location explicitly, 
but want to confirm.



Comment at: clang/unittests/Support/TimeProfilerTest.cpp:209
+  setupProfiler();
+  ASSERT_TRUE(compileFromString(Code, "-std=c99", "test.c"));
+  std::string Json = teardownProfiler();

**Question** Is adding the ability to plumb the standards mode just useful for 
this bug fix in the sense of reducing the trace graph output of the AST?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136549

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


[PATCH] D136022: [clang] Add time profile for constant evaluation

2022-10-16 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

I like the idea of this — +1 for the direction.  I'd like to see some tests 
through before I approve.

Thanks for working on this!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136022

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


[PATCH] D134316: [clang][docs] Fix supported element types for `__builtin_reduce_(add|mul)`

2022-09-22 Thread Joe Loser via Phabricator via cfe-commits
jloser closed this revision.
jloser added a comment.

This landed with 
https://github.com/llvm/llvm-project/commit/cf77333da986720e9aded4301d81a581e2be9611.
  The revision didn't auto-close for some reason.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D134316

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


[PATCH] D134316: [clang][docs] Fix supported element types for `__builtin_reduce_(add|mul)`

2022-09-20 Thread Joe Loser via Phabricator via cfe-commits
jloser created this revision.
jloser added reviewers: RKSimon, nikic, fhahn.
Herald added a project: All.
jloser requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

The docs mention that `__builtin_reduce_add` and `__builtin_reduce_mul` support
both integer and floating point element types, but only integer element types
are actually supported. See https://github.com/llvm/llvm-project/issues/57847,
and specifically,
https://github.com/llvm/llvm-project/blob/00874c48ea4d291908517afaab50d1dcbfb016c3/clang/lib/Sema/SemaChecking.cpp#L2631
 for the fact that floating point element types are not supported yet.

Fix the docs to only mention support for integer element types.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D134316

Files:
  clang/docs/LanguageExtensions.rst


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -648,8 +648,8 @@
  ET __builtin_reduce_min(VT a)   return x or y, whichever is smaller; 
If exactly one argument integer and floating point types
  is a NaN, return the other argument. 
If both arguments are
  NaNs, fmax() return a NaN.
- ET __builtin_reduce_add(VT a)   \+
   integer and floating point types
- ET __builtin_reduce_mul(VT a)   \*
   integer and floating point types
+ ET __builtin_reduce_add(VT a)   \+
   integer types
+ ET __builtin_reduce_mul(VT a)   \*
   integer types
  ET __builtin_reduce_and(VT a)   & 
   integer types
  ET __builtin_reduce_or(VT a)\|
   integer types
  ET __builtin_reduce_xor(VT a)   ^ 
   integer types
@@ -4244,7 +4244,7 @@
 
   #pragma clang attribute pop
 
-A single push directive can contain multiple attributes, however, 
+A single push directive can contain multiple attributes, however,
 only one syntax style can be used within a single directive:
 
 .. code-block:: c++
@@ -4254,7 +4254,7 @@
   void function1(); // The function now has the [[noreturn]] and [[noinline]] 
attributes
 
   #pragma clang attribute pop
-  
+
   #pragma clang attribute push (__attribute((noreturn, noinline)), apply_to = 
function)
 
   void function2(); // The function now has the __attribute((noreturn)) and 
__attribute((noinline)) attributes


Index: clang/docs/LanguageExtensions.rst
===
--- clang/docs/LanguageExtensions.rst
+++ clang/docs/LanguageExtensions.rst
@@ -648,8 +648,8 @@
  ET __builtin_reduce_min(VT a)   return x or y, whichever is smaller; If exactly one argument integer and floating point types
  is a NaN, return the other argument. If both arguments are
  NaNs, fmax() return a NaN.
- ET __builtin_reduce_add(VT a)   \+   integer and floating point types
- ET __builtin_reduce_mul(VT a)   \*   integer and floating point types
+ ET __builtin_reduce_add(VT a)   \+   integer types
+ ET __builtin_reduce_mul(VT a)   \*   integer types
  ET __builtin_reduce_and(VT a)   &integer types
  ET __builtin_reduce_or(VT a)\|   integer types
  ET __builtin_reduce_xor(VT a)   ^integer types
@@ -4244,7 +4244,7 @@
 
   #pragma clang attribute pop
 
-A single push directive can contain multiple attributes, however, 
+A single push directive can contain multiple attributes, however,
 only one syntax style can be used within a single directive:
 
 .. code-block:: c++
@@ -4254,7 +4254,7 @@
   void function1(); // The function now has the [[noreturn]] and [[noinline]] attributes
 
   #pragma clang attribute pop
-  
+
   #pragma clang attribute push (__attribute((noreturn, noinline)), apply_to = function)
 
   void function2(); // The function now has the __attribute((noreturn)) and __attribute((noinline)) attributes
___
cfe-commits mailing 

[PATCH] D133520: [clang] Use std::size instead of llvm::array_lengthof

2022-09-08 Thread Joe Loser via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG1b3a78d1d534: [clang] Use std::size instead of 
llvm::array_lengthof (authored by jloser).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D133520

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/AST/AttrDocTable.cpp
  clang/lib/AST/CommentCommandTraits.cpp
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/ParsedAttr.cpp
  clang/unittests/AST/CommentLexer.cpp
  clang/unittests/AST/CommentParser.cpp
  clang/unittests/AST/DeclPrinterTest.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -642,7 +642,7 @@
   // Adjust the given command line arguments to ensure that any positional
   // arguments in them are stripped.
   const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"};
-  int Argc = llvm::array_lengthof(Argv);
+  int Argc = std::size(Argv);
   std::string ErrorMessage;
   std::unique_ptr Database =
   FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage);
Index: clang/unittests/AST/DeclPrinterTest.cpp
===
--- clang/unittests/AST/DeclPrinterTest.cpp
+++ clang/unittests/AST/DeclPrinterTest.cpp
@@ -731,7 +731,7 @@
 "()", "[]"
   };
 
-  for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) {
+  for (unsigned i = 0, e = std::size(OperatorNames); i != e; ++i) {
 SmallString<128> Code;
 Code.append("struct Z { void operator");
 Code.append(OperatorNames[i]);
@@ -754,7 +754,7 @@
 "~", "!", "++", "--", "->"
   };
 
-  for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) {
+  for (unsigned i = 0, e = std::size(OperatorNames); i != e; ++i) {
 SmallString<128> Code;
 Code.append("struct Z { void operator");
 Code.append(OperatorNames[i]);
Index: clang/unittests/AST/CommentParser.cpp
===
--- clang/unittests/AST/CommentParser.cpp
+++ clang/unittests/AST/CommentParser.cpp
@@ -664,7 +664,7 @@
 "*/"),
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -801,7 +801,7 @@
 "// Bbb\n")
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -831,7 +831,7 @@
 "// Bbb\n"),
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -861,7 +861,7 @@
 "// Bbb\n"),
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -892,7 +892,7 @@
 "// Bbb\n"
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -947,7 +947,7 @@
 "// Bbb\n"
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -1081,7 +1081,7 @@
 "// "
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 1));
 
@@ -1103,7 +1103,7 @@
 "// "
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 1));
 
@@ -1127,7 +1127,7 @@
 "// ",
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 1));
 
@@ 

[PATCH] D133520: [clang] Use std::size instead of llvm::array_lengthof

2022-09-08 Thread Joe Loser via Phabricator via cfe-commits
jloser created this revision.
jloser added reviewers: MaskRay, kazu, dblaikie, aaron.ballman.
Herald added subscribers: mattd, gchakrabarti, asavonic, StephenFan.
Herald added a project: All.
jloser requested review of this revision.
Herald added subscribers: cfe-commits, jholewinski.
Herald added a project: clang.

LLVM contains a helpful function for getting the size of a C-style
array: `llvm::array_lengthof`. This is useful prior to C++17, but not as
helpful for C++17 or later: `std::size` already has support for C-style
arrays.

Change call sites to use `std::size` instead. Leave the few call sites that
use a locally defined `array_lengthof` that are meant to test previous bugs
with NTTPs in clang analyzer and SemaTemplate.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D133520

Files:
  clang/include/clang/AST/OpenMPClause.h
  clang/lib/AST/AttrDocTable.cpp
  clang/lib/AST/CommentCommandTraits.cpp
  clang/lib/Basic/DiagnosticIDs.cpp
  clang/lib/Basic/Targets/NVPTX.h
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGObjC.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/lib/Driver/Types.cpp
  clang/lib/Frontend/PrintPreprocessedOutput.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/ParsedAttr.cpp
  clang/unittests/AST/CommentLexer.cpp
  clang/unittests/AST/CommentParser.cpp
  clang/unittests/AST/DeclPrinterTest.cpp
  clang/unittests/Tooling/CompilationDatabaseTest.cpp

Index: clang/unittests/Tooling/CompilationDatabaseTest.cpp
===
--- clang/unittests/Tooling/CompilationDatabaseTest.cpp
+++ clang/unittests/Tooling/CompilationDatabaseTest.cpp
@@ -642,7 +642,7 @@
   // Adjust the given command line arguments to ensure that any positional
   // arguments in them are stripped.
   const char *Argv[] = {"--", "somefile.cpp", "-fsyntax-only", "-DDEF3"};
-  int Argc = llvm::array_lengthof(Argv);
+  int Argc = std::size(Argv);
   std::string ErrorMessage;
   std::unique_ptr Database =
   FixedCompilationDatabase::loadFromCommandLine(Argc, Argv, ErrorMessage);
Index: clang/unittests/AST/DeclPrinterTest.cpp
===
--- clang/unittests/AST/DeclPrinterTest.cpp
+++ clang/unittests/AST/DeclPrinterTest.cpp
@@ -731,7 +731,7 @@
 "()", "[]"
   };
 
-  for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) {
+  for (unsigned i = 0, e = std::size(OperatorNames); i != e; ++i) {
 SmallString<128> Code;
 Code.append("struct Z { void operator");
 Code.append(OperatorNames[i]);
@@ -754,7 +754,7 @@
 "~", "!", "++", "--", "->"
   };
 
-  for (unsigned i = 0, e = llvm::array_lengthof(OperatorNames); i != e; ++i) {
+  for (unsigned i = 0, e = std::size(OperatorNames); i != e; ++i) {
 SmallString<128> Code;
 Code.append("struct Z { void operator");
 Code.append(OperatorNames[i]);
Index: clang/unittests/AST/CommentParser.cpp
===
--- clang/unittests/AST/CommentParser.cpp
+++ clang/unittests/AST/CommentParser.cpp
@@ -664,7 +664,7 @@
 "*/"),
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -801,7 +801,7 @@
 "// Bbb\n")
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -831,7 +831,7 @@
 "// Bbb\n"),
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -861,7 +861,7 @@
 "// Bbb\n"),
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -892,7 +892,7 @@
 "// Bbb\n"
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -947,7 +947,7 @@
 "// Bbb\n"
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 2));
 
@@ -1081,7 +1081,7 @@
 "// "
   };
 
-  for (size_t i = 0, e = array_lengthof(Sources); i != e; i++) {
+  for (size_t i = 0, e = std::size(Sources); i != e; i++) {
 FullComment *FC = parseString(Sources[i]);
 ASSERT_TRUE(HasChildCount(FC, 1));
 
@@ -1103,7 +1103,7 @@
 "// "
   

[PATCH] D131935: [clang][llvm][NFC] Change misexpect's tolerance option to be 32-bit

2022-08-17 Thread Joe Loser via Phabricator via cfe-commits
jloser accepted this revision.
jloser added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks for the follow-up cleanup. I'll rebase once this lands to avoid 
the cast in https://reviews.llvm.org/D131869 if that works for you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131935

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


[PATCH] D131717: [ADT] Replace STLForwardCompat.h's C++17 equivalents

2022-08-12 Thread Joe Loser via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8578968f684: [ADT] Replace STLForwardCompat.hs C++17 
equivalents (authored by joe_loser).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131717

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  llvm/include/llvm/ADT/Any.h
  llvm/include/llvm/ADT/FunctionExtras.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/Support/HashBuilder.h
  llvm/unittests/ADT/OptionalTest.cpp

Index: llvm/unittests/ADT/OptionalTest.cpp
===
--- llvm/unittests/ADT/OptionalTest.cpp
+++ llvm/unittests/ADT/OptionalTest.cpp
@@ -14,7 +14,7 @@
 #include "gtest/gtest.h"
 
 #include 
-
+#include 
 
 using namespace llvm;
 
@@ -201,7 +201,7 @@
 
 TEST(OptionalTest, InPlaceConstructionNonDefaultConstructibleTest) {
   NonDefaultConstructible::ResetCounts();
-  { Optional A{in_place, 1}; }
+  { Optional A{std::in_place, 1}; }
   EXPECT_EQ(0u, NonDefaultConstructible::CopyConstructions);
   EXPECT_EQ(0u, NonDefaultConstructible::CopyAssignments);
   EXPECT_EQ(1u, NonDefaultConstructible::Destructions);
@@ -247,7 +247,7 @@
 TEST(OptionalTest, Emplace) {
   MultiArgConstructor::ResetCounts();
   Optional A;
-  
+
   A.emplace(1, 2);
   EXPECT_TRUE(A.has_value());
   EXPECT_TRUE(A.has_value());
@@ -266,12 +266,12 @@
 TEST(OptionalTest, InPlaceConstructionMultiArgConstructorTest) {
   MultiArgConstructor::ResetCounts();
   {
-Optional A{in_place, 1, 2};
+Optional A{std::in_place, 1, 2};
 EXPECT_TRUE(A.has_value());
 EXPECT_TRUE(A.has_value());
 EXPECT_EQ(1, A->x);
 EXPECT_EQ(2, A->y);
-Optional B{in_place, 5, false};
+Optional B{std::in_place, 5, false};
 EXPECT_TRUE(B.has_value());
 EXPECT_TRUE(B.has_value());
 EXPECT_EQ(5, B->x);
@@ -284,7 +284,7 @@
 TEST(OptionalTest, InPlaceConstructionAndEmplaceEquivalentTest) {
   MultiArgConstructor::ResetCounts();
   {
-Optional A{in_place, 1, 2};
+Optional A{std::in_place, 1, 2};
 Optional B;
 B.emplace(1, 2);
 EXPECT_EQ(0u, MultiArgConstructor::Destructions);
@@ -442,7 +442,7 @@
 
 TEST(OptionalTest, ImmovableInPlaceConstruction) {
   Immovable::ResetCounts();
-  Optional A{in_place, 4};
+  Optional A{std::in_place, 4};
   EXPECT_TRUE((bool)A);
   EXPECT_EQ(4, A->val);
   EXPECT_EQ(1u, Immovable::Constructions);
Index: llvm/include/llvm/Support/HashBuilder.h
===
--- llvm/include/llvm/Support/HashBuilder.h
+++ llvm/include/llvm/Support/HashBuilder.h
@@ -76,7 +76,7 @@
 
   template 
   explicit HashBuilderBase(ArgTypes &&...Args)
-  : OptionalHasher(in_place, std::forward(Args)...),
+  : OptionalHasher(std::in_place, std::forward(Args)...),
 Hasher(*OptionalHasher) {}
 
 private:
Index: llvm/include/llvm/ADT/STLExtras.h
===
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -155,12 +155,12 @@
 /// traits class for checking whether type T is one of any of the given
 /// types in the variadic list.
 template 
-using is_one_of = disjunction...>;
+using is_one_of = std::disjunction...>;
 
 /// traits class for checking whether type T is a base class for all
 ///  the given types in the variadic list.
 template 
-using are_base_of = conjunction...>;
+using are_base_of = std::conjunction...>;
 
 namespace detail {
 template  struct TypesAreDistinct;
@@ -1386,12 +1386,12 @@
 /// traits class for checking whether type T is one of any of the given
 /// types in the variadic list.
 template 
-using is_one_of = disjunction...>;
+using is_one_of = std::disjunction...>;
 
 /// traits class for checking whether type T is a base class for all
 ///  the given types in the variadic list.
 template 
-using are_base_of = conjunction...>;
+using are_base_of = std::conjunction...>;
 
 namespace detail {
 template  struct Visitor;
@@ -1550,7 +1550,7 @@
 template 
 // We can use qsort if the iterator type is a pointer and the underlying value
 // is trivially copyable.
-using sort_trivially_copyable = conjunction<
+using sort_trivially_copyable = std::conjunction<
 std::is_pointer,
 std::is_trivially_copyable::value_type>>;
 } // namespace detail
Index: llvm/include/llvm/ADT/Optional.h
===
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -81,7 +81,7 @@
   }
 
   template 
-  constexpr explicit OptionalStorage(in_place_t, Args &&...args)
+  constexpr explicit OptionalStorage(std::in_place_t, Args &&...args)
   : val(std::forward(args)...), hasVal(true) {}
 
   void reset() noexcept {
@@ -196,7 +196,7 @@
   OptionalStorage =(OptionalStorage &) = default;
 
   template 
- 

[PATCH] D131717: [ADT] Replace STLForwardCompat.h's C++17 equivalents

2022-08-11 Thread Joe Loser via Phabricator via cfe-commits
jloser updated this revision to Diff 452022.
jloser added a comment.

Fix unqualified use of `in_place` so the delegating constructor in `Optional` 
calls the one taking the `std::in_place_t` tag.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131717

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  llvm/include/llvm/ADT/Any.h
  llvm/include/llvm/ADT/FunctionExtras.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/Support/HashBuilder.h
  llvm/unittests/ADT/OptionalTest.cpp

Index: llvm/unittests/ADT/OptionalTest.cpp
===
--- llvm/unittests/ADT/OptionalTest.cpp
+++ llvm/unittests/ADT/OptionalTest.cpp
@@ -14,7 +14,7 @@
 #include "gtest/gtest.h"
 
 #include 
-
+#include 
 
 using namespace llvm;
 
@@ -201,7 +201,7 @@
 
 TEST(OptionalTest, InPlaceConstructionNonDefaultConstructibleTest) {
   NonDefaultConstructible::ResetCounts();
-  { Optional A{in_place, 1}; }
+  { Optional A{std::in_place, 1}; }
   EXPECT_EQ(0u, NonDefaultConstructible::CopyConstructions);
   EXPECT_EQ(0u, NonDefaultConstructible::CopyAssignments);
   EXPECT_EQ(1u, NonDefaultConstructible::Destructions);
@@ -247,7 +247,7 @@
 TEST(OptionalTest, Emplace) {
   MultiArgConstructor::ResetCounts();
   Optional A;
-  
+
   A.emplace(1, 2);
   EXPECT_TRUE(A.has_value());
   EXPECT_TRUE(A.has_value());
@@ -266,12 +266,12 @@
 TEST(OptionalTest, InPlaceConstructionMultiArgConstructorTest) {
   MultiArgConstructor::ResetCounts();
   {
-Optional A{in_place, 1, 2};
+Optional A{std::in_place, 1, 2};
 EXPECT_TRUE(A.has_value());
 EXPECT_TRUE(A.has_value());
 EXPECT_EQ(1, A->x);
 EXPECT_EQ(2, A->y);
-Optional B{in_place, 5, false};
+Optional B{std::in_place, 5, false};
 EXPECT_TRUE(B.has_value());
 EXPECT_TRUE(B.has_value());
 EXPECT_EQ(5, B->x);
@@ -284,7 +284,7 @@
 TEST(OptionalTest, InPlaceConstructionAndEmplaceEquivalentTest) {
   MultiArgConstructor::ResetCounts();
   {
-Optional A{in_place, 1, 2};
+Optional A{std::in_place, 1, 2};
 Optional B;
 B.emplace(1, 2);
 EXPECT_EQ(0u, MultiArgConstructor::Destructions);
@@ -442,7 +442,7 @@
 
 TEST(OptionalTest, ImmovableInPlaceConstruction) {
   Immovable::ResetCounts();
-  Optional A{in_place, 4};
+  Optional A{std::in_place, 4};
   EXPECT_TRUE((bool)A);
   EXPECT_EQ(4, A->val);
   EXPECT_EQ(1u, Immovable::Constructions);
Index: llvm/include/llvm/Support/HashBuilder.h
===
--- llvm/include/llvm/Support/HashBuilder.h
+++ llvm/include/llvm/Support/HashBuilder.h
@@ -76,7 +76,7 @@
 
   template 
   explicit HashBuilderBase(ArgTypes &&...Args)
-  : OptionalHasher(in_place, std::forward(Args)...),
+  : OptionalHasher(std::in_place, std::forward(Args)...),
 Hasher(*OptionalHasher) {}
 
 private:
Index: llvm/include/llvm/ADT/STLExtras.h
===
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -155,12 +155,12 @@
 /// traits class for checking whether type T is one of any of the given
 /// types in the variadic list.
 template 
-using is_one_of = disjunction...>;
+using is_one_of = std::disjunction...>;
 
 /// traits class for checking whether type T is a base class for all
 ///  the given types in the variadic list.
 template 
-using are_base_of = conjunction...>;
+using are_base_of = std::conjunction...>;
 
 namespace detail {
 template  struct TypesAreDistinct;
@@ -1386,12 +1386,12 @@
 /// traits class for checking whether type T is one of any of the given
 /// types in the variadic list.
 template 
-using is_one_of = disjunction...>;
+using is_one_of = std::disjunction...>;
 
 /// traits class for checking whether type T is a base class for all
 ///  the given types in the variadic list.
 template 
-using are_base_of = conjunction...>;
+using are_base_of = std::conjunction...>;
 
 namespace detail {
 template  struct Visitor;
@@ -1550,7 +1550,7 @@
 template 
 // We can use qsort if the iterator type is a pointer and the underlying value
 // is trivially copyable.
-using sort_trivially_copyable = conjunction<
+using sort_trivially_copyable = std::conjunction<
 std::is_pointer,
 std::is_trivially_copyable::value_type>>;
 } // namespace detail
Index: llvm/include/llvm/ADT/Optional.h
===
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -81,7 +81,7 @@
   }
 
   template 
-  constexpr explicit OptionalStorage(in_place_t, Args &&...args)
+  constexpr explicit OptionalStorage(std::in_place_t, Args &&...args)
   : val(std::forward(args)...), hasVal(true) {}
 
   void reset() noexcept {
@@ -196,7 +196,7 @@
   OptionalStorage =(OptionalStorage &) = default;
 
  

[PATCH] D131717: [ADT] Replace STLForwardCompat.h's C++17 equivalents

2022-08-11 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

In D131717#3717363 , @MaskRay wrote:

> The llvm/include/llvm/ADT/STLForwardCompat.h and 
> llvm/unittests/ADT/STLForwardCompatTest.cpp removal can be in a separate 
> patch.

Sure. I just split them out of this patch and I'll do the removal in a 
follow-up patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131717

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


[PATCH] D131717: [ADT] Replace STLForwardCompat.h's C++17 equivalents

2022-08-11 Thread Joe Loser via Phabricator via cfe-commits
jloser updated this revision to Diff 451977.
jloser added a comment.

Revert removal of these utilities and type traits from STLForwardCompat.h and 
their corresponding unit tests. The removal of these will be done in a separate 
patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D131717

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  llvm/include/llvm/ADT/Any.h
  llvm/include/llvm/ADT/FunctionExtras.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/Support/HashBuilder.h
  llvm/unittests/ADT/OptionalTest.cpp

Index: llvm/unittests/ADT/OptionalTest.cpp
===
--- llvm/unittests/ADT/OptionalTest.cpp
+++ llvm/unittests/ADT/OptionalTest.cpp
@@ -14,7 +14,7 @@
 #include "gtest/gtest.h"
 
 #include 
-
+#include 
 
 using namespace llvm;
 
@@ -201,7 +201,7 @@
 
 TEST(OptionalTest, InPlaceConstructionNonDefaultConstructibleTest) {
   NonDefaultConstructible::ResetCounts();
-  { Optional A{in_place, 1}; }
+  { Optional A{std::in_place, 1}; }
   EXPECT_EQ(0u, NonDefaultConstructible::CopyConstructions);
   EXPECT_EQ(0u, NonDefaultConstructible::CopyAssignments);
   EXPECT_EQ(1u, NonDefaultConstructible::Destructions);
@@ -247,7 +247,7 @@
 TEST(OptionalTest, Emplace) {
   MultiArgConstructor::ResetCounts();
   Optional A;
-  
+
   A.emplace(1, 2);
   EXPECT_TRUE(A.has_value());
   EXPECT_TRUE(A.has_value());
@@ -266,12 +266,12 @@
 TEST(OptionalTest, InPlaceConstructionMultiArgConstructorTest) {
   MultiArgConstructor::ResetCounts();
   {
-Optional A{in_place, 1, 2};
+Optional A{std::in_place, 1, 2};
 EXPECT_TRUE(A.has_value());
 EXPECT_TRUE(A.has_value());
 EXPECT_EQ(1, A->x);
 EXPECT_EQ(2, A->y);
-Optional B{in_place, 5, false};
+Optional B{std::in_place, 5, false};
 EXPECT_TRUE(B.has_value());
 EXPECT_TRUE(B.has_value());
 EXPECT_EQ(5, B->x);
@@ -284,7 +284,7 @@
 TEST(OptionalTest, InPlaceConstructionAndEmplaceEquivalentTest) {
   MultiArgConstructor::ResetCounts();
   {
-Optional A{in_place, 1, 2};
+Optional A{std::in_place, 1, 2};
 Optional B;
 B.emplace(1, 2);
 EXPECT_EQ(0u, MultiArgConstructor::Destructions);
@@ -442,7 +442,7 @@
 
 TEST(OptionalTest, ImmovableInPlaceConstruction) {
   Immovable::ResetCounts();
-  Optional A{in_place, 4};
+  Optional A{std::in_place, 4};
   EXPECT_TRUE((bool)A);
   EXPECT_EQ(4, A->val);
   EXPECT_EQ(1u, Immovable::Constructions);
Index: llvm/include/llvm/Support/HashBuilder.h
===
--- llvm/include/llvm/Support/HashBuilder.h
+++ llvm/include/llvm/Support/HashBuilder.h
@@ -76,7 +76,7 @@
 
   template 
   explicit HashBuilderBase(ArgTypes &&...Args)
-  : OptionalHasher(in_place, std::forward(Args)...),
+  : OptionalHasher(std::in_place, std::forward(Args)...),
 Hasher(*OptionalHasher) {}
 
 private:
Index: llvm/include/llvm/ADT/STLExtras.h
===
--- llvm/include/llvm/ADT/STLExtras.h
+++ llvm/include/llvm/ADT/STLExtras.h
@@ -155,12 +155,12 @@
 /// traits class for checking whether type T is one of any of the given
 /// types in the variadic list.
 template 
-using is_one_of = disjunction...>;
+using is_one_of = std::disjunction...>;
 
 /// traits class for checking whether type T is a base class for all
 ///  the given types in the variadic list.
 template 
-using are_base_of = conjunction...>;
+using are_base_of = std::conjunction...>;
 
 namespace detail {
 template  struct TypesAreDistinct;
@@ -1386,12 +1386,12 @@
 /// traits class for checking whether type T is one of any of the given
 /// types in the variadic list.
 template 
-using is_one_of = disjunction...>;
+using is_one_of = std::disjunction...>;
 
 /// traits class for checking whether type T is a base class for all
 ///  the given types in the variadic list.
 template 
-using are_base_of = conjunction...>;
+using are_base_of = std::conjunction...>;
 
 namespace detail {
 template  struct Visitor;
@@ -1550,7 +1550,7 @@
 template 
 // We can use qsort if the iterator type is a pointer and the underlying value
 // is trivially copyable.
-using sort_trivially_copyable = conjunction<
+using sort_trivially_copyable = std::conjunction<
 std::is_pointer,
 std::is_trivially_copyable::value_type>>;
 } // namespace detail
Index: llvm/include/llvm/ADT/Optional.h
===
--- llvm/include/llvm/ADT/Optional.h
+++ llvm/include/llvm/ADT/Optional.h
@@ -81,7 +81,7 @@
   }
 
   template 
-  constexpr explicit OptionalStorage(in_place_t, Args &&...args)
+  constexpr explicit OptionalStorage(std::in_place_t, Args &&...args)
   : val(std::forward(args)...), hasVal(true) {}
 
   void reset() noexcept {
@@ -196,7 +196,7 @@
   

[PATCH] D131717: [ADT] Replace STLForwardCompat.h's C++17 equivalents

2022-08-11 Thread Joe Loser via Phabricator via cfe-commits
jloser created this revision.
jloser added reviewers: scott.linder, MaskRay, bkramer, zero9178, dblaikie.
Herald added a subscriber: StephenFan.
Herald added a project: All.
jloser requested review of this revision.
Herald added projects: clang, LLVM.
Herald added subscribers: llvm-commits, cfe-commits.

STLForwardCompat.h defines several utilities and type traits to mimic that of
the ones in the C++17 standard library. Now that LLVM is built with the C++17
standards mode, remove these equivalents in favor of the ones from the
standard library.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131717

Files:
  clang/include/clang/Basic/DirectoryEntry.h
  clang/include/clang/Basic/FileEntry.h
  llvm/include/llvm/ADT/Any.h
  llvm/include/llvm/ADT/FunctionExtras.h
  llvm/include/llvm/ADT/Optional.h
  llvm/include/llvm/ADT/STLExtras.h
  llvm/include/llvm/ADT/STLForwardCompat.h
  llvm/include/llvm/Support/HashBuilder.h
  llvm/unittests/ADT/OptionalTest.cpp
  llvm/unittests/ADT/STLForwardCompatTest.cpp

Index: llvm/unittests/ADT/STLForwardCompatTest.cpp
===
--- llvm/unittests/ADT/STLForwardCompatTest.cpp
+++ llvm/unittests/ADT/STLForwardCompatTest.cpp
@@ -11,37 +11,6 @@
 
 namespace {
 
-TEST(STLForwardCompatTest, NegationTest) {
-  EXPECT_TRUE((llvm::negation::value));
-  EXPECT_FALSE((llvm::negation::value));
-}
-
-struct incomplete_type;
-
-TEST(STLForwardCompatTest, ConjunctionTest) {
-  EXPECT_TRUE((llvm::conjunction<>::value));
-  EXPECT_FALSE((llvm::conjunction::value));
-  EXPECT_TRUE((llvm::conjunction::value));
-  EXPECT_FALSE((llvm::conjunction::value));
-  EXPECT_FALSE((llvm::conjunction::value));
-  EXPECT_FALSE((llvm::conjunction::value));
-  EXPECT_TRUE((llvm::conjunction::value));
-  EXPECT_TRUE((llvm::conjunction::value));
-}
-
-TEST(STLForwardCompatTest, DisjunctionTest) {
-  EXPECT_FALSE((llvm::disjunction<>::value));
-  EXPECT_FALSE((llvm::disjunction::value));
-  EXPECT_TRUE((llvm::disjunction::value));
-  EXPECT_TRUE((llvm::disjunction::value));
-  EXPECT_TRUE((llvm::disjunction::value));
-  EXPECT_TRUE((llvm::disjunction::value));
-  EXPECT_TRUE((llvm::disjunction::value));
-  EXPECT_TRUE((llvm::disjunction::value));
-}
-
 template 
 class STLForwardCompatRemoveCVRefTest : public ::testing::Test {};
 
Index: llvm/unittests/ADT/OptionalTest.cpp
===
--- llvm/unittests/ADT/OptionalTest.cpp
+++ llvm/unittests/ADT/OptionalTest.cpp
@@ -14,7 +14,7 @@
 #include "gtest/gtest.h"
 
 #include 
-
+#include 
 
 using namespace llvm;
 
@@ -201,7 +201,7 @@
 
 TEST(OptionalTest, InPlaceConstructionNonDefaultConstructibleTest) {
   NonDefaultConstructible::ResetCounts();
-  { Optional A{in_place, 1}; }
+  { Optional A{std::in_place, 1}; }
   EXPECT_EQ(0u, NonDefaultConstructible::CopyConstructions);
   EXPECT_EQ(0u, NonDefaultConstructible::CopyAssignments);
   EXPECT_EQ(1u, NonDefaultConstructible::Destructions);
@@ -247,7 +247,7 @@
 TEST(OptionalTest, Emplace) {
   MultiArgConstructor::ResetCounts();
   Optional A;
-  
+
   A.emplace(1, 2);
   EXPECT_TRUE(A.has_value());
   EXPECT_TRUE(A.has_value());
@@ -266,12 +266,12 @@
 TEST(OptionalTest, InPlaceConstructionMultiArgConstructorTest) {
   MultiArgConstructor::ResetCounts();
   {
-Optional A{in_place, 1, 2};
+Optional A{std::in_place, 1, 2};
 EXPECT_TRUE(A.has_value());
 EXPECT_TRUE(A.has_value());
 EXPECT_EQ(1, A->x);
 EXPECT_EQ(2, A->y);
-Optional B{in_place, 5, false};
+Optional B{std::in_place, 5, false};
 EXPECT_TRUE(B.has_value());
 EXPECT_TRUE(B.has_value());
 EXPECT_EQ(5, B->x);
@@ -284,7 +284,7 @@
 TEST(OptionalTest, InPlaceConstructionAndEmplaceEquivalentTest) {
   MultiArgConstructor::ResetCounts();
   {
-Optional A{in_place, 1, 2};
+Optional A{std::in_place, 1, 2};
 Optional B;
 B.emplace(1, 2);
 EXPECT_EQ(0u, MultiArgConstructor::Destructions);
@@ -442,7 +442,7 @@
 
 TEST(OptionalTest, ImmovableInPlaceConstruction) {
   Immovable::ResetCounts();
-  Optional A{in_place, 4};
+  Optional A{std::in_place, 4};
   EXPECT_TRUE((bool)A);
   EXPECT_EQ(4, A->val);
   EXPECT_EQ(1u, Immovable::Constructions);
Index: llvm/include/llvm/Support/HashBuilder.h
===
--- llvm/include/llvm/Support/HashBuilder.h
+++ llvm/include/llvm/Support/HashBuilder.h
@@ -76,7 +76,7 @@
 
   template 
   explicit HashBuilderBase(ArgTypes &&...Args)
-  : OptionalHasher(in_place, std::forward(Args)...),
+  : OptionalHasher(std::in_place, std::forward(Args)...),
 Hasher(*OptionalHasher) {}
 
 private:
Index: llvm/include/llvm/ADT/STLForwardCompat.h
===
--- llvm/include/llvm/ADT/STLForwardCompat.h
+++ llvm/include/llvm/ADT/STLForwardCompat.h
@@ -21,49 +21,6 @@
 
 namespace llvm {
 

[PATCH] D99134: Lambdas are not necessarily locals. This resolves DR48250.

2022-02-10 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

Would love to see this cherry-picked into the llvm 14 release branch if 
possible!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99134

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


[PATCH] D45677: [libcxx] [test] Fix typo in filesystem test

2019-12-21 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

Jim, thanks for accepting the review.  Do you mind landing this on my behalf? I 
don't have commit rights.  Thanks!


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D45677



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


[PATCH] D45677: [libcxx] [test] Fix typo in filesystem test

2018-04-15 Thread Joe Loser via Phabricator via cfe-commits
jloser created this revision.
jloser added a reviewer: EricWF.
Herald added subscribers: cfe-commits, christof.

There was a typo in "omitted" in 
`/test/std/experimental/filesystem/fs.op.funcs/fs.op.relative/relative.pass.cpp 
`


Repository:
  rCXX libc++

https://reviews.llvm.org/D45677

Files:
  
libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.relative/relative.pass.cpp


Index: 
libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.relative/relative.pass.cpp
===
--- 
libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.relative/relative.pass.cpp
+++ 
libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.relative/relative.pass.cpp
@@ -46,7 +46,7 @@
   {StaticEnv::SymlinkToDir, StaticEnv::Dir},
   {StaticEnv::SymlinkToDir / "dir2/.", StaticEnv::Dir / "dir2"},
   // FIXME? If the trailing separator occurs in a part of the path that 
exists,
-  // it is ommitted. Otherwise it is added to the end of the result.
+  // it is omitted. Otherwise it is added to the end of the result.
   {StaticEnv::SymlinkToDir / "dir2/./", StaticEnv::Dir / "dir2"},
   {StaticEnv::SymlinkToDir / "dir2/DNE/./", StaticEnv::Dir / "dir2/DNE/"},
   {StaticEnv::SymlinkToDir / "dir2", StaticEnv::Dir2},


Index: libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.relative/relative.pass.cpp
===
--- libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.relative/relative.pass.cpp
+++ libcxx/test/std/experimental/filesystem/fs.op.funcs/fs.op.relative/relative.pass.cpp
@@ -46,7 +46,7 @@
   {StaticEnv::SymlinkToDir, StaticEnv::Dir},
   {StaticEnv::SymlinkToDir / "dir2/.", StaticEnv::Dir / "dir2"},
   // FIXME? If the trailing separator occurs in a part of the path that exists,
-  // it is ommitted. Otherwise it is added to the end of the result.
+  // it is omitted. Otherwise it is added to the end of the result.
   {StaticEnv::SymlinkToDir / "dir2/./", StaticEnv::Dir / "dir2"},
   {StaticEnv::SymlinkToDir / "dir2/DNE/./", StaticEnv::Dir / "dir2/DNE/"},
   {StaticEnv::SymlinkToDir / "dir2", StaticEnv::Dir2},
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D44411: [libcxx] [test] Fix Container::insert(value_type const&) tests

2018-04-08 Thread Joe Loser via Phabricator via cfe-commits
jloser added a comment.

In https://reviews.llvm.org/D44411#1056374, @EricWF wrote:

> Have you verified that we're not losing test coverage here? That is, are you 
> sure we still have tests for the rvalue overloads in other test files?


Yep. These containers already have tests for inserts with rvalues. No loss in 
test coverage here.


https://reviews.llvm.org/D44411



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


[PATCH] D44411: [libcxx] [test] Fix Container::insert(value_type const&) tests

2018-04-08 Thread Joe Loser via Phabricator via cfe-commits
jloser updated this revision to Diff 141573.
jloser added a comment.

Use `v3` rather than an rvalue of `3` in 
`libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp`


https://reviews.llvm.org/D44411

Files:
  libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp
  libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
  
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp

Index: libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
===
--- libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
+++ libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
@@ -24,53 +24,42 @@
 
 #include "min_allocator.h"
 
+template
+void do_insert_hint_const_lvalue_test()
+{
+typedef Container C;
+typedef typename C::iterator R;
+typedef typename C::value_type VT;
+C c;
+typename C::const_iterator e = c.end();
+const VT v1(3.5);
+R r = c.insert(e, v1);
+assert(c.size() == 1);
+assert(*r == 3.5);
+
+r = c.insert(e, v1);
+assert(c.size() == 1);
+assert(*r == 3.5);
+
+const VT v2(4.5);
+r = c.insert(e, v2);
+assert(c.size() == 2);
+assert(*r == 4.5);
+
+const VT v3(5.5);
+r = c.insert(e, v3);
+assert(c.size() == 3);
+assert(*r == 5.5);
+}
+
 int main()
 {
-{
-typedef std::unordered_set C;
-typedef C::iterator R;
-typedef C::value_type P;
-C c;
-C::const_iterator e = c.end();
-R r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(4.5));
-assert(c.size() == 2);
-assert(*r == 4.5);
-
-r = c.insert(e, P(5.5));
-assert(c.size() == 3);
-assert(*r == 5.5);
-}
+do_insert_hint_const_lvalue_test();
 #if TEST_STD_VER >= 11
 {
 typedef std::unordered_set C;
-typedef C::iterator R;
-typedef C::value_type P;
-C c;
-C::const_iterator e = c.end();
-R r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(4.5));
-assert(c.size() == 2);
-assert(*r == 4.5);
-
-r = c.insert(e, P(5.5));
-assert(c.size() == 3);
-assert(*r == 5.5);
+do_insert_hint_const_lvalue_test();
 }
 #endif
 #if _LIBCPP_DEBUG >= 1
Index: libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
===
--- libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
+++ libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
@@ -20,59 +20,45 @@
 
 #include "min_allocator.h"
 
+template
+void do_insert_const_lvalue_test()
+{
+typedef Container C;
+typedef std::pair R;
+typedef typename C::value_type VT;
+C c;
+const VT v1(3.5);
+R r = c.insert(v1);
+assert(c.size() == 1);
+assert(*r.first == 3.5);
+assert(r.second);
+
+r = c.insert(v1);
+assert(c.size() == 1);
+assert(*r.first == 3.5);
+assert(!r.second);
+
+const VT v2(4.5);
+r = c.insert(v2);
+assert(c.size() == 2);
+assert(*r.first == 4.5);
+assert(r.second);
+
+const VT v3(5.5);
+r = c.insert(v3);
+assert(c.size() == 3);
+assert(*r.first == 5.5);
+assert(r.second);
+}
+
 int main()
 {
-{
-typedef std::unordered_set C;
-typedef std::pair R;
-typedef C::value_type P;
-C c;
-R r = c.insert(P(3.5));
-assert(c.size() == 1);
-assert(*r.first == 3.5);
-assert(r.second);
-
-r = c.insert(P(3.5));
-assert(c.size() == 1);
-assert(*r.first == 3.5);
-assert(!r.second);
-
-r = c.insert(P(4.5));
-assert(c.size() == 2);
-assert(*r.first == 4.5);
-assert(r.second);
-
-r = 

[PATCH] D44411: [libc++] Fix Container::insert(value_type const&) tests

2018-03-12 Thread Joe Loser via Phabricator via cfe-commits
jloser created this revision.
jloser added reviewers: EricWF, matthew.
Herald added subscribers: cfe-commits, christof.

[libc++] Fix Container::insert(value_type const&) tests

Several unit tests meaning to test the behavior of lvalue insertion incorrectly 
pass rvalues.  Fixes bug 27394.


Repository:
  rCXX libc++

https://reviews.llvm.org/D44411

Files:
  libcxx/test/std/containers/associative/multiset/insert_cv.pass.cpp
  libcxx/test/std/containers/associative/set/insert_cv.pass.cpp
  
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp
  
libcxx/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
  libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp

Index: libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
===
--- libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
+++ libcxx/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp
@@ -24,53 +24,42 @@
 
 #include "min_allocator.h"
 
+template
+void do_insert_hint_const_lvalue_test()
+{
+typedef Container C;
+typedef typename C::iterator R;
+typedef typename C::value_type VT;
+C c;
+typename C::const_iterator e = c.end();
+const VT v1(3.5);
+R r = c.insert(e, v1);
+assert(c.size() == 1);
+assert(*r == 3.5);
+
+r = c.insert(e, v1);
+assert(c.size() == 1);
+assert(*r == 3.5);
+
+const VT v2(4.5);
+r = c.insert(e, v2);
+assert(c.size() == 2);
+assert(*r == 4.5);
+
+const VT v3(5.5);
+r = c.insert(e, v3);
+assert(c.size() == 3);
+assert(*r == 5.5);
+}
+
 int main()
 {
-{
-typedef std::unordered_set C;
-typedef C::iterator R;
-typedef C::value_type P;
-C c;
-C::const_iterator e = c.end();
-R r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(4.5));
-assert(c.size() == 2);
-assert(*r == 4.5);
-
-r = c.insert(e, P(5.5));
-assert(c.size() == 3);
-assert(*r == 5.5);
-}
+do_insert_hint_const_lvalue_test();
 #if TEST_STD_VER >= 11
 {
 typedef std::unordered_set C;
-typedef C::iterator R;
-typedef C::value_type P;
-C c;
-C::const_iterator e = c.end();
-R r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(3.5));
-assert(c.size() == 1);
-assert(*r == 3.5);
-
-r = c.insert(e, P(4.5));
-assert(c.size() == 2);
-assert(*r == 4.5);
-
-r = c.insert(e, P(5.5));
-assert(c.size() == 3);
-assert(*r == 5.5);
+do_insert_hint_const_lvalue_test();
 }
 #endif
 #if _LIBCPP_DEBUG >= 1
Index: libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
===
--- libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
+++ libcxx/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp
@@ -20,59 +20,45 @@
 
 #include "min_allocator.h"
 
+template
+void do_insert_const_lvalue_test()
+{
+typedef Container C;
+typedef std::pair R;
+typedef typename C::value_type VT;
+C c;
+const VT v1(3.5);
+R r = c.insert(v1);
+assert(c.size() == 1);
+assert(*r.first == 3.5);
+assert(r.second);
+
+r = c.insert(v1);
+assert(c.size() == 1);
+assert(*r.first == 3.5);
+assert(!r.second);
+
+const VT v2(4.5);
+r = c.insert(v2);
+assert(c.size() == 2);
+assert(*r.first == 4.5);
+assert(r.second);
+
+const VT v3(5.5);
+r = c.insert(v3);
+assert(c.size() == 3);
+assert(*r.first == 5.5);
+assert(r.second);
+}
+
 int main()
 {
-{
-typedef std::unordered_set C;
-typedef std::pair R;
-typedef C::value_type P;
-C c;
-R r = c.insert(P(3.5));
-assert(c.size() == 1);
-assert(*r.first == 3.5);
-assert(r.second);
-
-r = c.insert(P(3.5));
-assert(c.size() == 1);
-assert(*r.first == 3.5);
-assert(!r.second);
-
-r =