[PATCH] D116242: [clang] adds `__remove_volatile` as a compiler built-in

2021-12-24 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb abandoned this revision.
cjdb added a comment.

Merged into D116203 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D116242

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


[PATCH] D116242: [clang] adds `__remove_volatile` as a compiler built-in

2021-12-23 Thread Christopher Di Bella via Phabricator via cfe-commits
cjdb created this revision.
cjdb added a reviewer: aaron.ballman.
Herald added a subscriber: dexonsmith.
cjdb requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D116242

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Specifiers.h
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Sema/DeclSpec.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/JSONNodeDumper.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_cvref.cpp

Index: clang/test/SemaCXX/remove_cvref.cpp
===
--- clang/test/SemaCXX/remove_cvref.cpp
+++ clang/test/SemaCXX/remove_cvref.cpp
@@ -3,6 +3,12 @@
 template 
 constexpr bool check_remove_qualifiers() {
   static_assert(__is_same(__remove_const(const T), T), "");
+  static_assert(__is_same(__remove_const(volatile T), volatile T), "");
+  static_assert(__is_same(__remove_const(const volatile T), volatile T), "");
+
+  static_assert(__is_same(__remove_volatile(const T), const T), "");
+  static_assert(__is_same(__remove_volatile(volatile T), T), "");
+  static_assert(__is_same(__remove_volatile(const volatile T), const T), "");
   return true;
 }
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -1269,6 +1269,8 @@
 return UnaryTransformType::AddVolatile;
   case TST_remove_const:
 return UnaryTransformType::RemoveConst;
+  case TST_remove_volatile:
+return UnaryTransformType::RemoveVolatile;
   case TST_underlyingType:
 return UnaryTransformType::EnumUnderlyingType;
   default:
@@ -1663,6 +1665,7 @@
   case DeclSpec::TST_add_cv:
   case DeclSpec::TST_add_volatile:
   case DeclSpec::TST_remove_const:
+  case DeclSpec::TST_remove_volatile:
 Result = S.GetTypeFromParser(DS.getRepAsType());
 assert(!Result.isNull() && "Didn't get a type for the transformation?");
 Result = S.BuildUnaryTransformType(
@@ -6000,7 +6003,7 @@
 void VisitUnaryTransformTypeLoc(UnaryTransformTypeLoc TL) {
   // Make sure it is a unary transform type
   assert(DS.getTypeSpecType() >= DeclSpec::TST_underlyingType &&
- DS.getTypeSpecType() <= DeclSpec::TST_remove_const);
+ DS.getTypeSpecType() <= DeclSpec::TST_remove_volatile);
   TL.setKWLoc(DS.getTypeSpecTypeLoc());
   TL.setParensRange(DS.getTypeofParensRange());
   assert(DS.getRepAsType());
@@ -9093,7 +9096,8 @@
   case UnaryTransformType::AddConst:
   case UnaryTransformType::AddCV:
   case UnaryTransformType::AddVolatile:
-  case UnaryTransformType::RemoveConst: {
+  case UnaryTransformType::RemoveConst:
+  case UnaryTransformType::RemoveVolatile: {
 SplitQualType Split = BaseType.getSplitUnqualifiedType();
 Qualifiers Quals = BaseType.getQualifiers();
 if (BaseType->isReferenceType() || BaseType->isFunctionType())
@@ -9111,6 +9115,9 @@
 case UnaryTransformType::RemoveConst:
   Quals.removeConst();
   break;
+case UnaryTransformType::RemoveVolatile:
+  Quals.removeVolatile();
+  break;
 }
 QualType Underlying(Split.Ty, Quals.getAsOpaqueValue());
 return Context.getUnaryTransformType(BaseType, Underlying, UKind);
Index: clang/lib/Sema/SemaTemplateVariadic.cpp
===
--- clang/lib/Sema/SemaTemplateVariadic.cpp
+++ clang/lib/Sema/SemaTemplateVariadic.cpp
@@ -863,8 +863,9 @@
   case TST_underlyingType:
   case TST_add_const:
   case TST_add_cv:
-  case TST_remove_const:
   case TST_add_volatile:
+  case TST_remove_const:
+  case TST_remove_volatile:
   case TST_atomic: {
 QualType T = DS.getRepAsType().get();
 if (!T.isNull() && T->containsUnexpandedParameterPack())
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -147,8 +147,9 @@
   case tok::kw___underlying_type:
   case tok::kw___add_const:
   case tok::kw___add_cv:
-  case tok::kw___remove_const:
   case tok::kw___add_volatile:
+  case tok::kw___remove_const:
+  case tok::kw___remove_volatile:
   case tok::kw___auto_type:
 return true;
 
@@ -5605,8 +5606,9 @@
   case DeclSpec::TST_underlyingType:
   case DeclSpec::TST_add_const:
   case DeclSpec::TST_add_cv:
-  case DeclSpec::TST_remove_const:
   case DeclSpec::TST_add_volatile:
+  case DeclSpec::TST_remove_const:
+  case DeclSpec::TST_remove_volatile:
   case DeclSpec::TST_atomic: {
 // Grab the type from the parser.
 TypeSourceInfo