Use switch instead of series of comparisons
authorSerge Pavlov <sepavloff@gmail.com>
Sat, 3 Aug 2019 16:32:49 +0000 (16:32 +0000)
committerSerge Pavlov <sepavloff@gmail.com>
Sat, 3 Aug 2019 16:32:49 +0000 (16:32 +0000)
This is style correction, no functional changes.

Differential Revision: https://reviews.llvm.org/D65670

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

include/clang/Basic/TokenKinds.h
lib/Basic/TokenKinds.cpp

index 8bac28cd3933a4046997e751df956668df703552..c25181e6827c7b6dd8c48b0073eb8eb77c49f227 100644 (file)
@@ -90,13 +90,7 @@ inline bool isLiteral(TokenKind K) {
 }
 
 /// Return true if this is any of tok::annot_* kinds.
-inline bool isAnnotation(TokenKind K) {
-#define ANNOTATION(NAME) \
-  if (K == tok::annot_##NAME) \
-    return true;
-#include "clang/Basic/TokenKinds.def"
-  return false;
-}
+bool isAnnotation(TokenKind K);
 
 /// Return true if this is an annotation token representing a pragma.
 bool isPragmaAnnotation(TokenKind K);
index 0426edc316a4433ba9685b8e57b16250e72fa665..d55e176c72c4c57e1a348f1c4a78ea40f35e72a2 100644 (file)
@@ -46,6 +46,16 @@ const char *tok::getKeywordSpelling(TokenKind Kind) {
   return nullptr;
 }
 
+bool tok::isAnnotation(TokenKind Kind) {
+  switch (Kind) {
+#define ANNOTATION(X) case annot_ ## X: return true;
+#include "clang/Basic/TokenKinds.def"
+  default:
+    break;
+  }
+  return false;
+}
+
 bool tok::isPragmaAnnotation(TokenKind Kind) {
   switch (Kind) {
 #define PRAGMA_ANNOTATION(X) case annot_ ## X: return true;