[PATCH] D67052: Add reference type transformation builtins

2020-04-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 258834.
zoecarver marked 2 inline comments as done.
zoecarver added a comment.

- Rebase
- Fix based on review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/remove_cv.cpp
  clang/test/SemaCXX/remove_reference.cpp

Index: clang/test/SemaCXX/remove_reference.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_reference.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template
+struct test_remove_ref_trait
+{
+  typedef __remove_reference(T) type;
+};
+
+template
+struct test_remove_ref
+{
+  static const bool value = __is_same(typename test_remove_ref_trait::type, T)  &&
+__is_same(typename test_remove_ref_trait::type, T) &&
+__is_same(typename test_remove_ref_trait::type, T);
+};
+
+struct Foo { };
+
+template
+struct Bar { };
+
+template
+class Baz { };
+
+class Biz;
+
+void x() { }
+
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref>::value, "");
+static_assert(test_remove_ref>::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+
Index: clang/test/SemaCXX/remove_cv.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_cv.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template
+struct remove_const
+{
+  typedef __remove_const(T) type;
+};
+
+template
+struct remove_volatile
+{
+  typedef __remove_volatile(T) type;
+};
+
+template
+struct remove_cv
+{
+  typedef __remove_cv(T) type;
+};
+
+template
+struct test
+{
+  static const bool value =
+__is_same(typename remove_const::type, T) &&
+__is_same(typename remove_const::type, volatile T) &&
+__is_same(typename remove_const::type, T) &&
+
+__is_same(typename remove_volatile::type, T) &&
+__is_same(typename remove_volatile::type, const T) &&
+__is_same(typename remove_volatile::type, T) &&
+
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T);
+};
+
+struct Foo { };
+
+template
+struct Bar { };
+
+template
+class Baz { };
+
+class Biz;
+
+void x() { }
+
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test>::value, "");
+static_assert(test>::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1253,6 +1253,24 @@
   return OpenCLAccessAttr::Keyword_read_only;
 }
 
+static UnaryTransformType::UTTKind
+TSTToUnaryTransformType(DeclSpec::TST SwitchTST) {
+  switch (SwitchTST) {
+  case TST_removeCV:
+return UnaryTransformType::RemoveCV;
+  case TST_removeConst:
+return UnaryTransformType::RemoveConst;
+  case TST_removeVolatile:
+return UnaryTransformType::RemoveVolatile;
+  case TST_removeReferenceType:
+return UnaryTransformType::RemoveReferenceType;
+  case TST_underlyingType:
+return UnaryTransformType::EnumUnderlyingType;
+  default:
+llvm_unreachable("Cannot map TST to unary transform type");
+  }
+}
+
 static QualType ConvertConstrainedAutoDeclSpecToType(Sema , DeclSpec ,
  AutoTypeKeyword AutoKW) {
   assert(DS.isConstrainedAuto());
@@ -1605,16 +1623,23 @@
 break;
   }
   case DeclSpec::TST_underlyingType:
+  case DeclSpec::TST_removeReferenceType:
+  case DeclSpec::TST_removeCV:
+  case DeclSpec::TST_removeConst:
+  case DeclSpec::TST_removeVolatile: {
 Result = S.GetTypeFromParser(DS.getRepAsType());
-assert(!Result.isNull() && "Didn't get a type for __underlying_type?");
+assert(!Result.isNull() &&
+   "Type transform builtin 

[PATCH] D67052: Add reference type transformation builtins

2020-04-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 258836.
zoecarver added a comment.

- Format using clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/remove_cv.cpp
  clang/test/SemaCXX/remove_reference.cpp

Index: clang/test/SemaCXX/remove_reference.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_reference.cpp
@@ -0,0 +1,40 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template
+struct test_remove_ref_trait
+{
+  typedef __remove_reference(T) type;
+};
+
+template
+struct test_remove_ref
+{
+  static const bool value = __is_same(typename test_remove_ref_trait::type, T)  &&
+__is_same(typename test_remove_ref_trait::type, T) &&
+__is_same(typename test_remove_ref_trait::type, T);
+};
+
+struct Foo { };
+
+template
+struct Bar { };
+
+template
+class Baz { };
+
+class Biz;
+
+void x() { }
+
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref>::value, "");
+static_assert(test_remove_ref>::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+static_assert(test_remove_ref::value, "");
+
Index: clang/test/SemaCXX/remove_cv.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_cv.cpp
@@ -0,0 +1,58 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template
+struct remove_const
+{
+  typedef __remove_const(T) type;
+};
+
+template
+struct remove_volatile
+{
+  typedef __remove_volatile(T) type;
+};
+
+template
+struct remove_cv
+{
+  typedef __remove_cv(T) type;
+};
+
+template
+struct test
+{
+  static const bool value =
+__is_same(typename remove_const::type, T) &&
+__is_same(typename remove_const::type, volatile T) &&
+__is_same(typename remove_const::type, T) &&
+
+__is_same(typename remove_volatile::type, T) &&
+__is_same(typename remove_volatile::type, const T) &&
+__is_same(typename remove_volatile::type, T) &&
+
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T);
+};
+
+struct Foo { };
+
+template
+struct Bar { };
+
+template
+class Baz { };
+
+class Biz;
+
+void x() { }
+
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test>::value, "");
+static_assert(test>::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1253,6 +1253,24 @@
   return OpenCLAccessAttr::Keyword_read_only;
 }
 
+static UnaryTransformType::UTTKind
+TSTToUnaryTransformType(DeclSpec::TST SwitchTST) {
+  switch (SwitchTST) {
+  case TST_removeCV:
+return UnaryTransformType::RemoveCV;
+  case TST_removeConst:
+return UnaryTransformType::RemoveConst;
+  case TST_removeVolatile:
+return UnaryTransformType::RemoveVolatile;
+  case TST_removeReferenceType:
+return UnaryTransformType::RemoveReferenceType;
+  case TST_underlyingType:
+return UnaryTransformType::EnumUnderlyingType;
+  default:
+llvm_unreachable("Cannot map TST to unary transform type");
+  }
+}
+
 static QualType ConvertConstrainedAutoDeclSpecToType(Sema , DeclSpec ,
  AutoTypeKeyword AutoKW) {
   assert(DS.isConstrainedAuto());
@@ -1605,16 +1623,23 @@
 break;
   }
   case DeclSpec::TST_underlyingType:
+  case DeclSpec::TST_removeReferenceType:
+  case DeclSpec::TST_removeCV:
+  case DeclSpec::TST_removeConst:
+  case DeclSpec::TST_removeVolatile: {
 Result = S.GetTypeFromParser(DS.getRepAsType());
-assert(!Result.isNull() && "Didn't get a type for __underlying_type?");
+assert(!Result.isNull() &&
+   "Type transform builtin may not have received a type.");
 Result = 

[PATCH] D67052: Add reference type transformation builtins

2020-04-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked 6 inline comments as done.
zoecarver added a comment.

@EricWF and @miscco thanks for the review comments. Sorry for the delay, I 
forgot about this patch. All your comments have been addressed/fixed.




Comment at: clang/lib/AST/TypePrinter.cpp:1020
 
   switch (T->getUTTKind()) {
 case UnaryTransformType::EnumUnderlyingType:

miscco wrote:
> Couldn't we use `TextNodeDumper::VisitUnaryTransformType` to dump the string 
> and then simplify it to a single case.
> 
> Given the possibility that maybe some day one might add the `add_foo` builtins
> Couldn't we use TextNodeDumper::VisitUnaryTransformType to dump the string 
> and then simplify it to a single case.

Good call. Will do.

> Given the possibility that maybe some day one might add the add_foo builtins

I had a patch that added those builtins but, we decided that there was no real 
reason for them to exist.




Comment at: clang/lib/Sema/SemaType.cpp:1624
   }
+  case DeclSpec::TST_removeReferenceType:
+  case DeclSpec::TST_removeCV:

EricWF wrote:
> Why can't we share the implementation with `TST_underlyingType`?
Yep, fixed. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2020-04-17 Thread Michael Schellenberger Costa via Phabricator via cfe-commits
miscco added inline comments.



Comment at: clang/include/clang/Sema/DeclSpec.h:416
   static bool isTypeRep(TST T) {
-return (T == TST_typename || T == TST_typeofType ||
-T == TST_underlyingType || T == TST_atomic);
+return (TST_typename <= T <= TST_atomic);
   }

There is a bug here, this should probably be

```
return (TST_typename <= T && T <= TST_atomic);
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2020-03-01 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

LGTM once all of the inline comments are addressed.

After that, this is ready to land.




Comment at: clang/lib/AST/ItaniumMangle.cpp:3412
 break;
+  case UnaryTransformType::RemoveReferenceType:
+Out << "3err";

zoecarver wrote:
> Eric, I looked at your comment, but it seems that we no longer unary type 
> transformations that way. @rsmith is this correct? 
@rsmith Can you double check the mangling changes?



Comment at: clang/lib/Sema/SemaType.cpp:1624
   }
+  case DeclSpec::TST_removeReferenceType:
+  case DeclSpec::TST_removeCV:

Why can't we share the implementation with `TST_underlyingType`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2020-02-11 Thread Michael Schellenberger Costa via Phabricator via cfe-commits
miscco added subscribers: cjdb, miscco.
miscco added a comment.

Some nits, looks great, especially for library concepts. Pinging @cjdb




Comment at: clang/lib/AST/TypePrinter.cpp:1020
 
   switch (T->getUTTKind()) {
 case UnaryTransformType::EnumUnderlyingType:

Couldn't we use `TextNodeDumper::VisitUnaryTransformType` to dump the string 
and then simplify it to a single case.

Given the possibility that maybe some day one might add the `add_foo` builtins



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1110
+  if (T.expectAndConsume(diag::err_expected_lparen_after,
+ "reference manipulation builtin",
+ tok::r_paren)) return;

I dont think that this message is valid anymore now that you also remove 
qualifiers.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2020-02-11 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked 3 inline comments as done.
zoecarver added inline comments.



Comment at: clang/lib/AST/TypePrinter.cpp:1028
+case UnaryTransformType::RemoveReferenceType:
+  OS << "__remove_reference";
+  print(T->getBaseType(), OS, StringRef());

These need the opening paren. 



Comment at: clang/lib/AST/TypePrinter.cpp:1062
 case UnaryTransformType::EnumUnderlyingType:
+case UnaryTransformType::RemoveCV:
+case UnaryTransformType::RemoveConst:

Missing `RemoveReference`.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1105
+void Parser::ParseTypeTransformTypeSpecifier(DeclSpec ) {
+  DeclSpec::TST TypeTransformTST = TypeTransformTokToDeclSpec();
+

I'll work on your comment: 
> It would be really cool if we could simplify these conversions to 
> static_cast(Tok.getKind() - base);


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2020-02-11 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 243834.
zoecarver added a comment.

- Combine D67052  and D67588 
.
- Remove `__add*` type traits.
- Update mangling/dumping/encoding of all traits.
- Remove stress tests.
- Address comments in D67588 .

I'll work on some failing tests and add those when they're ready.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/remove_cv.cpp
  clang/test/SemaCXX/remove_reference.cpp

Index: clang/test/SemaCXX/remove_reference.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_reference.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template
+struct test_remove_ref_trait
+{
+  typedef __remove_reference(T) type;
+};
+
+template
+struct test_remove_ref
+{
+  static const bool value = __is_same(typename test_remove_ref_trait::type, T)  &&
+__is_same(typename test_remove_ref_trait::type, T) &&
+__is_same(typename test_remove_ref_trait::type, T);
+};
+
+template
+struct test
+{
+  static const bool value = test_remove_ref::value &&
+test_rval::value &&
+test_lval::value;
+};
+
+struct Foo { };
+
+template
+struct Bar { };
+
+template
+class Baz { };
+
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test>::value, "");
+static_assert(test>::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
Index: clang/test/SemaCXX/remove_cv.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/remove_cv.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang_cc1 -std=c++11 %s
+
+template
+struct remove_const
+{
+  typedef __remove_const(T) type;
+};
+
+template
+struct remove_volatile
+{
+  typedef __remove_volatile(T) type;
+};
+
+template
+struct remove_cv
+{
+  typedef __remove_cv(T) type;
+};
+
+template
+struct test
+{
+  static const bool value =
+__is_same(typename remove_const::type, T) &&
+__is_same(typename remove_const::type, volatile T) &&
+__is_same(typename remove_const::type, T) &&
+
+__is_same(typename remove_volatile::type, T) &&
+__is_same(typename remove_volatile::type, const T) &&
+__is_same(typename remove_volatile::type, T) &&
+
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T) &&
+__is_same(typename remove_cv::type, T);
+};
+
+struct Foo { };
+
+template
+struct Bar { };
+
+template
+class Baz { };
+
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test::value, "");
+static_assert(test>::value, "");
+static_assert(test>::value, "");
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1252,6 +1252,24 @@
   return OpenCLAccessAttr::Keyword_read_only;
 }
 
+static UnaryTransformType::UTTKind
+TSTToUnaryTransformType(DeclSpec::TST SwitchTST) {
+  switch (SwitchTST) {
+  case TST_removeCV:
+return UnaryTransformType::RemoveCV;
+  case TST_removeConst:
+return UnaryTransformType::RemoveConst;
+  case TST_removeVolatile:
+return UnaryTransformType::RemoveVolatile;
+  case TST_removeReferenceType:
+return UnaryTransformType::RemoveReferenceType;
+  case TST_underlyingType:
+return UnaryTransformType::EnumUnderlyingType;
+  default:
+llvm_unreachable("Cannot map TST to unary transform type");
+  }
+}
+
 static QualType ConvertConstrainedAutoDeclSpecToType(Sema , DeclSpec ,
  AutoTypeKeyword AutoKW) {
   assert(DS.isConstrainedAuto());
@@ -1603,6 +1621,21 @@
 }
 break;
   }
+  case DeclSpec::TST_removeReferenceType:
+  case DeclSpec::TST_removeCV:
+  case DeclSpec::TST_removeConst:
+  case DeclSpec::TST_removeVolatile: {
+Result = S.GetTypeFromParser(DS.getRepAsType());
+assert(!Result.isNull() &&
+   "Reference 

[PATCH] D67052: Add reference type transformation builtins

2019-12-08 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

@EricWF ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-10-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.
Herald added a reviewer: mclow.lists.

Friendly ping. Other than type mangling, does anything need to be fixed?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: clang/lib/AST/ItaniumMangle.cpp:3412
 break;
+  case UnaryTransformType::RemoveReferenceType:
+Out << "3err";

Eric, I looked at your comment, but it seems that we no longer unary type 
transformations that way. @rsmith is this correct? 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-20 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 221014.
zoecarver added a comment.
Herald added a subscriber: erik.pilkington.

- address review comments
- fix warnings in build


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/add_reference.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_lvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp

Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_remove_reference:   22.849 s  121 K
+// std::remove_reference:  25.643 s  121 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
+// RUN: %cxx %flags %compile_flags -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "template_cost_testing.h"
+
+template  struct Arg { enum { value = 1 }; };
+
+#ifdef TEST_NEW
+
+template 
+struct new_remove_reference
+{
+  typedef __remove_reference(T) type;
+};
+
+#define TEST_CASE_NOP()  new_remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename new_remove_reference< Arg< __COUNTER__ > >::type,
+
+#else
+
+#define TEST_CASE_NOP()  std::remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename std::remove_reference< Arg< __COUNTER__ > >::type,
+
+#endif
+
+int sink(...);
+
+int x = sink(
+  REPEAT_1(TEST_CASE_NOP)
+  REPEAT_1(TEST_CASE_NOP) 42
+);
+
+void Foo( REPEAT_1(TEST_CASE_TYPE) int) { }
+
+void escape() {
+
+sink();
+sink();
+}
+
+
Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_add_rvalue_reference:   56.398 s  171 K
+// std::add_rvalue_reference:  114.59 s  271 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
+// RUN: %cxx %flags %compile_flags -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "template_cost_testing.h"
+
+template  struct Arg { enum { value = 1 }; };
+
+#ifdef TEST_NEW
+
+template 
+struct new_add_rvalue_reference
+{
+  typedef __add_rvalue_reference(T) type;
+};
+
+#define TEST_CASE_NOP() 

[PATCH] D67052: Add reference type transformation builtins

2019-09-19 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked 5 inline comments as done.
zoecarver added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:1612
 break;
+  case DeclSpec::TST_addLValueReferenceType:
+  case DeclSpec::TST_addRValueReferenceType:

EricWF wrote:
> This should be merged with the above case. 
The reason I haven't done that is because `__underlying_type` will default to 
`IntTy` if it fails. We don't want that for the others (maybe we don't want 
that here either?). 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-19 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1099
+
+void Parser::ParseAddReferenceTypeSpecifier(DeclSpec ) {
+  DeclSpec::TST ReferenceTransformTST = ReferenceTransformTokToDeclSpec();

I think this should be generalized and merged with 
`ParseUnderlyingTypeSpecifier`.

Maybe called `ParseTransformationTypeSpecifier`.



Comment at: clang/lib/Sema/SemaType.cpp:1612
 break;
+  case DeclSpec::TST_addLValueReferenceType:
+  case DeclSpec::TST_addRValueReferenceType:

This should be merged with the above case. 



Comment at: clang/lib/Sema/SemaType.cpp:5490
+  // TODO: Should we check something like 
"IsUnaryTypeTransfrom(DS.getTypeSpecTypeLoc())"?
+  // assert(DS.getTypeSpecType() == DeclSpec::TST_underlyingType);
   TL.setKWLoc(DS.getTypeSpecTypeLoc());

`DS.getTypeSpecType() >= DeclSpec::TST_underlyingType && DS.getTypeSpecType() 
<= TST_removeReferenceType` would correct this assertion. 



Comment at: clang/test/SemaCXX/add_reference.cpp:66
+static_assert(test>::value, "");
+static_assert(test>::value, "");

You should test a lot more types here.  reference types, const types, pointer 
types, function types, non-referenceable types.




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-19 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: clang/include/clang/Parse/Parser.h:2606
+  DeclSpec::TST ReferenceTransformTokToDeclSpec();
+  void ParseAddReferenceTypeSpecifier(DeclSpec );
   void ParseAtomicSpecifier(DeclSpec );

These methods are generalized more in D67588.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-19 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: clang/include/clang/AST/Type.h:4353
+RemoveReferenceType,
+AddRValueType,
+AddLValueType

This should say ref in the name.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1094
+return DeclSpec::TST_removeReferenceType;
+  default:
+assert(false && "Not a reference type specifier");

Don't use default switch cases. It suppresses non-covered switch warnings, 
which we want fire when a new enumerator is added.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-03 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: 
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp:13
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size

zoecarver wrote:
> I think there is a good chance the reason that my added builtin isn't 
> significantly faster is that `std::remove_reference` is already optimized 
> somewhere.  Thoughts?
I think if I updated this test to actually remove a reference, it might show 
more of a difference. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-03 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1095
+  default:
+assert(false && "Not a reference type specifier");
+  }

Mordante wrote:
> Wouldn't it be better to use `llvm_unreachable("Not a reference type 
> specifier");`
> Maybe also move this line out of the switch, allowing the compiler to warn 
> about not handled enumeration values.
I'll update it to use `llvm_unreachable` but, I don't think we want the 
compiler to warn about unhandled enumeration values. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-03 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver added a comment.

In D67052#1656319 , @mclow.lists wrote:

> If you're going to do `__add__lvalue_reference`, `__add_rvalue_reference`, 
> and `__remove_reference`, why not go all the way and add `__is_reference`, 
> `__is_lvalue_reference` and `__is_rvalue_reference`?


Those already exist :)

I am planning on adding others, `__remove_cv`, `__decay`, etc. but wanted to 
land this first and make sure I was doing it right.

I'll update `type_traits` in libc++ after this lands. I'm also planning on 
making a patch to update a few of the builtin type traits. That should 
significantly speed up build times. FYI here is all the "type trait primitives" 
clang supports. 
 At 
some point, we should try to support all of them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-03 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

If you're going to do `__add__lvalue_reference`, `__add_rvalue_reference`, and 
`__remove_reference`, why not go all the way and add `__is_reference`, 
`__is_lvalue_reference` and `__is_rvalue_reference`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-03 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added inline comments.



Comment at: clang/lib/Parse/ParseDeclCXX.cpp:1095
+  default:
+assert(false && "Not a reference type specifier");
+  }

Wouldn't it be better to use `llvm_unreachable("Not a reference type 
specifier");`
Maybe also move this line out of the switch, allowing the compiler to warn 
about not handled enumeration values.



Comment at: clang/lib/Sema/SemaType.cpp:1266
+  default:
+assert(false && "Cannot map TST to unary transform type");
+  }

Same here?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver updated this revision to Diff 218276.
zoecarver added a comment.

- remove accedentally added file


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/add_reference.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_lvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp

Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_remove_reference:   22.849 s  121 K
+// std::remove_reference:  25.643 s  121 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
+// RUN: %cxx %flags %compile_flags -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "template_cost_testing.h"
+
+template  struct Arg { enum { value = 1 }; };
+
+#ifdef TEST_NEW
+
+template 
+struct new_remove_reference
+{
+  typedef __remove_reference(T) type;
+};
+
+#define TEST_CASE_NOP()  new_remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename new_remove_reference< Arg< __COUNTER__ > >::type,
+
+#else
+
+#define TEST_CASE_NOP()  std::remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename std::remove_reference< Arg< __COUNTER__ > >::type,
+
+#endif
+
+int sink(...);
+
+int x = sink(
+  REPEAT_1(TEST_CASE_NOP)
+  REPEAT_1(TEST_CASE_NOP) 42
+);
+
+void Foo( REPEAT_1(TEST_CASE_TYPE) int) { }
+
+void escape() {
+
+sink();
+sink();
+}
+
+
Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_add_rvalue_reference:   56.398 s  171 K
+// std::add_rvalue_reference:  114.59 s  271 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
+// RUN: %cxx %flags %compile_flags -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "template_cost_testing.h"
+
+template  struct Arg { enum { value = 1 }; };
+
+#ifdef TEST_NEW
+
+template 
+struct new_add_rvalue_reference
+{
+  typedef __add_rvalue_reference(T) type;
+};
+
+#define TEST_CASE_NOP()  new_add_rvalue_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename new_add_rvalue_reference< Arg< __COUNTER__ > >::type,
+
+#else
+
+#define TEST_CASE_NOP()  

[PATCH] D67052: Add reference type transformation builtins

2019-09-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver marked an inline comment as done.
zoecarver added inline comments.



Comment at: 
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp:13
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size

I think there is a good chance the reason that my added builtin isn't 
significantly faster is that `std::remove_reference` is already optimized 
somewhere.  Thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67052



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


[PATCH] D67052: Add reference type transformation builtins

2019-09-01 Thread Zoe Carver via Phabricator via cfe-commits
zoecarver created this revision.
zoecarver added reviewers: EricWF, eli.friedman, rsmith, craig.topper.
Herald added subscribers: libcxx-commits, cfe-commits, jfb, christof.
Herald added projects: clang, libc++.

This patch adds builtin type traits to transform reference types. Specifically, 
it adds `__add_lvalue_reference`, `__add_rvalue_reference`, and 
`__remove_reference`. The first two builtins speed up builds by around 3x while 
the last builtin only sees small improvements (we may be able to optimize it 
more, though). Once added to the standard library, this should make libc++ (and 
other code) much faster to compile.

I tried to generalize as much of the builtin as possible so, the only 
functional difference between the three builtins is in the file 
`BuildUnaryTransformType`.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67052

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/Format/FormatToken.cpp
  clang/lib/Lex/PPMacroExpansion.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Sema/DeclSpec.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaTemplateVariadic.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/add_reference.cpp
  libcxx/test/libcxx/utilities/meta/stress_tests/lit.site.cfg
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_lvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
  
libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp

Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_remove_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_remove_reference:   22.849 s  121 K
+// std::remove_reference:  25.643 s  121 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o %S/orig.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17
+// RUN: %cxx %flags %compile_flags -c %s -o %S/new.o -ggdb  -ggnu-pubnames -ftemplate-depth=5000 -ftime-trace -std=c++17 -DTEST_NEW
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "template_cost_testing.h"
+
+template  struct Arg { enum { value = 1 }; };
+
+#ifdef TEST_NEW
+
+template 
+struct new_remove_reference
+{
+  typedef __remove_reference(T) type;
+};
+
+#define TEST_CASE_NOP()  new_remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename new_remove_reference< Arg< __COUNTER__ > >::type,
+
+#else
+
+#define TEST_CASE_NOP()  std::remove_reference< Arg< __COUNTER__ > >{},
+#define TEST_CASE_TYPE() typename std::remove_reference< Arg< __COUNTER__ > >::type,
+
+#endif
+
+int sink(...);
+
+int x = sink(
+  REPEAT_1(TEST_CASE_NOP)
+  REPEAT_1(TEST_CASE_NOP) 42
+);
+
+void Foo( REPEAT_1(TEST_CASE_TYPE) int) { }
+
+void escape() {
+
+sink();
+sink();
+}
+
+
Index: libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
===
--- /dev/null
+++ libcxx/test/libcxx/utilities/meta/stress_tests/stress_test_add_rvalue_reference.sh.cpp
@@ -0,0 +1,63 @@
+//===--===//
+//
+// 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
+//
+//===--===//
+//
+// This is a dummy feature that prevents this test from running by default.
+
+// The table below compares the compile time and object size for each of the
+// variants listed in the RUN script.
+//
+//  Impl   Compile Time  Object Size
+// --
+// new_add_rvalue_reference:   56.398 s  171 K
+// std::add_rvalue_reference:  114.59 s  271 K
+//
+// RUN: %cxx %flags %compile_flags -c %s -o