]> granicus.if.org Git - clang/commitdiff
Move isCXXSimpleTypeSpecifier from Parser to Sema and tweak it for wider use.
authorKaelyn Uhrain <rikka@google.com>
Fri, 15 Jun 2012 23:45:51 +0000 (23:45 +0000)
committerKaelyn Uhrain <rikka@google.com>
Fri, 15 Jun 2012 23:45:51 +0000 (23:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@158572 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Parse/Parser.h
include/clang/Sema/Sema.h
lib/Parse/ParseExprCXX.cpp
lib/Parse/ParseObjc.cpp
lib/Sema/SemaDecl.cpp

index 395c5e0c1f544daadb443a2ad5ebb8a6b894156f..931e0840cae95bf3e1c60415fec9dda9df25cef1 100644 (file)
@@ -1287,8 +1287,6 @@ private:
   // C++ 5.2.3: Explicit type conversion (functional notation)
   ExprResult ParseCXXTypeConstructExpression(const DeclSpec &DS);
 
-  bool isCXXSimpleTypeSpecifier() const;
-
   /// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers.
   /// This should only be called when the current token is known to be part of
   /// simple-type-specifier.
index 868fab74cb30461991fc17c62d53dcfca5de634e..72ed636e60df75304574c056ae72cfafce692db9 100644 (file)
@@ -1112,6 +1112,8 @@ public:
 
   void DiagnoseUseOfUnimplementedSelectors();
 
+  bool isSimpleTypeSpecifier(tok::TokenKind Kind) const;
+
   ParsedType getTypeName(IdentifierInfo &II, SourceLocation NameLoc,
                          Scope *S, CXXScopeSpec *SS = 0,
                          bool isClassName = false,
index 1c7b56fd4d74c535d652fdde3f99dbf1b0ac02cd..65e3f62f571412332c32e37d533aa1f81e66c297 100644 (file)
@@ -1377,39 +1377,6 @@ bool Parser::ParseCXXCondition(ExprResult &ExprOut,
   return false;
 }
 
-/// \brief Determine whether the current token starts a C++
-/// simple-type-specifier.
-bool Parser::isCXXSimpleTypeSpecifier() const {
-  switch (Tok.getKind()) {
-  case tok::annot_typename:
-  case tok::kw_short:
-  case tok::kw_long:
-  case tok::kw___int64:
-  case tok::kw___int128:
-  case tok::kw_signed:
-  case tok::kw_unsigned:
-  case tok::kw_void:
-  case tok::kw_char:
-  case tok::kw_int:
-  case tok::kw_half:
-  case tok::kw_float:
-  case tok::kw_double:
-  case tok::kw_wchar_t:
-  case tok::kw_char16_t:
-  case tok::kw_char32_t:
-  case tok::kw_bool:
-  case tok::kw_decltype:
-  case tok::kw_typeof:
-  case tok::kw___underlying_type:
-    return true;
-
-  default:
-    break;
-  }
-
-  return false;
-}
-
 /// ParseCXXSimpleTypeSpecifier - [C++ 7.1.5.2] Simple type specifiers.
 /// This should only be called when the current token is known to be part of
 /// simple-type-specifier.
index 4e5b672804898d21c110896a684436bfe18f8bd2..d3016c7c15436a4876bf97960a774493de0aa65f 100644 (file)
@@ -2115,7 +2115,7 @@ bool Parser::ParseObjCXXMessageReceiver(bool &IsExpr, void *&TypeOrExpr) {
       Tok.is(tok::kw_typename) || Tok.is(tok::annot_cxxscope))
     TryAnnotateTypeOrScopeToken();
 
-  if (!isCXXSimpleTypeSpecifier()) {
+  if (!Actions.isSimpleTypeSpecifier(Tok.getKind())) {
     //   objc-receiver:
     //     expression
     ExprResult Receiver = ParseExpression();
index 924b0f73d673ea38d26b72d0aa9f9d1d0dd7dce1..5221322a14ecc6daf80b7538ae64d4c0274408f4 100644 (file)
@@ -80,6 +80,42 @@ class TypeNameValidatorCCC : public CorrectionCandidateCallback {
 
 }
 
+/// \brief Determine whether the token kind starts a simple-type-specifier.
+bool Sema::isSimpleTypeSpecifier(tok::TokenKind Kind) const {
+  switch (Kind) {
+  // FIXME: Take into account the current language when deciding whether a
+  // token kind is a valid type specifier
+  case tok::kw_short:
+  case tok::kw_long:
+  case tok::kw___int64:
+  case tok::kw___int128:
+  case tok::kw_signed:
+  case tok::kw_unsigned:
+  case tok::kw_void:
+  case tok::kw_char:
+  case tok::kw_int:
+  case tok::kw_half:
+  case tok::kw_float:
+  case tok::kw_double:
+  case tok::kw_wchar_t:
+  case tok::kw_bool:
+  case tok::kw___underlying_type:
+    return true;
+
+  case tok::annot_typename:
+  case tok::kw_char16_t:
+  case tok::kw_char32_t:
+  case tok::kw_typeof:
+  case tok::kw_decltype:
+    return getLangOpts().CPlusPlus;
+
+  default:
+    break;
+  }
+
+  return false;
+}
+
 /// \brief If the identifier refers to a type name within this scope,
 /// return the declaration of that type.
 ///