]> granicus.if.org Git - clang/commitdiff
Add the Microsoft __is_interface_class type trait.
authorJohn McCall <rjmccall@apple.com>
Tue, 25 Sep 2012 07:32:49 +0000 (07:32 +0000)
committerJohn McCall <rjmccall@apple.com>
Tue, 25 Sep 2012 07:32:49 +0000 (07:32 +0000)
Patch by Andy Gibbs!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@164591 91177308-0d34-0410-b5e6-96231b3b80d8

docs/LanguageExtensions.html
include/clang/Basic/TokenKinds.def
include/clang/Basic/TypeTraits.h
lib/AST/StmtPrinter.cpp
lib/Parse/ParseExpr.cpp
lib/Parse/ParseExprCXX.cpp
lib/Parse/ParseTentative.cpp
lib/Sema/SemaExprCXX.cpp
test/SemaCXX/ms-interface.cpp

index 21ac6277122c6d616167e6bac7e71f176a1b66c8..8c0e5b7ffcb0f1532874c1a683be12b83b760041 100644 (file)
@@ -1007,6 +1007,7 @@ struct is_convertible_to {
   <li><code>__is_convertible_to</code> (Microsoft)</li>
   <li><code>__is_empty</code> (GNU, Microsoft)</li>
   <li><code>__is_enum</code> (GNU, Microsoft)</li>
+  <li><code>__is_interface_class</code> (Microsoft)</li>
   <li><code>__is_pod</code> (GNU, Microsoft)</li>
   <li><code>__is_polymorphic</code> (GNU, Microsoft)</li>
   <li><code>__is_union</code> (GNU, Microsoft)</li>
index 0cc773355b454c51966f0be776549811520e5de0..9b61403f45d423d333a110c3e1c19018e9f99935 100644 (file)
@@ -365,6 +365,7 @@ KEYWORD(__is_convertible_to         , KEYCXX)
 KEYWORD(__is_empty                  , KEYCXX)
 KEYWORD(__is_enum                   , KEYCXX)
 KEYWORD(__is_final                  , KEYCXX)
+KEYWORD(__is_interface_class        , KEYCXX)
 // Tentative name - there's no implementation of std::is_literal_type yet.
 KEYWORD(__is_literal                , KEYCXX)
 // Name for GCC 4.6 compatibility - people have already written libraries using
index 0a5a8643a36e5bfc85bb150410de40fe3d8b19ae..882b52d489ec0c6f53309c6dcfd40efcd357a225 100644 (file)
@@ -41,6 +41,7 @@ namespace clang {
     UTT_IsFunction,
     UTT_IsFundamental,
     UTT_IsIntegral,
+    UTT_IsInterfaceClass,
     UTT_IsLiteral,
     UTT_IsLvalueReference,
     UTT_IsMemberFunctionPointer,
index 22b90dfa2c4dcfdecadbb4d444442e9b4cb33038..3a9f236f316f8c2088fb7af9ed6000763ab091d6 100644 (file)
@@ -1556,6 +1556,7 @@ static const char *getTypeTraitName(UnaryTypeTrait UTT) {
   case UTT_IsFunction:              return "__is_function";
   case UTT_IsFundamental:           return "__is_fundamental";
   case UTT_IsIntegral:              return "__is_integral";
+  case UTT_IsInterfaceClass:        return "__is_interface_class";
   case UTT_IsLiteral:               return "__is_literal";
   case UTT_IsLvalueReference:       return "__is_lvalue_reference";
   case UTT_IsMemberFunctionPointer: return "__is_member_function_pointer";
index 9b95641f46bd97e944cc66484f42da80fbeb3cc8..37cdd14407f8679b1ea9888eb19cfa96265d638e 100644 (file)
@@ -1208,6 +1208,7 @@ ExprResult Parser::ParseCastExpression(bool isUnaryExpression,
   case tok::kw___is_class:
   case tok::kw___is_empty:
   case tok::kw___is_enum:
+  case tok::kw___is_interface_class:
   case tok::kw___is_literal:
   case tok::kw___is_arithmetic:
   case tok::kw___is_integral:
index e02cb7a0264bad59943233a1f86daeb0638f1d89..3039368cf7b84358263516164e19abb6b8f8ed08 100644 (file)
@@ -2457,6 +2457,7 @@ static UnaryTypeTrait UnaryTypeTraitFromTokKind(tok::TokenKind kind) {
   case tok::kw___is_function:                return UTT_IsFunction;
   case tok::kw___is_fundamental:             return UTT_IsFundamental;
   case tok::kw___is_integral:                return UTT_IsIntegral;
+  case tok::kw___is_interface_class:         return UTT_IsInterfaceClass;
   case tok::kw___is_lvalue_reference:        return UTT_IsLvalueReference;
   case tok::kw___is_member_function_pointer: return UTT_IsMemberFunctionPointer;
   case tok::kw___is_member_object_pointer:   return UTT_IsMemberObjectPointer;
index 01ab0e4eeaabe5ac491d55f6591859e86f3ded31..40c4eee1994b3884924a30b35aee6ce3dca44bb8 100644 (file)
@@ -782,6 +782,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) {
   case tok::kw___is_convertible_to:
   case tok::kw___is_empty:
   case tok::kw___is_enum:
+  case tok::kw___is_interface_class:
   case tok::kw___is_final:
   case tok::kw___is_literal:
   case tok::kw___is_literal_type:
index ca4702d17eff2182faf1c72c15d92e5b08c6d414..763ef2891996b58e80de9d8c14d022fa5ce33201 100644 (file)
@@ -2927,6 +2927,7 @@ static bool CheckUnaryTypeTraitTypeCompleteness(Sema &S,
   case UTT_IsEmpty:
   case UTT_IsPolymorphic:
   case UTT_IsAbstract:
+  case UTT_IsInterfaceClass:
     // Fall-through
 
   // These traits require a complete type.
@@ -3057,6 +3058,10 @@ static bool EvaluateUnaryTypeTrait(Sema &Self, UnaryTypeTrait UTT,
     if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
       return RD->isAbstract();
     return false;
+  case UTT_IsInterfaceClass:
+    if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
+      return RD->isInterface();
+    return false;
   case UTT_IsFinal:
     if (const CXXRecordDecl *RD = T->getAsCXXRecordDecl())
       return RD->hasAttr<FinalAttr>();
index 62ae25482ff913073c5a9d2e9bf198a534be500b..3625f7027aa479de4f80f55ddc6cadfcc9c0d5e4 100644 (file)
@@ -59,6 +59,10 @@ struct S { };
 class C { };
 __interface I { };
 
+static_assert(!__is_interface_class(S), "oops");
+static_assert(!__is_interface_class(C), "oops");
+static_assert(__is_interface_class(I), "oops");
+
 // expected-error@55 {{interface type cannot inherit from 'struct S'}}
 // expected-note@+1 {{in instantiation of template class 'I6<S>' requested here}}
 struct S1 : I6<S> {