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 <class T>
 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 *TSI = nullptr;
Index: clang/lib/Sema/DeclSpec.cpp
===================================================================
--- clang/lib/Sema/DeclSpec.cpp
+++ clang/lib/Sema/DeclSpec.cpp
@@ -395,6 +395,7 @@
     case TST_add_cv:
     case TST_add_volatile:
     case TST_remove_const:
+    case TST_remove_volatile:
     case TST_typename:
     case TST_typeofType: {
       QualType QT = DS.getRepAsType().get();
@@ -586,10 +587,12 @@
     return "__add_const";
   case DeclSpec::TST_add_cv:
     return "__add_cv";
-  case DeclSpec::TST_remove_const:
-    return "__remove_const";
   case DeclSpec::TST_add_volatile:
     return "__add_volatile";
+  case DeclSpec::TST_remove_const:
+    return "__remove_const";
+  case DeclSpec::TST_remove_volatile:
+    return "__remove_volatile";
   case DeclSpec::TST_unknown_anytype: return "__unknown_anytype";
   case DeclSpec::TST_atomic: return "_Atomic";
   case DeclSpec::TST_BFloat16: return "__bf16";
Index: clang/lib/Parse/ParseDeclCXX.cpp
===================================================================
--- clang/lib/Parse/ParseDeclCXX.cpp
+++ clang/lib/Parse/ParseDeclCXX.cpp
@@ -1534,7 +1534,8 @@
           tok::kw___is_trivially_assignable,
           tok::kw___is_trivially_constructible, tok::kw___is_trivially_copyable,
           tok::kw___is_union, tok::kw___is_unsigned, tok::kw___is_void,
-          tok::kw___is_volatile, tok::kw___remove_const))
+          tok::kw___is_volatile, tok::kw___remove_const,
+          tok::kw___remove_volatile))
     // GNU libstdc++ 4.2 and libc++ use certain intrinsic names as the
     // name of struct templates, but some are keywords in GCC >= 4.3
     // and Clang. Therefore, when we see the token sequence "struct
Index: clang/lib/Parse/ParseDecl.cpp
===================================================================
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -4119,6 +4119,7 @@
     case tok::kw___add_cv:
     case tok::kw___add_volatile:
     case tok::kw___remove_const:
+    case tok::kw___remove_volatile:
       ParseTypeTransformTypeSpecifier(DS);
       continue;
 
@@ -4232,6 +4233,8 @@
     return DeclSpec::TST_add_volatile;
   case tok::kw___remove_const:
     return DeclSpec::TST_remove_const;
+  case tok::kw___remove_volatile:
+    return DeclSpec::TST_remove_volatile;
   }
 
   __builtin_unreachable();
Index: clang/lib/Lex/PPMacroExpansion.cpp
===================================================================
--- clang/lib/Lex/PPMacroExpansion.cpp
+++ clang/lib/Lex/PPMacroExpansion.cpp
@@ -1662,6 +1662,7 @@
               .Case("__add_cv", true)
               .Case("__add_volatile", true)
               .Case("__remove_const", true)
+              .Case("__remove_volatile", true)
               .Default(false);
         } else {
           return llvm::StringSwitch<bool>(II->getName())
Index: clang/lib/Format/FormatToken.cpp
===================================================================
--- clang/lib/Format/FormatToken.cpp
+++ clang/lib/Format/FormatToken.cpp
@@ -61,6 +61,7 @@
   case tok::kw___add_cv:
   case tok::kw___add_volatile:
   case tok::kw___remove_const:
+  case tok::kw___remove_volatile:
   case tok::annot_typename:
   case tok::kw_char8_t:
   case tok::kw_char16_t:
Index: clang/lib/AST/TypePrinter.cpp
===================================================================
--- clang/lib/AST/TypePrinter.cpp
+++ clang/lib/AST/TypePrinter.cpp
@@ -1122,11 +1122,12 @@
     case UnaryTransformType::EnumUnderlyingType:
     case UnaryTransformType::AddConst:
     case UnaryTransformType::AddCV:
+    case UnaryTransformType::AddVolatile:
     case UnaryTransformType::RemoveConst:
-    case UnaryTransformType::AddVolatile: {
-      constexpr std::array<const char *, 5> Transformation = {
-          "__underlying_type", "__add_const", "__add_cv", "__add_volatile",
-          "__remove_const"};
+    case UnaryTransformType::RemoveVolatile: {
+      constexpr std::array<const char *, 6> Transformation = {
+          "__underlying_type", "__add_const",    "__add_cv",
+          "__add_volatile",    "__remove_const", "__remove_volatile"};
       OS << Transformation[T->getUTTKind()] << '(';
       print(T->getBaseType(), OS, StringRef());
       OS << ')';
@@ -1148,6 +1149,7 @@
     case UnaryTransformType::AddCV:
     case UnaryTransformType::AddVolatile:
     case UnaryTransformType::RemoveConst:
+    case UnaryTransformType::RemoveVolatile:
       return;
   }
 
Index: clang/lib/AST/JSONNodeDumper.cpp
===================================================================
--- clang/lib/AST/JSONNodeDumper.cpp
+++ clang/lib/AST/JSONNodeDumper.cpp
@@ -677,6 +677,9 @@
   case UnaryTransformType::RemoveConst:
     JOS.attribute("transformedKind", "remove_const");
     break;
+  case UnaryTransformType::RemoveVolatile:
+    JOS.attribute("transformedKind", "remove_volatile");
+    break;
   }
 }
 
Index: clang/lib/AST/ItaniumMangle.cpp
===================================================================
--- clang/lib/AST/ItaniumMangle.cpp
+++ clang/lib/AST/ItaniumMangle.cpp
@@ -3937,6 +3937,9 @@
       case UnaryTransformType::RemoveConst:
         Out << "3rc";
         break;
+      case UnaryTransformType::RemoveVolatile:
+        Out << "3rv";
+        break;
     }
   }
 
Index: clang/include/clang/Sema/DeclSpec.h
===================================================================
--- clang/include/clang/Sema/DeclSpec.h
+++ clang/include/clang/Sema/DeclSpec.h
@@ -295,6 +295,7 @@
   static const TST TST_add_cv = clang::TST_add_cv;
   static const TST TST_add_volatile = clang::TST_add_volatile;
   static const TST TST_remove_const = clang::TST_remove_const;
+  static const TST TST_remove_volatile = clang::TST_remove_volatile;
   static const TST TST_auto = clang::TST_auto;
   static const TST TST_auto_type = clang::TST_auto_type;
   static const TST TST_unknown_anytype = clang::TST_unknown_anytype;
Index: clang/include/clang/Basic/TokenKinds.def
===================================================================
--- clang/include/clang/Basic/TokenKinds.def
+++ clang/include/clang/Basic/TokenKinds.def
@@ -512,6 +512,7 @@
 KEYWORD(__add_cv, KEYCXX)
 KEYWORD(__add_volatile, KEYCXX)
 KEYWORD(__remove_const, KEYCXX)
+KEYWORD(__remove_volatile, KEYCXX)
 
 // Clang-only C++ Type Traits
 TYPE_TRAIT_2(__reference_binds_to_temporary, ReferenceBindsToTemporary, KEYCXX)
Index: clang/include/clang/Basic/Specifiers.h
===================================================================
--- clang/include/clang/Basic/Specifiers.h
+++ clang/include/clang/Basic/Specifiers.h
@@ -87,6 +87,7 @@
     TST_add_cv,          // __add_cv extension
     TST_add_volatile,    // __add_volatile extension
     TST_remove_const,    // __remove_const extension
+    TST_remove_volatile, // __remove_volatile extension
     TST_auto,            // C++11 auto
     TST_decltype_auto,   // C++1y decltype(auto)
     TST_auto_type,       // __auto_type extension
Index: clang/include/clang/AST/Type.h
===================================================================
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -4558,6 +4558,7 @@
     AddConst,
     AddVolatile,
     RemoveConst,
+    RemoveVolatile,
   };
 
 private:
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D116242: [cla... Christopher Di Bella via Phabricator via cfe-commits

Reply via email to